use of org.apache.sis.metadata.iso.ImmutableIdentifier in project sis by apache.
the class AbstractReferenceSystemTest method testWKT.
/**
* Tests WKT formatting with a name that contains the quote character and optional information.
* We test that the closing quote character is doubled and the optional information properly formatted.
*/
@Test
@DependsOnMethod("testCreateFromMap")
public void testWKT() {
final Map<String, Object> properties = new HashMap<>(8);
assertNull(properties.put(NAME_KEY, "My “object”."));
assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
assertNull(properties.put(REMARKS_KEY, "注です。"));
assertNull(properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.EPSG, "EPSG", "4326", "8.2", null)));
assertNull(properties.put(DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("Netherlands offshore.", new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77), new DefaultVerticalExtent(10, 1000, VerticalCRSMock.DEPTH), // TODO: needs sis-temporal module for testing that one.
new DefaultTemporalExtent())));
final AbstractReferenceSystem object = new AbstractReferenceSystem(properties);
assertTrue(object.toString(Convention.WKT1).startsWith("ReferenceSystem[\"My “object”.\", AUTHORITY[\"EPSG\", \"4326\"]]"));
assertWktEquals(Convention.WKT1, "ReferenceSystem[“My \"object\".”, AUTHORITY[“EPSG”, “4326”]]", object);
assertWktEquals(Convention.WKT2, // Quotes replaced
"ReferenceSystem[“My \"object\".”,\n" + " SCOPE[“Large scale topographic mapping and cadastre.”],\n" + " AREA[“Netherlands offshore.”],\n" + " BBOX[51.43, 2.54, 55.77, 6.40],\n" + " VERTICALEXTENT[-1000, -10, LENGTHUNIT[“metre”, 1]],\n" + " ID[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + " REMARK[“注です。”]]", object);
assertWktEquals(Convention.WKT2_SIMPLIFIED, "ReferenceSystem[“My \"object\".”,\n" + " Scope[“Large scale topographic mapping and cadastre.”],\n" + " Area[“Netherlands offshore.”],\n" + " BBox[51.43, 2.54, 55.77, 6.40],\n" + " VerticalExtent[-1000, -10],\n" + " Id[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + " Remark[“注です。”]]", object);
assertWktEquals(Convention.INTERNAL, // Quote doubled
"ReferenceSystem[“My “object””.”,\n" + " Scope[“Large scale topographic mapping and cadastre.”],\n" + " Area[“Netherlands offshore.”],\n" + " BBox[51.43, 2.54, 55.77, 6.40],\n" + " VerticalExtent[-1000, -10],\n" + " Id[“EPSG”, 4326, “8.2”],\n" + " Remark[“注です。”]]", object);
}
use of org.apache.sis.metadata.iso.ImmutableIdentifier in project sis by apache.
the class BuilderTest method testAddIdentifiers.
/**
* Tests {@link Builder#addIdentifier(Citation, String)} and {@link Builder#addIdentifier(String)} with code space.
*/
@Test
public void testAddIdentifiers() {
// Expected values to be used later in the test.
final Identifier id1 = new ImmutableIdentifier(Citations.EPSG, "EPSG", "9804");
final Identifier id2 = new ImmutableIdentifier(Citations.GEOTIFF, "GeoTIFF", "7");
assertEquals("EPSG:9804", IdentifiedObjects.toString(id1));
assertEquals("GeoTIFF:7", IdentifiedObjects.toString(id2));
// The test.
final BuilderMock builder = createMercator(false, true);
assertArrayEquals(new Identifier[] { id1, id2 }, builder.getIdentifiers());
}
use of org.apache.sis.metadata.iso.ImmutableIdentifier in project sis by apache.
the class CodeTest method testForIdentifiedObject.
/**
* Tests {@link Code#forIdentifiedObject(Class, Iterable)}.
*/
@Test
@DependsOnMethod("testWithVersion")
public void testForIdentifiedObject() {
final ReferenceIdentifier id = new ImmutableIdentifier(Citations.EPSG, "EPSG", "4326", "8.2", null);
final Code value = Code.forIdentifiedObject(GeographicCRS.class, Collections.singleton(id));
assertNotNull(value);
assertEquals("codeSpace", Constants.IOGP, value.codeSpace);
assertEquals("code", "urn:ogc:def:crs:EPSG:8.2:4326", value.code);
}
use of org.apache.sis.metadata.iso.ImmutableIdentifier in project sis by apache.
the class CodeTest method testSimple.
/**
* Tests the {@link Code#Code(ReferenceIdentifier)} constructor with {@code "EPSG:4326"} identifier.
* This test intentionally uses an identifier with the {@code IOGP} authority instead than
* EPSG in order to make sure that the {@code codeSpace} attribute is set from
* {@code Identifier.getCodeSpace()}, not from {@code Identifier.getAuthority()}.
*/
@Test
public void testSimple() {
final SimpleCitation IOGP = new SimpleCitation("IOGP");
// See above javadoc.
final ReferenceIdentifier id = new ImmutableIdentifier(IOGP, "EPSG", "4326");
final Code value = new Code(id);
assertEquals("codeSpace", "EPSG", value.codeSpace);
assertEquals("code", "4326", value.code);
/*
* Reverse operation. Note that the authority is lost since there is no room for that in a
* <gml:identifier> element. Current implementation sets the authority to the code space.
*/
final ReferenceIdentifier actual = value.getIdentifier();
assertSame("authority", Citations.EPSG, actual.getAuthority());
assertEquals("codeSpace", "EPSG", actual.getCodeSpace());
assertNull("version", actual.getVersion());
assertEquals("code", "4326", actual.getCode());
}
use of org.apache.sis.metadata.iso.ImmutableIdentifier in project sis by apache.
the class CodeTest method testWithVersion.
/**
* Tests the {@link Code#Code(ReferenceIdentifier)} constructor with {@code "EPSG:8.3:4326"} identifier.
* This test intentionally uses an identifier with the {@code IOGP} authority instead than EPSG
* for the same reason than {@link #testSimple()}.
*/
@Test
@DependsOnMethod("testSimple")
public void testWithVersion() {
final SimpleCitation IOGP = new SimpleCitation("IOGP");
// See above javadoc.
final ReferenceIdentifier id = new ImmutableIdentifier(IOGP, "EPSG", "4326", "8.2", null);
final Code value = new Code(id);
assertEquals("codeSpace", "EPSG:8.2", value.codeSpace);
assertEquals("code", "4326", value.code);
/*
* Reverse operation. Note that the authority is lost since there is no room for that in a
* <gml:identifier> element. Current implementation sets the authority to the code space.
*/
final ReferenceIdentifier actual = value.getIdentifier();
assertSame("authority", Citations.EPSG, actual.getAuthority());
assertEquals("codeSpace", "EPSG", actual.getCodeSpace());
assertEquals("version", "8.2", actual.getVersion());
assertEquals("code", "4326", actual.getCode());
}
Aggregations