Search in sources :

Example 1 with EngineeringCRS

use of org.opengis.referencing.crs.EngineeringCRS in project sis by apache.

the class CommonAuthorityFactoryTest method testCRS1.

/**
 * Tests {@link CommonAuthorityFactory#createEngineeringCRS(String)} with the {@code "CRS:1"} code.
 *
 * @throws FactoryException if an error occurred while creating a CRS.
 */
@Test
public void testCRS1() throws FactoryException {
    EngineeringCRS crs = factory.createEngineeringCRS("CRS:1");
    assertSame(crs, factory.createEngineeringCRS("1"));
    assertSame(crs, factory.createEngineeringCRS("CRS1"));
    assertSame(crs, factory.createEngineeringCRS("CRS:CRS 1"));
    assertAxisDirectionsEqual("CS", crs.getCoordinateSystem(), AxisDirection.EAST, AxisDirection.SOUTH);
}
Also used : EngineeringCRS(org.opengis.referencing.crs.EngineeringCRS) Test(org.junit.Test)

Example 2 with EngineeringCRS

use of org.opengis.referencing.crs.EngineeringCRS in project sis by apache.

the class CRS method horizontalCode.

/**
 * If the given CRS would quality as horizontal except for its number of dimensions, returns that number.
 * Otherwise returns 0. The number of dimensions can only be 2 or 3.
 */
private static int horizontalCode(final CoordinateReferenceSystem crs) {
    /*
         * In order to determine if the CRS is geographic, checking the CoordinateSystem type is more reliable
         * then checking if the CRS implements the GeographicCRS interface.  This is because the GeographicCRS
         * type did not existed in ISO 19111:2007, so a CRS could be standard-compliant without implementing
         * the GeographicCRS interface.
         */
    boolean isEngineering = false;
    final boolean isGeodetic = (crs instanceof GeodeticCRS);
    if (isGeodetic || crs instanceof ProjectedCRS || (isEngineering = (crs instanceof EngineeringCRS))) {
        final CoordinateSystem cs = crs.getCoordinateSystem();
        final int dim = cs.getDimension();
        if ((dim & ~1) == 2 && (!isGeodetic || (cs instanceof EllipsoidalCS))) {
            if (isEngineering) {
                int n = 0;
                for (int i = 0; i < dim; i++) {
                    if (AxisDirections.isCompass(cs.getAxis(i).getDirection()))
                        n++;
                }
                // If we don't have exactly 2 east, north, etc. directions, consider as non-horizontal.
                if (n != 2)
                    return 0;
            }
            return dim;
        }
    }
    return 0;
}
Also used : EngineeringCRS(org.opengis.referencing.crs.EngineeringCRS) DefaultEngineeringCRS(org.apache.sis.referencing.crs.DefaultEngineeringCRS) ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) DefaultProjectedCRS(org.apache.sis.referencing.crs.DefaultProjectedCRS) CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) EllipsoidalCS(org.opengis.referencing.cs.EllipsoidalCS) GeodeticCRS(org.opengis.referencing.crs.GeodeticCRS)

Example 3 with EngineeringCRS

use of org.opengis.referencing.crs.EngineeringCRS in project sis by apache.

the class SubTypes method castOrCopy.

/**
 * Returns a SIS implementation for the given coordinate reference system.
 *
 * @see AbstractCRS#castOrCopy(CoordinateReferenceSystem)
 */
