Skip to content

Commit 1066a87

Browse files
committed
Merge pull request #33 from Esri/stolstov/issue_32
make RasterizedGeometry2D public
2 parents 27cef2c + b7e6972 commit 1066a87

9 files changed

Lines changed: 858 additions & 707 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
Copyright 1995-2013 Esri
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
For additional information, contact:
17+
Environmental Systems Research Institute, Inc.
18+
Attn: Contracts Dept
19+
380 New York Street
20+
Redlands, California, USA 92373
21+
22+
email: contracts@esri.com
23+
*/
24+
package com.esri.core.geometry;
25+
26+
import java.util.ArrayList;
27+
import org.codehaus.jackson.JsonParser;
28+
import org.codehaus.jackson.JsonToken;
29+
import org.json.JSONArray;
30+
import org.json.JSONObject;
31+
32+
final class JSONArrayEnumerator {
33+
34+
private JSONArray m_jsonArray;
35+
private boolean m_bStarted;
36+
private int m_currentIndex;
37+
38+
JSONArrayEnumerator(JSONArray jsonArray) {
39+
m_bStarted = false;
40+
m_currentIndex = -1;
41+
m_jsonArray = jsonArray;
42+
}
43+
44+
Object getCurrentObject() {
45+
if (!m_bStarted) {
46+
throw new GeometryException("invalid call");
47+
}
48+
49+
if (m_currentIndex == m_jsonArray.length()) {
50+
throw new GeometryException("invalid call");
51+
}
52+
53+
return m_jsonArray.opt(m_currentIndex);
54+
}
55+
56+
boolean next() {
57+
if (!m_bStarted) {
58+
m_currentIndex = 0;
59+
m_bStarted = true;
60+
} else if (m_currentIndex != m_jsonArray.length()) {
61+
m_currentIndex++;
62+
}
63+
64+
return m_currentIndex != m_jsonArray.length();
65+
}
66+
}
67+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
Copyright 1995-2013 Esri
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
For additional information, contact:
17+
Environmental Systems Research Institute, Inc.
18+
Attn: Contracts Dept
19+
380 New York Street
20+
Redlands, California, USA 92373
21+
22+
email: contracts@esri.com
23+
*/
24+
package com.esri.core.geometry;
25+
26+
import java.util.ArrayList;
27+
import org.codehaus.jackson.JsonParser;
28+
import org.codehaus.jackson.JsonToken;
29+
import org.json.JSONArray;
30+
import org.json.JSONObject;
31+
32+
final class JSONObjectEnumerator {
33+
34+
private JSONObject m_jsonObject;
35+
private boolean m_bStarted;
36+
private int m_currentIndex;
37+
private String[] m_keys;
38+
39+
JSONObjectEnumerator(JSONObject jsonObject) {
40+
m_bStarted = false;
41+
m_currentIndex = -1;
42+
m_jsonObject = jsonObject;
43+
}
44+
45+
String getCurrentKey() {
46+
if (!m_bStarted) {
47+
throw new GeometryException("invalid call");
48+
}
49+
50+
if (m_currentIndex == m_jsonObject.length()) {
51+
throw new GeometryException("invalid call");
52+
}
53+
54+
return m_keys[m_currentIndex];
55+
}
56+
57+
Object getCurrentObject() {
58+
if (!m_bStarted) {
59+
throw new GeometryException("invalid call");
60+
}
61+
62+
if (m_currentIndex == m_jsonObject.length()) {
63+
throw new GeometryException("invalid call");
64+
}
65+
66+
return m_jsonObject.opt(m_keys[m_currentIndex]);
67+
}
68+
69+
boolean next() {
70+
if (!m_bStarted) {
71+
m_currentIndex = 0;
72+
m_keys = JSONObject.getNames(m_jsonObject);
73+
m_bStarted = true;
74+
} else if (m_currentIndex != m_jsonObject.length()) {
75+
m_currentIndex++;
76+
}
77+
78+
return m_currentIndex != m_jsonObject.length();
79+
}
80+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 1995-2013 Esri
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
For additional information, contact:
17+
Environmental Systems Research Institute, Inc.
18+
Attn: Contracts Dept
19+
380 New York Street
20+
Redlands, California, USA 92373
21+
22+
email: contracts@esri.com
23+
*/
24+
package com.esri.core.geometry;
25+
26+
import java.util.ArrayList;
27+
import org.codehaus.jackson.JsonParser;
28+
import org.codehaus.jackson.JsonToken;
29+
import org.json.JSONArray;
30+
import org.json.JSONObject;
31+
32+
final class JsonParserReader extends JsonReader {
33+
34+
private JsonParser m_jsonParser;
35+
36+
JsonParserReader(JsonParser jsonParser) {
37+
m_jsonParser = jsonParser;
38+
}
39+
40+
@Override
41+
JsonToken nextToken() throws Exception {
42+
JsonToken token = m_jsonParser.nextToken();
43+
return token;
44+
}
45+
46+
@Override
47+
JsonToken currentToken() throws Exception {
48+
return m_jsonParser.getCurrentToken();
49+
}
50+
51+
@Override
52+
void skipChildren() throws Exception {
53+
m_jsonParser.skipChildren();
54+
}
55+
56+
@Override
57+
String currentString() throws Exception {
58+
return m_jsonParser.getText();
59+
}
60+
61+
@Override
62+
double currentDoubleValue() throws Exception {
63+
return m_jsonParser.getValueAsDouble();
64+
}
65+
66+
@Override
67+
int currentIntValue() throws Exception {
68+
return m_jsonParser.getValueAsInt();
69+
}
70+
}
71+

0 commit comments

Comments
 (0)