Skip to content

Commit

Permalink
add map transform with proj
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaMN committed Sep 26, 2024
1 parent a40be1a commit 6702a24
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"csNet": "10.4.0.0",
"serverNet": "10.5.0.0",
"tmcNet": "10.6.0.0"
}
},
"georeference":"+proj=tmerc +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"
},
"federates": {
"application": true,
Expand Down
21 changes: 21 additions & 0 deletions co-simulation/lib/mosaic-geomath/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.locationtech.proj4j</groupId>
<artifactId>proj4j</artifactId>
</dependency>
<dependency>
<groupId>org.locationtech.proj4j</groupId>
<artifactId>proj4j-epsg</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -33,6 +41,19 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
12 changes: 11 additions & 1 deletion co-simulation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.language>java</sonar.language>
<sonar.language>java</sonar.language>
<!-- JaCoCo Properties -->
<jacoco.version>0.8.8</jacoco.version>
<mosaic.version>22.1-SNAPSHOT</mosaic.version>
Expand Down Expand Up @@ -152,6 +152,16 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.locationtech.proj4j</groupId>
<artifactId>proj4j</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.locationtech.proj4j</groupId>
<artifactId>proj4j-epsg</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<!-- PURPOSE: Logging -->
<groupId>ch.qos.logback</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.eclipse.mosaic.lib.geo.CartesianPoint;
import org.eclipse.mosaic.lib.geo.GeoPoint;

import edu.umd.cs.findbugs.annotations.Nullable;

/**
* Configuration for the Projection of geographic coordinates to cartesian coordinates.
*/
Expand All @@ -32,5 +34,8 @@ public class CProjection {
* The cartesian offset which is considered when transformation from or to geographic coordinates.
*/
public CartesianPoint cartesianOffset;

@Nullable
public String georeference;
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@

package org.eclipse.mosaic.starter;

import org.eclipse.mosaic.lib.geo.MutableGeoPoint;
import org.eclipse.mosaic.lib.geo.UtmPoint;
import org.eclipse.mosaic.lib.geo.UtmZone;
import org.eclipse.mosaic.lib.objects.addressing.IpResolver;
import org.eclipse.mosaic.lib.transform.GeoProjection;
import org.eclipse.mosaic.lib.transform.Proj4Projection;
import org.eclipse.mosaic.lib.transform.UtmGeoCalculator;
import org.eclipse.mosaic.lib.transform.Wgs84Projection;
import org.eclipse.mosaic.lib.util.NameGenerator;
Expand Down Expand Up @@ -255,6 +257,13 @@ private GeoProjection createTransformation(CScenario scenarioConfiguration) {
Validate.notNull(projectionConfig.cartesianOffset,
"Invalid Wgs84UtmTransform configuration: no cartesian offset given");

// Check if georeference is specified
if (scenarioConfiguration.simulation.georeference != null)
{
MutableGeoPoint origin = new MutableGeoPoint(projectionConfig.centerCoordinates.getLongitude(), projectionConfig.centerCoordinates.getLongitude(), projectionConfig.centerCoordinates.getAltitude());
return new Proj4Projection(origin, projectionConfig.cartesianOffset.getX(), projectionConfig.cartesianOffset.getY(), scenarioConfiguration.simulation.georeference);
}

UtmPoint origin = UtmPoint.eastNorth(
UtmZone.from(projectionConfig.centerCoordinates),
-projectionConfig.cartesianOffset.getX(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public static class Simulation {
*/
@SerializedName("network")
public CIpResolver networkConfig = new CIpResolver();

@Nullable
public String georeference;
}

}

0 comments on commit 6702a24

Please sign in to comment.