예제 #1
0
 @Override
 public KmlGeometry clone() {
   KmlGeometry kmlGeometry = null;
   try {
     kmlGeometry = (KmlGeometry) super.clone();
   } catch (CloneNotSupportedException e) {
     e.printStackTrace();
     return null;
   }
   if (mCoordinates != null) kmlGeometry.mCoordinates = cloneArrayOfGeoPoint(mCoordinates);
   return kmlGeometry;
 }
예제 #2
0
 @Override
 public Overlay buildOverlay(
     MapView map, Style defaultStyle, Styler styler, KmlDocument kmlDocument) {
   if (mGeometry != null)
     return mGeometry.buildOverlay(map, defaultStyle, styler, this, kmlDocument);
   else return null;
 }
예제 #3
0
 /** @return this as a GeoJSON object. */
 @Override
 public JsonObject asGeoJSON(boolean isRoot) {
   JsonObject json = new JsonObject();
   json.addProperty("type", "Feature");
   if (mId != null) json.addProperty("id", mId);
   json.add("geometry", mGeometry.asGeoJSON());
   json.add("properties", geoJSONProperties());
   return json;
 }
예제 #4
0
 /**
  * Build an array of Positions in GeoJSON format.
  *
  * @param coordinates
  * @return the GeoJSON array of Positions.
  */
 public static JsonArray geoJSONCoordinates(ArrayList<GeoPoint> coordinates) {
   JsonArray json = new JsonArray();
   Iterator<GeoPoint> it = coordinates.iterator();
   while (it.hasNext()) {
     GeoPoint position = it.next();
     json.add(KmlGeometry.geoJSONPosition(position));
   }
   return json;
 }
예제 #5
0
 /** parse a GeoJSON array of Positions: [ [lon, lat, alt],... [lon, lat, alt] ] */
 public static ArrayList<GeoPoint> parseGeoJSONPositions(JsonArray json) {
   if (json == null) return null;
   ArrayList<GeoPoint> coordinates = new ArrayList<GeoPoint>(json.size());
   for (int i = 0; i < json.size(); i++) {
     JsonArray position = json.get(i).getAsJsonArray();
     GeoPoint p = KmlGeometry.parseGeoJSONPosition(position);
     if (p != null) coordinates.add(p);
   }
   return coordinates;
 }
예제 #6
0
 /** constructs a Placemark from a Polyline overlay, as a KML LineString */
 public KmlPlacemark(Polyline polyline, KmlDocument kmlDoc) {
   this();
   mName = "LineString - " + polyline.getNumberOfPoints() + " points";
   mGeometry = new KmlLineString();
   mGeometry.mCoordinates = (ArrayList<GeoPoint>) polyline.getPoints();
   mVisibility = polyline.isEnabled();
   // Style:
   Style style = new Style();
   style.mLineStyle = new LineStyle(polyline.getColor(), polyline.getWidth());
   mStyle = kmlDoc.addStyle(style);
 }
예제 #7
0
 /** constructs a Placemark from a Polygon overlay, as a KML Polygon */
 public KmlPlacemark(Polygon polygon, KmlDocument kmlDoc) {
   this();
   mName = polygon.getTitle();
   mDescription = polygon.getSnippet();
   mGeometry = new KmlPolygon();
   mGeometry.mCoordinates = (ArrayList<GeoPoint>) polygon.getPoints();
   ((KmlPolygon) mGeometry).mHoles = (ArrayList<ArrayList<GeoPoint>>) polygon.getHoles();
   mVisibility = polygon.isEnabled();
   // Style:
   Style style = new Style();
   style.mPolyStyle = new ColorStyle(polygon.getFillColor());
   style.mLineStyle = new LineStyle(polygon.getStrokeColor(), polygon.getStrokeWidth());
   mStyle = kmlDoc.addStyle(style);
 }
예제 #8
0
 /** GeoJSON constructor */
 public KmlPlacemark(JsonObject json) {
   this();
   if (json.has("id")) mId = json.get("id").getAsString();
   JsonObject geometry = json.getAsJsonObject("geometry");
   if (geometry != null) {
     mGeometry = KmlGeometry.parseGeoJSON(geometry);
   }
   if (json.has("properties")) {
     // Parse properties:
     JsonObject properties = json.getAsJsonObject("properties");
     Set<Map.Entry<String, JsonElement>> entrySet = properties.entrySet();
     for (Map.Entry<String, JsonElement> entry : entrySet) {
       String key = entry.getKey();
       String value = entry.getValue().getAsString();
       if (key != null && value != null) setExtendedData(key, value);
     }
     // Put "name" property in standard KML format:
     if (mExtendedData != null && mExtendedData.containsKey("name")) {
       mName = mExtendedData.get("name");
       mExtendedData.remove("name");
     }
   }
 }
예제 #9
0
 @Override
 public KmlPlacemark clone() {
   KmlPlacemark kmlPlacemark = (KmlPlacemark) super.clone();
   if (mGeometry != null) kmlPlacemark.mGeometry = mGeometry.clone();
   return kmlPlacemark;
 }
예제 #10
0
 @Override
 public void writeKMLSpecifics(Writer writer) {
   if (mGeometry != null) mGeometry.saveAsKML(writer);
 }
예제 #11
0
 @Override
 public BoundingBoxE6 getBoundingBox() {
   if (mGeometry != null) return mGeometry.getBoundingBox();
   else return null;
 }