Skip to content

Commit a5ac9b4

Browse files
author
red-fenix
committed
bugfix: rename all "polygon" references to "geometry"
1 parent eff3b06 commit a5ac9b4

21 files changed

+87
-87
lines changed

app/es_embedded/src/main/java/de/komoot/photon/Server.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class Server {
5656
private static final String FIELD_VERSION = "database_version";
5757
private static final String FIELD_LANGUAGES = "indexed_languages";
5858
private static final String FIELD_IMPORT_DATE = "import_date";
59-
private static final String FIELD_SUPPORT_POLYGONS = "support_polygons";
59+
private static final String FIELD_SUPPORT_GEOMETRIES = "support_geometries";
6060

6161
private Node esNode;
6262

@@ -178,7 +178,7 @@ private void setupDirectories(URL directoryName) throws IOException, URISyntaxEx
178178

179179
}
180180

181-
public DatabaseProperties recreateIndex(String[] languages, Date importDate, boolean supportStructuredQueries, boolean supportPolygons) throws IOException {
181+
public DatabaseProperties recreateIndex(String[] languages, Date importDate, boolean supportStructuredQueries, boolean supportGeometries) throws IOException {
182182
deleteIndex();
183183

184184
loadIndexSettings().createIndex(esClient, PhotonIndex.NAME);
@@ -188,7 +188,7 @@ public DatabaseProperties recreateIndex(String[] languages, Date importDate, boo
188188
DatabaseProperties dbProperties = new DatabaseProperties()
189189
.setLanguages(languages)
190190
.setImportDate(importDate)
191-
.setSupportPolygons(supportPolygons);
191+
.setSupportGeometries(supportGeometries);
192192

193193
saveToDatabase(dbProperties);
194194

@@ -244,7 +244,7 @@ public void saveToDatabase(DatabaseProperties dbProperties) throws IOException
244244
.field(FIELD_VERSION, DATABASE_VERSION)
245245
.field(FIELD_LANGUAGES, String.join(",", dbProperties.getLanguages()))
246246
.field(FIELD_IMPORT_DATE, dbProperties.getImportDate() instanceof Date ? dbProperties.getImportDate().toInstant() : null)
247-
.field(FIELD_SUPPORT_POLYGONS, Boolean.toString(dbProperties.getSupportPolygons()))
247+
.field(FIELD_SUPPORT_GEOMETRIES, Boolean.toString(dbProperties.getSupportGeometries()))
248248
.endObject().endObject();
249249

250250
esClient.prepareIndex(PhotonIndex.NAME, PhotonIndex.TYPE).
@@ -285,12 +285,12 @@ public DatabaseProperties loadFromDatabase() {
285285

286286
String importDateString = properties.get(FIELD_IMPORT_DATE);
287287

288-
String supportPolygons = properties.get(FIELD_SUPPORT_POLYGONS);
288+
String supportGeometries = properties.get(FIELD_SUPPORT_GEOMETRIES);
289289

290290
return new DatabaseProperties(langString == null ? null : langString.split(","),
291291
importDateString == null ? null : Date.from(Instant.parse(importDateString)),
292292
false,
293-
Boolean.parseBoolean(supportPolygons));
293+
Boolean.parseBoolean(supportGeometries));
294294
}
295295

296296
public Importer createImporter(String[] languages, String[] extraTags) {

app/es_embedded/src/test/java/de/komoot/photon/ESBaseTester.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ public void setUpES() throws IOException {
5050
setUpES(dataDirectory, false,"en");
5151
}
5252

53-
public void setUpESWithPolygons() throws IOException {
53+
public void setUpESWithGeometry() throws IOException {
5454
setUpES(dataDirectory, true,"en");
5555
}
5656
/**
5757
* Setup the ES server
5858
*
5959
* @throws IOException
6060
*/
61-
public void setUpES(Path testDirectory, boolean supportPolygons, String... languages) throws IOException {
61+
public void setUpES(Path testDirectory, boolean supportGeometries, String... languages) throws IOException {
6262
server = new ElasticTestServer(testDirectory.toString());
6363
server.start(TEST_CLUSTER_NAME, new String[]{});
64-
server.recreateIndex(languages, new Date(), false, supportPolygons);
64+
server.recreateIndex(languages, new Date(), false, supportGeometries);
6565
refresh();
6666
}
6767

app/opensearch/src/main/java/de/komoot/photon/Server.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void shutdown() {
120120
}
121121
}
122122

123-
public DatabaseProperties recreateIndex(String[] languages, Date importDate, boolean supportStructuredQueries, boolean supportPolygons) throws IOException {
123+
public DatabaseProperties recreateIndex(String[] languages, Date importDate, boolean supportStructuredQueries, boolean supportGeometries) throws IOException {
124124
// delete any existing data
125125
if (client.indices().exists(e -> e.index(PhotonIndex.NAME)).value()) {
126126
client.indices().delete(d -> d.index(PhotonIndex.NAME));
@@ -130,7 +130,7 @@ public DatabaseProperties recreateIndex(String[] languages, Date importDate, boo
130130

131131
(new IndexMapping(supportStructuredQueries)).addLanguages(languages).putMapping(client, PhotonIndex.NAME);
132132

133-
var dbProperties = new DatabaseProperties(languages, importDate, supportStructuredQueries, supportPolygons);
133+
var dbProperties = new DatabaseProperties(languages, importDate, supportStructuredQueries, supportGeometries);
134134
saveToDatabase(dbProperties);
135135

136136
return dbProperties;
@@ -182,7 +182,7 @@ public DatabaseProperties loadFromDatabase() throws IOException {
182182
return new DatabaseProperties(dbEntry.source().languages,
183183
dbEntry.source().importDate,
184184
dbEntry.source().supportStructuredQueries,
185-
dbEntry.source().supportPolygons);
185+
dbEntry.source().supportGeometries);
186186
}
187187

188188
public Importer createImporter(String[] languages, String[] extraTags) {

app/opensearch/src/main/java/de/komoot/photon/opensearch/DBPropertyEntry.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class DBPropertyEntry {
99
public Date importDate;
1010
public String[] languages;
1111
public boolean supportStructuredQueries;
12-
public boolean supportPolygons;
12+
public boolean supportGeometries;
1313

1414
public DBPropertyEntry() {}
1515

@@ -18,6 +18,6 @@ public DBPropertyEntry(DatabaseProperties props, String databaseVersion) {
1818
importDate = props.getImportDate();
1919
languages = props.getLanguages();
2020
supportStructuredQueries = props.getSupportStructuredQueries();
21-
supportPolygons = props.getSupportPolygons();
21+
supportGeometries = props.getSupportGeometries();
2222
}
2323
}

app/opensearch/src/test/java/de/komoot/photon/ESBaseTester.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ public void setUpES() throws IOException {
5151
setUpES(dataDirectory, false, "en");
5252
}
5353

54-
public void setUpESWithPolygons() throws IOException {
54+
public void setUpESWithGeometry() throws IOException {
5555
setUpES(dataDirectory, true, "en");
5656
}
5757

58-
public void setUpES(Path testDirectory, boolean supportPolygons, String... languages) throws IOException {
58+
public void setUpES(Path testDirectory, boolean supportGeometries, String... languages) throws IOException {
5959
server = new OpenSearchTestServer(testDirectory.toString());
6060
server.startTestServer(TEST_CLUSTER_NAME);
61-
server.recreateIndex(languages, new Date(), true, supportPolygons);
61+
server.recreateIndex(languages, new Date(), true, supportGeometries);
6262
server.refreshIndexes();
6363
}
6464

app/opensearch/src/test/java/de/komoot/photon/opensearch/ImporterTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ImporterTest extends ESBaseTester {
2020

2121
@BeforeEach
2222
public void setUp() throws IOException {
23-
setUpESWithPolygons();
23+
setUpESWithGeometry();
2424
}
2525

2626
@Test

src/main/java/de/komoot/photon/App.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ private static void startApi(CommandLineArgs args, Server server) throws IOExcep
253253
}
254254

255255
LOGGER.info("Starting API with the following settings: " +
256-
"\n Languages: {} \n Import Date: {} \n Support Structured Queries: {} \n Support Polygons: {}",
257-
dbProperties.getLanguages(), dbProperties.getImportDate(), dbProperties.getSupportStructuredQueries(), dbProperties.getSupportPolygons());
256+
"\n Languages: {} \n Import Date: {} \n Support Structured Queries: {} \n Support Geometries: {}",
257+
dbProperties.getLanguages(), dbProperties.getImportDate(), dbProperties.getSupportStructuredQueries(), dbProperties.getSupportGeometries());
258258

259259
port(args.getListenPort());
260260
ipAddress(args.getListenIp());
@@ -271,13 +271,13 @@ private static void startApi(CommandLineArgs args, Server server) throws IOExcep
271271
String[] langs = dbProperties.getLanguages();
272272

273273
SearchHandler searchHandler = server.createSearchHandler(langs, args.getQueryTimeout());
274-
get("api", new SearchRequestHandler("api", searchHandler, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportPolygons()));
275-
get("api/", new SearchRequestHandler("api/", searchHandler, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportPolygons()));
274+
get("api", new SearchRequestHandler("api", searchHandler, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportGeometries()));
275+
get("api/", new SearchRequestHandler("api/", searchHandler, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportGeometries()));
276276

277277
if (dbProperties.getSupportStructuredQueries()) {
278278
StructuredSearchHandler structured = server.createStructuredSearchHandler(langs, args.getQueryTimeout());
279-
get("structured", new StructuredSearchRequestHandler("structured", structured, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportPolygons()));
280-
get("structured/", new StructuredSearchRequestHandler("structured/", structured, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportPolygons()));
279+
get("structured", new StructuredSearchRequestHandler("structured", structured, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportGeometries()));
280+
get("structured/", new StructuredSearchRequestHandler("structured/", structured, langs, args.getDefaultLanguage(), args.getMaxResults(), dbProperties.getSupportGeometries()));
281281
}
282282

283283
ReverseHandler reverseHandler = server.createReverseHandler(args.getQueryTimeout());

src/main/java/de/komoot/photon/CommandLineArgs.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public class CommandLineArgs {
9898
@Parameter(names = "-max-reverse-results", description = "The maximum possible 'limit' parameter for reverse geocoding searches")
9999
private int maxReverseResults = 50;
100100

101-
@Parameter(names = "-import-geometry-column", description = "[import-only] Add the 'geometry' column from Nominatim on import (i.e. add Polygons for cities, countries etc.). WARNING: This will increase the Elasticsearch Index size! (~575GB for Planet)")
101+
@Parameter(names = "-import-geometry-column", description = "[import-only] Add the 'geometry' column from Nominatim on import (i.e. add Polygons/Linestrings/Multipolygons etc. for cities, countries etc.). WARNING: This will increase the Elasticsearch Index size! (~575GB for Planet)")
102102
private boolean importGeometryColumn = false;
103103

104104
public String[] getLanguages(boolean useDefaultIfEmpty) {

src/main/java/de/komoot/photon/DatabaseProperties.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public class DatabaseProperties {
1111
private String[] languages;
1212
private Date importDate;
1313
private boolean supportStructuredQueries;
14-
private boolean supportPolygons;
14+
private boolean supportGeometries;
1515

16-
public DatabaseProperties(String[] languages, Date importDate, boolean supportStructuredQueries, boolean supportPolygons) {
16+
public DatabaseProperties(String[] languages, Date importDate, boolean supportStructuredQueries, boolean supportGeometries) {
1717
this.languages = languages;
1818
this.importDate = importDate;
1919
this.supportStructuredQueries = supportStructuredQueries;
20-
this.supportPolygons = supportPolygons;
20+
this.supportGeometries = supportGeometries;
2121
}
2222

2323
public DatabaseProperties() {
@@ -100,12 +100,12 @@ public DatabaseProperties setSupportStructuredQueries(boolean supportStructuredQ
100100
return this;
101101
}
102102

103-
public boolean getSupportPolygons() {
104-
return supportPolygons;
103+
public boolean getSupportGeometries() {
104+
return supportGeometries;
105105
}
106106

107-
public DatabaseProperties setSupportPolygons(boolean supportPolygons) {
108-
this.supportPolygons = supportPolygons;
107+
public DatabaseProperties setSupportGeometries(boolean supportGeometries) {
108+
this.supportGeometries = supportGeometries;
109109
return this;
110110
}
111111

@@ -115,7 +115,7 @@ public String toString() {
115115
"languages=" + Arrays.toString(languages) +
116116
", importDate=" + importDate +
117117
", supportStructuredQueries=" + supportStructuredQueries +
118-
", supportPolygons=" + supportPolygons +
118+
", supportGeometries=" + supportGeometries +
119119
'}';
120120
}
121121
}

src/main/java/de/komoot/photon/PhotonDoc.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public PhotonDoc centroid(Geometry centroid) {
9898
return this;
9999
}
100100

101-
public PhotonDoc geometry(Geometry polygon) {
102-
this.geometry = (Geometry) polygon;
101+
public PhotonDoc geometry(Geometry geometry) {
102+
this.geometry = (Geometry) geometry;
103103
return this;
104104
}
105105

src/main/java/de/komoot/photon/ReverseSearchRequestHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public String handle(Request request, Response response) {
5353
debugInfo = requestHandler.dumpQuery(photonRequest);
5454
}
5555

56-
return new GeocodeJsonFormatter(false, photonRequest.getLanguage(), photonRequest.getPolygon()).convert(results, debugInfo);
56+
return new GeocodeJsonFormatter(false, photonRequest.getLanguage(), photonRequest.getGeometry()).convert(results, debugInfo);
5757
}
5858
}

src/main/java/de/komoot/photon/SearchRequestHandler.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
public class SearchRequestHandler extends RouteImpl {
2121
private final PhotonRequestFactory photonRequestFactory;
2222
private final SearchHandler requestHandler;
23-
private final boolean supportPolygons;
23+
private final boolean supportGeometries;
2424

25-
SearchRequestHandler(String path, SearchHandler dbHandler, String[] languages, String defaultLanguage, int maxResults, boolean supportPolygons) {
25+
SearchRequestHandler(String path, SearchHandler dbHandler, String[] languages, String defaultLanguage, int maxResults, boolean supportGeometries) {
2626
super(path);
2727
List<String> supportedLanguages = Arrays.asList(languages);
28-
this.photonRequestFactory = new PhotonRequestFactory(supportedLanguages, defaultLanguage, maxResults, supportPolygons);
28+
this.photonRequestFactory = new PhotonRequestFactory(supportedLanguages, defaultLanguage, maxResults, supportGeometries);
2929
this.requestHandler = dbHandler;
30-
this.supportPolygons = supportPolygons;
30+
this.supportGeometries = supportGeometries;
3131
}
3232

3333
@Override
@@ -41,9 +41,9 @@ public String handle(Request request, Response response) throws BadRequestExcept
4141
throw halt(e.getHttpStatus(), json.toString());
4242
}
4343

44-
if (!supportPolygons && photonRequest.getReturnPolygon()) {
44+
if (!supportGeometries && photonRequest.getReturnGeometry()) {
4545
JSONObject json = new JSONObject();
46-
json.put("message", "You're explicitly requesting a polygon, but polygons are not imported!");
46+
json.put("message", "You're explicitly requesting a geometry, but geometries are not imported!");
4747
throw halt(400, json.toString());
4848
}
4949

@@ -62,6 +62,6 @@ public String handle(Request request, Response response) throws BadRequestExcept
6262
debugInfo = requestHandler.dumpQuery(photonRequest);
6363
}
6464

65-
return new GeocodeJsonFormatter(photonRequest.getDebug(), photonRequest.getLanguage(), photonRequest.getReturnPolygon()).convert(results, debugInfo);
65+
return new GeocodeJsonFormatter(photonRequest.getDebug(), photonRequest.getLanguage(), photonRequest.getReturnGeometry()).convert(results, debugInfo);
6666
}
6767
}

src/main/java/de/komoot/photon/StructuredSearchRequestHandler.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
public class StructuredSearchRequestHandler extends RouteImpl {
1818
private final PhotonRequestFactory photonRequestFactory;
1919
private final StructuredSearchHandler requestHandler;
20-
private final boolean supportPolygons;
20+
private final boolean supportGeometries;
2121

22-
StructuredSearchRequestHandler(String path, StructuredSearchHandler dbHandler, String[] languages, String defaultLanguage, int maxResults, boolean supportPolygons) {
22+
StructuredSearchRequestHandler(String path, StructuredSearchHandler dbHandler, String[] languages, String defaultLanguage, int maxResults, boolean supportGeometries) {
2323
super(path);
2424
List<String> supportedLanguages = Arrays.asList(languages);
25-
this.photonRequestFactory = new PhotonRequestFactory(supportedLanguages, defaultLanguage, maxResults, supportPolygons);
25+
this.photonRequestFactory = new PhotonRequestFactory(supportedLanguages, defaultLanguage, maxResults, supportGeometries);
2626
this.requestHandler = dbHandler;
27-
this.supportPolygons = supportPolygons;
27+
this.supportGeometries = supportGeometries;
2828
}
2929

3030
@Override
@@ -38,9 +38,9 @@ public String handle(Request request, Response response) {
3838
throw halt(e.getHttpStatus(), json.toString());
3939
}
4040

41-
if (!supportPolygons && photonRequest.getReturnPolygon()) {
41+
if (!supportGeometries && photonRequest.getReturnGeometry()) {
4242
JSONObject json = new JSONObject();
43-
json.put("message", "You're requesting a polygon, but polygons are not imported!");
43+
json.put("message", "You're requesting a Geometry, but Geometries are not imported!");
4444
throw halt(400, json.toString());
4545
}
4646

@@ -60,6 +60,6 @@ public String handle(Request request, Response response) {
6060
debugInfo = requestHandler.dumpQuery(photonRequest);
6161
}
6262
*/
63-
return new GeocodeJsonFormatter(photonRequest.getDebug(), photonRequest.getLanguage(), photonRequest.getReturnPolygon()).convert(results, debugInfo);
63+
return new GeocodeJsonFormatter(photonRequest.getDebug(), photonRequest.getLanguage(), photonRequest.getReturnGeometry()).convert(results, debugInfo);
6464
}
6565
}

src/main/java/de/komoot/photon/query/PhotonRequestBase.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class PhotonRequestBase
1818
private int zoom = 14;
1919
private Envelope bbox = null;
2020
private boolean debug = false;
21-
private boolean returnPolygon = false;
21+
private boolean returnGeometry = false;
2222

2323
private final List<TagFilter> osmTagFilters = new ArrayList<>(1);
2424
private Set<String> layerFilters = new HashSet<>(1);
@@ -54,7 +54,7 @@ public String getLanguage() {
5454

5555
public boolean getDebug() { return debug; }
5656

57-
public boolean getReturnPolygon() { return returnPolygon; }
57+
public boolean getReturnGeometry() { return returnGeometry; }
5858

5959
public List<TagFilter> getOsmTagFilters() {
6060
return osmTagFilters;
@@ -104,8 +104,8 @@ void enableDebug() {
104104
this.debug = true;
105105
}
106106

107-
void setReturnPolygon(boolean returnPolygon) {
108-
this.returnPolygon = returnPolygon;
107+
void setReturnGeometry(boolean returnGeometry) {
108+
this.returnGeometry = returnGeometry;
109109
}
110110

111111
}

0 commit comments

Comments
 (0)