Hi Martin,

thanks for the response and info.

I tried something different and have therefore a general  question of the 
reprojection process.

I am using the maven dependencies  org.apache.sis.core (v.1.0) and 
org.apache.sis.non-free and I want to reproject a SIS DirectPosition2D point.

I assume that my WGS84 point is in lng / lat that's why I use a special 
axisConvention.


So here my example:

CoordinateReferenceSystem sourceCRS = CRS.forCode("EPSG:4326");
CoordinateReferenceSystem targetCRS = CRS.forCode("EPSG:32632");
CoordinateReferenceSystem alternativCRSsource = 
AbstractCRS.castOrCopy(sourceCRS).forConvention(AxesConvention.RIGHT_HANDED);


CoordinateOperation op = CRS.findOperation(alternativCRSsource, targetCRS, 
null);

DirectPosition2D sisPoint = new DirectPosition2D(8.4036527, 49.0068901);
DirectPosition2D projPoint = (DirectPosition2D) 
op.getMathTransform().transform(sisPoint, null);

System.out.println(projPoint.toString()); // POINT(456387.7786436868 
5428393.033233286)



To get this run I need following packages:

import org.apache.sis.geometry.DirectPosition2D;
import org.apache.sis.referencing.CRS;
import org.apache.sis.referencing.crs.AbstractCRS;
import org.apache.sis.referencing.cs.AxesConvention;

import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.CoordinateOperation;
import org.opengis.referencing.operation.TransformException;
import org.opengis.util.FactoryException;


I found a similar example on https://sis.apache.org/book/en/developer-guide.html

I am wondering off the org.opengis.* packades and why I have to cast the  op 
object result from org.opengis.geometry.DirectPosition; to 
org.apache.sis.geometry.DirectPosition2D;

The apache project I am working on is not allowed to use LGPL and I know this 
packages from another geotools project.

So is my example correct? Under which license do the org.opengis packages run 
which are apparently included in one of the sis dependencies (just to be save 
in this part)


Thanks!

Florian



Am 08.03.20 um 21:49 schrieb Martin Desruisseaux:

Hello Florian, and welcome!

Disy Informationssysteme GmbH
Florian Micklich
Lösungsentwickler
+49 721 16006 477,  [email protected]

Firmensitz: Ludwig-Erhard-Allee 6, 76131 Karlsruhe
Registergericht: Amtsgericht Mannheim, HRB 107964
Geschäftsführer: Claus Hofmann

Bitte beachten Sie folgende Informationen für Kunden, Lieferanten und Bewerber
- Datenschutz: www.disy.net/datenschutz
- Informationspflichten:  www.disy.net/informationspflichten


Le 08/03/2020 à 21:17, Florian Micklich a écrit :

I am pretty new to Apache SIS but did already some coordinate transformations 
like this example:

https://sis.apache.org/book/en/developer-guide.html#CoordinateOperations

Is there also a possibility to reproject other geometries like LineStrings and 
Polygons or do I have to use a CoordinateSequens to reproject such kind of 
types?

Yes, but not yet with a public, committed API. The support of geometries in 
Apache SIS is a work in progress. Geometries are defined by the ISO 19107 
international standard, which supports up to three-dimensional geometries with 
curves. JTS can been seen as a subset of that standard for two-dimensional line 
strings in Cartesian space. Our plan is to define an API based on ISO 19107, 
then create wrappers around JTS objects for exposing those objects through that 
API. That way the same API can also be used with ESRI API (another library 
which can pretty much compete with JTS), and the API is ready for 3 dimensional 
objects in the future.

But we are not yet there. In the meantime it is possible to do some operations 
on JTS objects using the given class:

 *   org.apache.sis.internal.feature.jts.JTS

It has a static method like below:

 *   public static Geometry transform(Geometry geometry, CoordinateOperation 
operation)

However everything in "internal" packages are not committed API; they may 
change in any future SIS version. As said before we plan to provide this service in the 
future through an API which work with JTS as well as with ESRI API and future libraries. 
But we are not yet there and for now that internal API is the only way.


Is there an example to do a transformation with JTS geometry with SIS?

If "source" and "target" are two EPSG code as Strings, it could be:

CoordinateReferenceSystem sourceCRS = CRS.forCode(source);
CoordinateReferenceSystem targetCRS = CRS.forCode(target);
CoordinateOperation op = CRS.findOperation(sourceCRS, targetCRS, null);

Geometry original = ...;
Geometry converted = JRS.transform(original, op);       // WARNING: internal 
class, may change in any future version.


Regards,

   Martin

Reply via email to