Skip to content

Commit 9db289f

Browse files
authored
Merge pull request #41 from govlt/setup-label-points
setup label points
2 parents 88cc6b6 + b8e4d1e commit 9db289f

File tree

8 files changed

+95
-1
lines changed

8 files changed

+95
-1
lines changed

.github/workflows/publish-pmtiles.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ jobs:
9595
timeout-minutes: 20
9696
concurrency: publish-release
9797
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
98+
outputs:
99+
version: ${{ steps.version.outputs.version || '' }}
98100
needs:
99101
- generate-geopackage
100102
- generate-pmtiles
@@ -156,6 +158,7 @@ jobs:
156158
needs:
157159
- generate-geopackage
158160
- generate-pmtiles
161+
- publish-release
159162
permissions:
160163
contents: read
161164
packages: write
@@ -175,7 +178,7 @@ jobs:
175178
docker-image: ghcr.io/govlt/national-boundaries-vector
176179
docker-context: vector/docker/static
177180
file: vector/docker/static/Dockerfile
178-
environment: ${{ startsWith(github.ref, 'refs/tags/') && 'stable' || 'preview' }}
181+
environment: ${{ (startsWith(github.ref, 'refs/tags/') || needs.publish-release.outputs.version) && 'stable' || 'preview' }}
179182
no-cache: true
180183
push: true
181184
cache-from: ''

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repositories {
1414

1515
dependencies {
1616
implementation("com.onthegomap.planetiler:planetiler-core:0.8.2")
17+
implementation("org.geotools:gt-process-geometry:31.2")
1718

1819
testImplementation(platform("org.junit:junit-bom:5.10.0"))
1920
testImplementation("org.junit.jupiter:junit-jupiter")

src/main/java/lt/startupgov/boundaries/constants/Layers.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
public class Layers {
44
public static final String COUNTIES = "counties";
5+
public static final String COUNTIES_LABEL = "counties_label";
6+
57
public static final String MUNICIPALITIES = "municipalities";
8+
public static final String MUNICIPALITIES_LABEL = "municipalities_label";
9+
610
public static final String ELDERSHIPS = "elderships";
11+
public static final String ELDERSHIPS_LABEL = "elderships_label";
12+
713
public static final String RESIDENTIAL_AREAS = "residential_areas";
14+
public static final String RESIDENTIAL_AREAS_LABEL = "residential_areas_label";
15+
816
public static final String STREETS = "streets";
17+
918
public static final String PARCELS = "parcels";
19+
public static final String PARCELS_LABEL = "parcels_label";
1020

1121
private Layers() {
1222
}

src/main/java/lt/startupgov/boundaries/layers/Counties.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package lt.startupgov.boundaries.layers;
22

33
import com.onthegomap.planetiler.FeatureCollector;
4+
import com.onthegomap.planetiler.geo.GeometryException;
45
import com.onthegomap.planetiler.reader.SourceFeature;
56
import lt.startupgov.boundaries.constants.Layers;
67
import lt.startupgov.boundaries.constants.Source;
8+
import org.geotools.process.geometry.GeometryFunctions;
79

810
public class Counties implements Layer {
911

@@ -19,6 +21,20 @@ public void processFeature(SourceFeature sf, FeatureCollector features) {
1921
.setAttr("feature_id", featureId)
2022
.setAttr("name", sf.getTag("name"))
2123
.setAttr("code", sf.getTag("code"));
24+
25+
try {
26+
var pointGeom = GeometryFunctions.interiorPoint(sf.polygon());
27+
28+
features.geometry(Layers.COUNTIES_LABEL, pointGeom)
29+
.setBufferPixels(4)
30+
.setMinPixelSizeAtAllZooms(0)
31+
.setId(featureId)
32+
.setAttr("feature_id", featureId)
33+
.setAttr("code", sf.getTag("code"))
34+
.setAttr("name", sf.getTag("name"));
35+
} catch (GeometryException e) {
36+
throw new RuntimeException(e);
37+
}
2238
}
2339
}
2440
}

src/main/java/lt/startupgov/boundaries/layers/Elderships.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package lt.startupgov.boundaries.layers;
22

33
import com.onthegomap.planetiler.FeatureCollector;
4+
import com.onthegomap.planetiler.geo.GeometryException;
45
import com.onthegomap.planetiler.reader.SourceFeature;
56
import lt.startupgov.boundaries.constants.Layers;
67
import lt.startupgov.boundaries.constants.Source;
8+
import org.geotools.process.geometry.GeometryFunctions;
79

810
public class Elderships implements Layer {
911

@@ -20,6 +22,20 @@ public void processFeature(SourceFeature sf, FeatureCollector features) {
2022
.setAttr("name", sf.getTag("name"))
2123
.setAttr("code", sf.getTag("code"))
2224
.setAttr("municipality_code", sf.getTag("municipality_code"));
25+
26+
try {
27+
var pointGeom = GeometryFunctions.interiorPoint(sf.polygon());
28+
29+
features.geometry(Layers.ELDERSHIPS_LABEL, pointGeom)
30+
.setBufferPixels(4)
31+
.setMinPixelSizeAtAllZooms(0)
32+
.setId(featureId)
33+
.setAttr("feature_id", featureId)
34+
.setAttr("code", sf.getTag("code"))
35+
.setAttr("name", sf.getTag("name"));
36+
} catch (GeometryException e) {
37+
throw new RuntimeException(e);
38+
}
2339
}
2440
}
2541
}

src/main/java/lt/startupgov/boundaries/layers/Municipalities.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package lt.startupgov.boundaries.layers;
22

33
import com.onthegomap.planetiler.FeatureCollector;
4+
import com.onthegomap.planetiler.geo.GeometryException;
45
import com.onthegomap.planetiler.reader.SourceFeature;
56
import lt.startupgov.boundaries.constants.Layers;
67
import lt.startupgov.boundaries.constants.Source;
8+
import org.geotools.process.geometry.GeometryFunctions;
79

810
public class Municipalities implements Layer {
911

@@ -20,6 +22,20 @@ public void processFeature(SourceFeature sf, FeatureCollector features) {
2022
.setAttr("code", sf.getTag("code"))
2123
.setAttr("county_code", sf.getTag("county_code"))
2224
.setAttr("name", sf.getTag("name"));
25+
26+
try {
27+
var pointGeom = GeometryFunctions.interiorPoint(sf.polygon());
28+
29+
features.geometry(Layers.MUNICIPALITIES_LABEL, pointGeom)
30+
.setBufferPixels(4)
31+
.setMinPixelSizeAtAllZooms(0)
32+
.setId(featureId)
33+
.setAttr("feature_id", featureId)
34+
.setAttr("code", sf.getTag("code"))
35+
.setAttr("name", sf.getTag("name"));
36+
} catch (GeometryException e) {
37+
throw new RuntimeException(e);
38+
}
2339
}
2440
}
2541
}

