001: /**
002: * Marker.java
003: */package org.wfp.vam.intermap.kernel.marker;
004:
005: /**
006: * A Marker is a geographic point, with a title and a description.
007: *
008: * @author ETj
009: */
010: import org.jdom.Element;
011:
012: public class Marker {
013: private static long counter = 1;
014:
015: private final long id;
016: private double _lat;
017: private double _lon;
018: private String _title;
019: private String _desc;
020:
021: /**
022: * Constructor
023: */
024: public Marker(double lat, double lon, String title, String desc) {
025: synchronized (getClass()) {
026: id = counter++;
027: }
028:
029: _lat = lat;
030: _lon = lon;
031: _title = title;
032: _desc = desc;
033: }
034:
035: /**
036: * Returns Id
037: *
038: * @return a long
039: */
040: public long getId() {
041: return id;
042: }
043:
044: public boolean isIn(double minlat, double maxlat, double minlon,
045: double maxlon) {
046: if (_lat < minlat)
047: return false;
048: if (maxlat < _lat)
049: return false;
050: if (_lon < minlon)
051: return false;
052: if (maxlon < _lon)
053: return false;
054:
055: return true;
056: }
057:
058: /**
059: * Sets Lat
060: */
061: public void setLat(double lat) {
062: _lat = lat;
063: }
064:
065: /**
066: * Returns Lat
067: */
068: public double getLat() {
069: return _lat;
070: }
071:
072: /**
073: * Sets Lon
074: */
075: public void setLon(double lon) {
076: _lon = lon;
077: }
078:
079: /**
080: * Returns Lon
081: */
082: public double getLon() {
083: return _lon;
084: }
085:
086: /**
087: * Sets Title
088: */
089: public void setTitle(String title) {
090: _title = title;
091: }
092:
093: /**
094: * Returns Title
095: */
096: public String getTitle() {
097: return _title;
098: }
099:
100: /**
101: * Sets Desc
102: */
103: public void setDesc(String desc) {
104: _desc = desc;
105: }
106:
107: /**
108: * Returns Desc
109: */
110: public String getDesc() {
111: return _desc;
112: }
113:
114: public Element toElement() {
115: Element ret = new Element("marker");
116:
117: ret.setAttribute("id", "" + id);
118:
119: ret.setAttribute("lat", "" + _lat);
120: ret.setAttribute("lon", "" + _lon);
121:
122: if (_title != null)
123: ret.addContent(new Element("title").setText(_title));
124:
125: if (_desc != null)
126: ret.addContent(new Element("description").setText(_desc));
127:
128: return ret;
129: }
130: }
|