Skip to content

Commit

Permalink
Merge pull request #50 from pailakka/update-java-deps
Browse files Browse the repository at this point in the history
Updates and cleanup
  • Loading branch information
pailakka authored Dec 31, 2024
2 parents 3f5e656 + bfda748 commit 185189e
Show file tree
Hide file tree
Showing 29 changed files with 380 additions and 20,181 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/dockerimage.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/mtk2garmin-converter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: mtk2garmin-converter docker image

on:
workflow_dispatch:
push:
paths:
- 'mtk2garmin-converter/**'
- '.github/workflows/mtk2garmin-converter.yaml'
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v6
with:
push: true
context: "{{defaultContext}}:mtk2garmin-converter"
tags: teemupel/mtk2garmin-converter:latest
31 changes: 31 additions & 0 deletions .github/workflows/ubuntugis-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ubuntugis-base docker image

on:
workflow_dispatch:
push:
paths:
- 'mapcreator/ubuntugis-base/**'
- '.github/workflows/ubuntugis-base.yaml'
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v6
with:
push: true
context: "{{defaultContext}}:mapcreator/ubuntugis-base"
tags: teemupel/mtk2garmin-ubuntugis-base:latest
2 changes: 1 addition & 1 deletion mapcreator/convert_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ printf -v date '%(%Y%m%d)T' -1

docker compose down -v --remove-orphans

docker pull ghcr.io/osgeo/gdal:ubuntu-full-3.6.3
docker pull ghcr.io/osgeo/gdal:ubuntu-full-3.10.0
docker build --tag teemupel/mtk2garmin-ubuntugis-base -f ./ubuntugis-base/Dockerfile ./ubuntugis-base
docker push teemupel/mtk2garmin-ubuntugis-base

Expand Down
1 change: 0 additions & 1 deletion mapcreator/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3'
services:
mml-client:
image: teemupel/mml-muutostietopalvelu-client
Expand Down
6 changes: 3 additions & 3 deletions mapcreator/ubuntugis-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ghcr.io/osgeo/gdal:ubuntu-full-3.6.3
FROM ghcr.io/osgeo/gdal:ubuntu-full-3.10.0

RUN apt update && apt install -y curl

RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
apt update && \
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash && \
. /root/.bashrc && nvm install 22 && apt update && apt upgrade -y && \
apt install -y git p7zip-full nodejs default-jdk maven&& \
npm install -g svgo &&\
apt clean
37 changes: 23 additions & 14 deletions mtk2garmin-converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.11</maven.compiler.source>
<maven.compiler.target>1.11</maven.compiler.target>
<maven.compiler.source>1.21</maven.compiler.source>
<maven.compiler.target>1.21</maven.compiler.target>
</properties>
<repositories>
<repository>
Expand All @@ -33,30 +33,39 @@
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.4.1</version>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>org.gdal</groupId>
<artifactId>gdal</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.15.6</version>
<version>3.10.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/it.unimi.dsi/fastutil -->
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.5.4</version>
<version>8.5.15</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
<version>2.18.0</version>
</dependency>
<dependency>
<groupId>org.openstreetmap.pbf</groupId>
<artifactId>osmpbf</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-pbf</artifactId>
<version>0.49.2</version>
</dependency>
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-core</artifactId>
<version>0.49.2</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -86,8 +95,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.stream.Stream;