static AbstractCRS castOrCopy(final CoordinateReferenceSystem object) {
    if (object instanceof DerivedCRS) {
        return DefaultDerivedCRS.castOrCopy((DerivedCRS) object);
    }
    if (object instanceof ProjectedCRS) {
        return DefaultProjectedCRS.castOrCopy((ProjectedCRS) object);
    }
    if (object instanceof GeodeticCRS) {
        if (object instanceof GeographicCRS) {
            return DefaultGeographicCRS.castOrCopy((GeographicCRS) object);
        }
        if (object instanceof GeocentricCRS) {
            return DefaultGeocentricCRS.castOrCopy((GeocentricCRS) object);
        }
        /*
             * The GeographicCRS and GeocentricCRS types are not part of ISO 19111.
             * ISO uses a single type, GeodeticCRS, for both of them and infer the
             * geographic or geocentric type from the coordinate system. We do this
             * check here for instantiating the most appropriate SIS type, but only
             * if we need to create a new object anyway (see below for rational).
             */
        if (object instanceof DefaultGeodeticCRS) {
            /*
                 * Result of XML unmarshalling — keep as-is. We avoid creating a new object because it
                 * would break object identities specified in GML document by the xlink:href attribute.
                 * However we may revisit this policy in the future. See SC_CRS.setElement(AbstractCRS).
                 */
            return (DefaultGeodeticCRS) object;
        }
        final Map<String, ?> properties = IdentifiedObjects.getProperties(object);
        final GeodeticDatum datum = ((GeodeticCRS) object).getDatum();
        final CoordinateSystem cs = object.getCoordinateSystem();
        if (cs instanceof EllipsoidalCS) {
            return new DefaultGeographicCRS(properties, datum, (EllipsoidalCS) cs);
        }
        if (cs instanceof SphericalCS) {
            return new DefaultGeocentricCRS(properties, datum, (SphericalCS) cs);
        }
        if (cs instanceof CartesianCS) {
            return new DefaultGeocentricCRS(properties, datum, (CartesianCS) cs);
        }
    }
    if (object instanceof VerticalCRS) {
        return DefaultVerticalCRS.castOrCopy((VerticalCRS) object);
    }
    if (object instanceof TemporalCRS) {
        return DefaultTemporalCRS.castOrCopy((TemporalCRS) object);
    }
    if (object instanceof EngineeringCRS) {
        return DefaultEngineeringCRS.castOrCopy((EngineeringCRS) object);
    }
    if (object instanceof ImageCRS) {
        return DefaultImageCRS.castOrCopy((ImageCRS) object);
    }
    if (object instanceof CompoundCRS) {
        return DefaultCompoundCRS.castOrCopy((CompoundCRS) object);
    }
    /*
         * Intentionally check for AbstractCRS after the interfaces because user may have defined his own
         * subclass implementing the interface. If we were checking for AbstractCRS before the interfaces,
         * the returned instance could have been a user subclass without the JAXB annotations required
         * for XML marshalling.
         */
    if (object == null || object instanceof AbstractCRS) {
        return (AbstractCRS) object;
    }
    return new AbstractCRS(object);
}
Also used : CartesianCS(org.opengis.referencing.cs.CartesianCS) EngineeringCRS(org.opengis.referencing.crs.EngineeringCRS) CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) DerivedCRS(org.opengis.referencing.crs.DerivedCRS) CompoundCRS(org.opengis.referencing.crs.CompoundCRS) GeodeticDatum(org.opengis.referencing.datum.GeodeticDatum) GeodeticCRS(org.opengis.referencing.crs.GeodeticCRS) SphericalCS(org.opengis.referencing.cs.SphericalCS) TemporalCRS(org.opengis.referencing.crs.TemporalCRS) ProjectedCRS(org.opengis.referencing.crs.ProjectedCRS) ImageCRS(org.opengis.referencing.crs.ImageCRS) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) EllipsoidalCS(org.opengis.referencing.cs.EllipsoidalCS) GeographicCRS(org.opengis.referencing.crs.GeographicCRS) GeocentricCRS(org.opengis.referencing.crs.GeocentricCRS)

Aggregations

EngineeringCRS (org.opengis.referencing.crs.EngineeringCRS)3 GeodeticCRS (org.opengis.referencing.crs.GeodeticCRS)2 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)2 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)2 EllipsoidalCS (org.opengis.referencing.cs.EllipsoidalCS)2 DefaultEngineeringCRS (org.apache.sis.referencing.crs.DefaultEngineeringCRS)1 DefaultProjectedCRS (org.apache.sis.referencing.crs.DefaultProjectedCRS)1 Test (org.junit.Test)1 CompoundCRS (org.opengis.referencing.crs.CompoundCRS)1 DerivedCRS (org.opengis.referencing.crs.DerivedCRS)1 GeocentricCRS (org.opengis.referencing.crs.GeocentricCRS)1 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)1 ImageCRS (org.opengis.referencing.crs.ImageCRS)1 TemporalCRS (org.opengis.referencing.crs.TemporalCRS)1 VerticalCRS (org.opengis.referencing.crs.VerticalCRS)1 CartesianCS (org.opengis.referencing.cs.CartesianCS)1 SphericalCS (org.opengis.referencing.cs.SphericalCS)1 GeodeticDatum (org.opengis.referencing.datum.GeodeticDatum)1