Search in sources :

Example 36 with InternationalString

use of org.opengis.util.InternationalString in project hale by halestudio.

the class WKTPreferencesCRSFactory method getDescriptionText.

/**
 * @see AuthorityFactory#getDescriptionText(String)
 */
@Override
public InternationalString getDescriptionText(String code) throws FactoryException {
    if (code == null) {
        return null;
    }
    if (code.startsWith("EPSG:")) {
        // $NON-NLS-1$
        code = code.substring(5);
    }
    code = code.trim();
    String wkt = node.get(code, null);
    if (wkt == null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        throw new FactoryException("Unknown EPSG code: '" + code + "'");
    }
    wkt = wkt.trim();
    int start = wkt.indexOf('"');
    int end = wkt.indexOf('"', start + 1);
    return new org.geotools.util.SimpleInternationalString(wkt.substring(start + 1, end));
}
Also used : FactoryException(org.opengis.referencing.FactoryException) InternationalString(org.opengis.util.InternationalString)

Example 37 with InternationalString

use of org.opengis.util.InternationalString in project sldeditor by robward-scisys.

the class DataSourceInfo method getPropertyDescriptorList.

/**
 * Gets the property descriptor list.
 *
 * @return the property descriptor list
 */
public Collection<PropertyDescriptor> getPropertyDescriptorList() {
    if (schema != null) {
        return schema.getDescriptors();
    } else {
        if (geometryType == GeometryTypeEnum.RASTER) {
            if (rasterPropertyDescriptorList == null) {
                rasterPropertyDescriptorList = new ArrayList<PropertyDescriptor>();
                CoordinateReferenceSystem crs = null;
                boolean isIdentifiable = false;
                boolean isAbstract = false;
                List<Filter> restrictions = null;
                AttributeType superType = null;
                InternationalString description = null;
                GeometryType type = featureTypeFactory.createGeometryType(new NameImpl(rasterGeometryField), GridCoverage2D.class, crs, isIdentifiable, isAbstract, restrictions, superType, description);
                GeometryDescriptor descriptor = featureTypeFactory.createGeometryDescriptor(type, new NameImpl(rasterGeometryField), 0, 1, false, null);
                rasterPropertyDescriptorList.add(descriptor);
            }
            return rasterPropertyDescriptorList;
        }
    }
    return null;
}
Also used : GeometryType(org.opengis.feature.type.GeometryType) NameImpl(org.geotools.feature.NameImpl) GeometryDescriptor(org.opengis.feature.type.GeometryDescriptor) PropertyDescriptor(org.opengis.feature.type.PropertyDescriptor) Filter(org.opengis.filter.Filter) InternationalString(org.opengis.util.InternationalString) AttributeType(org.opengis.feature.type.AttributeType) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 38 with InternationalString

use of org.opengis.util.InternationalString in project sldeditor by robward-scisys.

the class StandardPanel method populateStandardData.

/**
 * Populate standard data.
 *
 * @param standardData the standard data
 */
private void populateStandardData(StandardData standardData) {
    Description description = standardData.description;
    String titleString = "";
    String descriptionString = "";
    if (description != null) {
        InternationalString title = description.getTitle();
        if (title != null) {
            titleString = title.toString();
        }
        InternationalString abstractDesc = description.getAbstract();
        if (abstractDesc != null) {
            descriptionString = abstractDesc.toString();
        }
    }
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.NAME) != null) {
        fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, standardData.name);
    }
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.TITLE) != null) {
        fieldConfigVisitor.populateTextField(FieldIdEnum.TITLE, titleString);
    }
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.DESCRIPTION) != null) {
        fieldConfigVisitor.populateTextField(FieldIdEnum.DESCRIPTION, descriptionString);
    }
    FieldConfigBase uomFieldConfig = fieldConfigManager.get(FieldIdEnum.UOM);
    if (uomFieldConfig != null) {
        uomFieldConfig.updateAttributeSelection(SelectedSymbol.getInstance().isRasterSymbol());
        String uomString = UnitsOfMeasure.getInstance().convert(standardData.unit);
        fieldConfigVisitor.populateField(FieldIdEnum.UOM, getFilterFactory().literal(uomString));
    }
}
Also used : Description(org.geotools.styling.Description) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) InternationalString(org.opengis.util.InternationalString) InternationalString(org.opengis.util.InternationalString)

Example 39 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class PropertyAccessorTest method testSetWithConversion.

