X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fsrc%2Forg%2Fsimantics%2Fdistrict%2Fnetwork%2FModelledCRS.java;h=af0bf4182ee70ddd77d109c364fe9391867cee80;hb=440c2b11fd49be2feb9edd39b931306b824b8aba;hp=23e68f2b273453c7a2636f2331c2bd417028447c;hpb=1bc60c2213f9b3fc7b4d935ba9afda2b767290e5;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network/src/org/simantics/district/network/ModelledCRS.java b/org.simantics.district.network/src/org/simantics/district/network/ModelledCRS.java index 23e68f2b..af0bf418 100644 --- a/org.simantics.district.network/src/org/simantics/district/network/ModelledCRS.java +++ b/org.simantics.district.network/src/org/simantics/district/network/ModelledCRS.java @@ -7,15 +7,15 @@ import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; -import org.simantics.district.network.ontology.DistrictNetworkResource; +import org.simantics.layer0.Layer0; public class ModelledCRS implements CRS { private GeodeticCalculator calculator; public ModelledCRS(ReadGraph graph, Resource type) throws DatabaseException, FactoryException { - String wkt = graph.getRelatedValue2(type, DistrictNetworkResource.getInstance(graph).HasSRTEXT, Bindings.STRING); - CoordinateReferenceSystem crs = org.geotools.referencing.CRS.parseWKT(wkt); + String code = graph.getRelatedValue2(type, Layer0.getInstance(graph).HasLabel, Bindings.STRING); + CoordinateReferenceSystem crs = org.geotools.referencing.CRS.decode(code); this.calculator = new GeodeticCalculator(crs); } @@ -28,12 +28,11 @@ public class ModelledCRS implements CRS { return dist; } - // TODO: these only work with Spherical Mercator public static double xToLongitude(double x) { return x; } - + public static double yToLatitude(double y) { double rad = Math.toRadians(y); double sinh = Math.sinh(rad); @@ -41,7 +40,7 @@ public class ModelledCRS implements CRS { double finald = Math.toDegrees(atan); return finald; } - + public static double longitudeToX(double lon) { return lon; }