/** * Validates the given coordinate reference system. * * @param object The object to validate, or {@code null}. */ public void validate(final EngineeringCRS object) { if (object == null) { return; } validateReferenceSystem(object); final CoordinateSystem cs = object.getCoordinateSystem(); mandatory("EngineeringCRS: must have a CoordinateSystem.", cs); container.cs.dispatch(cs); final Datum datum = object.getDatum(); mandatory("EngineeringCRS: must have a Datum.", datum); container.datum.dispatch(datum); }
/** * Constructs a new coordinate reference system with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param crs the coordinate reference system to copy. * * @see #castOrCopy(EngineeringCRS) */ protected DefaultEngineeringCRS(final EngineeringCRS crs) { super(crs); datum = crs.getDatum(); }
/** * 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); }
/** * Compares the specified object to this CRS for equality. This method is overridden * because, otherwise, {@code CARTESIAN_xD} and {@code GENERIC_xD} would be considered * equals when metadata are ignored. */ @Override public boolean equals(final Object object, final ComparisonMode mode) { if (object instanceof EngineeringCRS && super.equals(object, mode)) { switch (mode) { case STRICT: case BY_CONTRACT: { // No need to performs the check below if metadata were already compared. return true; } default: { final EngineeringCRS that = (EngineeringCRS) object; return Objects.equals(getName().getCode(), that.getName().getCode()); } } } return false; } }
/** * Constructs a new coordinate reference system with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param crs the coordinate reference system to copy. * * @see #castOrCopy(EngineeringCRS) */ protected DefaultEngineeringCRS(final EngineeringCRS crs) { super(crs); datum = crs.getDatum(); }
/** * Validates the given coordinate reference system. * * @param object the object to validate, or {@code null}. */ public void validate(final EngineeringCRS object) { if (object == null) { return; } validateReferenceSystem(object); final CoordinateSystem cs = object.getCoordinateSystem(); mandatory("EngineeringCRS: shall have a CoordinateSystem.", cs); container.validate(cs); assertTrue("EngineeringCRS: illegal coordinate system type. Shall be one of affine, " + "Cartesian, cylindrical, linear, polar, spherical or user defined.", cs instanceof AffineCS || // Include the CartesianCS case. cs instanceof CylindricalCS || cs instanceof LinearCS || cs instanceof PolarCS || cs instanceof SphericalCS || cs instanceof UserDefinedCS); final Datum datum = object.getDatum(); mandatory("EngineeringCRS: shall have a Datum.", datum); container.validate(datum); }
return new DefaultEngineeringCRS(properties, ((EngineeringCRS) crs).getDatum(), cs);
verifyDatum (crs.getDatum(), "P1"); assertNullOrEquals ("datum.anchor", "Peg in south corner", crs.getDatum().getAnchorPoint()); verifyCoordinateSystem (crs.getCoordinateSystem(), CartesianCS.class, new AxisDirection[] {SOUTH_WEST, SOUTH_EAST}, metre);
return new DefaultEngineeringCRS(properties, ((EngineeringCRS) crs).getDatum(), cs);
verifyDatum (crs.getDatum(), "Ship reference point"); assertNullOrEquals ("datum.anchor", "Centre of buoyancy", crs.getDatum().getAnchorPoint()); verifyAxisAbbreviations(cs = crs.getCoordinateSystem(), "x", "y", "z"); verifyCoordinateSystem (cs, CartesianCS.class, new AxisDirection[] {valueOf("forward"), valueOf("starboard"), DOWN}, metre);
verifyDatum (crs.getDatum(), "Astra Minas"); verifyAxisAbbreviations(cs = crs.getCoordinateSystem(), "X", "Y"); verifyCoordinateSystem (cs, CartesianCS.class, new AxisDirection[] {NORTH,WEST}, metre);
/** * Tests the "Barcelona Grid B1" engineering CRS (EPSG:5801). * * @throws FactoryException if an error occurred while querying the factory. */ @Test public void testEngineering() throws FactoryException { final EPSGFactory factory = TestFactorySource.factory; assumeNotNull(factory); final EngineeringCRS crs = factory.createEngineeringCRS("EPSG:5801"); assertEpsgNameAndIdentifierEqual("Barcelona Grid B1", 5801, crs); assertEpsgNameAndIdentifierEqual("Barcelona", 9301, crs.getDatum()); assertAxisDirectionsEqual("EPSG::4500", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST); assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("5801")); }
/** * Tests the parsing of an engineering CRS from a WKT 2 string. * * @throws ParseException if the parsing failed. */ @Test public void testEngineeringCRS() throws ParseException { final EngineeringCRS crs = parse(EngineeringCRS.class, "EngineeringCRS[“A building-centred CRS”,\n" + " EngineeringDatum[“Building reference point”],\n" + " CS[Cartesian, 3],\n" + " Axis[“x”, east],\n" + " Axis[“y”, north],\n" + " Axis[“z”, up],\n" + " Unit[“metre”, 1]]"); assertNameAndIdentifierEqual("A building-centred CRS", 0, crs); assertNameAndIdentifierEqual("Building reference point", 0, crs.getDatum()); final CoordinateSystem cs = crs.getCoordinateSystem(); assertEquals("dimension", 3, cs.getDimension()); // Axis names are arbitrary and could change in future SIS versions. assertUnboundedAxisEquals("Easting", "x", AxisDirection.EAST, Units.METRE, cs.getAxis(0)); assertUnboundedAxisEquals("Northing", "y", AxisDirection.NORTH, Units.METRE, cs.getAxis(1)); assertUnboundedAxisEquals("z", "z", AxisDirection.UP, Units.METRE, cs.getAxis(2)); }