Skip to content

Commit 86141c8

Browse files
authored
Add country codes (#24)
* chore: add `code` field to Boundary and update schema, FlatBuffers, and ImportService accordingly * fix: resolve BufferUnderflowException by adding country code serialization * feature: add `code` field to HierarchyData and update related classes, FlatBuffers, and schema integration
1 parent 798bf24 commit 86141c8

13 files changed

Lines changed: 83 additions & 156 deletions

File tree

schema/boundary.fbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ table Boundary {
88
osm_id: long;
99
level: int;
1010
name: string;
11-
11+
code: string;
12+
1213
// Minimum Bounding Rectangle (The "Outer" box)
1314
min_x: double;
1415
min_y: double;

schema/poi.fbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ table HierarchyItem {
2121
type:string; // e.g., "country", "state", "city"
2222
name:string; // Localized name
2323
osm_id:long; // Reference to boundary geometry
24+
code:string; // ISO3166-1 if available
2425
}
2526

2627
// POI Geometry (stored as WKB bytes)

src/main/java/com/dedicatedcode/paikka/dto/POIResponse.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,28 @@ public static class HierarchyItem {
111111

112112
@JsonProperty("osm_id")
113113
private long osmId;
114-
114+
115+
@JsonProperty("country_code")
116+
private String code;
117+
115118
@JsonProperty("geometry_url")
116119
private String geometryUrl;
117120

118121
public HierarchyItem() {}
119122

120-
public HierarchyItem(int level, String type, String name, long osmId) {
123+
public HierarchyItem(int level, String type, String name, String code, long osmId) {
121124
this.level = level;
122125
this.type = type;
123126
this.name = name;
127+
this.code = code;
124128
this.osmId = osmId;
125129
}
126130

127-
public HierarchyItem(int level, String type, String name, long osmId, String geometryUrl) {
131+
public HierarchyItem(int level, String type, String name, String code, long osmId, String geometryUrl) {
128132
this.level = level;
129133
this.type = type;
130134
this.name = name;
135+
this.code = code;
131136
this.osmId = osmId;
132137
this.geometryUrl = geometryUrl;
133138
}
@@ -146,6 +151,9 @@ public HierarchyItem(int level, String type, String name, long osmId, String geo
146151

147152
public String getGeometryUrl() { return geometryUrl; }
148153
public void setGeometryUrl(String geometryUrl) { this.geometryUrl = geometryUrl; }
154+
155+
public String getCode() { return code; }
156+
public void setCode(String code) { this.code = code; }
149157
}
150158

151159
public static class QueryInfo {

src/main/java/com/dedicatedcode/paikka/flatbuffers/Address.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* This file is part of paikka.
3-
*
4-
* Paikka is free software: you can redistribute it and/or
5-
* modify it under the terms of the GNU Affero General Public License
6-
* as published by the Free Software Foundation, either version 3 or
7-
* any later version.
8-
*
9-
* Paikka is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied
11-
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Affero General Public License for more details.
13-
* You should have received a copy of the GNU Affero General Public License
14-
* along with Paikka. If not, see <https://www.gnu.org/licenses/>.
15-
*/
16-
171
// automatically generated by the FlatBuffers compiler, do not modify
182

193
package com.dedicatedcode.paikka.flatbuffers;

src/main/java/com/dedicatedcode/paikka/flatbuffers/Boundary.java

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* This file is part of paikka.
3-
*
4-
* Paikka is free software: you can redistribute it and/or
5-
* modify it under the terms of the GNU Affero General Public License
6-
* as published by the Free Software Foundation, either version 3 or
7-
* any later version.
8-
*
9-
* Paikka is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied
11-
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Affero General Public License for more details.
13-
* You should have received a copy of the GNU Affero General Public License
14-
* along with Paikka. If not, see <https://www.gnu.org/licenses/>.
15-
*/
16-
171
// automatically generated by the FlatBuffers compiler, do not modify
182

193
package com.dedicatedcode.paikka.flatbuffers;
@@ -36,21 +20,25 @@ public final class Boundary extends Table {
3620
public String name() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
3721
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
3822
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
39-
public double minX() { int o = __offset(10); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
40-
public double minY() { int o = __offset(12); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
41-
public double maxX() { int o = __offset(14); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
42-
public double maxY() { int o = __offset(16); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
43-
public double mirMinX() { int o = __offset(18); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
44-
public double mirMinY() { int o = __offset(20); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
45-
public double mirMaxX() { int o = __offset(22); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
46-
public double mirMaxY() { int o = __offset(24); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
23+
public String code() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; }
24+
public ByteBuffer codeAsByteBuffer() { return __vector_as_bytebuffer(10, 1); }
25+
public ByteBuffer codeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
26+
public double minX() { int o = __offset(12); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
27+
public double minY() { int o = __offset(14); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
28+
public double maxX() { int o = __offset(16); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
29+
public double maxY() { int o = __offset(18); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
30+
public double mirMinX() { int o = __offset(20); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
31+
public double mirMinY() { int o = __offset(22); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
32+
public double mirMaxX() { int o = __offset(24); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
33+
public double mirMaxY() { int o = __offset(26); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
4734
public com.dedicatedcode.paikka.flatbuffers.Geometry geometry() { return geometry(new com.dedicatedcode.paikka.flatbuffers.Geometry()); }
48-
public com.dedicatedcode.paikka.flatbuffers.Geometry geometry(com.dedicatedcode.paikka.flatbuffers.Geometry obj) { int o = __offset(26); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
35+
public com.dedicatedcode.paikka.flatbuffers.Geometry geometry(com.dedicatedcode.paikka.flatbuffers.Geometry obj) { int o = __offset(28); return o != 0 ? obj.__assign(__indirect(o + bb_pos), bb) : null; }
4936

5037
public static int createBoundary(FlatBufferBuilder builder,
5138
long osmId,
5239
int level,
5340
int nameOffset,
41+
int codeOffset,
5442
double minX,
5543
double minY,
5644
double maxX,
@@ -60,7 +48,7 @@ public static int createBoundary(FlatBufferBuilder builder,
6048
double mirMaxX,
6149
double mirMaxY,
6250
int geometryOffset) {
63-
builder.startTable(12);
51+
builder.startTable(13);
6452
Boundary.addMirMaxY(builder, mirMaxY);
6553
Boundary.addMirMaxX(builder, mirMaxX);
6654
Boundary.addMirMinY(builder, mirMinY);
@@ -71,24 +59,26 @@ public static int createBoundary(FlatBufferBuilder builder,
7159
Boundary.addMinX(builder, minX);
7260
Boundary.addOsmId(builder, osmId);
7361
Boundary.addGeometry(builder, geometryOffset);
62+
Boundary.addCode(builder, codeOffset);
7463
Boundary.addName(builder, nameOffset);
7564
Boundary.addLevel(builder, level);
7665
return Boundary.endBoundary(builder);
7766
}
7867

79-
public static void startBoundary(FlatBufferBuilder builder) { builder.startTable(12); }
68+
public static void startBoundary(FlatBufferBuilder builder) { builder.startTable(13); }
8069
public static void addOsmId(FlatBufferBuilder builder, long osmId) { builder.addLong(0, osmId, 0L); }
8170
public static void addLevel(FlatBufferBuilder builder, int level) { builder.addInt(1, level, 0); }
8271
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(2, nameOffset, 0); }
83-
public static void addMinX(FlatBufferBuilder builder, double minX) { builder.addDouble(3, minX, 0.0); }
84-
public static void addMinY(FlatBufferBuilder builder, double minY) { builder.addDouble(4, minY, 0.0); }
85-
public static void addMaxX(FlatBufferBuilder builder, double maxX) { builder.addDouble(5, maxX, 0.0); }
86-
public static void addMaxY(FlatBufferBuilder builder, double maxY) { builder.addDouble(6, maxY, 0.0); }
87-
public static void addMirMinX(FlatBufferBuilder builder, double mirMinX) { builder.addDouble(7, mirMinX, 0.0); }
88-
public static void addMirMinY(FlatBufferBuilder builder, double mirMinY) { builder.addDouble(8, mirMinY, 0.0); }
89-
public static void addMirMaxX(FlatBufferBuilder builder, double mirMaxX) { builder.addDouble(9, mirMaxX, 0.0); }
90-
public static void addMirMaxY(FlatBufferBuilder builder, double mirMaxY) { builder.addDouble(10, mirMaxY, 0.0); }
91-
public static void addGeometry(FlatBufferBuilder builder, int geometryOffset) { builder.addOffset(11, geometryOffset, 0); }
72+
public static void addCode(FlatBufferBuilder builder, int codeOffset) { builder.addOffset(3, codeOffset, 0); }
73+
public static void addMinX(FlatBufferBuilder builder, double minX) { builder.addDouble(4, minX, 0.0); }
74+
public static void addMinY(FlatBufferBuilder builder, double minY) { builder.addDouble(5, minY, 0.0); }
75+
public static void addMaxX(FlatBufferBuilder builder, double maxX) { builder.addDouble(6, maxX, 0.0); }
76+
public static void addMaxY(FlatBufferBuilder builder, double maxY) { builder.addDouble(7, maxY, 0.0); }
77+
public static void addMirMinX(FlatBufferBuilder builder, double mirMinX) { builder.addDouble(8, mirMinX, 0.0); }
78+
public static void addMirMinY(FlatBufferBuilder builder, double mirMinY) { builder.addDouble(9, mirMinY, 0.0); }
79+
public static void addMirMaxX(FlatBufferBuilder builder, double mirMaxX) { builder.addDouble(10, mirMaxX, 0.0); }
80+
public static void addMirMaxY(FlatBufferBuilder builder, double mirMaxY) { builder.addDouble(11, mirMaxY, 0.0); }
81+
public static void addGeometry(FlatBufferBuilder builder, int geometryOffset) { builder.addOffset(12, geometryOffset, 0); }
9282
public static int endBoundary(FlatBufferBuilder builder) {
9383
int o = builder.endTable();
9484
return o;

src/main/java/com/dedicatedcode/paikka/flatbuffers/Geometry.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* This file is part of paikka.
3-
*
4-
* Paikka is free software: you can redistribute it and/or
5-
* modify it under the terms of the GNU Affero General Public License
6-
* as published by the Free Software Foundation, either version 3 or
7-
* any later version.
8-
*
9-
* Paikka is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied
11-
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Affero General Public License for more details.
13-
* You should have received a copy of the GNU Affero General Public License
14-
* along with Paikka. If not, see <https://www.gnu.org/licenses/>.
15-
*/
16-
171
// automatically generated by the FlatBuffers compiler, do not modify
182

193
package com.dedicatedcode.paikka.flatbuffers;

src/main/java/com/dedicatedcode/paikka/flatbuffers/HierarchyItem.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* This file is part of paikka.
3-
*
4-
* Paikka is free software: you can redistribute it and/or
5-
* modify it under the terms of the GNU Affero General Public License
6-
* as published by the Free Software Foundation, either version 3 or
7-
* any later version.
8-
*
9-
* Paikka is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied
11-
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Affero General Public License for more details.
13-
* You should have received a copy of the GNU Affero General Public License
14-
* along with Paikka. If not, see <https://www.gnu.org/licenses/>.
15-
*/
16-
171
// automatically generated by the FlatBuffers compiler, do not modify
182

193
package com.dedicatedcode.paikka.flatbuffers;
@@ -39,25 +23,31 @@ public final class HierarchyItem extends Table {
3923
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
4024
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
4125
public long osmId() { int o = __offset(10); return o != 0 ? bb.getLong(o + bb_pos) : 0L; }
26+
public String code() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; }
27+
public ByteBuffer codeAsByteBuffer() { return __vector_as_bytebuffer(12, 1); }
28+
public ByteBuffer codeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 1); }
4229

4330
public static int createHierarchyItem(FlatBufferBuilder builder,
4431
int level,
4532
int typeOffset,
4633
int nameOffset,
47-
long osmId) {
48-
builder.startTable(4);
34+
long osmId,
35+
int codeOffset) {
36+
builder.startTable(5);
4937
HierarchyItem.addOsmId(builder, osmId);
38+
HierarchyItem.addCode(builder, codeOffset);
5039
HierarchyItem.addName(builder, nameOffset);
5140
HierarchyItem.addType(builder, typeOffset);
5241
HierarchyItem.addLevel(builder, level);
5342
return HierarchyItem.endHierarchyItem(builder);
5443
}
5544

56-
public static void startHierarchyItem(FlatBufferBuilder builder) { builder.startTable(4); }
45+
public static void startHierarchyItem(FlatBufferBuilder builder) { builder.startTable(5); }
5746
public static void addLevel(FlatBufferBuilder builder, int level) { builder.addInt(0, level, 0); }
5847
public static void addType(FlatBufferBuilder builder, int typeOffset) { builder.addOffset(1, typeOffset, 0); }
5948
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(2, nameOffset, 0); }
6049
public static void addOsmId(FlatBufferBuilder builder, long osmId) { builder.addLong(3, osmId, 0L); }
50+
public static void addCode(FlatBufferBuilder builder, int codeOffset) { builder.addOffset(4, codeOffset, 0); }
6151
public static int endHierarchyItem(FlatBufferBuilder builder) {
6252
int o = builder.endTable();
6353
return o;

src/main/java/com/dedicatedcode/paikka/flatbuffers/Name.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* This file is part of paikka.
3-
*
4-
* Paikka is free software: you can redistribute it and/or
5-
* modify it under the terms of the GNU Affero General Public License
6-
* as published by the Free Software Foundation, either version 3 or
7-
* any later version.
8-
*
9-
* Paikka is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied
11-
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Affero General Public License for more details.
13-
* You should have received a copy of the GNU Affero General Public License
14-
* along with Paikka. If not, see <https://www.gnu.org/licenses/>.
15-
*/
16-
171
// automatically generated by the FlatBuffers compiler, do not modify
182

193
package com.dedicatedcode.paikka.flatbuffers;

src/main/java/com/dedicatedcode/paikka/flatbuffers/POI.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* This file is part of paikka.
3-
*
4-
* Paikka is free software: you can redistribute it and/or
5-
* modify it under the terms of the GNU Affero General Public License
6-
* as published by the Free Software Foundation, either version 3 or
7-
* any later version.
8-
*
9-
* Paikka is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied
11-
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Affero General Public License for more details.
13-
* You should have received a copy of the GNU Affero General Public License
14-
* along with Paikka. If not, see <https://www.gnu.org/licenses/>.
15-
*/
16-
171
// automatically generated by the FlatBuffers compiler, do not modify
182

193
package com.dedicatedcode.paikka.flatbuffers;

src/main/java/com/dedicatedcode/paikka/flatbuffers/POIList.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* This file is part of paikka.
3-
*
4-
* Paikka is free software: you can redistribute it and/or
5-
* modify it under the terms of the GNU Affero General Public License
6-
* as published by the Free Software Foundation, either version 3 or
7-
* any later version.
8-
*
9-
* Paikka is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied
11-
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12-
* See the GNU Affero General Public License for more details.
13-
* You should have received a copy of the GNU Affero General Public License
14-
* along with Paikka. If not, see <https://www.gnu.org/licenses/>.
15-
*/
16-
171
// automatically generated by the FlatBuffers compiler, do not modify
182

193
package com.dedicatedcode.paikka.flatbuffers;

0 commit comments

Comments
 (0)