7
7
import com .fasterxml .jackson .databind .node .ArrayNode ;
8
8
import com .fasterxml .jackson .databind .node .ObjectNode ;
9
9
import de .komoot .photon .Constants ;
10
- import de .komoot .photon .searcher .GeometryType ;
11
10
import de .komoot .photon .searcher .PhotonResult ;
12
11
13
12
import java .io .IOException ;
@@ -30,17 +29,9 @@ public OpenSearchResult deserialize(JsonParser p, DeserializationContext ctxt) t
30
29
final Map <String , Object > tags = new HashMap <>();
31
30
final Map <String , Map <String , String >> localeTags = new HashMap <>();
32
31
33
- double [][] geometry = new double [0 ][];
34
- GeometryType geometryType = GeometryType .UNKNOWN ;
35
-
36
- if (node .get ("geometry" ) != null && node .get ("geometry" ).get ("type" ) != null ) {
37
- if (node .get ("geometry" ).get ("type" ).asText ().equals ("Polygon" )) {
38
- geometry = extractPolygon ((ObjectNode ) node .get ("geometry" ));
39
- geometryType = GeometryType .POLYGON ;
40
- } else if (node .get ("geometry" ).get ("type" ).asText ().equals ("LineString" )) {
41
- geometry = extractLineString ((ObjectNode ) node .get ("geometry" ));
42
- geometryType = GeometryType .LINESTRING ;
43
- }
32
+ String geometry = null ;
33
+ if (node .get ("geometry" ) != null ) {
34
+ geometry = node .get ("geometry" ).toString ();
44
35
}
45
36
46
37
var fields = node .fields ();
@@ -69,7 +60,7 @@ public OpenSearchResult deserialize(JsonParser p, DeserializationContext ctxt) t
69
60
}
70
61
}
71
62
72
- return new OpenSearchResult (extent , coordinates , tags , localeTags , geometry , geometryType );
63
+ return new OpenSearchResult (extent , coordinates , tags , localeTags , geometry );
73
64
}
74
65
75
66
private double [] extractExtent (ObjectNode node ) {
@@ -92,32 +83,4 @@ private double[] extractCoordinate(ObjectNode node) {
92
83
93
84
return new double []{node .get (Constants .LON ).doubleValue (), node .get (Constants .LAT ).doubleValue ()};
94
85
}
95
-
96
- private double [][] extractPolygon (ObjectNode node ) {
97
- if (node == null ) {
98
- return PhotonResult .INVALID_GEOMETRY ;
99
- }
100
-
101
- double [][] coordinates = new double [node .get ("coordinates" ).get (0 ).size ()][];
102
- for (int i =0 ; i <node .get ("coordinates" ).get (0 ).size (); i ++) {
103
- double [] coordinate = new double [] {node .get ("coordinates" ).get (0 ).get (i ).get (0 ).doubleValue (), node .get ("coordinates" ).get (0 ).get (i ).get (1 ).doubleValue ()};
104
- coordinates [i ] = coordinate ;
105
- }
106
-
107
- return coordinates ;
108
- }
109
-
110
- private double [][] extractLineString (ObjectNode node ) {
111
- if (node == null ) {
112
- return PhotonResult .INVALID_GEOMETRY ;
113
- }
114
-
115
- double [][] coordinates = new double [node .get ("coordinates" ).size ()][];
116
- for (int i =0 ; i <node .get ("coordinates" ).size (); i ++) {
117
- double [] coordinate = new double [] {node .get ("coordinates" ).get (i ).get (0 ).doubleValue (), node .get ("coordinates" ).get (i ).get (1 ).doubleValue ()};
118
- coordinates [i ] = coordinate ;
119
- }
120
-
121
- return coordinates ;
122
- }
123
86
}
0 commit comments