class CachedAdditionalDataSources {
private Logger logger = Logger.getLogger(CachedAdditionalDataSources.class.getName());
private final Logger logger = Logger.getLogger(CachedAdditionalDataSources.class.getName());
private final Driver memoryd;

private final DataSource syvyyskayrat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.util.concurrent.atomic.AtomicLong;

class FeatureIDProvider {
private AtomicLong nodeIDCounter = new AtomicLong(50000000000L);
private AtomicLong wayIDCounter = new AtomicLong(50000000000L);
private AtomicLong relationIDCounter = new AtomicLong(50000000000L);
private final AtomicLong nodeIDCounter = new AtomicLong(50000000000L);
private final AtomicLong wayIDCounter = new AtomicLong(50000000000L);
private final AtomicLong relationIDCounter = new AtomicLong(50000000000L);

long getNodeID() {
return nodeIDCounter.getAndIncrement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.ArrayList;

class GeomHandlerResult {
final ArrayList<Node> nodes = new ArrayList<>();
final ArrayList<Way> ways = new ArrayList<>();
final ArrayList<Relation> relations = new ArrayList<>();
final ArrayList<LightNode> lightNodes = new ArrayList<>();
final ArrayList<LightWay> lightWays = new ArrayList<>();
final ArrayList<LightRelation> lightRelations = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
package org.hylly.mtk2garmin;

import org.gdal.ogr.GeomTransformer;
import org.gdal.osr.CoordinateTransformation;
import org.gdal.osr.SpatialReference;
import org.gdal.osr.osr;

import java.util.HashMap;
import java.util.Map;

import static org.gdal.osr.osrConstants.OAMS_TRADITIONAL_GIS_ORDER;

class GeomUtils {
private final double COORD_DELTA_X = 62000.0 - 6e3;
private final double COORD_DELTA_Y = 6594000.0;

private final SpatialReference wgs84ref = new SpatialReference();

private Map<String, CoordinateTransformation> coordinateTransformationCache = new HashMap<>();
private final SpatialReference sphericmercref = new SpatialReference();
public final GeomTransformer spherictowgs;

GeomUtils() {
this.wgs84ref.SetWellKnownGeogCS("WGS84");
this.wgs84ref.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
SpatialReference wgs84ref = new SpatialReference();
wgs84ref.SetWellKnownGeogCS("WGS84");
wgs84ref.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

this.sphericmercref.ImportFromProj4("+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs");
this.sphericmercref.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

this.spherictowgs = new GeomTransformer(new CoordinateTransformation(sphericmercref, wgs84ref));

}

Expand All @@ -38,21 +40,6 @@ int xy2grid(double x, double y) {
Math.min(ext1[2], ext2[2]), Math.max(ext1[3], ext2[3])};
}

CoordinateTransformation getTransformationToWGS84(String proj4str) {
if (coordinateTransformationCache.containsKey(proj4str)) {
return coordinateTransformationCache.get(proj4str);
}

SpatialReference from = new SpatialReference();
from.ImportFromProj4(proj4str);
from.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

CoordinateTransformation transform = new CoordinateTransformation(from, wgs84ref);

coordinateTransformationCache.put(proj4str, transform);
return transform;
}

long hashCoords(double x, double y) {
double COORD_ACC = 2;
return calcHash((long) ((int) (x - COORD_DELTA_X) * COORD_ACC), (long) ((int) (y - COORD_DELTA_Y) * COORD_ACC));
Expand All @@ -72,4 +59,14 @@ boolean pointInside(double[] searchBBox, double[] search) {
return search[0] >= searchBBox[0] && search[0] <= searchBBox[1] &&
search[1] >= searchBBox[2] && search[1] <= searchBBox[3];
}

public GeomTransformer getTransformationToSphereMercator(String proj4str) {
SpatialReference from = new SpatialReference();
from.ImportFromProj4(proj4str);
from.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

CoordinateTransformation transform = new CoordinateTransformation(from, sphericmercref);

return new GeomTransformer(transform);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.hylly.mtk2garmin;

import it.unimi.dsi.fastutil.shorts.Short2ShortOpenHashMap;
import org.openstreetmap.osmosis.core.container.v0_6.NodeContainer;
import org.openstreetmap.osmosis.core.domain.v0_6.*;

import java.util.Date;

class LightNode {
final long id;
final double lon;
final double lat;
final long hash;
Short2ShortOpenHashMap nodeTags;
boolean wayPart;

LightNode(long id, long hash, double lon, double lat, boolean wayPart) {
this.id = id;
this.hash = hash;
this.lon = lon;
this.lat = lat;
this.wayPart = wayPart;
}

void addTag(short key, short value) {
if (nodeTags == null) {
nodeTags = new Short2ShortOpenHashMap();
}

nodeTags.put(key, value);
}

long getId() {
return id;
}

boolean isWayPart() {
return wayPart;
}

long getHash() {
return hash;
}

public NodeContainer toOsmiumEntity(StringTable stringTable, Date timestamp) {
CommonEntityData ced = new CommonEntityData(this.id, -1, timestamp, OsmUser.NONE, 0);
if (nodeTags != null) {
nodeTags.short2ShortEntrySet().forEach(t -> ced.getTags().add(new Tag(stringTable.getStringById(t.getShortKey()), stringTable.getStringById(t.getShortValue()))));
}

return new NodeContainer(new Node(ced, this.lat, this.lon));
}

public WayNode toOsmiumWayNode() {
return new WayNode(this.id, this.lat, this.lon);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.hylly.mtk2garmin;

import it.unimi.dsi.fastutil.shorts.Short2ShortRBTreeMap;
import org.openstreetmap.osmosis.core.container.v0_6.RelationContainer;
import org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData;
import org.openstreetmap.osmosis.core.domain.v0_6.OsmUser;
import org.openstreetmap.osmosis.core.domain.v0_6.Relation;
import org.openstreetmap.osmosis.core.domain.v0_6.Tag;

import java.util.ArrayList;
import java.util.Date;

class LightRelation {
final Short2ShortRBTreeMap tags = new Short2ShortRBTreeMap();
final ArrayList<LightRelationMember> members = new ArrayList<>();
long id;

long getId() {
return id;
}

void setId(long id) {
this.id = id;
}

public RelationContainer toOsmiumEntity(StringTable stringTable, Date timestamp) {
CommonEntityData ced = new CommonEntityData(this.id, -1, timestamp, OsmUser.NONE, 0);
tags.short2ShortEntrySet().forEach(t -> ced.getTags().add(new Tag(stringTable.getStringById(t.getShortKey()), stringTable.getStringById(t.getShortValue()))));

Relation r = new Relation(ced, this.members.stream().map(LightRelationMember::toOsmiumEntity).toList());

return new RelationContainer(r);

}
}
Loading

0 comments on commit 185189e

Please sign in to comment.