diff --git a/vtm-extras/src/org/oscim/tiling/source/geojson/GeoJsonTileDecoder.java b/vtm-extras/src/org/oscim/tiling/source/geojson/GeoJsonTileDecoder.java index 9d7d0e6f..341bd577 100644 --- a/vtm-extras/src/org/oscim/tiling/source/geojson/GeoJsonTileDecoder.java +++ b/vtm-extras/src/org/oscim/tiling/source/geojson/GeoJsonTileDecoder.java @@ -72,7 +72,7 @@ public class GeoJsonTileDecoder implements ITileDecoder { private double mTileY, mTileX, mTileScale; - GeoJsonTileDecoder(GeoJsonTileSource tileSource) { + public GeoJsonTileDecoder(GeoJsonTileSource tileSource) { mTileSource = tileSource; mTagMap = new LinkedHashMap(); mJsonFactory = new JsonFactory(); diff --git a/vtm-web-js/build.gradle b/vtm-web-js/build.gradle index a04cda3f..fa4acb8c 100644 --- a/vtm-web-js/build.gradle +++ b/vtm-web-js/build.gradle @@ -24,6 +24,7 @@ sourceSets { dependencies { providedCompile project(':vtm-web') + providedCompile project(':vtm-extras') providedCompile "com.badlogicgames.gdx:gdx:$gdxVersion:sources" providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources" providedCompile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion" @@ -36,6 +37,7 @@ dependencies { evaluationDependsOn(':vtm') evaluationDependsOn(':vtm-themes') evaluationDependsOn(':vtm-gdx') +//evaluationDependsOn(':vtm-extras') evaluationDependsOn(':vtm-web') gwt { @@ -56,6 +58,7 @@ gwt { src += files(project(':vtm-themes').sourceSets.main.allJava.srcDirs) src += files(project(':vtm-themes').sourceSets.main.resources.srcDirs) src += files(project(':vtm-gdx').sourceSets.main.allJava.srcDirs) + //src += files(project(':vtm-extras').sourceSets.main.allJava.srcDirs) src += files(project(':vtm-web').sourceSets.main.allJava.srcDirs) } diff --git a/vtm-web/build.gradle b/vtm-web/build.gradle index c3d2bf2f..24980f17 100644 --- a/vtm-web/build.gradle +++ b/vtm-web/build.gradle @@ -25,6 +25,7 @@ sourceSets { dependencies { compile project(':vtm-gdx') + compile project(':vtm-extras') compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources" compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources" compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion" @@ -36,6 +37,7 @@ dependencies { evaluationDependsOn(':vtm') evaluationDependsOn(':vtm-themes') evaluationDependsOn(':vtm-gdx') +evaluationDependsOn(':vtm-extras') gwt { gwtVersion='2.6.0' diff --git a/vtm-web/src/org/oscim/gdx/emu/org/oscim/tiling/source/geojson/GeoJsonTileSource.java b/vtm-web/src/org/oscim/gdx/emu/org/oscim/tiling/source/geojson/GeoJsonTileSource.java new file mode 100644 index 00000000..2e5c2c8b --- /dev/null +++ b/vtm-web/src/org/oscim/gdx/emu/org/oscim/tiling/source/geojson/GeoJsonTileSource.java @@ -0,0 +1,63 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +import java.util.Map; + +import org.oscim.core.MapElement; +import org.oscim.core.Tag; +import org.oscim.tiling.ITileDataSource; +import org.oscim.tiling.source.JsonTileDataSource; +import org.oscim.tiling.source.UrlTileSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class GeoJsonTileSource extends UrlTileSource { + static final Logger log = LoggerFactory.getLogger(GeoJsonTileSource.class); + + public GeoJsonTileSource(String url) { + super(url); + setExtension(".json"); + } + + @Override + public ITileDataSource getDataSource() { + return new JsonTileDataSource(this); + } + + public Tag getFeatureTag() { + return null; + } + + /** allow overriding tag handling */ + public abstract void decodeTags(MapElement mapElement, Map properties); + + public Tag rewriteTag(String key, Object value) { + + if (value == null) + return null; + + String val = (value instanceof String) ? (String) value : String.valueOf(value); + + return new Tag(key, val); + } + + /** modify mapElement before process() */ + public void postGeomHook(MapElement mapElement) { + + } +} diff --git a/vtm-web/src/org/oscim/tiling/source/JsonTileDataSource.java b/vtm-web/src/org/oscim/tiling/source/JsonTileDataSource.java new file mode 100644 index 00000000..f4b257e0 --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/JsonTileDataSource.java @@ -0,0 +1,126 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source; + +import static org.oscim.tiling.ITileDataSink.QueryResult.FAILED; +import static org.oscim.tiling.ITileDataSink.QueryResult.SUCCESS; + +import java.io.InputStream; + +import org.oscim.layers.tile.MapTile; +import org.oscim.layers.tile.MapTile.State; +import org.oscim.tiling.ITileDataSink; +import org.oscim.tiling.ITileDataSource; +import org.oscim.tiling.source.geojson.GeoJsonTileDecoder; +import org.oscim.tiling.source.geojson.GeoJsonTileSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.jsonp.client.JsonpRequest; +import com.google.gwt.jsonp.client.JsonpRequestBuilder; +import com.google.gwt.user.client.rpc.AsyncCallback; + +public class JsonTileDataSource implements ITileDataSource { + static final Logger log = LoggerFactory.getLogger(JsonTileDataSource.class); + + protected final GeoJsonTileDecoder mTileDecoder; + protected final UrlTileSource mTileSource; + + private final byte[] mRequestBuffer = new byte[1024]; + + public JsonTileDataSource(GeoJsonTileSource tileSource) { + mTileSource = tileSource; + mTileDecoder = new GeoJsonTileDecoder(tileSource); + } + + UrlTileSource getTileSource() { + return mTileSource; + } + + private ITileDataSink mSink; + private MapTile mTile; + + @Override + public void query(MapTile tile, ITileDataSink sink) { + mTile = tile; + mSink = sink; + + try { + int pos = mTileSource.formatTilePath(tile, mRequestBuffer, 0); + + String url = mTileSource.getUrl() + + (new String(mRequestBuffer, 0, pos)); + + doGet(url); + } catch (Exception e) { + e.printStackTrace(); + sink.completed(FAILED); + } + } + + public void process(InputStream is) { + } + + boolean mFinished; + + @Override + public void destroy() { + mFinished = true; + } + + JsonpRequest mRequestHandle; + + void doGet(final String url) { + JsonpRequestBuilder builder = new JsonpRequestBuilder(); + //builder.setCallbackParam("json_callback"); + + mRequestHandle = builder.requestObject(url, new AsyncCallback() { + public void onFailure(Throwable caught) { + + mSink.completed(FAILED); + log.debug("fail! {} {}", mRequestHandle, caught.getMessage()); + //mRequestHandle.cancel(); + } + + public void onSuccess(JavaScriptObject jso) { + if (mTile.state(State.NONE)) { + log.debug("tile cleared {}", url); + mSink.completed(FAILED); + return; + } + + if (jso == null) { + log.debug("Couldn't retrieve JSON for {}", url); + mSink.completed(FAILED); + return; + } + + try { + if (mTileDecoder.decode(mTile, mSink, jso)) { + mSink.completed(SUCCESS); + return; + } + } catch (Exception e) { + log.debug("Couldn't retrieve JSON for {} {}" + url, e); + // FIXME need to check where it might be thrown + mSink.completed(FAILED); + } + } + }); + } +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/Feature.java b/vtm-web/src/org/oscim/tiling/source/geojson/Feature.java new file mode 100644 index 00000000..0773ce57 --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/Feature.java @@ -0,0 +1,52 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +import java.util.HashMap; +import java.util.Map; + +public class Feature extends GeoJsonObject { + + protected Feature() { + + } + + public final native Geometry getGeometry() /*-{ + return this.geometry; + }-*/; + + public final native String getId() /*-{ + return this.id; + }-*/; + + public final native void setId(String id) /*-{ + this.id = id; + }-*/; + + public final Map getProperties(HashMap map) { + map.clear(); + fromJavascriptObject(map); + + return map; + } + + public final native void fromJavascriptObject(HashMap s) /*-{ + for(var key in this.properties) { + s.@java.util.HashMap::put(Ljava/lang/Object;Ljava/lang/Object;)(key, Object(this.properties[key])); + } + }-*/; +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/FeatureCollection.java b/vtm-web/src/org/oscim/tiling/source/geojson/FeatureCollection.java new file mode 100644 index 00000000..0ef10d4e --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/FeatureCollection.java @@ -0,0 +1,38 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +import java.util.Collection; + +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.core.client.JsArray; + +public class FeatureCollection extends JavaScriptObject { + + protected FeatureCollection() { + + } + + public final Collection getFeatures() { + return new JsArrayCollection(getFeaturesInternal()); + } + + public final native JsArray getFeaturesInternal()/*-{ + return this.features; + }-*/; + +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/GeoJsonObject.java b/vtm-web/src/org/oscim/tiling/source/geojson/GeoJsonObject.java new file mode 100644 index 00000000..c8589256 --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/GeoJsonObject.java @@ -0,0 +1,34 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +import com.google.gwt.core.client.JavaScriptObject; + +public abstract class GeoJsonObject extends JavaScriptObject { + + protected GeoJsonObject() { + + } + + public final native double[] getBbox()/*-{ + return bbox; + }-*/; + + public final native void setBbox(double[] bbox) /*-{ + this.bbox = bbox; + }-*/; +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/GeoJsonTileDecoder.java b/vtm-web/src/org/oscim/tiling/source/geojson/GeoJsonTileDecoder.java new file mode 100644 index 00000000..23e6ae0a --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/GeoJsonTileDecoder.java @@ -0,0 +1,139 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +import static org.oscim.core.MercatorProjection.latitudeToY; +import static org.oscim.core.MercatorProjection.longitudeToX; + +import java.io.IOException; +import java.io.InputStream; +import java.util.LinkedHashMap; + +import org.oscim.core.GeometryBuffer.GeometryType; +import org.oscim.core.MapElement; +import org.oscim.core.Tile; +import org.oscim.tiling.ITileDataSink; +import org.oscim.tiling.source.ITileDecoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gwt.core.client.JavaScriptObject; + +public class GeoJsonTileDecoder implements ITileDecoder { + static final Logger log = LoggerFactory.getLogger(GeoJsonTileDecoder.class); + + private final MapElement mapElement; + private final GeoJsonTileSource mTileSource; + + private ITileDataSink mTileDataSink; + + public GeoJsonTileDecoder(GeoJsonTileSource tileSource) { + mTileSource = tileSource; + mapElement = new MapElement(); + mapElement.layer = 5; + } + + final static LinkedHashMap mProperties = new LinkedHashMap(10); + + double mTileY, mTileX, mTileScale; + + public boolean decode(Tile tile, ITileDataSink sink, JavaScriptObject jso) { + mTileDataSink = sink; + + mTileScale = 1 << tile.zoomLevel; + mTileX = tile.tileX / mTileScale; + mTileY = tile.tileY / mTileScale; + mTileScale *= Tile.SIZE; + + FeatureCollection c = (FeatureCollection) jso; + + for (Feature f : c.getFeatures()) { + mapElement.clear(); + mapElement.tags.clear(); + + /* add tag information */ + mTileSource.decodeTags(mapElement, f.getProperties(mProperties)); + if (mapElement.tags.numTags == 0) + continue; + + /* add geometry information */ + decodeGeometry(f.getGeometry()); + + if (mapElement.type == GeometryType.NONE) + continue; + + mTileDataSink.process(mapElement); + } + + return true; + } + + private void decodeGeometry(Geometry geometry) { + String type = geometry.type(); + + if ("Polygon".equals(type)) { + Polygon p = (Polygon) geometry.getCoordinates(); + decodePolygon(p); + } else if ("MultiPolygon".equals(type)) { + MultiPolygon mp = (MultiPolygon) geometry.getCoordinates(); + for (int k = 0, l = mp.getNumGeometries(); k < l; k++) + decodePolygon(mp.getGeometryN(k)); + + } else if ("LineString".equals(type)) { + LineString ls = (LineString) geometry.getCoordinates(); + decodeLineString(ls); + + } else if ("MultiLineString".equals(type)) { + MultiLineString ml = (MultiLineString) geometry.getCoordinates(); + for (int k = 0, n = ml.getNumGeometries(); k < n; k++) + decodeLineString(ml.getGeometryN(k)); + } + } + + private void decodeLineString(LineString l) { + mapElement.startLine(); + for (int j = 0, m = l.length(); j < m; j++) { + decodePoint(l.get(j)); + } + } + + private void decodePolygon(Polygon p) { + for (int i = 0, n = p.getNumRings(); i < n; i++) { + if (i > 0) + mapElement.startHole(); + else + mapElement.startPolygon(); + + LineString ls = p.getRing(i); + for (int j = 0, m = ls.length() - 1; j < m; j++) + decodePoint(ls.get(j)); + } + } + + private void decodePoint(LngLat point) { + + float x = (float) ((longitudeToX(point.getLongitude()) - mTileX) * mTileScale); + float y = (float) ((latitudeToY(point.getLatitude()) - mTileY) * mTileScale); + + mapElement.addPoint(x, y); + } + + @Override + public boolean decode(Tile tile, ITileDataSink sink, InputStream is) throws IOException { + return false; + } +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/Geometry.java b/vtm-web/src/org/oscim/tiling/source/geojson/Geometry.java new file mode 100644 index 00000000..c9a51d78 --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/Geometry.java @@ -0,0 +1,35 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +import com.google.gwt.core.client.JavaScriptObject; +import com.google.gwt.core.client.JsArray; + +public abstract class Geometry extends JsArray { + + protected Geometry() { + + } + + public final native String type()/*-{ + return this.type + }-*/; + + public final native JsArray getCoordinates() /*-{ + return this.coordinates; + }-*/; +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/JsArrayCollection.java b/vtm-web/src/org/oscim/tiling/source/geojson/JsArrayCollection.java new file mode 100644 index 00000000..ed45484c --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/JsArrayCollection.java @@ -0,0 +1,100 @@ +package org.oscim.tiling.source.geojson; + +import java.util.AbstractCollection; +import java.util.Iterator; + +import com.google.gwt.core.client.JavaScriptObject; + +/** + * a Java Friendly way of working with Js Arrays using the Java.util.Collection + * API + * https://groups.google.com/forum/#!topic/google-web-toolkit/_8X9WPL6qwM + * + * @author sg + * + * @param + */ +public class JsArrayCollection extends AbstractCollection { + + private JsArr _data; + + /** + * creates an empty array + */ + public JsArrayCollection() { + _data = JsArr.create().cast(); + } + + /** + * creates JsArrayCollection wrapping an existing js array + */ + public JsArrayCollection(JavaScriptObject data) { + this._data = data.cast(); + } + + public static JsArrayCollection create(JavaScriptObject data) { + return new JsArrayCollection(data); + } + + @Override + public Iterator iterator() { + return new JsArrayIterator(this); + } + + @Override + public int size() { + return _data.size(); + } + + public static class JsArrayIterator implements Iterator { + + private JsArrayCollection arr; + int currentIndex; + + public JsArrayIterator(JsArrayCollection arr) { + this.arr = arr; + currentIndex = 0; + } + + @Override + public boolean hasNext() { + // System.out.println(currentIndex+" - "+arr.size()); + return currentIndex < arr.size(); + } + + @Override + public T next() { + currentIndex++; + return arr._data.get(currentIndex - 1); + } + + @Override + public void remove() { + arr._data.slice(currentIndex - 1, currentIndex); + } + + } + + /** untyped array */ + private static class JsArr extends JavaScriptObject { + protected JsArr() { + } + + public native final JsArr slice(int start, int end)/*-{ + return this.slice(start, end); + }-*/; + + public static final native JsArr create() /*-{ + return []; + }-*/; + + public final native int size() /*-{ + return this.length; + }-*/; + + public final native T get(int i) /*-{ + return this[i]; + }-*/; + } + +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/LineString.java b/vtm-web/src/org/oscim/tiling/source/geojson/LineString.java new file mode 100644 index 00000000..490e1cf0 --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/LineString.java @@ -0,0 +1,23 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +public class LineString extends Geometry { + + protected LineString() { + } +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/LngLat.java b/vtm-web/src/org/oscim/tiling/source/geojson/LngLat.java new file mode 100644 index 00000000..0fdf879f --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/LngLat.java @@ -0,0 +1,18 @@ +package org.oscim.tiling.source.geojson; + +import com.google.gwt.core.client.JavaScriptObject; + +public class LngLat extends JavaScriptObject { + + protected LngLat() { + + } + + public final native double getLongitude() /*-{ + return this[0]; + }-*/; + + public final native double getLatitude() /*-{ + return this[1]; + }-*/; +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/MultiLineString.java b/vtm-web/src/org/oscim/tiling/source/geojson/MultiLineString.java new file mode 100644 index 00000000..422a3b44 --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/MultiLineString.java @@ -0,0 +1,32 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +public class MultiLineString extends Geometry { + + protected MultiLineString() { + } + + public final native LineString getGeometryN(int i) /*-{ + return this[i]; + }-*/; + + public final native int getNumGeometries() /*-{ + return this.length; + }-*/; + +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/MultiPolygon.java b/vtm-web/src/org/oscim/tiling/source/geojson/MultiPolygon.java new file mode 100644 index 00000000..c52b89a5 --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/MultiPolygon.java @@ -0,0 +1,32 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +public class MultiPolygon extends Geometry { + + protected MultiPolygon() { + } + + public final native Polygon getGeometryN(int i) /*-{ + return this[i]; + }-*/; + + public final native int getNumGeometries() /*-{ + return this.length; + }-*/; + +} diff --git a/vtm-web/src/org/oscim/tiling/source/geojson/Polygon.java b/vtm-web/src/org/oscim/tiling/source/geojson/Polygon.java new file mode 100644 index 00000000..3ef0bc0b --- /dev/null +++ b/vtm-web/src/org/oscim/tiling/source/geojson/Polygon.java @@ -0,0 +1,36 @@ +/* + * Copyright 2014 Hannes Janetzek + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * This program is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ +package org.oscim.tiling.source.geojson; + +public class Polygon extends Geometry { + + protected Polygon() { + } + + public final native LineString getExteriorRing()/*-{ + return this[0]; + }-*/; + + public final native LineString getRing(int i) /*-{ + return this[i]; + }-*/; + + public final native int getNumRings() /*-{ + return this.length; + }-*/; + +}