├── .gitignore
├── CONTRIBUTING.md
├── JsonObjectReader
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── esri
│ │ └── core
│ │ └── geometry
│ │ └── examples
│ │ └── JsonObjectReader.java
│ └── test
│ └── java
│ └── com
│ └── esri
│ └── core
│ └── geometry
│ └── examples
│ └── JsonObjectReaderTest.java
├── OperatorSimplifyOGCTest
├── README.md
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── esri
│ └── core
│ └── geometry
│ └── examples
│ └── OperatorSimplifyOGCTest.java
├── README.md
├── ShapefileGeometryCursor
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── esri
│ │ └── core
│ │ └── geometry
│ │ └── examples
│ │ ├── MixedEndianDataInputStream.java
│ │ └── ShapefileGeometryCursor.java
│ └── test
│ ├── java
│ └── com
│ │ └── esri
│ │ └── core
│ │ └── geometry
│ │ └── examples
│ │ └── ShapefileGeometryCursorTest.java
│ └── resources
│ ├── multipoints.shp
│ ├── points.shp
│ ├── polygons.shp
│ └── polylines.shp
└── license.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | depfiles/
3 | target/
4 | .DS_Store
5 | .settings*
6 | *.jar
7 | *.iml
8 | .idea
9 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing).
2 |
--------------------------------------------------------------------------------
/JsonObjectReader/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.esri.geometry.examples
5 | JsonObjectReader
6 | 1.0.0
7 | jar
8 |
9 | Sample using Esri Geometry API for Java to load geometry from JSONObject
10 | Sample using Esri Geometry API for Java to load geometry from JSONObject
11 |
12 | https://github.com/Esri/samples-geometry-api-java
13 |
14 |
15 |
16 | The Apache Software License, Version 2.0
17 | http://www.apache.org/licenses/LICENSE-2.0.txt
18 | repo
19 |
20 |
21 |
22 |
23 |
24 | stolstov
25 | Sergey Tolstov
26 | Esri
27 | http://esri.com
28 |
29 | developer
30 |
31 |
32 |
33 |
34 |
35 | scm:git:git@github.com:Esri/samples-geometry-api-java.git
36 | scm:git:git@github.com:Esri/samples-geometry-api-java.git
37 | git@github.com:Esri/samples-geometry-api-java.git
38 |
39 |
40 |
41 |
42 | release-sign-artifacts
43 |
44 |
45 | performRelease
46 | true
47 |
48 |
49 |
50 |
51 |
52 | org.apache.maven.plugins
53 | maven-gpg-plugin
54 |
55 |
56 | sign-artifacts
57 | verify
58 |
59 | sign
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | java8-disable-doclint
69 |
70 | [1.8,)
71 |
72 |
73 | -Xdoclint:none
74 |
75 |
76 |
77 |
78 |
79 |
80 | ossrh
81 | https://oss.sonatype.org/content/repositories/snapshots
82 |
83 |
84 |
85 |
86 | UTF-8
87 |
88 | 1.7
89 | 1.7
90 |
91 |
92 | 2.0.0
93 |
94 |
95 | 2.3.1
96 | 2.2.1
97 | 2.9
98 |
99 |
100 |
101 |
102 | com.esri.geometry
103 | esri-geometry-api
104 | ${geometry.version}
105 |
106 |
107 | org.json
108 | json
109 | 20140107
110 |
111 |
112 | junit
113 | junit
114 | 4.12
115 | test
116 |
117 |
118 |
119 |
120 | ${project.basedir}/target
121 | ${project.build.directory}/classes
122 | ${project.artifactId}-${project.version}
123 | ${project.build.directory}/test-classes
124 | ${project.basedir}/src/main/java
125 | ${project.basedir}/src/test/java
126 |
127 |
128 | ${project.basedir}/src/main/resources
129 |
130 |
131 |
132 |
133 | ${project.basedir}/src/test/resources
134 |
135 |
136 |
137 |
138 | maven-compiler-plugin
139 | ${compiler.plugin.version}
140 |
141 | ${java.source.version}
142 | ${java.target.version}
143 |
144 |
145 |
146 | org.apache.maven.plugins
147 | maven-source-plugin
148 | ${source.plugin.version}
149 |
150 |
151 | attach-sources
152 |
153 | jar
154 |
155 |
156 |
157 |
158 |
159 | org.apache.maven.plugins
160 | maven-javadoc-plugin
161 | ${javadoc.plugin.version}
162 |
163 |
164 | http://help.arcgis.com/EN/sdk/10.0/Java_AO_ADF/api/arcobjects
165 | http://docs.oracle.com/javase/6/docs/api/
166 |
167 |
168 |
169 |
170 | attach-javadocs
171 |
172 | jar
173 |
174 |
175 | ${javadoc.doclint.param}
176 |
177 |
178 |
179 |
180 |
181 | org.sonatype.plugins
182 | nexus-staging-maven-plugin
183 | 1.6.2
184 | true
185 |
186 | ossrh
187 | https://oss.sonatype.org/
188 | true
189 |
190 |
191 |
192 |
193 |
194 |
--------------------------------------------------------------------------------
/JsonObjectReader/src/main/java/com/esri/core/geometry/examples/JsonObjectReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | package com.esri.core.geometry.examples;
16 |
17 | import java.util.ArrayList;
18 |
19 | import org.json.*;
20 |
21 | import com.esri.core.geometry.GeometryException;
22 | import com.esri.core.geometry.JsonGeometryException;
23 | import com.esri.core.geometry.JsonReader;
24 |
25 | /**
26 | * Sample implementation of a JsonReader around JSONObject class
27 | * To use pass new JsonObjectReader(jsonObject) to a method that accepts JsonReader instance.
28 | * It'll read geometry from an JSONObject then.
29 | *
30 | */
31 |
32 | public final class JsonObjectReader implements JsonReader {
33 |
34 | final static class JSONObjectEnumerator {
35 |
36 | private JSONObject m_jsonObject;
37 | private boolean m_bStarted;
38 | private int m_currentIndex;
39 | private String[] m_keys;
40 |
41 | JSONObjectEnumerator(JSONObject jsonObject) {
42 | m_bStarted = false;
43 | m_currentIndex = -1;
44 | m_jsonObject = jsonObject;
45 | }
46 |
47 | String getCurrentKey() {
48 | if (!m_bStarted) {
49 | throw new GeometryException("invalid call");
50 | }
51 |
52 | if (m_currentIndex == m_jsonObject.length()) {
53 | throw new GeometryException("invalid call");
54 | }
55 |
56 | return m_keys[m_currentIndex];
57 | }
58 |
59 | Object getCurrentObject() {
60 | if (!m_bStarted) {
61 | throw new GeometryException("invalid call");
62 | }
63 |
64 | if (m_currentIndex == m_jsonObject.length()) {
65 | throw new GeometryException("invalid call");
66 | }
67 |
68 | return m_jsonObject.opt(m_keys[m_currentIndex]);
69 | }
70 |
71 | boolean next() {
72 | if (!m_bStarted) {
73 | m_currentIndex = 0;
74 | m_keys = JSONObject.getNames(m_jsonObject);
75 | m_bStarted = true;
76 | } else if (m_currentIndex != m_jsonObject.length()) {
77 | m_currentIndex++;
78 | }
79 |
80 | return m_currentIndex != m_jsonObject.length();
81 | }
82 | }
83 |
84 | final static class JSONArrayEnumerator {
85 |
86 | private JSONArray m_jsonArray;
87 | private boolean m_bStarted;
88 | private int m_currentIndex;
89 |
90 | JSONArrayEnumerator(JSONArray jsonArray) {
91 | m_bStarted = false;
92 | m_currentIndex = -1;
93 | m_jsonArray = jsonArray;
94 | }
95 |
96 | Object getCurrentObject() {
97 | if (!m_bStarted) {
98 | throw new GeometryException("invalid call");
99 | }
100 |
101 | if (m_currentIndex == m_jsonArray.length()) {
102 | throw new GeometryException("invalid call");
103 | }
104 |
105 | return m_jsonArray.opt(m_currentIndex);
106 | }
107 |
108 | boolean next() {
109 | if (!m_bStarted) {
110 | m_currentIndex = 0;
111 | m_bStarted = true;
112 | } else if (m_currentIndex != m_jsonArray.length()) {
113 | m_currentIndex++;
114 | }
115 |
116 | return m_currentIndex != m_jsonArray.length();
117 | }
118 | }
119 |
120 | private Object m_object;
121 | private JsonReader.Token m_currentToken;
122 | private ArrayList m_parentStack;
123 | private ArrayList m_objIters;
124 | private ArrayList m_arrIters;
125 |
126 | public JsonObjectReader(Object object) {
127 | m_object = object;
128 |
129 | boolean bJSONObject = (m_object instanceof JSONObject);
130 | boolean bJSONArray = (m_object instanceof JSONArray);
131 |
132 | if (!bJSONObject && !bJSONArray) {
133 | throw new IllegalArgumentException();
134 | }
135 |
136 | m_parentStack = new ArrayList(0);
137 | m_objIters = new ArrayList(0);
138 | m_arrIters = new ArrayList(0);
139 |
140 | m_parentStack.ensureCapacity(4);
141 | m_objIters.ensureCapacity(4);
142 | m_arrIters.ensureCapacity(4);
143 |
144 | if (bJSONObject) {
145 | JSONObjectEnumerator objIter = new JSONObjectEnumerator((JSONObject) m_object);
146 | m_parentStack.add(JsonReader.Token.START_OBJECT);
147 | m_objIters.add(objIter);
148 | m_currentToken = JsonReader.Token.START_OBJECT;
149 | } else {
150 | JSONArrayEnumerator arrIter = new JSONArrayEnumerator((JSONArray) m_object);
151 | m_parentStack.add(JsonReader.Token.START_ARRAY);
152 | m_arrIters.add(arrIter);
153 | m_currentToken = JsonReader.Token.START_ARRAY;
154 | }
155 | }
156 |
157 | private void setCurrentToken_(Object obj) {
158 | if (obj instanceof String) {
159 | m_currentToken = JsonReader.Token.VALUE_STRING;
160 | } else if (obj instanceof Double || obj instanceof Float) {
161 | m_currentToken = JsonReader.Token.VALUE_NUMBER_FLOAT;
162 | } else if (obj instanceof Integer || obj instanceof Long || obj instanceof Short) {
163 | m_currentToken = JsonReader.Token.VALUE_NUMBER_INT;
164 | } else if (obj instanceof Boolean) {
165 | Boolean bObj = (Boolean) obj;
166 | boolean b = bObj.booleanValue();
167 | if (b) {
168 | m_currentToken = JsonReader.Token.VALUE_TRUE;
169 | } else {
170 | m_currentToken = JsonReader.Token.VALUE_FALSE;
171 | }
172 | } else if (obj instanceof JSONObject) {
173 | m_currentToken = JsonReader.Token.START_OBJECT;
174 | } else if (obj instanceof JSONArray) {
175 | m_currentToken = JsonReader.Token.START_ARRAY;
176 | } else {
177 | m_currentToken = JsonReader.Token.VALUE_NULL;
178 | }
179 | }
180 |
181 | Object currentObject_() {
182 | assert (!m_parentStack.isEmpty());
183 |
184 | JsonReader.Token parentType = m_parentStack.get(m_parentStack.size() - 1);
185 |
186 | if (parentType == JsonReader.Token.START_OBJECT) {
187 | JSONObjectEnumerator objIter = m_objIters.get(m_objIters.size() - 1);
188 | return objIter.getCurrentObject();
189 | }
190 |
191 | JSONArrayEnumerator arrIter = m_arrIters.get(m_arrIters.size() - 1);
192 | return arrIter.getCurrentObject();
193 | }
194 |
195 | @Override
196 | public JsonReader.Token nextToken() throws JsonGeometryException {
197 | if (m_parentStack.isEmpty()) {
198 | m_currentToken = null;
199 | return m_currentToken;
200 | }
201 |
202 | JsonReader.Token parentType = m_parentStack.get(m_parentStack.size() - 1);
203 |
204 | if (parentType == JsonReader.Token.START_OBJECT) {
205 | JSONObjectEnumerator iterator = m_objIters.get(m_objIters.size() - 1);
206 |
207 | if (m_currentToken == JsonReader.Token.FIELD_NAME) {
208 | Object nextJSONValue = iterator.getCurrentObject();
209 |
210 | if (nextJSONValue instanceof JSONObject) {
211 | m_parentStack.add(JsonReader.Token.START_OBJECT);
212 | m_objIters.add(new JSONObjectEnumerator((JSONObject) nextJSONValue));
213 | m_currentToken = JsonReader.Token.START_OBJECT;
214 | } else if (nextJSONValue instanceof JSONArray) {
215 | m_parentStack.add(JsonReader.Token.START_ARRAY);
216 | m_arrIters.add(new JSONArrayEnumerator((JSONArray) nextJSONValue));
217 | m_currentToken = JsonReader.Token.START_ARRAY;
218 | } else {
219 | setCurrentToken_(nextJSONValue);
220 | }
221 | } else {
222 | if (iterator.next()) {
223 | m_currentToken = JsonReader.Token.FIELD_NAME;
224 | } else {
225 | m_objIters.remove(m_objIters.size() - 1);
226 | m_parentStack.remove(m_parentStack.size() - 1);
227 | m_currentToken = JsonReader.Token.END_OBJECT;
228 | }
229 | }
230 | } else {
231 | assert (parentType == JsonReader.Token.START_ARRAY);
232 | JSONArrayEnumerator iterator = m_arrIters.get(m_arrIters.size() - 1);
233 | if (iterator.next()) {
234 | Object nextJSONValue = iterator.getCurrentObject();
235 |
236 | if (nextJSONValue instanceof JSONObject) {
237 | m_parentStack.add(JsonReader.Token.START_OBJECT);
238 | m_objIters.add(new JSONObjectEnumerator((JSONObject) nextJSONValue));
239 | m_currentToken = JsonReader.Token.START_OBJECT;
240 | } else if (nextJSONValue instanceof JSONArray) {
241 | m_parentStack.add(JsonReader.Token.START_ARRAY);
242 | m_arrIters.add(new JSONArrayEnumerator((JSONArray) nextJSONValue));
243 | m_currentToken = JsonReader.Token.START_ARRAY;
244 | } else {
245 | setCurrentToken_(nextJSONValue);
246 | }
247 | } else {
248 | m_arrIters.remove(m_arrIters.size() - 1);
249 | m_parentStack.remove(m_parentStack.size() - 1);
250 | m_currentToken = JsonReader.Token.END_ARRAY;
251 | }
252 | }
253 |
254 | return m_currentToken;
255 | }
256 |
257 | @Override
258 | public JsonReader.Token currentToken() throws JsonGeometryException {
259 | return m_currentToken;
260 | }
261 |
262 | @Override
263 | public void skipChildren() throws JsonGeometryException {
264 | assert (!m_parentStack.isEmpty());
265 |
266 | if (m_currentToken != JsonReader.Token.START_OBJECT && m_currentToken != JsonReader.Token.START_ARRAY) {
267 | return;
268 | }
269 |
270 | JsonReader.Token parentType = m_parentStack.get(m_parentStack.size() - 1);
271 |
272 | if (parentType == JsonReader.Token.START_OBJECT) {
273 | m_objIters.remove(m_objIters.size() - 1);
274 | m_parentStack.remove(m_parentStack.size() - 1);
275 | m_currentToken = JsonReader.Token.END_OBJECT;
276 | } else {
277 | m_arrIters.remove(m_arrIters.size() - 1);
278 | m_parentStack.remove(m_parentStack.size() - 1);
279 | m_currentToken = JsonReader.Token.END_ARRAY;
280 | }
281 | }
282 |
283 | @Override
284 | public String currentString() throws JsonGeometryException {
285 | if (m_currentToken == JsonReader.Token.FIELD_NAME) {
286 | return m_objIters.get(m_objIters.size() - 1).getCurrentKey();
287 | }
288 |
289 | if (m_currentToken != JsonReader.Token.VALUE_STRING) {
290 | throw new GeometryException("invalid call");
291 | }
292 |
293 | return ((String) currentObject_()).toString();
294 | }
295 |
296 | @Override
297 | public double currentDoubleValue() throws JsonGeometryException {
298 | if (m_currentToken != JsonReader.Token.VALUE_NUMBER_FLOAT && m_currentToken != JsonReader.Token.VALUE_NUMBER_INT) {
299 | throw new GeometryException("invalid call");
300 | }
301 |
302 | return ((Number) currentObject_()).doubleValue();
303 | }
304 |
305 | @Override
306 | public int currentIntValue() throws JsonGeometryException {
307 | if (m_currentToken != JsonReader.Token.VALUE_NUMBER_INT) {
308 | throw new GeometryException("invalid call");
309 | }
310 |
311 | return ((Number) currentObject_()).intValue();
312 | }
313 |
314 | @Override
315 | public boolean currentBooleanValue() throws JsonGeometryException {
316 | JsonReader.Token toc = currentToken();
317 | if (toc == JsonReader.Token.VALUE_TRUE) {
318 | return true;
319 | }
320 | else if (toc == JsonReader.Token.VALUE_FALSE) {
321 | return false;
322 | }
323 | throw new GeometryException("invalid call");
324 | }
325 | }
326 |
--------------------------------------------------------------------------------
/JsonObjectReader/src/test/java/com/esri/core/geometry/examples/JsonObjectReaderTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 |
15 | package com.esri.core.geometry.examples;
16 |
17 | import com.esri.core.geometry.*;
18 |
19 | import org.json.JSONObject;
20 | import org.junit.Test;
21 |
22 | import static org.junit.Assert.assertTrue;
23 |
24 | public class JsonObjectReaderTest {
25 |
26 | //Demonstrate how to pass JSONObject instead of JsonReader, using the JsonObjectReader wrapper.
27 | @Test
28 | public void loadFromJsonObject() {
29 | String geoJson = "{\"type\":\"MultiPolygon\",\"coordinates\":[[[[10,10,5],[20,10,5],[20,20,5],[10,20,5],[10,10,5]],[[12,12,3],[12,12,3],[12,12,3]],[[10,10,1],[12,12,1],[10,10,1]]],[[[90,90,88],[60,90,7],[60,60,7],[90,90,88]],[[70,70,7],[70,80,7],[80,80,7],[70,70,7]]]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:3857\"}}}";
30 | JSONObject obj = new JSONObject(geoJson);
31 | //Wrap JSONObject into a class that present it as a JSONReader:
32 | JsonReader reader = new JsonObjectReader(obj);
33 | MapGeometry geomFromJsonObject = OperatorImportFromGeoJson.local().execute(0, Geometry.Type.Unknown, reader, null);
34 | assertTrue(geomFromJsonObject.getGeometry().getType() == Geometry.Type.Polygon);
35 | MapGeometry geom2 = OperatorImportFromGeoJson.local().execute(0, Geometry.Type.Unknown, geoJson, null);
36 | assertTrue(geom2.equals(geomFromJsonObject));
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/OperatorSimplifyOGCTest/README.md:
--------------------------------------------------------------------------------
1 | samples-geometry-api-java
2 | =========================
3 |
4 | A sample for [Esri Java Geometry Library] (https://github.com/Esri/geometry-api-java) that demonstrates how to validate OGC geometry.
5 |
6 |
7 |
--------------------------------------------------------------------------------
/OperatorSimplifyOGCTest/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.esri.geometry.examples
5 | OperatorSimplifyOGCTest
6 | 1.0.0
7 | jar
8 |
9 | Samples for Esri Geometry API for Java
10 | Samples for the Esri Geometry API for Java.
11 |
12 | https://github.com/Esri/samples-geometry-api-java
13 |
14 |
15 |
16 | The Apache Software License, Version 2.0
17 | http://www.apache.org/licenses/LICENSE-2.0.txt
18 | repo
19 |
20 |
21 |
22 |
23 |
24 | stolstov
25 | Sergey Tolstov
26 | Esri
27 | http://www.esri.com
28 |
29 | developer
30 |
31 |
32 |
33 |
34 |
35 | scm:git:git@github.com:Esri/samples-geometry-api-java.git
36 | scm:git:git@github.com:Esri/samples-geometry-api-java.git
37 | git@github.com:Esri/samples-geometry-api-java.git
38 |
39 |
40 |
41 |
42 | release-sign-artifacts
43 |
44 |
45 | performRelease
46 | true
47 |
48 |
49 |
50 |
51 |
52 | org.apache.maven.plugins
53 | maven-gpg-plugin
54 |
55 |
56 | sign-artifacts
57 | verify
58 |
59 | sign
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | java8-disable-doclint
69 |
70 | [1.8,)
71 |
72 |
73 | -Xdoclint:none
74 |
75 |
76 |
77 |
78 |
79 |
80 | ossrh
81 | https://oss.sonatype.org/content/repositories/snapshots
82 |
83 |
84 |
85 |
86 | UTF-8
87 |
88 | 1.6
89 | 1.6
90 |
91 |
92 | 20140107
93 | 1.9.13
94 | 1.2.1
95 |
96 |
97 | 2.3.1
98 | 2.2.1
99 | 2.9
100 |
101 |
102 |
103 |
104 | org.json
105 | json
106 | ${json.version}
107 |
108 |
109 | org.codehaus.jackson
110 | jackson-core-asl
111 | ${jackson.version}
112 |
113 |
114 | com.esri.geometry
115 | esri-geometry-api
116 | ${geometry.version}
117 |
118 |
119 |
120 |
121 | ${project.basedir}/target
122 | ${project.build.directory}/classes
123 | ${project.artifactId}-${project.version}
124 | ${project.build.directory}/test-classes
125 | ${project.basedir}/src/main/java
126 |
127 |
128 |
129 |
130 | ${project.basedir}/src/main/resources
131 |
132 |
133 |
134 |
135 | ${project.basedir}/src/test/resources
136 |
137 |
138 |
139 |
140 | maven-compiler-plugin
141 | ${compiler.plugin.version}
142 |
143 | ${java.source.version}
144 | ${java.target.version}
145 |
146 |
147 |
148 | org.apache.maven.plugins
149 | maven-source-plugin
150 | ${source.plugin.version}
151 |
152 |
153 | attach-sources
154 |
155 | jar
156 |
157 |
158 |
159 |
160 |
161 | org.apache.maven.plugins
162 | maven-javadoc-plugin
163 | ${javadoc.plugin.version}
164 |
165 |
166 | http://help.arcgis.com/EN/sdk/10.0/Java_AO_ADF/api/arcobjects
167 | http://docs.oracle.com/javase/6/docs/api/
168 |
169 |
170 |
171 |
172 | attach-javadocs
173 |
174 | jar
175 |
176 |
177 | ${javadoc.doclint.param}
178 |
179 |
180 |
181 |
182 |
183 | org.sonatype.plugins
184 | nexus-staging-maven-plugin
185 | 1.6.2
186 | true
187 |
188 | ossrh
189 | https://oss.sonatype.org/
190 | true
191 |
192 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/OperatorSimplifyOGCTest/src/main/java/com/esri/core/geometry/examples/OperatorSimplifyOGCTest.java:
--------------------------------------------------------------------------------
1 | package com.esri.core.geometry.examples;
2 |
3 | import java.nio.file.Files;
4 | import java.nio.file.Paths;
5 | import java.io.IOException;
6 |
7 | import com.esri.core.geometry.Geometry;
8 | import com.esri.core.geometry.MultiPath;
9 | import com.esri.core.geometry.OperatorImportFromWkt;
10 | import com.esri.core.geometry.OperatorSimplifyOGC;
11 |
12 | //This opens a text file with name passed as a command line argument. The file should contain an OGC Polygon, MultiPolygon, LineString, or
13 | //MultiLineString (WKT format).
14 | //The program validates geometry topological correctness with isSimpleOGC,
15 | //Then it fixes any potential issues with OperatorSimplifyOGC (even if non were found, just to demonstrate the time),
16 | //Then it revalidates the result geometry.
17 | public final class OperatorSimplifyOGCTest {
18 |
19 | public static void main(String[] args) throws IOException {
20 | byte[] bytes = Files.readAllBytes(Paths.get(args[0]));
21 | String text = new String(bytes, "US-ASCII");
22 | Geometry g = OperatorImportFromWkt.local().execute(0, Geometry.Type.Unknown, text, null);
23 | System.out.println(args[0] + " : " + g.getType() +
24 | " " + ((MultiPath)g).getPathCount() + " rings" + " " + ((MultiPath)g).getPointCount() + " vertices");
25 | System.out.print("Checking if simple... ");
26 | boolean isSimple = OperatorSimplifyOGC.local().isSimpleOGC(g, null, true, null, null);
27 | System.out.println(isSimple);
28 | System.out.print("Running simplify operation... ");
29 | Geometry gSimple = OperatorSimplifyOGC.local().execute(g, null, true, null);
30 | System.out.println("Simple" + " : " + g.getType() +
31 | " " + ((MultiPath)gSimple).getPathCount() + " rings" + " " + ((MultiPath)gSimple).getPointCount() + " vertices");
32 | System.out.println("Done");
33 | System.out.print("Running simplify operation (should be simple now)... ");
34 | isSimple = OperatorSimplifyOGC.local().isSimpleOGC(gSimple, null, true, null, null);
35 | System.out.println(isSimple);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | samples-geometry-api-java
2 | =========================
3 |
4 | A collection of samples for the [Esri Java Geometry Library] (https://github.com/Esri/geometry-api-java)
5 |
6 | ## Instructions
7 | Start out by navigating to samples and following the instructions provided with each sample.
8 |
9 | ## Requirements
10 |
11 | * Java JDK 1.6 or greater.
12 | * [Apache Ant](http://ant.apache.org/) build system.
13 | * [Apache Maven](http://maven.apache.org/) build system.
14 |
15 | ## Documentation
16 | * [geometry-api-java/Wiki](https://github.com/Esri/geometry-api-java/wiki/)
17 | * [geometry-api-java/Javadoc](http://esri.github.com/geometry-api-java/javadoc/)
18 |
19 | ## Resources
20 |
21 | * [ArcGIS Geodata Resource Center]( http://resources.arcgis.com/en/communities/geodata/)
22 | * [ArcGIS Blog](http://blogs.esri.com/esri/arcgis/)
23 | * [twitter@esri](http://twitter.com/esri)
24 |
25 | ## Issues
26 |
27 | Find a bug or want to request a new feature? Please let us know by submitting an issue.
28 |
29 | ## Contributing
30 |
31 | Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing)
32 |
33 | ## Licensing
34 | Copyright 2016 Esri
35 |
36 | Licensed under the Apache License, Version 2.0 (the "License");
37 | you may not use this file except in compliance with the License.
38 | You may obtain a copy of the License at
39 |
40 | http://www.apache.org/licenses/LICENSE-2.0
41 |
42 | Unless required by applicable law or agreed to in writing, software
43 | distributed under the License is distributed on an "AS IS" BASIS,
44 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45 | See the License for the specific language governing permissions and
46 | limitations under the License.
47 |
48 | A copy of the license is available in the repository's [license.txt](https://raw.github.com/Esri/samples-geometry-api-java/master/license.txt) file.
49 |
50 | [](Esri Tags: ArcGIS, Java, Geometry, Relationship, Analysis, JSON, WKT, Shape, Sample)
51 | [](Esri Language: Java)
52 |
53 |
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 | com.esri.geometry.examples
5 | ShapefileGeometryCursor
6 | 1.0.0
7 | jar
8 |
9 | Sample using Esri Geometry API for Java to work with shapefiles
10 | Sample using Esri Geometry API for Java to work with shapefiles
11 |
12 | https://github.com/Esri/samples-geometry-api-java
13 |
14 |
15 |
16 | The Apache Software License, Version 2.0
17 | http://www.apache.org/licenses/LICENSE-2.0.txt
18 | repo
19 |
20 |
21 |
22 |
23 |
24 | willtemperley
25 | Will Temperley
26 |
27 |
28 |
29 | developer
30 |
31 |
32 |
33 |
34 |
35 | scm:git:git@github.com:Esri/samples-geometry-api-java.git
36 | scm:git:git@github.com:Esri/samples-geometry-api-java.git
37 | git@github.com:Esri/samples-geometry-api-java.git
38 |
39 |
40 |
41 |
42 | release-sign-artifacts
43 |
44 |
45 | performRelease
46 | true
47 |
48 |
49 |
50 |
51 |
52 | org.apache.maven.plugins
53 | maven-gpg-plugin
54 |
55 |
56 | sign-artifacts
57 | verify
58 |
59 | sign
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | java8-disable-doclint
69 |
70 | [1.8,)
71 |
72 |
73 | -Xdoclint:none
74 |
75 |
76 |
77 |
78 |
79 |
80 | ossrh
81 | https://oss.sonatype.org/content/repositories/snapshots
82 |
83 |
84 |
85 |
86 | UTF-8
87 |
88 | 1.6
89 | 1.6
90 |
91 |
92 | 1.2.1
93 |
94 |
95 | 2.3.1
96 | 2.2.1
97 | 2.9
98 |
99 |
100 |
101 |
102 | com.esri.geometry
103 | esri-geometry-api
104 | ${geometry.version}
105 |
106 |
107 | junit
108 | junit
109 | 4.10
110 | test
111 |
112 |
113 |
114 |
115 | ${project.basedir}/target
116 | ${project.build.directory}/classes
117 | ${project.artifactId}-${project.version}
118 | ${project.build.directory}/test-classes
119 | ${project.basedir}/src/main/java
120 | ${project.basedir}/src/test/java
121 |
122 |
123 | ${project.basedir}/src/main/resources
124 |
125 |
126 |
127 |
128 | ${project.basedir}/src/test/resources
129 |
130 |
131 |
132 |
133 | maven-compiler-plugin
134 | ${compiler.plugin.version}
135 |
136 | ${java.source.version}
137 | ${java.target.version}
138 |
139 |
140 |
141 | org.apache.maven.plugins
142 | maven-source-plugin
143 | ${source.plugin.version}
144 |
145 |
146 | attach-sources
147 |
148 | jar
149 |
150 |
151 |
152 |
153 |
154 | org.apache.maven.plugins
155 | maven-javadoc-plugin
156 | ${javadoc.plugin.version}
157 |
158 |
159 | http://help.arcgis.com/EN/sdk/10.0/Java_AO_ADF/api/arcobjects
160 | http://docs.oracle.com/javase/6/docs/api/
161 |
162 |
163 |
164 |
165 | attach-javadocs
166 |
167 | jar
168 |
169 |
170 | ${javadoc.doclint.param}
171 |
172 |
173 |
174 |
175 |
176 | org.sonatype.plugins
177 | nexus-staging-maven-plugin
178 | 1.6.2
179 | true
180 |
181 | ossrh
182 | https://oss.sonatype.org/
183 | true
184 |
185 |
186 |
187 |
188 |
189 |
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/src/main/java/com/esri/core/geometry/examples/MixedEndianDataInputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 | package com.esri.core.geometry.examples;
15 |
16 | import java.io.DataInputStream;
17 | import java.io.EOFException;
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 |
21 | /**
22 | * Augments DataInputStream with methods to read little-endian primitives, as the ESRI
23 | * shapefile format is mixed.
24 | */
25 | class MixedEndianDataInputStream extends DataInputStream {
26 | private byte readBuffer[] = new byte[8];
27 |
28 | MixedEndianDataInputStream(InputStream inputStream) {
29 | super(inputStream);
30 | }
31 |
32 | /**
33 | * modification of {@link DataInputStream#readInt()} reversing byte order
34 | */
35 | final int readLittleEndianInt() throws IOException {
36 | int ch4 = in.read();
37 | int ch3 = in.read();
38 | int ch2 = in.read();
39 | int ch1 = in.read();
40 | if ((ch1 | ch2 | ch3 | ch4) < 0)
41 | throw new EOFException();
42 | return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4));
43 | }
44 |
45 | /**
46 | * modification {@link DataInputStream#readLong()} ()} reversing the array indices
47 | */
48 | private long readLittleEndianLong() throws IOException {
49 | readFully(readBuffer, 0, 8);
50 | return (((long)readBuffer[7] << 56) +
51 | ((long)(readBuffer[6] & 255) << 48) +
52 | ((long)(readBuffer[5] & 255) << 40) +
53 | ((long)(readBuffer[4] & 255) << 32) +
54 | ((long)(readBuffer[3] & 255) << 24) +
55 | ((readBuffer[2] & 255) << 16) +
56 | ((readBuffer[1] & 255) << 8) +
57 | ((readBuffer[0] & 255)));
58 | }
59 |
60 | double readLittleEndianDouble() throws IOException {
61 | return Double.longBitsToDouble(readLittleEndianLong());
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/src/main/java/com/esri/core/geometry/examples/ShapefileGeometryCursor.java:
--------------------------------------------------------------------------------
1 | /*
2 | Licensed under the Apache License, Version 2.0 (the "License");
3 | you may not use this file except in compliance with the License.
4 | You may obtain a copy of the License at
5 |
6 | http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | Unless required by applicable law or agreed to in writing, software
9 | distributed under the License is distributed on an "AS IS" BASIS,
10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | See the License for the specific language governing permissions and
12 | limitations under the License.
13 | */
14 | package com.esri.core.geometry.examples;
15 |
16 | import com.esri.core.geometry.*;
17 |
18 | import java.io.File;
19 | import java.io.FileInputStream;
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.nio.ByteBuffer;
23 |
24 | /**
25 | *
26 | * Reads a shapefile
27 | * Created by willtemperley@gmail.com on 07-Nov-16.
28 | */
29 | public class ShapefileGeometryCursor extends GeometryCursor {
30 |
31 | private final MixedEndianDataInputStream inputStream;
32 | private final Envelope2D envelope2D;
33 |
34 | private OperatorImportFromESRIShape importFromESRIShape = OperatorImportFromESRIShape.local();
35 | private final int fileLengthBytes;
36 | private int position = 0; //keeps track of where inputstream is
37 | private int recordNumber; //the record number according to shapefile
38 |
39 | private final Geometry.Type geomType;
40 |
41 | @Override
42 | public Geometry next() {
43 | if (! hasNext()) {
44 | return null;
45 | }
46 | try {
47 |
48 | recordNumber = inputStream.readInt();//1 based
49 | int recLength = inputStream.readInt();
50 | position += 8;
51 |
52 | int recordSizeBytes = (recLength * 2);
53 | byte[] bytes = new byte[recordSizeBytes];
54 | int read = inputStream.read(bytes);
55 |
56 | Geometry polyline = importFromESRIShape.execute(0, geomType, ByteBuffer.wrap(bytes));
57 | position += recordSizeBytes;
58 |
59 | return polyline;
60 |
61 | } catch (IOException e) {
62 | e.printStackTrace();
63 | }
64 | return null;
65 | }
66 |
67 | @Override
68 | public int getGeometryID() {
69 | return recordNumber;
70 | }
71 |
72 | public Envelope2D getEnvelope2D() {
73 | return envelope2D;
74 | }
75 |
76 | public ShapefileGeometryCursor(File inFile) throws IOException {
77 | this(new FileInputStream(inFile));
78 | }
79 |
80 | public ShapefileGeometryCursor(InputStream in) throws IOException {
81 |
82 | this.inputStream = new MixedEndianDataInputStream(in);
83 |
84 | /*
85 | Byte 0 File Code 9994 Integer Big
86 | */
87 | int fileCode = inputStream.readInt();
88 | if (fileCode != 9994) {
89 | throw new IOException("file code " + fileCode + " is not supported.");
90 | }
91 |
92 | /*
93 | Byte 4 Unused 0 Integer Big
94 | Byte 8 Unused 0 Integer Big
95 | Byte 12 Unused 0 Integer Big
96 | Byte 16 Unused 0 Integer Big
97 | Byte 20 Unused 0 Integer Big
98 | */
99 | inputStream.skipBytes(20);
100 |
101 | fileLengthBytes = inputStream.readInt() * 2;
102 |
103 | int v = this.inputStream.readLittleEndianInt();
104 |
105 | if (v != 1000) {
106 | throw new IOException("version " + v + " is not supported.");
107 | }
108 |
109 | int shpTypeId = this.inputStream.readLittleEndianInt();
110 | geomType = geometryTypeFromShpType(shpTypeId);
111 |
112 | /*
113 | Byte 24 File Length File Length Integer Big
114 | Byte 28 Version 1000 Integer Little
115 | Byte 32 Shape Type Shape Type Integer Little
116 | Byte 36 Bounding Box Xmin Double Little
117 | Byte 44 Bounding Box Ymin Double Little
118 | Byte 52 Bounding Box Xmax Double Little
119 | Byte 60 Bounding Box Ymax Double Little
120 | Byte 68* Bounding Box Zmin Double Little
121 | Byte 76* Bounding Box Zmax Double Little
122 | Byte 84* Bounding Box Mmin Double Little
123 | Byte 92* Bounding Box Mmax Double Little
124 | */
125 | double xmin = this.inputStream.readLittleEndianDouble();
126 | double ymin = this.inputStream.readLittleEndianDouble();
127 | double xmax = this.inputStream.readLittleEndianDouble();
128 | double ymax = this.inputStream.readLittleEndianDouble();
129 | double zmin = this.inputStream.readLittleEndianDouble();
130 | double zmax = this.inputStream.readLittleEndianDouble();
131 | double mmin = this.inputStream.readLittleEndianDouble();
132 | double mmax = this.inputStream.readLittleEndianDouble();
133 |
134 | envelope2D = new Envelope2D(xmin, ymin, xmax, ymax);
135 | // envelope3D = new Envelope3D(xmin, ymin, zmin, xmax, ymax, zmax);
136 |
137 | position = 2 * 50; //header is always 50 words long
138 |
139 | }
140 |
141 | /**
142 | from esri spec:
143 | 0 Null Shape
144 | 1 Point
145 | 3 PolyLine
146 | 5 Polygon
147 | 8 MultiPoint
148 | 11 PointZ
149 | 13 PolyLineZ
150 | 15 PolygonZ
151 | 18 MultiPointZ
152 | 21 PointM
153 | 23 PolyLineM
154 | 25 PolygonM
155 | 28 MultiPointM
156 | 31 MultiPatch
157 | therefore final digit suffices to determine type (PolyLine, PolyLineM, PolylineZ are 1, 13 and 23 respectively).
158 | *
159 | * @param shpTypeId shape type id from shapfile
160 | * @return the geom type
161 | */
162 | private Geometry.Type geometryTypeFromShpType(int shpTypeId) {
163 | int shpType = shpTypeId % 10;
164 |
165 | switch (shpType) {
166 | case 1: //Point
167 | return Geometry.Type.Point;
168 | case 3: //Polyline
169 | return Geometry.Type.Polyline;
170 | case 5: //Polygon
171 | return Geometry.Type.Polygon;
172 | case 8: //Multipoint
173 | return Geometry.Type.MultiPoint;
174 | default:
175 | return Geometry.Type.Unknown;
176 | }
177 | }
178 |
179 |
180 | public boolean hasNext() {
181 | return position < fileLengthBytes;
182 | }
183 |
184 | public Geometry.Type getGeometryType() {
185 | return geomType;
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/src/test/java/com/esri/core/geometry/examples/ShapefileGeometryCursorTest.java:
--------------------------------------------------------------------------------
1 | package com.esri.core.geometry.examples;
2 |
3 | import com.esri.core.geometry.*;
4 | import org.junit.Test;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import static org.junit.Assert.assertTrue;
12 |
13 | public class ShapefileGeometryCursorTest {
14 |
15 | /**
16 | * The shapefile reader implements {@link GeometryCursor} so can be used directly as input to spatial operations
17 | */
18 | @Test
19 | public void spatialOpsWithShapefileAsGeometryCursor() throws IOException {
20 |
21 | {
22 | File file = getTestShapefile("polygons");
23 |
24 | ShapefileGeometryCursor polygonShapefileCursor = new ShapefileGeometryCursor(file);
25 | GeometryCursor unionCursor = OperatorUnion.local().execute(polygonShapefileCursor, null, null);
26 |
27 | Geometry dissolvedGeometry = unionCursor.next();
28 | Polygon multiPoly = (Polygon) dissolvedGeometry;
29 | assertTrue(multiPoly.getExteriorRingCount() == 4); //the test file has three polys, one with two outer rings
30 | assertTrue(unionCursor.next() == null); //should only be one polygon
31 | }
32 |
33 | {
34 | File file = getTestShapefile("polylines");
35 |
36 | ShapefileGeometryCursor polylineShapefileCursor = new ShapefileGeometryCursor(file);
37 | GeometryCursor bufferCursor = OperatorBuffer.local().execute(polylineShapefileCursor, null, new double[]{0.5}, true, null);
38 |
39 | Polygon polygon = (Polygon) bufferCursor.next();
40 | assertTrue(bufferCursor.next() == null);//should only be one polygon as union was specified on buffer
41 | assertTrue(polygon.getExteriorRingCount() == 3); //test file has three lines
42 | }
43 | }
44 |
45 | /**
46 | * Read the four main types of shapefile
47 | */
48 | @Test
49 | public void shapefileReaderTest() throws IOException {
50 |
51 | {
52 | File file = getTestShapefile("points");
53 | ShapefileGeometryCursor geometryCursor = new ShapefileGeometryCursor(file);
54 |
55 | Geometry geom;
56 | List points = new ArrayList();
57 | while ((geom = geometryCursor.next()) != null) {
58 | Point point = (Point) geom;
59 | points.add(point);
60 | }
61 | assertTrue(points.size() == 7);
62 |
63 | Geometry.Type geometryType = geometryCursor.getGeometryType();
64 | assertTrue(geometryType.equals(Geometry.Type.Point));
65 | }
66 |
67 | {
68 | File file = getTestShapefile("multipoints");
69 | ShapefileGeometryCursor geometryCursor = new ShapefileGeometryCursor(file);
70 |
71 | Geometry geom;
72 | List multiPoints = new ArrayList();
73 | while ((geom = geometryCursor.next()) != null) {
74 | MultiPoint multiPoint = (MultiPoint) geom;
75 | multiPoints.add(multiPoint);
76 | }
77 | assertTrue(multiPoints.size() == 2);
78 |
79 | Geometry.Type geometryType = geometryCursor.getGeometryType();
80 | assertTrue(geometryType.equals(Geometry.Type.MultiPoint));
81 | }
82 |
83 | {
84 | File file = getTestShapefile("polygons");
85 | ShapefileGeometryCursor geometryCursor = new ShapefileGeometryCursor(file);
86 |
87 | Geometry geom;
88 | List polygons = new ArrayList();
89 | while ((geom = geometryCursor.next()) != null) {
90 | Polygon polygon = (Polygon) geom;
91 | polygons.add(polygon);
92 | }
93 | assertTrue(polygons.size() == 3);
94 |
95 | Geometry.Type geometryType = geometryCursor.getGeometryType();
96 | assertTrue(geometryType.equals(Geometry.Type.Polygon));
97 | }
98 |
99 | {
100 | File file = getTestShapefile("polylines");
101 | ShapefileGeometryCursor geometryCursor = new ShapefileGeometryCursor(file);
102 |
103 | Geometry geom;
104 | List polylines = new ArrayList();
105 | while ((geom = geometryCursor.next()) != null) {
106 | Polyline polyline = (Polyline) geom;
107 | polylines.add(polyline);
108 | }
109 | assertTrue(polylines.size() == 2);
110 |
111 | Geometry.Type geometryType = geometryCursor.getGeometryType();
112 | assertTrue(geometryType.equals(Geometry.Type.Polyline));
113 | }
114 |
115 | }
116 |
117 | private File getTestShapefile(String name) {
118 | return new File("src/test/resources/" + name + ".shp");
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/src/test/resources/multipoints.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/samples-geometry-api-java/5a17b40430e368446dcfc843f9b6fb75296763be/ShapefileGeometryCursor/src/test/resources/multipoints.shp
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/src/test/resources/points.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/samples-geometry-api-java/5a17b40430e368446dcfc843f9b6fb75296763be/ShapefileGeometryCursor/src/test/resources/points.shp
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/src/test/resources/polygons.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/samples-geometry-api-java/5a17b40430e368446dcfc843f9b6fb75296763be/ShapefileGeometryCursor/src/test/resources/polygons.shp
--------------------------------------------------------------------------------
/ShapefileGeometryCursor/src/test/resources/polylines.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/samples-geometry-api-java/5a17b40430e368446dcfc843f9b6fb75296763be/ShapefileGeometryCursor/src/test/resources/polylines.shp
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------