Skip to content

Commit 8753186

Browse files
authored
Merge pull request #136 from Esri/sergey/remove_org_json
removed org.json dependency
2 parents dcbabdc + 9bedde3 commit 8753186

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+902
-1592
lines changed
253 KB
Binary file not shown.
-227 KB
Binary file not shown.

DepFiles/public/java-json.jar

-41.1 KB
Binary file not shown.

DepFiles/unittest/junit-4.12.jar

308 KB
Binary file not shown.

DepFiles/unittest/junit-4.8.2.jar

-232 KB
Binary file not shown.

build.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
<property name="dir.result" value="results" />
1515
<property name="dir.root" value="." />
1616
<property name="file.jarname" value="esri-geometry-api.jar" />
17+
<property name="jackson.version" value="2.6.2" />
1718

1819
<path id="project.classpath">
19-
<pathelement location="${dir.depfiles}/public/jackson-core-asl-1.9.11.jar" />
20-
<pathelement location="${dir.depfiles}/public/java-json.jar" />
21-
<pathelement location="${dir.depfiles}/unittest/junit-4.8.2.jar" />
20+
<pathelement location="${dir.depfiles}/public/jackson-core-${jackson.version}.jar" />
21+
<pathelement location="${dir.depfiles}/unittest/junit-4.12.jar" />
2222
<pathelement location="${dir.build}" />
2323
</path>
2424

pom.xml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>com.esri.geometry</groupId>
55
<artifactId>esri-geometry-api</artifactId>
6-
<version>1.2.1</version>
6+
<version>2.0.0</version>
77
<packaging>jar</packaging>
88

99
<name>Esri Geometry API for Java</name>
@@ -98,8 +98,7 @@
9898
<java.target.version>1.6</java.target.version>
9999

100100
<!-- dependency versions -->
101-
<json.version>20140107</json.version>
102-
<jackson.version>1.9.13</jackson.version>
101+
<jackson.version>2.6.5</jackson.version>
103102
<junit.version>4.12</junit.version>
104103

105104
<!-- plugin versions -->
@@ -110,14 +109,10 @@
110109

111110
<dependencies>
112111
<dependency>
113-
<groupId>org.json</groupId>
114-
<artifactId>json</artifactId>
115-
<version>${json.version}</version>
116-
</dependency>
117-
<dependency>
118-
<groupId>org.codehaus.jackson</groupId>
119-
<artifactId>jackson-core-asl</artifactId>
112+
<groupId>com.fasterxml.jackson.core</groupId>
113+
<artifactId>jackson-core</artifactId>
120114
<version>${jackson.version}</version>
115+
<optional>false</optional>
121116
</dependency>
122117
<dependency>
123118
<groupId>junit</groupId>

src/main/java/com/esri/core/geometry/GeometryEngine.java

Lines changed: 73 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 1995-2015 Esri
2+
Copyright 1995-2017 Esri
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -29,9 +29,7 @@
2929
import java.nio.ByteOrder;
3030
import java.util.ArrayList;
3131

32-
import org.codehaus.jackson.JsonParseException;
33-
import org.codehaus.jackson.JsonParser;
34-
import org.json.JSONException;
32+
import com.fasterxml.jackson.core.JsonParser;
3533

3634
/**
3735
* Provides services that operate on geometry instances. The methods of GeometryEngine class call corresponding OperatorXXX classes.
@@ -57,10 +55,27 @@ public class GeometryEngine {
5755
* spatial reference.
5856
*/
5957
public static MapGeometry jsonToGeometry(JsonParser json) {
60-
MapGeometry geom = OperatorImportFromJson.local().execute(Geometry.Type.Unknown, json);
58+
MapGeometry geom = OperatorImportFromJson.local().execute(Geometry.Type.Unknown, new JsonParserReader(json));
6159
return geom;
6260
}
6361

