2010-05-14 23:05:18 +02:00
|
|
|
package com.osmand.data;
|
|
|
|
|
|
|
|
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;
|
|
|
|
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-05-14 23:05:18 +02:00
|
|
|
public String getName() {
|
|
|
|
if (this.name != null) {
|
|
|
|
return this.name;
|
|
|
|
}
|
2010-05-27 13:02:02 +02:00
|
|
|
if (id != null) {
|
|
|
|
return id + "";
|
2010-05-14 23:05:18 +02:00
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-05-14 23:05:18 +02:00
|
|
|
return getName().compareTo(o.getName());
|
|
|
|
}
|
2010-05-27 13:02:02 +02:00
|
|
|
|
|
|
|
public void doDataPreparation() {
|
|
|
|
|
|
|
|
}
|
2010-05-14 23:05:18 +02:00
|
|
|
|
|
|
|
}
|