src/main/java/lt/startupgov/boundaries/layers/Parcels.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package lt.startupgov.boundaries.layers;
22

33
import com.onthegomap.planetiler.FeatureCollector;
4+
import com.onthegomap.planetiler.geo.GeometryException;
45
import com.onthegomap.planetiler.reader.SourceFeature;
56
import lt.startupgov.boundaries.constants.Layers;
67
import lt.startupgov.boundaries.constants.Source;
8+
import org.geotools.process.geometry.GeometryFunctions;
79

810
public class Parcels implements Layer {
911

@@ -27,6 +29,20 @@ public void processFeature(SourceFeature sf, FeatureCollector features) {
2729
.setAttr("area_ha", sf.getString("area_ha"))
2830
.setAttr("municipality_code", municipality_code != 0 ? municipality_code : null)
2931
.setAttr("eldership_code", eldership_code != 0 ? eldership_code : null);
32+
33+
try {
34+
var pointGeom = GeometryFunctions.interiorPoint(sf.polygon());
35+
36+
features.geometry(Layers.PARCELS_LABEL, pointGeom)
37+
.setBufferPixels(4)
38+
.setMinPixelSizeAtAllZooms(0)
39+
.setMinZoom(14)
40+
.setAttr("unique_number", sf.getLong("unique_number"))
41+
.setAttr("cadastral_number", sf.getString("cadastral_number"))
42+
.setAttr("area_ha", sf.getString("area_ha"));
43+
} catch (GeometryException e) {
44+
throw new RuntimeException(e);
45+
}
3046
}
3147
}
3248
}

src/main/java/lt/startupgov/boundaries/layers/ResidentialAreas.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package lt.startupgov.boundaries.layers;
22

33
import com.onthegomap.planetiler.FeatureCollector;
4+
import com.onthegomap.planetiler.geo.GeometryException;
45
import com.onthegomap.planetiler.reader.SourceFeature;
56
import lt.startupgov.boundaries.constants.Layers;
67
import lt.startupgov.boundaries.constants.Source;
8+
import org.geotools.process.geometry.GeometryFunctions;
79

810
public class ResidentialAreas implements Layer {
911

@@ -21,6 +23,20 @@ public void processFeature(SourceFeature sf, FeatureCollector features) {
2123
.setAttr("name", sf.getTag("name"))
2224
.setAttr("code", sf.getTag("code"))
2325
.setAttr("municipality_code", sf.getTag("municipality_code"));
26+
27+
try {
28+
var pointGeom = GeometryFunctions.interiorPoint(sf.polygon());
29+
30+
features.geometry(Layers.RESIDENTIAL_AREAS_LABEL, pointGeom)
31+
.setBufferPixels(4)
32+
.setMinPixelSizeAtAllZooms(0)
33+
.setId(featureId)
34+
.setAttr("feature_id", featureId)
35+
.setAttr("code", sf.getTag("code"))
36+
.setAttr("name", sf.getTag("name"));
37+
} catch (GeometryException e) {
38+
throw new RuntimeException(e);
39+
}
2440
}
2541
}
2642
}

0 commit comments

Comments
 (0)