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));
}
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;
}
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));
}
}
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());
}
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);
}
Aggregations