use of com.sldeditor.common.datasource.DataSourceFieldInterface in project sldeditor by robward-scisys.
the class MXDParser method importLayer.
/**
* Import layer.
*
* @param layer the layer
* @param outputFormat the output format
* @return the styled layer descriptor
*/
private SLDDataInterface importLayer(JsonObject layer, SLDOutputFormatEnum outputFormat) {
StyledLayerDescriptor sld = null;
String layerName = layer.get("name").getAsString();
double minScale = layer.get("minScale").getAsDouble();
double maxScale = layer.get("maxScale").getAsDouble();
int transparency = layer.get("transparency").getAsInt();
JsonElement renderElement = layer.get("renderer");
sld = getRenderer(layerName, minScale, maxScale, transparency, renderElement);
JsonElement labelRenderArrayElement = layer.get("labelRenderers");
if (labelRenderArrayElement != null) {
processLabelRenderer(sld, labelRenderArrayElement.getAsJsonArray(), transparency);
}
JsonElement fieldArray = layer.get("fields");
List<DataSourceFieldInterface> fieldList = processFields(layerName, fieldArray);
JsonElement dataSourcePropertiesElement = layer.get("dataSource");
DataSourcePropertiesInterface dataSourceProperties = processDataSource(layerName, dataSourcePropertiesElement);
String sldContents = SLDWriterFactory.createWriter(outputFormat).encodeSLD(sld);
StyleWrapper styleWrapper = new StyleWrapper(layerName, layerName);
SLDDataInterface sldData = new SLDData(styleWrapper, sldContents);
sldData.setDataSourceProperties(dataSourceProperties);
sldData.setFieldList(fieldList);
sldData.setReadOnly(true);
return sldData;
}
use of com.sldeditor.common.datasource.DataSourceFieldInterface in project sldeditor by robward-scisys.
the class MXDParser method processFields.
/**
* Process fields.
*
* @param layerName the layer name
* @param fieldArrayElement the field array element
* @return the list
*/
private List<DataSourceFieldInterface> processFields(String layerName, JsonElement fieldArrayElement) {
List<DataSourceFieldInterface> fieldList = new ArrayList<DataSourceFieldInterface>();
if (fieldArrayElement != null) {
JsonArray fieldArray = fieldArrayElement.getAsJsonArray();
for (int index = 0; index < fieldArray.size(); index++) {
JsonObject fieldObject = null;
try {
fieldObject = fieldArray.get(index).getAsJsonObject();
} catch (IllegalStateException e) {
ConsoleManager.getInstance().error(this, "Layer : " + layerName);
ConsoleManager.getInstance().exception(this, e);
}
if (fieldObject != null) {
Class<?> fieldType = convertFieldType(fieldObject.get("type").getAsString());
DataSourceField esriField = new DataSourceField(fieldObject.get("field").getAsString(), fieldType);
fieldList.add(esriField);
}
}
}
return fieldList;
}
Aggregations