Search in sources :

Example 6 with ImmutableIdentifier

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);
}
Also used : DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) DefaultExtent(org.apache.sis.metadata.iso.extent.DefaultExtent) DefaultVerticalExtent(org.apache.sis.metadata.iso.extent.DefaultVerticalExtent) HashMap(java.util.HashMap) DefaultTemporalExtent(org.apache.sis.metadata.iso.extent.DefaultTemporalExtent) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 7 with ImmutableIdentifier

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());
}
Also used : ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) SimpleIdentifier(org.apache.sis.internal.simple.SimpleIdentifier) Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test)

Example 8 with ImmutableIdentifier

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);
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 9 with ImmutableIdentifier

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());
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) SimpleCitation(org.apache.sis.internal.simple.SimpleCitation) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test)

Example 10 with ImmutableIdentifier

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());
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) SimpleCitation(org.apache.sis.internal.simple.SimpleCitation) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)17 Test (org.junit.Test)8 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)7 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)6 HashMap (java.util.HashMap)5 DependsOnMethod (org.apache.sis.test.DependsOnMethod)5 Identifier (org.opengis.metadata.Identifier)5 Date (java.util.Date)3 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)3 InternationalString (org.opengis.util.InternationalString)3 ResultSet (java.sql.ResultSet)2 SimpleCitation (org.apache.sis.internal.simple.SimpleCitation)2 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)2 DefaultExtent (org.apache.sis.metadata.iso.extent.DefaultExtent)2 DefaultGeographicBoundingBox (org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox)2 DefaultTemporalExtent (org.apache.sis.metadata.iso.extent.DefaultTemporalExtent)2 Citation (org.opengis.metadata.citation.Citation)2 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)2 IdentifiedObject (org.opengis.referencing.IdentifiedObject)2 URI (java.net.URI)1