This is an automated email from the ASF dual-hosted git repository. jsorel pushed a commit to branch feat/geojson in repository https://gitbox.apache.org/repos/asf/sis.git
commit b8be7b82ded3e781f5ac07b5d72ad8b5e459a466 Author: jsorel <[email protected]> AuthorDate: Wed Nov 13 09:11:13 2019 +0100 GeoJson : reorganize packages --- .../utils => internal/geojson}/GeoJSONUtils.java | 5 +- .../geojson/binding/GeoJSONCRS.java | 4 +- .../geojson/binding/GeoJSONFeature.java | 2 +- .../geojson/binding/GeoJSONFeatureCollection.java | 10 +- .../geojson/binding/GeoJSONGeometry.java} | 175 ++++++++++++++++++-- .../geojson/binding/GeoJSONObject.java | 4 +- .../org/apache/sis/storage/geojson/Bundle.java | 4 +- .../sis/storage/geojson/GeoJSONFileWriter.java | 7 +- .../sis/storage/geojson/GeoJSONProvider.java | 2 +- .../apache/sis/storage/geojson/GeoJSONReader.java | 30 ++-- .../apache/sis/storage/geojson/GeoJSONStore.java | 26 +-- .../sis/storage/geojson/GeoJSONStreamWriter.java | 9 +- .../apache/sis/storage/geojson/GeoJSONWriter.java | 41 ++--- .../storage/geojson/binding/GeoJSONGeometry.java | 177 --------------------- .../storage/geojson/utils/FeatureTypeUtils.java | 1 + .../geojson/utils/GeoJSONFeatureIterator.java | 44 ----- .../sis/storage/geojson/utils/GeoJSONParser.java | 20 ++- .../storage/geojson/FeatureTypeUtilsTest.java | 2 +- .../internal/storage/geojson/GeoJSONReadTest.java | 4 +- .../internal/storage/geojson/GeoJSONWriteTest.java | 2 +- .../storage/geojson/LiteJsonLocationTest.java | 2 +- 21 files changed, 253 insertions(+), 318 deletions(-) diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONUtils.java b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/GeoJSONUtils.java similarity index 99% rename from storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONUtils.java rename to storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/GeoJSONUtils.java index 55a41ac..95ce225 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONUtils.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/GeoJSONUtils.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.storage.geojson.utils; +package org.apache.sis.internal.geojson; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonGenerator; @@ -24,7 +24,7 @@ import org.apache.sis.storage.DataStoreException; import org.apache.sis.io.wkt.Convention; import org.apache.sis.geometry.GeneralEnvelope; import org.apache.sis.util.ArgumentChecks; -import org.apache.sis.storage.geojson.binding.GeoJSONObject; +import org.apache.sis.internal.geojson.binding.GeoJSONObject; import org.opengis.geometry.Envelope; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.util.FactoryException; @@ -60,6 +60,7 @@ import org.apache.sis.internal.storage.io.IOUtilities; import org.apache.sis.io.wkt.WKTFormat; import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.referencing.IdentifiedObjects; +import org.apache.sis.storage.geojson.utils.GeoJSONParser; import org.apache.sis.util.Numbers; import static org.apache.sis.storage.geojson.utils.GeoJSONMembres.*; import static org.apache.sis.storage.geojson.utils.GeoJSONTypes.*; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONCRS.java b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONCRS.java similarity index 96% rename from storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONCRS.java rename to storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONCRS.java index cd118c0..d988322 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONCRS.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONCRS.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.storage.geojson.binding; +package org.apache.sis.internal.geojson.binding; import java.io.Serializable; import java.net.MalformedURLException; @@ -25,7 +25,7 @@ import org.apache.sis.referencing.crs.AbstractCRS; import org.apache.sis.referencing.cs.AxesConvention; import static org.apache.sis.storage.geojson.utils.GeoJSONMembres.*; import static org.apache.sis.storage.geojson.utils.GeoJSONTypes.*; -import org.apache.sis.storage.geojson.utils.GeoJSONUtils; +import org.apache.sis.internal.geojson.GeoJSONUtils; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.util.FactoryException; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONFeature.java b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONFeature.java similarity index 97% rename from storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONFeature.java rename to storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONFeature.java index f15d589..2b6500d 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONFeature.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONFeature.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.storage.geojson.binding; +package org.apache.sis.internal.geojson.binding; import org.apache.sis.storage.geojson.utils.GeoJSONTypes; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONFeatureCollection.java b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONFeatureCollection.java similarity index 97% rename from storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONFeatureCollection.java rename to storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONFeatureCollection.java index a563cde..57fc264 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONFeatureCollection.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONFeatureCollection.java @@ -14,20 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.storage.geojson.binding; +package org.apache.sis.internal.geojson.binding; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; - -import org.apache.sis.storage.geojson.utils.*; - +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import org.apache.sis.storage.geojson.utils.*; import org.apache.sis.util.collection.BackingStoreException; /** @@ -37,7 +37,7 @@ import org.apache.sis.util.collection.BackingStoreException; * @since 2.0 * @module */ -public class GeoJSONFeatureCollection extends GeoJSONObject implements GeoJSONFeatureIterator<GeoJSONFeature> { +public class GeoJSONFeatureCollection extends GeoJSONObject implements Iterator<GeoJSONFeature>, Closeable { private List<GeoJSONFeature> features = new ArrayList<>(); diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeometryUtils.java b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONGeometry.java similarity index 75% rename from storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeometryUtils.java rename to storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONGeometry.java index b41748f..cd82640 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeometryUtils.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONGeometry.java @@ -14,20 +14,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.storage.geojson.utils; +package org.apache.sis.internal.geojson.binding; +import java.io.Serializable; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import org.apache.sis.storage.geojson.binding.*; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONGeometryCollection; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONLineString; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiLineString; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiPoint; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiPolygon; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONPoint; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONPolygon; -import org.apache.sis.util.Static; -import org.locationtech.jts.geom.*; +import java.util.List; +import org.apache.sis.storage.geojson.utils.GeoJSONTypes; +import org.locationtech.jts.geom.Coordinate; +import org.locationtech.jts.geom.CoordinateSequence; +import org.locationtech.jts.geom.Geometry; +import org.locationtech.jts.geom.GeometryCollection; +import org.locationtech.jts.geom.GeometryFactory; +import org.locationtech.jts.geom.LineString; +import org.locationtech.jts.geom.LinearRing; +import org.locationtech.jts.geom.MultiLineString; +import org.locationtech.jts.geom.MultiPoint; +import org.locationtech.jts.geom.MultiPolygon; +import org.locationtech.jts.geom.Point; +import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.geom.impl.CoordinateArraySequence; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -38,7 +44,152 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; * @since 2.0 * @module */ -public final class GeometryUtils extends Static { +public class GeoJSONGeometry extends GeoJSONObject implements Serializable { + + public GeoJSONGeometry() { + } + + /** + * POINT + */ + public static class GeoJSONPoint extends GeoJSONGeometry { + + private double[] coordinates = null; + + public GeoJSONPoint() { + setType(GeoJSONTypes.POINT); + } + + public double[] getCoordinates() { + return coordinates; + } + + public void setCoordinates(double[] coordinates) { + this.coordinates = coordinates; + } + + } + + /** + * MULTI-POINT + */ + public static class GeoJSONMultiPoint extends GeoJSONGeometry { + + private double[][] coordinates = null; + + public GeoJSONMultiPoint() { + setType(GeoJSONTypes.MULTI_POINT); + } + + public double[][] getCoordinates() { + return coordinates; + } + + public void setCoordinates(double[][] coordinates) { + this.coordinates = coordinates; + } + } + + /** + * LINESTRING + */ + public static class GeoJSONLineString extends GeoJSONGeometry { + + private double[][] coordinates = null; + + public GeoJSONLineString() { + setType(GeoJSONTypes.LINESTRING); + } + + public double[][] getCoordinates() { + return coordinates; + } + + public void setCoordinates(double[][] coordinates) { + this.coordinates = coordinates; + } + } + + /** + * MULTI-LINESTRING + */ + public static class GeoJSONMultiLineString extends GeoJSONGeometry { + + private double[][][] coordinates = null; + + public GeoJSONMultiLineString() { + setType(GeoJSONTypes.MULTI_LINESTRING); + } + + public double[][][] getCoordinates() { + return coordinates; + } + + public void setCoordinates(double[][][] coordinates) { + this.coordinates = coordinates; + } + } + + /** + * POLYGON + */ + public static class GeoJSONPolygon extends GeoJSONGeometry { + + private double[][][] coordinates = null; + + public GeoJSONPolygon() { + setType(GeoJSONTypes.POLYGON); + } + + public double[][][] getCoordinates() { + return coordinates; + } + + public void setCoordinates(double[][][] coordinates) { + this.coordinates = coordinates; + } + } + + /** + * MULTI-POLYGON + */ + public static class GeoJSONMultiPolygon extends GeoJSONGeometry { + + private double[][][][] coordinates = null; + + public GeoJSONMultiPolygon() { + setType(GeoJSONTypes.MULTI_POLYGON); + } + + public double[][][][] getCoordinates() { + return coordinates; + } + + public void setCoordinates(double[][][][] coordinates) { + this.coordinates = coordinates; + } + } + + /** + * GEOMETRY-COLLECTION + */ + public static class GeoJSONGeometryCollection extends GeoJSONGeometry { + + protected List<GeoJSONGeometry> geometries = new ArrayList<GeoJSONGeometry>(); + + public GeoJSONGeometryCollection() { + setType(GeoJSONTypes.GEOMETRY_COLLECTION); + } + + public List<GeoJSONGeometry> getGeometries() { + return geometries; + } + + public void setGeometries(List<GeoJSONGeometry> geometries) { + this.geometries = geometries; + } + } + private static final GeometryFactory GF = new GeometryFactory(); diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONObject.java b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONObject.java similarity index 95% rename from storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONObject.java rename to storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONObject.java index 5658c23..d3fca44 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONObject.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/internal/geojson/binding/GeoJSONObject.java @@ -14,12 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.storage.geojson.binding; +package org.apache.sis.internal.geojson.binding; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import static org.apache.sis.storage.geojson.binding.GeoJSONGeometry.*; +import static org.apache.sis.internal.geojson.binding.GeoJSONGeometry.*; import java.io.Serializable; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/Bundle.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/Bundle.java index b6074e0..0e09243 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/Bundle.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/Bundle.java @@ -17,11 +17,11 @@ package org.apache.sis.storage.geojson; import java.util.Locale; -import java.util.ResourceBundle; import java.util.MissingResourceException; -import org.opengis.util.InternationalString; +import java.util.ResourceBundle; import org.apache.sis.util.iso.ResourceInternationalString; import org.apache.sis.util.resources.IndexedResourceBundle; +import org.opengis.util.InternationalString; /** diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONFileWriter.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONFileWriter.java index c0d8e2b..ca387ae 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONFileWriter.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONFileWriter.java @@ -17,16 +17,13 @@ package org.apache.sis.storage.geojson; import com.fasterxml.jackson.core.JsonEncoding; -import java.io.Closeable; -import org.apache.sis.storage.DataStoreException; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; -import java.util.Iterator; import java.util.concurrent.locks.ReadWriteLock; import org.apache.sis.internal.feature.AttributeConvention; +import org.apache.sis.storage.DataStoreException; import org.apache.sis.util.collection.BackingStoreException; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; @@ -39,7 +36,7 @@ import org.opengis.feature.FeatureType; * @since 2.0 * @module */ -class GeoJSONFileWriter extends GeoJSONReader { +final class GeoJSONFileWriter extends GeoJSONReader { private final GeoJSONWriter writer; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONProvider.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONProvider.java index ab7148a..02d98c2 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONProvider.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONProvider.java @@ -50,7 +50,7 @@ import org.opengis.parameter.ParameterValueGroup; capabilities = {Capability.READ, Capability.WRITE, Capability.CREATE}, fileSuffixes = {"json", "geojson", "topojson"}, resourceTypes = {FeatureSet.class}) -public class GeoJSONProvider extends DataStoreProvider { +public final class GeoJSONProvider extends DataStoreProvider { public static final String NAME = "geojson"; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONReader.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONReader.java index 4ab24df..04cba99 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONReader.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONReader.java @@ -16,19 +16,6 @@ */ package org.apache.sis.storage.geojson; -import org.locationtech.jts.geom.Geometry; -import org.apache.sis.util.logging.Logging; -import org.apache.sis.storage.geojson.binding.GeoJSONFeature; -import org.apache.sis.storage.geojson.binding.GeoJSONFeatureCollection; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry; -import org.apache.sis.storage.geojson.binding.GeoJSONObject; -import org.apache.sis.storage.geojson.utils.GeoJSONParser; -import org.apache.sis.storage.geojson.utils.GeometryUtils; -import org.apache.sis.util.ObjectConverters; -import org.apache.sis.util.UnconvertibleObjectException; -import org.apache.sis.util.ObjectConverter; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - import java.io.IOException; import java.lang.reflect.Array; import java.nio.file.Path; @@ -43,14 +30,25 @@ import java.util.function.Function; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.sis.internal.feature.AttributeConvention; -import org.apache.sis.storage.geojson.utils.GeoJSONUtils; +import org.apache.sis.internal.geojson.binding.GeoJSONFeature; +import org.apache.sis.internal.geojson.binding.GeoJSONFeatureCollection; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry; +import org.apache.sis.internal.geojson.binding.GeoJSONObject; +import org.apache.sis.storage.geojson.utils.GeoJSONParser; +import org.apache.sis.internal.geojson.GeoJSONUtils; +import org.apache.sis.util.ObjectConverter; +import org.apache.sis.util.ObjectConverters; +import org.apache.sis.util.UnconvertibleObjectException; import org.apache.sis.util.collection.BackingStoreException; +import org.apache.sis.util.logging.Logging; +import org.locationtech.jts.geom.Geometry; import org.opengis.feature.Attribute; import org.opengis.feature.AttributeType; import org.opengis.feature.Feature; import org.opengis.feature.FeatureAssociationRole; import org.opengis.feature.FeatureType; import org.opengis.feature.PropertyType; +import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * @author Quentin Boileau (Geomatys) @@ -166,7 +164,7 @@ public class GeoJSONReader implements Iterator<Feature>, AutoCloseable { protected Feature toFeature(GeoJSONFeature jsonFeature) throws BackingStoreException { //Build geometry - final Geometry geom = GeometryUtils.toJTS(jsonFeature.getGeometry(), crs); + final Geometry geom = GeoJSONGeometry.toJTS(jsonFeature.getGeometry(), crs); //empty feature final Feature feature = featureType.newInstance(); @@ -323,7 +321,7 @@ public class GeoJSONReader implements Iterator<Feature>, AutoCloseable { */ protected Feature toFeature(GeoJSONGeometry jsonGeometry) { final Feature feature = featureType.newInstance(); - final Geometry geom = GeometryUtils.toJTS(jsonGeometry, crs); + final Geometry geom = GeoJSONGeometry.toJTS(jsonGeometry, crs); feature.setPropertyValue(geometryName, geom); return feature; } diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStore.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStore.java index a57b41f..1b0740e 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStore.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStore.java @@ -34,28 +34,30 @@ import java.util.stream.StreamSupport; import org.apache.sis.feature.builder.AttributeRole; import org.apache.sis.feature.builder.AttributeTypeBuilder; import org.apache.sis.feature.builder.FeatureTypeBuilder; +import org.apache.sis.internal.geojson.binding.GeoJSONFeature; +import org.apache.sis.internal.geojson.binding.GeoJSONFeatureCollection; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONGeometryCollection; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONLineString; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiLineString; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiPoint; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiPolygon; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONPoint; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONPolygon; +import org.apache.sis.internal.geojson.binding.GeoJSONObject; import org.apache.sis.internal.storage.ResourceOnFileSystem; import org.apache.sis.metadata.iso.DefaultMetadata; import org.apache.sis.parameter.Parameters; import org.apache.sis.storage.DataStore; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.DataStoreProvider; -import org.apache.sis.storage.Query; import org.apache.sis.storage.WritableFeatureSet; -import org.apache.sis.util.logging.Logging; import static org.apache.sis.storage.geojson.GeoJSONProvider.*; -import org.apache.sis.storage.geojson.binding.*; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONGeometryCollection; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONLineString; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiLineString; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiPoint; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiPolygon; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONPoint; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONPolygon; import org.apache.sis.storage.geojson.utils.FeatureTypeUtils; import org.apache.sis.storage.geojson.utils.GeoJSONParser; -import org.apache.sis.storage.geojson.utils.GeoJSONUtils; +import org.apache.sis.internal.geojson.GeoJSONUtils; import org.apache.sis.util.iso.Names; +import org.apache.sis.util.logging.Logging; import org.locationtech.jts.geom.*; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; @@ -99,7 +101,7 @@ public class GeoJSONStore extends DataStore implements ResourceOnFileSystem, Wri this(provider, toParameter(uri, coordAccuracy)); } - public GeoJSONStore (DataStoreProvider provider, final ParameterValueGroup params) throws DataStoreException { + public GeoJSONStore(DataStoreProvider provider, final ParameterValueGroup params) throws DataStoreException { super(); this.provider = provider; this.parameters = params; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStreamWriter.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStreamWriter.java index f43a42d..7942b4e 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStreamWriter.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONStreamWriter.java @@ -17,9 +17,6 @@ package org.apache.sis.storage.geojson; import com.fasterxml.jackson.core.JsonEncoding; -import org.locationtech.jts.geom.Geometry; -import org.apache.sis.storage.DataStoreException; - import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; @@ -29,10 +26,12 @@ import java.util.stream.Collectors; import org.apache.sis.feature.builder.FeatureTypeBuilder; import org.apache.sis.feature.builder.PropertyTypeBuilder; import org.apache.sis.internal.feature.AttributeConvention; +import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.FeatureNaming; import org.apache.sis.storage.IllegalNameException; -import org.apache.sis.storage.geojson.utils.GeoJSONUtils; +import org.apache.sis.internal.geojson.GeoJSONUtils; import org.apache.sis.util.collection.BackingStoreException; +import org.locationtech.jts.geom.Geometry; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; import org.opengis.feature.Operation; @@ -44,7 +43,7 @@ import org.opengis.feature.Operation; * @since 2.0 * @module */ -public class GeoJSONStreamWriter implements Iterator<Feature>, AutoCloseable { +public final class GeoJSONStreamWriter implements Iterator<Feature>, AutoCloseable { private final GeoJSONWriter writer; private final FeatureType featureType; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONWriter.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONWriter.java index 72aac30..f519cd3 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONWriter.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/GeoJSONWriter.java @@ -18,34 +18,35 @@ package org.apache.sis.storage.geojson; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonGenerator; -import org.locationtech.jts.geom.Geometry; -import org.apache.sis.referencing.CommonCRS; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry; -import org.apache.sis.storage.geojson.utils.GeoJSONParser; -import org.apache.sis.storage.geojson.utils.GeoJSONUtils; -import org.apache.sis.storage.geojson.utils.GeometryUtils; -import org.opengis.geometry.Envelope; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - import java.io.*; import java.nio.file.Files; import java.nio.file.Path; +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static java.nio.file.StandardOpenOption.WRITE; import java.text.NumberFormat; import java.util.Collection; import java.util.List; import java.util.Locale; - -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; -import static java.nio.file.StandardOpenOption.WRITE; import java.util.Optional; import java.util.logging.Level; import java.util.stream.Collectors; import org.apache.sis.internal.feature.AttributeConvention; -import org.apache.sis.util.Utilities; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONGeometryCollection; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONLineString; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiLineString; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiPoint; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiPolygon; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONPoint; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONPolygon; +import org.apache.sis.referencing.CommonCRS; import static org.apache.sis.storage.geojson.utils.GeoJSONMembres.*; +import org.apache.sis.storage.geojson.utils.GeoJSONParser; import static org.apache.sis.storage.geojson.utils.GeoJSONTypes.*; -import static org.apache.sis.storage.geojson.binding.GeoJSONGeometry.*; +import org.apache.sis.internal.geojson.GeoJSONUtils; +import org.apache.sis.util.Utilities; +import org.locationtech.jts.geom.Geometry; import org.opengis.feature.Attribute; import org.opengis.feature.AttributeType; import org.opengis.feature.Feature; @@ -54,6 +55,8 @@ import org.opengis.feature.FeatureType; import org.opengis.feature.Operation; import org.opengis.feature.PropertyNotFoundException; import org.opengis.feature.PropertyType; +import org.opengis.geometry.Envelope; +import org.opengis.referencing.crs.CoordinateReferenceSystem; /** * @author Quentin Boileau (Geomatys) @@ -62,7 +65,7 @@ import org.opengis.feature.PropertyType; * @since 2.0 * @module */ -class GeoJSONWriter implements Closeable, Flushable { +final class GeoJSONWriter implements Closeable, Flushable { private final static String SYS_LF; static { @@ -341,7 +344,7 @@ class GeoJSONWriter implements Closeable, Flushable { assert(!isFeatureCollection && !isSingleFeature && !isSingleGeometry) : "writeSingleGeometry can called only once per GeoJSONWriter."; isSingleGeometry = true; - GeoJSONGeometry jsonGeometry = GeometryUtils.toGeoJSONGeometry((Geometry) geom.getValue()); + GeoJSONGeometry jsonGeometry = GeoJSONGeometry.toGeoJSONGeometry((Geometry) geom.getValue()); writeGeoJSONGeometry(jsonGeometry); } @@ -354,7 +357,7 @@ class GeoJSONWriter implements Closeable, Flushable { assert(!isFeatureCollection && !isSingleFeature && !isSingleGeometry) : "writeSingleGeometry can called only once per GeoJSONWriter."; isSingleGeometry = true; - GeoJSONGeometry jsonGeometry = GeometryUtils.toGeoJSONGeometry(geom); + GeoJSONGeometry jsonGeometry = GeoJSONGeometry.toGeoJSONGeometry(geom); writeGeoJSONGeometry(jsonGeometry); } @@ -364,7 +367,7 @@ class GeoJSONWriter implements Closeable, Flushable { * @throws IOException */ private void writeFeatureGeometry(Geometry geom) throws IOException { - writeGeoJSONGeometry(GeometryUtils.toGeoJSONGeometry(geom)); + writeGeoJSONGeometry(GeoJSONGeometry.toGeoJSONGeometry(geom)); } /** diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONGeometry.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONGeometry.java deleted file mode 100644 index 4c0a1db..0000000 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/binding/GeoJSONGeometry.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.geojson.binding; - -import org.apache.sis.storage.geojson.utils.GeoJSONTypes; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Quentin Boileau (Geomatys) - * @author Johann Sorel (Geomatys) - * @version 2.0 - * @since 2.0 - * @module - */ -public class GeoJSONGeometry extends GeoJSONObject implements Serializable { - - public GeoJSONGeometry() { - } - - /** - * POINT - */ - public static class GeoJSONPoint extends GeoJSONGeometry { - - private double[] coordinates = null; - - public GeoJSONPoint() { - setType(GeoJSONTypes.POINT); - } - - public double[] getCoordinates() { - return coordinates; - } - - public void setCoordinates(double[] coordinates) { - this.coordinates = coordinates; - } - - } - - /** - * MULTI-POINT - */ - public static class GeoJSONMultiPoint extends GeoJSONGeometry { - - private double[][] coordinates = null; - - public GeoJSONMultiPoint() { - setType(GeoJSONTypes.MULTI_POINT); - } - - public double[][] getCoordinates() { - return coordinates; - } - - public void setCoordinates(double[][] coordinates) { - this.coordinates = coordinates; - } - } - - /** - * LINESTRING - */ - public static class GeoJSONLineString extends GeoJSONGeometry { - - private double[][] coordinates = null; - - public GeoJSONLineString() { - setType(GeoJSONTypes.LINESTRING); - } - - public double[][] getCoordinates() { - return coordinates; - } - - public void setCoordinates(double[][] coordinates) { - this.coordinates = coordinates; - } - } - - /** - * MULTI-LINESTRING - */ - public static class GeoJSONMultiLineString extends GeoJSONGeometry { - - private double[][][] coordinates = null; - - public GeoJSONMultiLineString() { - setType(GeoJSONTypes.MULTI_LINESTRING); - } - - public double[][][] getCoordinates() { - return coordinates; - } - - public void setCoordinates(double[][][] coordinates) { - this.coordinates = coordinates; - } - } - - /** - * POLYGON - */ - public static class GeoJSONPolygon extends GeoJSONGeometry { - - private double[][][] coordinates = null; - - public GeoJSONPolygon() { - setType(GeoJSONTypes.POLYGON); - } - - public double[][][] getCoordinates() { - return coordinates; - } - - public void setCoordinates(double[][][] coordinates) { - this.coordinates = coordinates; - } - } - - /** - * MULTI-POLYGON - */ - public static class GeoJSONMultiPolygon extends GeoJSONGeometry { - - private double[][][][] coordinates = null; - - public GeoJSONMultiPolygon() { - setType(GeoJSONTypes.MULTI_POLYGON); - } - - public double[][][][] getCoordinates() { - return coordinates; - } - - public void setCoordinates(double[][][][] coordinates) { - this.coordinates = coordinates; - } - } - - /** - * GEOMETRY-COLLECTION - */ - public static class GeoJSONGeometryCollection extends GeoJSONGeometry { - - protected List<GeoJSONGeometry> geometries = new ArrayList<GeoJSONGeometry>(); - - public GeoJSONGeometryCollection() { - setType(GeoJSONTypes.GEOMETRY_COLLECTION); - } - - public List<GeoJSONGeometry> getGeometries() { - return geometries; - } - - public void setGeometries(List<GeoJSONGeometry> geometries) { - this.geometries = geometries; - } - } -} diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/FeatureTypeUtils.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/FeatureTypeUtils.java index 8f6e50b..3f64c65 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/FeatureTypeUtils.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/FeatureTypeUtils.java @@ -16,6 +16,7 @@ */ package org.apache.sis.storage.geojson.utils; +import org.apache.sis.internal.geojson.GeoJSONUtils; import com.fasterxml.jackson.core.JsonEncoding; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONFeatureIterator.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONFeatureIterator.java deleted file mode 100644 index 697b0f4..0000000 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONFeatureIterator.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.geojson.utils; - -import java.io.Closeable; -import java.util.Iterator; -import org.apache.sis.storage.geojson.binding.GeoJSONFeature; -import org.apache.sis.util.collection.BackingStoreException; - -/** - * Custom FeatureIterator used for lazy parsing of GeoJSONFeature in a json file. - * - * @author Quentin Boileau (Geomatys) - * @author Johann Sorel (Geomatys) - * @version 2.0 - * @since 2.0 - * @module - */ -public interface GeoJSONFeatureIterator<F extends GeoJSONFeature> extends Iterator<F>, Closeable { - - @Override - F next() throws BackingStoreException; - - @Override - boolean hasNext() throws BackingStoreException; - - @Override - void close() throws BackingStoreException; - -} diff --git a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONParser.java b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONParser.java index e7a678f..9daf792 100644 --- a/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONParser.java +++ b/storage/sis-geojson/src/main/java/org/apache/sis/storage/geojson/utils/GeoJSONParser.java @@ -16,6 +16,11 @@ */ package org.apache.sis.storage.geojson.utils; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry; +import org.apache.sis.internal.geojson.binding.GeoJSONCRS; +import org.apache.sis.internal.geojson.binding.GeoJSONObject; +import org.apache.sis.internal.geojson.binding.GeoJSONFeatureCollection; +import org.apache.sis.internal.geojson.binding.GeoJSONFeature; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; @@ -28,14 +33,13 @@ import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.apache.sis.util.logging.Logging; -import org.apache.sis.storage.geojson.binding.*; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONGeometryCollection; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONLineString; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiLineString; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiPoint; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONMultiPolygon; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONPoint; -import org.apache.sis.storage.geojson.binding.GeoJSONGeometry.GeoJSONPolygon; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONGeometryCollection; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONLineString; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiLineString; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiPoint; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiPolygon; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONPoint; +import org.apache.sis.internal.geojson.binding.GeoJSONGeometry.GeoJSONPolygon; import static org.apache.sis.storage.geojson.utils.GeoJSONMembres.*; import static org.apache.sis.storage.geojson.utils.GeoJSONTypes.*; diff --git a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/FeatureTypeUtilsTest.java b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/FeatureTypeUtilsTest.java index 4a2b1c0..474f6b6 100644 --- a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/FeatureTypeUtilsTest.java +++ b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/FeatureTypeUtilsTest.java @@ -33,7 +33,7 @@ import org.apache.sis.feature.builder.AttributeRole; import org.apache.sis.feature.builder.FeatureTypeBuilder; import org.apache.sis.internal.feature.AttributeConvention; import org.apache.sis.storage.geojson.utils.FeatureTypeUtils; -import org.apache.sis.storage.geojson.utils.GeoJSONUtils; +import org.apache.sis.internal.geojson.GeoJSONUtils; import org.apache.sis.test.TestCase; import static org.junit.Assert.*; diff --git a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONReadTest.java b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONReadTest.java index b9e1831..16b563a 100644 --- a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONReadTest.java +++ b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONReadTest.java @@ -30,8 +30,8 @@ import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.DataStores; import org.apache.sis.storage.FeatureSet; import org.apache.sis.storage.geojson.GeoJSONStore; -import org.apache.sis.storage.geojson.binding.GeoJSONFeatureCollection; -import org.apache.sis.storage.geojson.binding.GeoJSONObject; +import org.apache.sis.internal.geojson.binding.GeoJSONFeatureCollection; +import org.apache.sis.internal.geojson.binding.GeoJSONObject; import org.apache.sis.storage.geojson.utils.GeoJSONParser; import org.apache.sis.test.TestCase; import org.apache.sis.util.iso.Names; diff --git a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONWriteTest.java b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONWriteTest.java index d4894c8..c4475f8 100644 --- a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONWriteTest.java +++ b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/GeoJSONWriteTest.java @@ -544,7 +544,7 @@ public class GeoJSONWriteTest extends TestCase { } return cp; }else if (candidate instanceof Map) { - final Map map = (Map)candidate; + final Map map = (Map) candidate; final Map cp = new HashMap(map.size()); for(final Iterator<Map.Entry> ite=map.entrySet().iterator(); ite.hasNext();) { final Map.Entry entry = ite.next(); diff --git a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/LiteJsonLocationTest.java b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/LiteJsonLocationTest.java index 1043c1c..15ba514 100644 --- a/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/LiteJsonLocationTest.java +++ b/storage/sis-geojson/src/test/java/org/apache/sis/internal/storage/geojson/LiteJsonLocationTest.java @@ -31,7 +31,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import org.apache.sis.storage.geojson.utils.GeoJSONParser; -import org.apache.sis.storage.geojson.utils.GeoJSONUtils; +import org.apache.sis.internal.geojson.GeoJSONUtils; import org.apache.sis.storage.geojson.utils.LiteJsonLocation; import org.apache.sis.test.TestCase;
