TomasJohansson / crsTransformations

Coordinate Reference System Transformations. This is a "JVM library" implemented with Kotlin, but usable from e.g. Java/Kotlin/Scala/Groovy/Jython/JRuby (see the sample code). Most of the test code is written with Java, and the third-part libraries used from Kotlin are also implemented with Java.
MIT License
3 stars 2 forks source link

Only Swedish CRS is working #2

Open robertoricotti opened 1 year ago

robertoricotti commented 1 year ago

Great repo, but i don't understand how let it wotks with all EPSG, only 3006, the one in example, is working for me, any other is failing the Transformation. Where i'm making wrong? I just copied example code and trying to change values of Lat Lon and EPSG.

TomasJohansson commented 1 year ago

Can you please show the code you tried to use? How does it fail for you, I mean do you get an incorrect result or is some exception thrown? Are you using the latest published version 2.0.0 or are you using the latest commited source code in this github repository?

robertoricotti commented 1 year ago

gradle:

//crs implementation 'com.programmerare.crs-transformation:crs-transformation-constants:10.027' // only one class with constants // The above "crs-transformation-constants" is a Java library def crsTransformationAdapterVersion = "2.0.0" implementation "com.programmerare.crs-transformation:crs-transformation-adapter-core:$crsTransformationAdapterVersion" implementation "com.programmerare.crs-transformation:crs-transformation-adapter-impl-proj4jlocationtech:$crsTransformationAdapterVersion" implementation "com.programmerare.crs-transformation:crs-transformation-adapter-impl-proj4j:$crsTransformationAdapterVersion" implementation "com.programmerare.crs-transformation:crs-transformation-adapter-impl-orbisgis:$crsTransformationAdapterVersion" implementation "com.programmerare.crs-transformation:crs-transformation-adapter-impl-nga:$crsTransformationAdapterVersion" implementation "com.programmerare.crs-transformation:crs-transformation-adapter-impl-goober:$crsTransformationAdapterVersion" // only swedish CRS implementation "com.programmerare.crs-transformation:crs-transformation-adapter-impl-geotools:$crsTransformationAdapterVersion" // you should also include the above geotools (repo.osgeo.org) repository

code in activity that is working:

final int epsgWgs84 = 4326; final int epsgSweRef = 3006; CrsCoordinate centralStockholmWgs84 = CrsCoordinateFactory.latLon(43.78147, 11.21845, epsgWgs84); CrsTransformationAdapter crsTransformationAdapter = CrsTransformationAdapterCompositeFactory.createCrsTransformationMedian(); CrsTransformationResult centralStockholmResultSweRef = crsTransformationAdapter.transform(centralStockholmWgs84, epsgSweRef); if(centralStockholmResultSweRef.isSuccess()) { Log.d("OutTest", String.valueOf(centralStockholmResultSweRef.getOutputCoordinate())); //out=Coordinate(xEastingLongitude=195697.355, yNorthingLatitude=4854555.05) }else{ Log.d("OutTest", "Error Transform"); }

code in activity is not working:

final int epsgWgs84 = 4326; final int epsgSweRef = 3064; CrsCoordinate centralStockholmWgs84 = CrsCoordinateFactory.latLon(43.78147, 11.21845, epsgWgs84); CrsTransformationAdapter crsTransformationAdapter = CrsTransformationAdapterCompositeFactory.createCrsTransformationMedian(); CrsTransformationResult centralStockholmResultSweRef = crsTransformationAdapter.transform(centralStockholmWgs84, epsgSweRef); if(centralStockholmResultSweRef.isSuccess()) { Log.d("OutTest", String.valueOf(centralStockholmResultSweRef.getOutputCoordinate())); //out=Coordinate(xEastingLongitude=195697.355, yNorthingLatitude=4854555.05) }else{ Log.d("OutTest", "Error Transform"); //out=OutTest: Error Transform }

second example print "Error Transform" in Log Page


Da: Tomas Johansson @.> Inviato: mercoledì 4 gennaio 2023 14:18 A: TomasJohansson/crsTransformations @.> Cc: robertoricotti @.>; Author @.> Oggetto: Re: [TomasJohansson/crsTransformations] Only Swedish CRS is working (Issue #2)

Can you please show the code you tried to use? How does it fail for you, I mean do you get an incorrect result or is some exception thrown? Are you using the latest published version 2.0.0https://github.com/TomasJohansson/crsTransformations/releases/tag/v2.0.0 or are you using the latest commited source code in this github repository?

— Reply to this email directly, view it on GitHubhttps://github.com/TomasJohansson/crsTransformations/issues/2#issuecomment-1370919859, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVE4PKIR24DMLISEXEJOTW3WQV2BNANCNFSM6AAAAAATQGUV2Y. You are receiving this because you authored the thread.Message ID: @.***>

TomasJohansson commented 1 year ago

It worked fine when I was running it from a console application, but I noticed the word you used "activity" and code "Log.d" so I see that you are using Android. Therefore I generated a new Android project and tried it from Android. I got a compilation error related to geotools ("Task :app:mergeDebugJavaResource FAILED") but it compiled when I disabled geotools. Then the transformations worked as expected (for the others than the disabled geotools of course). I am attaching the project in a zip file so you can try it. Let me know if it worked. crstransformation_issue_2_android_java.zip

robertoricotti commented 1 year ago

yes, your code seems to be ok without GeoTools. Now i have to understand why is not working for me even if Geotools is not implemented. Is it enough to //comment geotools implementation and re import project? no other action are required?

robertoricotti commented 1 year ago

Last update,is working also in my project now, without geotools. I let you know if i find a way to implement geotools too. Great and thank you for you support.

TomasJohansson commented 1 year ago

You're welcome. Nice to hear that it works for you now, and yes please let me know if you figure out how to use the geotools implementation from Android, thank you.

robertoricotti commented 1 year ago

Well, trying to success in Geotools implementation in Android i found this problem : " FATAL EXCEPTION: main Process: com.example.stx_piler, PID: 14785 java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/RenderingHints; at org.geotools.referencing.CRS.decode(CRS.java:428)" As i undestood GeoTools need 'java.awt' dependencies, that are not available on android,only desktop version. This could be the problem and why the other 5 libraries are working fine, but GeoTools. I'm afraid that only GeoTools could give us the solution, with a Android library release... Anyway i'll continue to looks for a solution and will back to you in case of any news. Please let me know if something will changes about this issue. proj4j output is enough for me right now, and it seems to works perfectly.

TomasJohansson commented 1 year ago

Thank you for bringing my attention to the awt problem. I have now updated the github page with some info about the GeoTools implementation not working with Android.

robertoricotti commented 1 year ago

Is there a way to know the unit (m,USfeet,deg and so on) of every transformation result?

TomasJohansson commented 1 year ago

No. Possibly can be added in some future version, but currently that feature is not included.

robertoricotti commented 1 year ago

Ok, I'll check periodically for upgrades,and will be great to find this feature in a next release

robertoricotti commented 1 year ago

Hi Tomas,me again. I see last EPSG constant update is 10.027, in 2021. Epsg.io is arrived now at 10.082. is there a way to let me update EPSGNumber class or generate a new one by myself? Thanks in advance.

robertoricotti commented 1 year ago

Found, browsing code there is perfectly explained how to do it.

robertoricotti commented 5 months ago

Is it possible to use a gtx file for geode apply to the Z?

TomasJohansson commented 5 months ago

Sorry, but the answer is no.

JigneshPiZone commented 1 month ago

@TomasJohansson i have use your demo android app but it show different result than https://epsg.io/, am i missing something?

        crs_transform(32642, 21.7680412, 72.14742);
        crs_transform(32643, 21.7680412, 72.14742);
TomasJohansson commented 1 month ago

@TomasJohansson i have use your demo android app but it show different result than https://epsg.io/, am i missing something?

        crs_transform(32642, 21.7680412, 72.14742);
        crs_transform(32643, 21.7680412, 72.14742);

I got the following results, with all five (i.e. Proj4j, NGA, Orbis ...) adapter implementations, when trying with my above android app:

Transforming to EPSG:32642 (UTM zone 42N) x 825524.534 y 2410470.802

Transforming to EPSG:32643 (UTM zone 43N) x 204988.885 y 2409877.751

You get the same results from these two websites: https://mygeodata.cloud/cs2cs/ https://tool-online.com/en/coordinate-converter.php and also from the website you mentioned i.e. https://epsg.io

Two screenshots below from epsg.io (and their URL's) : https://epsg.io/transform#s_srs=4326&t_srs=32642&x=72.1474200&y=21.7680411 epsg_io_32642

https://epsg.io/transform#s_srs=4326&t_srs=32643&x=72.1474200&y=21.7680411 epsg_io_32643