/**
 * Tests the {@link PropertyAccessor#set(int, Object, Object, int)} method
 * with a value that will need to be converted. The conversion will be from
 * {@link String} to {@link InternationalString}. The created metadata object is:
 *
 * {@preformat text
 *   DefaultCitation
 *     └─Title……………… Some title
 * }
 */
@Test
@DependsOnMethod("testSet")
public void testSetWithConversion() {
    final String expected = "Some title";
    final DefaultCitation instance = new DefaultCitation();
    final PropertyAccessor accessor = createPropertyAccessor();
    final int index = accessor.indexOf("title", true);
    final Object oldValue = accessor.set(index, instance, expected, RETURN_PREVIOUS);
    final Object value = accessor.get(index, instance);
    assertNull("title", oldValue);
    assertInstanceOf("title", InternationalString.class, value);
    assertSame("title", expected, value.toString());
    assertSame("title", value, instance.getTitle());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) IdentifiedObject(org.opengis.referencing.IdentifiedObject) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 40 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class PropertyAccessorTest method testSetInAppendMode.

/**
 * Tests the {@link PropertyAccessor#set(int, Object, Object, int)} method in
 * {@link PropertyAccessor#APPEND} mode. In this mode, new collections
 * are added into existing collections instead than replacing them.
 * The metadata object created by this test after the merge is:
 *
 * {@preformat text
 *   DefaultCitation
 *     ├─Title……………………………………………………… Added title
 *     ├─Alternate title (1 of 4)…… Old title 1
 *     ├─Alternate title (2 of 4)…… Old title 2
 *     ├─Alternate title (3 of 4)…… New title 1
 *     └─Alternate title (4 of 4)…… New title 2
 * }
 *
 * @see #testSetCollection()
 */
public void testSetInAppendMode() {
    final DefaultCitation instance = new DefaultCitation();
    final List<InternationalString> oldTitles = Arrays.<InternationalString>asList(new SimpleInternationalString("Old title 1"), new SimpleInternationalString("Old title 2"));
    final List<InternationalString> newTitles = Arrays.<InternationalString>asList(new SimpleInternationalString("New title 1"), new SimpleInternationalString("New title 2"));
    final List<InternationalString> merged = new ArrayList<>(oldTitles);
    assertTrue(merged.addAll(newTitles));
    // Set the title.
    instance.setAlternateTitles(oldTitles);
    final PropertyAccessor accessor = createPropertyAccessor();
    final int titleIndex = accessor.indexOf("title", true);
    Object titleChanged = accessor.set(titleIndex, instance, "Added title", APPEND);
    // Set the alternate titles.
    final int index = accessor.indexOf("alternateTitles", true);
    final Object changed = accessor.set(index, instance, newTitles, APPEND);
    final Object newValue = accessor.get(index, instance);
    // Verify the values.
    assertEquals("set(…, APPEND)", Boolean.TRUE, titleChanged);
    assertEquals("set(…, APPEND)", Boolean.TRUE, changed);
    assertEquals("get(…)", merged, newValue);
    assertSame("alternateTitles", newValue, instance.getAlternateTitles());
    assertTitleEquals("title", "Added title", instance);
    // Test setting again the title to the same value.
    titleChanged = accessor.set(titleIndex, instance, "Added title", APPEND);
    assertEquals("set(…, APPEND)", Boolean.FALSE, titleChanged);
    assertTitleEquals("title", "Added title", instance);
    // Test setting the title to a different value.
    titleChanged = accessor.set(titleIndex, instance, "Different title", APPEND);
    // Operation shall be refused.
    assertNull("set(…, APPEND)", titleChanged);
    assertTitleEquals("title", "Added title", instance);
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ArrayList(java.util.ArrayList) IdentifiedObject(org.opengis.referencing.IdentifiedObject)

Aggregations

InternationalString (org.opengis.util.InternationalString)86 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)20 Test (org.junit.Test)17 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)13 IdentifiedObject (org.opengis.referencing.IdentifiedObject)10 ArrayList (java.util.ArrayList)7 Locale (java.util.Locale)6 GenericName (org.opengis.util.GenericName)6 Extent (org.opengis.metadata.extent.Extent)5 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 Vocabulary (org.apache.sis.util.resources.Vocabulary)4 Citation (org.opengis.metadata.citation.Citation)4 IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TableAppender (org.apache.sis.io.TableAppender)3 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)3 DataStoreException (org.apache.sis.storage.DataStoreException)3