You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@sis.apache.org by Michael Arneson <mi...@geotoolkit.net> on 2021/04/09 02:38:01 UTC
Crerating CoordinateTransformation from WKT
I am trying to create a CoordinateOperation from 3 different WKT strings
using the following code:
WKTFormat wf = new WKTFormat(null, null);
CoordinateOperation cp = (CoordinateOperation)
wf.parseObject(rfkWkt);
When attempting to create a CoordinateOperation from the WKT, the following
error is thrown:
*org.apache.sis.io.wkt.UnparsableObjectException: Keyword “GEOGCRS” is
unknown.*
* at
org.apache.sis.io.wkt.Element.missingOrUnknownComponent(Element.java:466)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseCoordinateReferenceSystem(GeodeticObjectParser.java:336)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseCoordinateReferenceSystem(GeodeticObjectParser.java:358)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseOperation(GeodeticObjectParser.java:2255)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseObject(GeodeticObjectParser.java:306)*
* at
org.apache.sis.io.wkt.AbstractParser.parseObject(AbstractParser.java:283)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseObject(GeodeticObjectParser.java:244)*
* at org.apache.sis.io.wkt.WKTFormat.parse(WKTFormat.java:753)*
I have attached a class that has the 3 WKT strings and the code I was using
to create CoordinatesOperation objects from these WKT strings.
Are the WKT strings I am trying to convert valid?
If they are not valid, do you know how I could modify the WKT string so
that they would be valid?
Thanks,
--
*Michael Arneson*
*Software Engineer*
*Office:* +1 (713) 975-7434
michael.arneson@int.com
*INT *| *Empowering Visualization*
Re: Crerating CoordinateTransformation from WKT
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Michael
Yes this is a bug is SIS. Actually the WKT formatting is okay, the bug
is in the WKT parser. It should not be necessary to specify the
“tgt_semi_major” and similar parameters. This parameter should be
inferred from the ellipsoid.
Would you like to fill a JIRA issue on
https://issues.apache.org/jira/browse/SIS ? Just putting the content of
your email in the description would be enough. Otherwise I can do it if
you prefer.
Regards,
Martin
Le 25/04/2021 à 03:33, Michael Arneson a écrit :
> Hi Martin,
> Thanks for your help.
> When validating the previously mentioned transform, we encountered
> what looks to be a bug.
> We are unable to create a /CoordinateOperation/ from the WKT that
> comes from an existing /CoordinateOperation/ object.
> The code below can be used to test this:
>
> / CoordinateOperationAuthorityFactory opFactory =
> (CoordinateOperationAuthorityFactory) CRS.getAuthorityFactory("EPSG");
> CoordinateOperation opFromCode =
> opFactory.createCoordinateOperation("5630");
> String operationWKT = opFromCode.toWKT();
> WKTFormat wf = new WKTFormat(null, null);
> CoordinateOperation opFromWKT = (CoordinateOperation)
> wf.parseObject(operationWKT);/
>
> When trying to execute this code the following error is returned:
>
> /org.apache.sis.io.wkt.UnparsableObjectException: Error in
> “COORDINATEOPERATION”: Missing value for “tgt_semi_major” parameter./
>
> /at org.apache.sis.io.wkt.Element.parseFailed(Element.java:383)/
>
> /at
> org.apache.sis.io.wkt.GeodeticObjectParser.parseOperation(GeodeticObjectParser.java:2279)/
>
> /at
> org.apache.sis.io.wkt.GeodeticObjectParser.parseObject(GeodeticObjectParser.java:306)/
>
> /at
> org.apache.sis.io.wkt.AbstractParser.parseObject(AbstractParser.java:283)/
>
> /at
> org.apache.sis.io.wkt.GeodeticObjectParser.parseObject(GeodeticObjectParser.java:244)/
>
> /at org.apache.sis.io.wkt.WKTFormat.parse(WKTFormat.java:753)/
>
> /at
> org.apache.sis.io.CompoundFormat.parseObject(CompoundFormat.java:317)/
>
>
> Is this an issue that the WKT returned from
> CoordinateOperation/.toWKT() /is not returning all the necessary
> parameters or that WKTFormat/.parseObject(String) /is expecting
> parameters that are not needed.
> Thanks
> Michael
Re: Crerating CoordinateTransformation from WKT
Posted by Michael Arneson <mi...@geotoolkit.net>.
Hi Martin,
Thanks for your help.
When validating the previously mentioned transform, we encountered what
looks to be a bug.
We are unable to create a *CoordinateOperation* from the WKT that comes
from an existing *CoordinateOperation* object.
The code below can be used to test this:
* CoordinateOperationAuthorityFactory opFactory =
(CoordinateOperationAuthorityFactory) CRS.getAuthorityFactory("EPSG");
CoordinateOperation opFromCode =
opFactory.createCoordinateOperation("5630"); String operationWKT =
opFromCode.toWKT(); WKTFormat wf = new WKTFormat(null, null);
CoordinateOperation opFromWKT = (CoordinateOperation)
wf.parseObject(operationWKT);*
When trying to execute this code the following error is returned:
*org.apache.sis.io.wkt.UnparsableObjectException: Error in
“COORDINATEOPERATION”: Missing value for “tgt_semi_major” parameter.*
* at org.apache.sis.io.wkt.Element.parseFailed(Element.java:383)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseOperation(GeodeticObjectParser.java:2279)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseObject(GeodeticObjectParser.java:306)*
* at
org.apache.sis.io.wkt.AbstractParser.parseObject(AbstractParser.java:283)*
* at
org.apache.sis.io.wkt.GeodeticObjectParser.parseObject(GeodeticObjectParser.java:244)*
* at org.apache.sis.io.wkt.WKTFormat.parse(WKTFormat.java:753)*
* at org.apache.sis.io.CompoundFormat.parseObject(CompoundFormat.java:317)*
Is this an issue that the WKT returned from CoordinateOperation*.toWKT() *is
not returning all the necessary parameters or that
WKTFormat*.parseObject(String)
*is expecting parameters that are not needed.
Thanks
Michael
On Thu, Apr 15, 2021 at 8:05 AM Martin Desruisseaux <
martin.desruisseaux@geomatys.com> wrote:
> Hello Michael
>
> Le 15/04/2021 à 02:18, Michael Arneson a écrit :
>
> I was not able to create the transformations by adding the parameters
> "src_semi_major", "dst_semi_major", however, I was able to create the
> transformation when I added in the parameters "tgt_semi_major", "
> tgt_semi_minor".
>
> It is possible that "src_semi_major" and "src_semi_minor" are required as
> well. But if it works without them it is worth to try.
>
> Could you take a look at the attached file and let me know if the
> modifications I have made to the WKTs are correct?
>
> It seems close. But in the following parameters:
>
> PARAMETER["tgt_semi_major",6378137.0],
> PARAMETER["tgt_semi_minor",298.257223563]
>
> the 298.257… value is the inverse flattening factor. Value for semi-minor
> axis should rather be 6356752.314245179 (computed from semi-major and
> inverse flattening factor).
>
> Martin
>
>
>
--
*Michael Arneson*
*Software Engineer*
*Office:* +1 (713) 975-7434
michael.arneson@int.com
*INT *| *Empowering Visualization*
Re: Crerating CoordinateTransformation from WKT
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Michael
Le 15/04/2021 à 02:18, Michael Arneson a écrit :
> I was not able to create the transformations by adding the parameters
> "src_semi_major", "dst_semi_major", however, I was able to create the
> transformation when I added in the parameters "tgt_semi_major",
> "tgt_semi_minor".
>
It is possible that "src_semi_major" and "src_semi_minor" are required
as well. But if it works without them it is worth to try.
> Could you take a look at the attached file and let me know if the
> modifications I have made to the WKTs are correct?
>
It seems close. But in the following parameters:
PARAMETER["tgt_semi_major",6378137.0],
PARAMETER["tgt_semi_minor",298.257223563]
the 298.257… value is the inverse flattening factor. Value for
semi-minor axis should rather be 6356752.314245179 (computed from
semi-major and inverse flattening factor).
Martin
Re: Crerating CoordinateTransformation from WKT
Posted by Michael Arneson <mi...@geotoolkit.net>.
Hi Martin,
I was not able to create the transformations by adding the parameters
"src_semi_major", "dst_semi_major", however, I was able to create the
transformation when I added in the parameters "tgt_semi_major", "
tgt_semi_minor".
Could you take a look at the attached file and let me know if the
modifications I have made to the WKTs are correct?
Thanks,
Michael
On Fri, Apr 9, 2021 at 11:20 AM Martin Desruisseaux <
martin.desruisseaux@geomatys.com> wrote:
> Correction: what I wrote below is wrong. The expected parameters should be
> "src_semi_major", "dst_semi_major", etc. or something like that (I did
> not verified). I.e. source and target ellipsoids are specified separately,
> so there is no confusion. Why SIS does not pickup those parameters
> automatically in the WKT you provided needs to be investigated, but in the
> meantime specifying the values explicitly should work.
>
> Martin
>
> Le 09/04/2021 à 13:45, Martin Desruisseaux a écrit :
>
> In my test I saw that the code complains about missing semi-major and
> semi-minor axis length, but it should be possible to fix by adding the
> following lines together with other parameters. I would need to check the
> code again, but it may be because SIS does not know which ellipsoid to use
> between "Clarke 1880" and "WGS 84".
>
> PARAMETER["semi_major", put value here],
> PARAMETER["semi_minor", put value here],
>
>
>
--
*Michael Arneson*
*Software Engineer*
*Office:* +1 (713) 975-7434
michael.arneson@int.com
*INT *| *Empowering Visualization*
Re: Crerating CoordinateTransformation from WKT
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Correction: what I wrote below is wrong. The expected parameters should
be "src_semi_major", "dst_semi_major", etc. or something like that (I
did not verified). I.e. source and target ellipsoids are specified
separately, so there is no confusion. Why SIS does not pickup those
parameters automatically in the WKT you provided needs to be
investigated, but in the meantime specifying the values explicitly
should work.
Martin
Le 09/04/2021 à 13:45, Martin Desruisseaux a écrit :
> In my test I saw that the code complains about missing semi-major and
> semi-minor axis length, but it should be possible to fix by adding the
> following lines together with other parameters. I would need to check
> the code again, but it may be because SIS does not know which
> ellipsoid to use between "Clarke 1880" and "WGS 84".
>
> PARAMETER["semi_major", put value here],
> PARAMETER["semi_minor", put value here],
>
Re: Crerating CoordinateTransformation from WKT
Posted by Martin Desruisseaux <ma...@geomatys.com>.
Hello Michael
The WKT is valid, but it conforms the ISO 19162:2019. Apache SIS
implements ISO 19162:2015; we have not yet upgraded to the 2019
revision. This is something we really want to do, hopefully this year.
But this is a task that need to be done together with an upgrade to ISO
19111:2019 and to version 10 of EPSG database.
In the meantime, the WKT in the first method of the test case you
provided can be downgraded to ISO 19162:2015 as below:
* Rename GEOGCRS as GEODCRS ("G" changed to "D").
* Rename ENSEMBLE["World Geodetic System 1984 ensemble", …] (8 lines)
by DATUM["World Geodetic System 1984"].
In theory it should be sufficient. In my test I saw that the code
complains about missing semi-major and semi-minor axis length, but it
should be possible to fix by adding the following lines together with
other parameters. I would need to check the code again, but it may be
because SIS does not know which ellipsoid to use between "Clarke 1880"
and "WGS 84".
PARAMETER["semi_major", put value here],
PARAMETER["semi_minor", put value here],
Martin