62+
/**
63+
* Imports the MapGeometry from its JSON representation. M and Z values are
64+
* not imported from JSON representation.
65+
*
66+
* See OperatorImportFromJson.
67+
*
68+
* @param json
69+
* The JSON representation of the geometry (with spatial
70+
* reference).
71+
* @return The MapGeometry instance containing the imported geometry and its
72+
* spatial reference.
73+
*/
74+
public static MapGeometry jsonToGeometry(JsonReader json) {
75+
MapGeometry geom = OperatorImportFromJson.local().execute(Geometry.Type.Unknown, json);
76+
return geom;
77+
}
78+
6479
/**
6580
* Imports the MapGeometry from its JSON representation. M and Z values are
6681
* not imported from JSON representation.
@@ -75,7 +90,7 @@ public static MapGeometry jsonToGeometry(JsonParser json) {
7590
* @throws IOException
7691
* @throws JsonParseException
7792
*/
78-
public static MapGeometry jsonToGeometry(String json) throws JsonParseException, IOException {
93+
public static MapGeometry jsonToGeometry(String json) {
7994
MapGeometry geom = OperatorImportFromJson.local().execute(Geometry.Type.Unknown, json);
8095
return geom;
8196
}
@@ -126,43 +141,60 @@ public static String geometryToGeoJson(Geometry geometry) {
126141
return exporter.execute(geometry);
127142
}
128143

129-
/**
130-
* Exports the specified geometry instance to its GeoJSON representation.
131-
*
132-
*See OperatorExportToGeoJson.
133-
*
134-
* @see GeometryEngine#geometryToGeoJson(SpatialReference spatialReference,
135-
* Geometry geometry)
136-
*
137-
* @param wkid
138-
* The spatial reference Well Known ID to be used for the GeoJSON representation.
139-
* @param geometry
140-
* The geometry to be exported to GeoJSON.
141-
* @return The GeoJSON representation of the specified geometry.
142-
*/
143-
public static String geometryToGeoJson(int wkid, Geometry geometry) {
144-
return GeometryEngine.geometryToGeoJson(
145-
wkid > 0 ? SpatialReference.create(wkid) : null, geometry);
146-
}
144+
/**
145+
* Imports the MapGeometry from its JSON representation. M and Z values are
146+
* not imported from JSON representation.
147+
*
148+
* See OperatorImportFromJson.
149+
*
150+
* @param json
151+
* The JSON representation of the geometry (with spatial
152+
* reference).
153+
* @return The MapGeometry instance containing the imported geometry and its
154+
* spatial reference.
155+
* @throws IOException
156+
* @throws JsonParseException
157+
*/
158+
public static MapGeometry geoJsonToGeometry(String json, int importFlags, Geometry.Type type) {
159+
MapGeometry geom = OperatorImportFromGeoJson.local().execute(importFlags, type, json, null);
160+
return geom;
161+
}
147162

148-
/**
149-
* Exports the specified geometry instance to it's JSON representation.
150-
*
151-
*See OperatorImportFromGeoJson.
152-
*
153-
* @param spatialReference
154-
* The spatial reference of associated object.
155-
* @param geometry
156-
* The geometry.
157-
* @return The GeoJSON representation of the specified geometry.
158-
*/
159-
public static String geometryToGeoJson(SpatialReference spatialReference,
160-
Geometry geometry) {
161-
OperatorExportToGeoJson exporter = (OperatorExportToGeoJson) factory
162-
.getOperator(Operator.Type.ExportToGeoJson);
163+
/**
164+
* Exports the specified geometry instance to its GeoJSON representation.
165+
*
166+
* See OperatorExportToGeoJson.
167+
*
168+
* @see GeometryEngine#geometryToGeoJson(SpatialReference spatialReference,
169+
* Geometry geometry)
170+
*
171+
* @param wkid
172+
* The spatial reference Well Known ID to be used for the GeoJSON
173+
* representation.
174+
* @param geometry
175+
* The geometry to be exported to GeoJSON.
176+
* @return The GeoJSON representation of the specified geometry.
177+
*/
178+
public static String geometryToGeoJson(int wkid, Geometry geometry) {
179+
return GeometryEngine.geometryToGeoJson(wkid > 0 ? SpatialReference.create(wkid) : null, geometry);
180+
}
163181

164-
return exporter.execute(spatialReference, geometry);
165-
}
182+
/**
183+
* Exports the specified geometry instance to it's JSON representation.
184+
*
185+
* See OperatorImportFromGeoJson.
186+
*
187+
* @param spatialReference
188+
* The spatial reference of associated object.
189+
* @param geometry
190+
* The geometry.
191+
* @return The GeoJSON representation of the specified geometry.
192+
*/
193+
public static String geometryToGeoJson(SpatialReference spatialReference, Geometry geometry) {
194+
OperatorExportToGeoJson exporter = (OperatorExportToGeoJson) factory.getOperator(Operator.Type.ExportToGeoJson);
195+
196+
return exporter.execute(spatialReference, geometry);
197+
}
166198

167199
/**
168200
* Imports geometry from the ESRI shape file format.
@@ -230,26 +262,6 @@ public static Geometry geometryFromWkt(String wkt, int importFlags,
230262
return op.execute(importFlags, geometryType, wkt, null);
231263
}
232264

233-
/**
234-
* Imports a geometry from a geoJson string.
235-
*
236-
* See OperatorImportFromGeoJson.
237-
*
238-
* @param geoJson The string containing the geometry in geoJson format.
239-
* @param importFlags Use the {@link GeoJsonImportFlags} interface.
240-
* @param geometryType The required type of the Geometry to be imported. Use Geometry.Type.Unknown if the geometry type needs to be determined from the geoJson context.
241-
* @return The geometry.
242-
* @throws GeometryException when the geometryType is not Geometry.Type.Unknown and the geoJson contains a geometry that cannot be converted to the given geometryType.
243-
* @throws IllegalArgument exception if an error is found while parsing the geoJson string.
244-
*/
245-
@Deprecated
246-
public static MapGeometry geometryFromGeoJson(String geoJson,
247-
int importFlags, Geometry.Type geometryType) throws JSONException {
248-
OperatorImportFromGeoJson op = (OperatorImportFromGeoJson) factory
249-
.getOperator(Operator.Type.ImportFromGeoJson);
250-
return op.execute(importFlags, geometryType, geoJson, null);
251-
}
252-
253265
/**
254266
* Exports a geometry to a string in WKT format.
255267
*

src/main/java/com/esri/core/geometry/JSONArrayEnumerator.java

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/main/java/com/esri/core/geometry/JSONObjectEnumerator.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)