use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class InlineFeatureUtilsTest method testSetInlineFeatures.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUtils#setInlineFeatures(org.geotools.styling.UserLayer, java.lang.String)}.
*/
@Test
public void testSetInlineFeatures() {
UserLayer userLayer = DefaultSymbols.createNewUserLayer();
InlineFeatureUtils.setInlineFeatures(null, null);
InlineFeatureUtils.setInlineFeatures(userLayer, null);
InlineFeatureUtils.setInlineFeatures(null, "");
assertNull(userLayer.getInlineFeatureDatastore());
InlineFeatureUtils.setInlineFeatures(userLayer, testInline2);
assertNotNull(userLayer.getInlineFeatureDatastore());
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class InlineFeatureUtilsTest method testDetermineGeometryType.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUtils#determineGeometryType(org.opengis.feature.type.GeometryDescriptor, org.geotools.data.simple.SimpleFeatureCollection)}.
*/
@Test
public void testDetermineGeometryType() {
// Test 1
SLDData sldData = new SLDData(null, testInline1a);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
UserLayer userLayer1 = (UserLayer) sld.layers().get(0);
GeometryDescriptor geometryDescriptor = userLayer1.getInlineFeatureType().getGeometryDescriptor();
String typeName = userLayer1.getInlineFeatureType().getTypeName();
SimpleFeatureCollection simpleFeatureCollection = null;
try {
simpleFeatureCollection = userLayer1.getInlineFeatureDatastore().getFeatureSource(typeName).getFeatures();
} catch (IOException e) {
e.printStackTrace();
}
assertEquals(GeometryTypeEnum.UNKNOWN, InlineFeatureUtils.determineGeometryType(null, null));
assertEquals(GeometryTypeEnum.UNKNOWN, InlineFeatureUtils.determineGeometryType(geometryDescriptor, null));
assertEquals(GeometryTypeEnum.POLYGON, InlineFeatureUtils.determineGeometryType(geometryDescriptor, simpleFeatureCollection));
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class InlineDatastoreVisitor method visit.
/**
* (non-Javadoc)
* @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.UserLayer)
*/
public void visit(UserLayer layer) {
Style[] style = layer.getUserStyles();
int length = style.length;
Style[] styleCopy = new Style[length];
for (int i = 0; i < length; i++) {
if (style[i] != null) {
style[i].accept(this);
styleCopy[i] = (Style) pages.pop();
}
}
FeatureTypeConstraint[] lfc = layer.getLayerFeatureConstraints();
FeatureTypeConstraint[] lfcCopy = new FeatureTypeConstraint[lfc.length];
length = lfc.length;
for (int i = 0; i < length; i++) {
if (lfc[i] != null) {
lfc[i].accept(this);
lfcCopy[i] = (FeatureTypeConstraint) pages.pop();
}
}
UserLayer copy = sf.createUserLayer();
copy.setName(layer.getName());
copy.setUserStyles(styleCopy);
copy.setLayerFeatureConstraints(lfcCopy);
// Reuse the existing inline feature data store
copy.setInlineFeatureDatastore(layer.getInlineFeatureDatastore());
copy.setInlineFeatureType(layer.getInlineFeatureType());
if (STRICT && !copy.equals(layer)) {
throw new IllegalStateException("Was unable to duplicate provided UserLayer:" + layer);
}
pages.push(copy);
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class DataSourceImpl method getUserLayerFeatureSource.
/*
* (non-Javadoc)
*
* @see com.sldeditor.datasource.DataSourceInterface#getUserLayerFeatureSource()
*/
@Override
public // CHECKSTYLE:OFF
Map<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>> getUserLayerFeatureSource() {
// CHECKSTYLE:ON
Map<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>> map = new HashMap<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>>();
for (DataSourceInfo dsInfo : userLayerDataSourceInfo) {
FeatureSource<SimpleFeatureType, SimpleFeature> features = dsInfo.getFeatures();
UserLayer userLayer = dsInfo.getUserLayer();
map.put(userLayer, features);
}
return map;
}
use of org.geotools.styling.UserLayer in project sldeditor by robward-scisys.
the class FieldConfigInlineFeature method redoAction.
/**
* Redo action.
*
* @param undoRedoObject the undo/redo object
*/
@Override
public void redoAction(UndoInterface undoRedoObject) {
if (undoRedoObject != null) {
if (undoRedoObject.getNewValue() instanceof String) {
String newValue = (String) undoRedoObject.getNewValue();
UserLayer userLayer = DefaultSymbols.createNewUserLayer();
InlineFeatureUtils.setInlineFeatures(userLayer, newValue);
if (inlineGML != null) {
inlineGML.setInlineFeatures(newValue);
}
if (inlineFeature != null) {
inlineFeature.setInlineFeatures(userLayer);
}
}
}
}
Aggregations