Skip to content

Commit cc993bf

Browse files
Ajit GeorgeAjit George
authored andcommitted
No Task - Modified data files for geo-code 2 and test file. Changes
needed to handle server side geo-code fixes.
1 parent 24921ae commit cc993bf

File tree

9 files changed

+48
-44
lines changed

9 files changed

+48
-44
lines changed

test-complete/src/test/java/com/marklogic/client/functionaltest/TestDoublePrecisionGeoOps.java

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static void setUp() throws Exception
9595
/*
9696
* Linestring contains Point(point is the endpoint of linestring
9797
*/
98-
@Ignore
98+
@Test
9999
public void testLinestringContainsPoint() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
100100
{
101101
System.out.println("Running testLinestringContainsPoint");
@@ -137,29 +137,30 @@ public void testLinestringContainsPoint() throws KeyManagementException, NoSuchA
137137
String snippetFromSummary = null;
138138
String snippetFromRead = null;
139139

140-
// Making sure that we proper results
141-
expectedMap.put("/Equator-json.json", "Json Linestring In Equator - South America");
142-
expectedMap.put("/Equator.xml", "Linestring In Equator - South America");
140+
// Making sure that we proper results. Snippets are not complete. Taking in what appears in summary.
141+
expectedMap.put("/Equator-json.json", "Json Point In Equator - South America");
142+
expectedMap.put("/Equator.xml", "Point In Equator - South America");
143143

144144
for (MatchDocumentSummary summary : matches) {
145145
String docUri = summary.getUri();
146146
System.out.println("docURI is " + docUri);
147147
System.out.println("Snippet from Summary is " + summary.getFirstSnippetText());
148148
// Get only the numbers. Strip away others. Refer to data files.
149-
snippetFromSummary = summary.getFirstSnippetText().split("LINESTRING\\(")[1];
149+
snippetFromSummary = summary.getFirstSnippetText().split("LINESTRING\\(")[0];
150150
// Strip the ... characters from snippets.
151-
if (snippetFromSummary.contains("74.077"))
152-
snippetFromSummary = snippetFromSummary.split("74.077")[0];
151+
if (snippetFromSummary.contains("Json"))
152+
snippetFromSummary = "Json " + snippetFromSummary.split("Json")[1].trim();
153+
else
154+
snippetFromSummary = "Point " + snippetFromSummary.split("Point")[1].trim();
153155
if (summary.getFormat().name().equalsIgnoreCase("XML")) {
154156
DOMHandle contentHandle = readDocumentUsingDOMHandle(client, docUri, "XML");
155157
Document readDoc = contentHandle.get();
156-
linedesc = readDoc.getElementsByTagName("line-desc").item(0).getFirstChild().getNodeValue();
157-
snippetFromRead = readDoc.getElementsByTagName("linestring").item(0).getFirstChild().getNodeValue();
158-
System.out.println("linedesc from XML file is " + linedesc);
159-
System.out.println("Snippet linestring from XML file is " + snippetFromRead);
158+
linedesc = readDoc.getElementsByTagName("point-desc").item(0).getFirstChild().getNodeValue().trim();
159+
160+
System.out.println("Point desc from XML file is " + linedesc);
160161

161162
// Verify that snippets from qb and read contain the same.
162-
assertTrue("Snippets from summary and from XML file are incorrect ", snippetFromRead.contains(snippetFromSummary) );
163+
assertTrue("Snippets from summary and from XML file are incorrect ", linedesc.contains(snippetFromSummary) );
163164

164165
readDoc = null;
165166
contentHandle = null;
@@ -168,13 +169,12 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
168169
JacksonHandle jacksonhandle = new JacksonHandle();
169170
docMgr.read(docUri, jacksonhandle);
170171
JsonNode resultNode = jacksonhandle.get();
171-
linedesc = resultNode.path("root").path("item").path("line-desc").asText();
172-
snippetFromRead = resultNode.path("root").path("item").path("linestring").asText();
173-
System.out.println("linedesc from JSON file is " + linedesc);
174-
System.out.println("Snippet linestring from JSON file is " + snippetFromRead);
172+
linedesc = resultNode.path("root").path("item").path("point-desc").asText().trim();
173+
174+
System.out.println("Snippet point-desc from JSON file is " + linedesc);
175175

176176
// Verify that snippets from qb and read contain the same.
177-
assertTrue("Snippets from summary and from JSON file are incorrect ", snippetFromRead.contains(snippetFromSummary) );
177+
assertTrue("Snippets from summary and from JSON file are incorrect ", linedesc.contains(snippetFromSummary) );
178178
jacksonhandle = null;
179179
resultNode = null;
180180
}
@@ -187,7 +187,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
187187
/*
188188
* Circle contains circle
189189
*/
190-
@Ignore
190+
@Test
191191
public void testCircleContainsCircle() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
192192
{
193193
System.out.println("Running testCircleContainsCircle");
@@ -216,7 +216,7 @@ public void testCircleContainsCircle() throws KeyManagementException, NoSuchAlgo
216216
/*
217217
* Box contains Polygon
218218
*/
219-
@Ignore
219+
@Test
220220
public void testBoxContainsPolygon() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
221221
{
222222
System.out.println("Running testBoxContainsPolygon");
@@ -246,7 +246,7 @@ public void testBoxContainsPolygon() throws KeyManagementException, NoSuchAlgori
246246
/*
247247
* Circle intersects Point
248248
*/
249-
@Ignore
249+
@Test
250250
public void testCircleIntersectsPoint() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
251251
{
252252
System.out.println("Running testCircleIntersectsPoint");
@@ -287,7 +287,7 @@ public void testCircleIntersectsPoint() throws KeyManagementException, NoSuchAlg
287287
/*
288288
* linestring covered-by Polygon
289289
*/
290-
@Ignore
290+
@Test
291291
public void testcircleCoveredByPolygon() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
292292
{
293293
System.out.println("Running testcircleCoveredByPolygon");
@@ -336,7 +336,7 @@ public void testcircleCoveredByPolygon() throws KeyManagementException, NoSuchAl
336336
/*
337337
* Box covers Polygon
338338
*/
339-
@Ignore
339+
@Test
340340
public void testBoxCoversPolygon() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
341341
{
342342
System.out.println("Running testBoxCoversPolygon");
@@ -422,7 +422,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
422422
}
423423

424424
/*
425-
* Linestring crosses Box TODO Once server side issues are sorted in 4.0-2
425+
* Linestring crosses Box - TODO to be handled in 9.0-2 as of 04/112/2017.
426426
*/
427427
@Ignore
428428
public void testLinestringCrossesBox() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
@@ -446,15 +446,14 @@ public void testLinestringCrossesBox() throws KeyManagementException, NoSuchAlgo
446446
JsonNode jsonPointNodes = resultNode.path("results");
447447

448448
// Should have 2 nodes returned.
449-
//assertEquals("Two nodes not returned from testPolygonCoversBox method ", 2, resultNode.path("total").asInt());
450-
451-
// Work on the asserts once server bugs are fixed.
449+
assertEquals("Two nodes not returned from testPolygonCoversBox method ", 2, resultNode.path("total").asInt());
450+
452451
}
453452

454453
/*
455454
* Box overlaps Circle
456455
*/
457-
@Ignore
456+
@Test
458457
public void testBoxOverlapsCircle() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
459458
{
460459
System.out.println("Running testBoxOverlapsCircle");
@@ -540,7 +539,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
540539
/*
541540
* Polygon disjoint Polygon - polygon near south east
542541
*/
543-
@Ignore
542+
@Test
544543
public void testPolygonDisjointPolygon() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
545544
{
546545
System.out.println("Running testPolygonDisjointPolygon");
@@ -573,7 +572,7 @@ public void testPolygonDisjointPolygon() throws KeyManagementException, NoSuchAl
573572
/*
574573
* Box disjoint Box--except Tropic of Capricorn-Australia
575574
*/
576-
@Ignore
575+
@Test
577576
public void testBoxDisjointBox() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
578577
{
579578
System.out.println("Running testBoxDisjointBox");
@@ -654,7 +653,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
654653
* Point equals Point
655654
*/
656655

657-
@Ignore
656+
@Test
658657
public void testPointEqualsPoint() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
659658
{
660659
System.out.println("Running testPointEqualsPoint");
@@ -739,10 +738,10 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
739738
}
740739

741740
/*
742-
* Polygon touches Point TODO - Once Server side issues are fixed in 4.0-2
741+
* Polygon touches Point
743742
*/
744743

745-
@Ignore
744+
@Test
746745
public void testPolygonTouchesPoint() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
747746
{
748747
System.out.println("Running testPolygonTouchesPoint");
@@ -753,7 +752,7 @@ public void testPolygonTouchesPoint() throws KeyManagementException, NoSuchAlgor
753752
StructuredQueryBuilder qb = queryMgr.newStructuredQueryBuilder();
754753
StructuredQueryDefinition t = qb.geospatial(qb.geoRegionPath(qb.pathIndex("/root/item/polygon")),
755754
GeospatialOperator.TOUCHES,
756-
qb.point(-26.797920, 136.406250)
755+
qb.point(-26.0, 100.89)
757756
);
758757
// create handle
759758
JacksonHandle resultsHandle = new JacksonHandle();
@@ -764,16 +763,21 @@ public void testPolygonTouchesPoint() throws KeyManagementException, NoSuchAlgor
764763
JsonNode jsonPointNodes = resultNode.path("results");
765764

766765
// Should have 2 nodes returned.
767-
//assertEquals("Two nodes not returned from testPolygonCoversBox method ", 2, resultNode.path("total").asInt());
766+
assertEquals("Two nodes not returned from testPolygonTouchesPoint method ", 2, resultNode.path("total").asInt());
768767

769-
// Work on the asserts once server bugs are fixed.
768+
String exptdString = "POLYGON((153.65 -8.35,170.57 -26.0,162.52 -52.52,136.0 -56.35,111.0 -51.0,100.89 -26.0,108.18 1.82,136.0 10.26,153.65 -8.35))";
769+
String polygondesc1 = jsonPointNodes.get(0).path("matches").get(0).path("match-text").get(0).path("highlight").asText();
770+
String polygondesc2 = jsonPointNodes.get(1).path("matches").get(0).path("match-text").get(0).path("highlight").asText();
771+
772+
assertTrue("Polygon Node not returned from testPolygonTouchesPoint method ", exptdString.equalsIgnoreCase(polygondesc1));
773+
assertTrue("Polygon Node not returned from testPolygonTouchesPoint method ", exptdString.equalsIgnoreCase(polygondesc2));
770774
}
771775

772776
/*
773777
* Circle within Box
774778
*/
775779

776-
@Ignore
780+
@Test
777781
public void testCircleWithinBox() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException, XpathException, TransformerException
778782
{
779783
System.out.println("Running testCircleWithinBox");

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/Equator-json.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"point":"POINT(-66.09375 0)",
44
"point-desc":"Json Point In Equator - South America",
55

6-
"linestring":"LINESTRING(-50.9877 -1,-52.986 -1,-54.6798 -1,-56.876 -1,-58.987 -1,-61.5678 0,-63.989 0,-65.456 0,-67.57857 0,-69.09 0,-72.597 1,-74.077 1,-76.4056 1,-78.09023 1,-79.8761 1,-81.987 2,-82.658 2,-84.56978 2,-87.8798 2,-89.12132 2,-66.09375 0)",
6+
"linestring":"LINESTRING(-87.36328125 -3.11857621678199,-80.5078125 2.85526278436658,-77.34375 -1.40610883543516,-73.0810546875 3.33795396141649,-61.611328125 -2.28455066023696,-55.01953125 1.66968550098658)",
77
"line-desc":"Json Linestring In Equator - South America",
88
"line-vertices":"20",
99

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/Equator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<point>POINT(-66.09375 0)</point>
55
<point-desc>Point In Equator - South America</point-desc>
66

7-
<linestring>LINESTRING(-50.9877 -1,-52.986 -1,-54.6798 -1,-56.876 -1,-58.987 -1,-61.5678 0,-63.989 0,-65.456 0,-67.57857 0,-69.09 0,-72.597 1,-74.077 1,-76.4056 1,-78.09023 1,-79.8761 1,-81.987 2,-82.658 2,-84.56978 2,-87.8798 2,-89.12132 2,-66.09375 0)</linestring>
7+
<linestring>LINESTRING(-87.36328125 -3.11857621678199,-80.5078125 2.85526278436658,-77.34375 -1.40610883543516,-73.0810546875 3.33795396141649,-61.611328125 -2.28455066023696,-55.01953125 1.66968550098658)</linestring>
88
<line-desc>Linestring In Equator - South America</line-desc>
99
<line-vertices>20</line-vertices>
1010

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/North-West-json.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"point":"POINT(-154.687500 61.410743)",
44
"point-desc":"Json Point In North West part",
55

6-
"linestring":"LINESTRING(-154.7866 55.987,-151.56976 57.6896,-155.7866 59.579,-145.8383 61.89776,-167.777 63.5676,-125.8775 65.765,-144.8373 67.78609,-135.8976 69.765,-124.667897 71.7866,-156.987887 31.9237)",
6+
"linestring":"LINESTRING(-167.87109375 49.6107099380742,-168.57421875 64.244594767982,-154.51171875 56.0720354718009,-145.37109375 72.7119031080366,-123.57421875 58.7225988280434,-105.8203125 62.8350890114228,-108.6328125 55.9737982050766)",
77
"line-desc":"Json Linestring In North West part",
88
"line-vertices":"10",
99

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/North-West.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<point>POINT(-154.687500 61.410743)</point>
55
<point-desc>Point In North West part</point-desc>
66

7-
<linestring>LINESTRING(-154.7866 55.987,-151.56976 57.6896,-155.7866 59.579,-145.8383 61.89776,-167.777 63.5676,-125.8775 65.765,-144.8373 67.78609,-135.8976 69.765,-124.667897 71.7866,-156.987887 31.9237)</linestring>
7+
<linestring>LINESTRING(-167.87109375 49.6107099380742,-168.57421875 64.244594767982,-154.51171875 56.0720354718009,-145.37109375 72.7119031080366,-123.57421875 58.7225988280434,-105.8203125 62.8350890114228,-108.6328125 55.9737982050766)</linestring>
88
<line-desc>Linestring In North West part</line-desc>
99
<line-vertices>10</line-vertices>
1010

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/Prime-Meridian-json.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"line-desc":"Json Linestring In Prime-Meridian",
88
"line-vertices":"6",
99

10-
"circle":"@5673.4567 37.463235,0",
10+
"circle":"@3525 37.463235,0",
1111
"circle-desc":"Json Circle In Prime-Meridian",
1212

1313
"box":"[30.8456, -10.34634, 40.345, 10.4564]",

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/Prime-Meridian.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<line-desc>Linestring In Prime-Meridian</line-desc>
99
<line-vertices>6</line-vertices>
1010

11-
<circle>@5673.4567 37.463235,0</circle>
11+
<circle>@3525 37.463235,0</circle>
1212
<circle-desc>Circle In Prime-Meridian</circle-desc>
1313

1414
<box>[30.8456, -10.34634, 40.345, 10.4564]</box>

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/South-More-json.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"point":"POINT(-121.175079 -61.888897)",
44
"point-desc":"Json Point more towards South Pole",
55

6-
"linestring":"LINESTRING(-130.8787 -63.7776,-121.89778 -66.7123,-130.8787 -61.2324,-133.78656 -64.348,-115.8789 -56.88857,-123.7866 -56.2098,-140.6776 -55.23428,-130.7655 -61.232,-140.8765 -63.9919,-130.7866 -66.81161,-133.78656 -64.8887,-130.7866 -63.897,-123.78656 -61.877,-121.78676 -55.8121,-130.6656 -56.1211,-133.786 -64.1978,-115.888 -56.8998,-130.8171 -66.89897,-140.98798 -63.7655,-130.8977 -61.7677,-123.856 -55.9234,-140.12312 -64.353,-133.878 -63.7866,-115.879 -64.232332,-121.9171 -61.8786,-130.12312 -66.9889)",
6+
"linestring":"LINESTRING(-151.69921875 -67.5421666883853,-152.9296875 -57.1362393191774,-143.61328125 -66.0893642704709,-142.734375 -55.2791152920156,-122.16796875 -60.3269477429984,-110.7421875 -51.8357775204525,-107.75390625 -59.5343180010956,-100.01953125 -58.3556303628097)",
77
"line-desc":"Json Linestring more towards South Pole",
88
"line-vertices":"26",
99

test-complete/src/test/java/com/marklogic/client/functionaltest/data/geodouble/South-More.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<point>POINT(-121.175079 -61.888897)</point>
55
<point-desc>Point more towards South Pole</point-desc>
66

7-
<linestring>LINESTRING(-130.8787 -63.7776,-121.89778 -66.7123,-130.8787 -61.2324,-133.78656 -64.348,-115.8789 -56.88857,-123.7866 -56.2098,-140.6776 -55.23428,-130.7655 -61.232,-140.8765 -63.9919,-130.7866 -66.81161,-133.78656 -64.8887,-130.7866 -63.897,-123.78656 -61.877,-121.78676 -55.8121,-130.6656 -56.1211,-133.786 -64.1978,-115.888 -56.8998,-130.8171 -66.89897,-140.98798 -63.7655,-130.8977 -61.7677,-123.856 -55.9234,-140.12312 -64.353,-133.878 -63.7866,-115.879 -64.232332,-121.9171 -61.8786,-130.12312 -66.9889)</linestring>
7+
<linestring>LINESTRING(-151.69921875 -67.5421666883853,-152.9296875 -57.1362393191774,-143.61328125 -66.0893642704709,-142.734375 -55.2791152920156,-122.16796875 -60.3269477429984,-110.7421875 -51.8357775204525,-107.75390625 -59.5343180010956,-100.01953125 -58.3556303628097)</linestring>
88
<line-desc>Linestring more towards South Pole</line-desc>
99
<line-vertices>26</line-vertices>
1010

0 commit comments

Comments
 (0)