2010-05-14 23:05:18 +02:00
|
|
|
package com.osmand.data;
|
|
|
|
|
2010-06-01 23:16:56 +02:00
|
|
|
import java.text.Collator;
|
|
|
|
|
2010-05-14 23:05:18 +02:00
|
|
|
import com.osmand.osm.Entity;
|
|
|
|
import com.osmand.osm.LatLon;
|
|
|
|
import com.osmand.osm.MapUtils;
|
|
|
|
import com.osmand.osm.OSMSettings.OSMTagKey;
|
|
|
|
|
2010-05-27 13:02:02 +02:00
|
|
|
public abstract class MapObject implements Comparable<MapObject> {
|
2010-05-14 23:05:18 +02:00
|
|
|
|
|
|
|
protected String name = null;
|
2010-06-01 23:16:56 +02:00
|
|
|
protected String enName = null;
|
2010-05-14 23:05:18 +02:00
|
|
|
protected LatLon location = null;
|
2010-05-16 23:49:11 +02:00
|
|
|
protected Long id = null;
|
2010-05-17 14:03:16 +02:00
|
|
|
|
|
|
|
public MapObject(){}
|
|
|
|
|
2010-05-27 13:02:02 +02:00
|
|
|
public MapObject(Entity e){
|
|
|
|
setEntity(e);
|
2010-05-17 14:03:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-27 13:02:02 +02:00
|
|
|
public void setEntity(Entity e){
|
|
|
|
this.id = e.getId();
|
|
|
|
if(this.name == null){
|
|
|
|
this.name = e.getTag(OSMTagKey.NAME);
|
|
|
|
}
|
|
|
|
if(this.location == null){
|
|
|
|
this.location = MapUtils.getCenter(e);
|
|
|
|
}
|
2010-05-17 14:03:16 +02:00
|
|
|
}
|
2010-05-14 23:05:18 +02:00
|
|
|
|
2010-05-16 23:49:11 +02:00
|
|
|
public void setId(Long id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Long getId() {
|
|
|
|
if(id != null){
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2010-06-01 23:16:56 +02:00
|
|
|
public String getName(boolean en){
|
|
|
|
if(en){
|
|
|
|
return getEnName();
|
|
|
|
} else {
|
|
|
|
return getName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-14 23:05:18 +02:00
|
|
|
public String getName() {
|
|
|
|
if (this.name != null) {
|
|
|
|
return this.name;
|
|
|
|
}
|
2010-06-02 00:15:19 +02:00
|
|
|
return "";
|
2010-05-14 23:05:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
2010-06-01 23:16:56 +02:00
|
|
|
public String getEnName() {
|
2010-06-02 00:15:19 +02:00
|
|
|
if(this.enName != null){
|
|
|
|
return this.enName;
|
|
|
|
}
|
|
|
|
return "";
|
2010-06-01 23:16:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setEnName(String enName) {
|
|
|
|
this.enName = enName;
|
|
|
|
}
|
|
|
|
|
2010-05-14 23:05:18 +02:00
|
|
|
public LatLon getLocation(){
|
2010-05-27 13:02:02 +02:00
|
|
|
return location;
|
2010-05-14 23:05:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setLocation(double latitude, double longitude){
|
|
|
|
location = new LatLon(latitude, longitude);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2010-05-27 13:02:02 +02:00
|
|
|
public int compareTo(MapObject o) {
|
2010-06-01 23:16:56 +02:00
|
|
|
return Collator.getInstance().compare(getName(), o.getName());
|
2010-05-14 23:05:18 +02:00
|
|
|
}
|
2010-05-27 13:02:02 +02:00
|
|
|
|
|
|
|
public void doDataPreparation() {
|
|
|
|
|
|
|
|
}
|
2010-05-14 23:05:18 +02:00
|
|
|
|
|
|
|
}
|