本文整理汇总了Java中org.geotools.styling.StyledLayerDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java StyledLayerDescriptor类的具体用法?Java StyledLayerDescriptor怎么用?Java StyledLayerDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StyledLayerDescriptor类属于org.geotools.styling包,在下文中一共展示了StyledLayerDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: encodeSLD
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Encode sld to a string
*
* @param sld the sld
* @return the string
*/
public String encodeSLD(StyledLayerDescriptor sld)
{
String xml = "";
if(sld != null)
{
SLDTransformer transformer = new SLDTransformer();
transformer.setIndentation(2);
try {
xml = transformer.transform(sld);
} catch (TransformerException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
return xml;
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:SLDWriterImpl.java
示例2: internalOpenFile
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Internal open file.
*
* @param f the file
* @param list the list
*/
private void internalOpenFile(File f, List<SLDDataInterface> list) {
if (f.isFile() && FileSystemUtils.isFileExtensionSupported(f, getFileExtensionList())) {
try {
String contents = readFile(f, Charset.defaultCharset());
StyledLayerDescriptor sld = Ysld.parse(contents);
// Convert YSLD to SLD string
if (sldWriter == null) {
sldWriter = SLDWriterFactory.createWriter(SLDOutputFormatEnum.SLD);
}
String sldContents = sldWriter.encodeSLD(null, sld);
SLDDataInterface sldData = new SLDData(new StyleWrapper(f.getName()), sldContents);
sldData.setSLDFile(f);
sldData.setReadOnly(false);
sldData.setOriginalFormat(SLDOutputFormatEnum.YSLD);
list.add(sldData);
} catch (IOException e) {
e.printStackTrace();
}
}
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:32,代码来源:YSLDFileHandler.java
示例3: checkAttributes
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
@Override
public void checkAttributes(SLDEditorFileInterface editorFile) {
ExtractAttributes extract = new ExtractAttributes();
StyledLayerDescriptor sld = editorFile.getSLD();
extract.extractDefaultFields(sld);
List<DataSourceAttributeData> sldFieldList = extract.getFields();
List<DataSourceAttributeData> dataSourceList = editorFile.getSLDData().getFieldList();
for (DataSourceAttributeData sldField : sldFieldList) {
if (!dataSourceList.contains(sldField)) {
ConsoleManager.getInstance()
.error(this,
Localisation.getField(DataSourceImpl.class,
"DataSourceImpl.missingAttribute") + " "
+ sldField.getName());
}
}
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:20,代码来源:MissingSLDAttributes.java
示例4: saveAllLegendToFolder
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Save all legend to folder.
*
* @param destinationFolder the destination folder
*/
private void saveAllLegendToFolder(File destinationFolder) {
if (!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
logger.info(Localisation.getString(LegendTool.class, "LegendTool.saveAllLayerLegends"));
for (SLDDataInterface sldData : sldDataList) {
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
if (sld != null) {
String heading = null;
String filename = null;
String layerName = sldData.getLayerNameWithOutSuffix();
List<String> filenameList = new ArrayList<String>();
LegendManager.getInstance().saveLegendImage(sld, destinationFolder, layerName,
heading, filename, filenameList);
}
}
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:29,代码来源:LegendTool.java
示例5: testGetInlineFeaturesText
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUtils#getInlineFeaturesText(org.geotools.styling.UserLayer)}.
*/
@Test
public void testGetInlineFeaturesText() {
String actualResult = InlineFeatureUtils.getInlineFeaturesText(null);
assertTrue(actualResult.compareTo("") == 0);
// Test 1
SLDData sldData = new SLDData(null, testInline1a);
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
UserLayer userLayer1 = (UserLayer) sld.layers().get(0);
actualResult = InlineFeatureUtils.getInlineFeaturesText(userLayer1);
assertTrue(actualResult.startsWith("<FeatureCollection>"));
assertTrue(actualResult.endsWith("</FeatureCollection>"));
// Test 2
sldData = new SLDData(null, testInline1b);
sld = SLDUtils.createSLDFromString(sldData);
UserLayer userLayer2 = (UserLayer) sld.layers().get(0);
actualResult = InlineFeatureUtils.getInlineFeaturesText(userLayer2);
assertTrue(actualResult.startsWith("<FeatureCollection>"));
assertTrue(actualResult.endsWith("</FeatureCollection>"));
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:30,代码来源:InlineFeatureUtilsTest.java
示例6: encodeSLD
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Encode sld to a string.
*
* @param resourceLocator the resource locator
* @param sld the sld
* @return the MppBox string
*/
@Override
public String encodeSLD(URL resourceLocator, StyledLayerDescriptor sld) {
SLDDataInterface sldData = SLDEditorFile.getInstance().getSLDData();
if (sldData.getOriginalFormat() == SLDOutputFormatEnum.MAPBOX) {
File f = sldData.getSLDFile();
if ((cachedFile == null) || !cachedFile.equals(f)) {
cachedFile = f;
try {
StringBuilder data = new StringBuilder();
Stream<String> lines = Files.lines(f.toPath());
lines.forEach(line -> data.append(line).append("\n"));
lines.close();
cachedString = data.toString();
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
return cachedString;
}
return Localisation.getString(MapBoxWriterImpl.class, "MapBoxWriterImpl.notSupported");
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:33,代码来源:MapBoxWriterImpl.java
示例7: testUpdateLegendOptionData
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
@Test
public void testUpdateLegendOptionData() {
StyledLayerDescriptor sld = testSLD1();
String heading = "Test Heading";
LegendOptionData legendOption = new LegendOptionData();
legendOption.setBackgroundColour(Color.CYAN);
legendOption.setBorder(true);
legendOption.setBandInformation(true);
legendOption.setBorderColour(Color.GREEN);
legendOption.setImageHeight(100);
legendOption.setImageWidth(100);
legendOption.setImageHeight(100);
legendOption.setShowLabels(true);
legendOption.setShowTitle(true);
LegendManager.getInstance().SLDLoaded(legendOption);
boolean actualResult = compareLegendImage(sld, heading);
assertTrue(actualResult);
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:22,代码来源:LegendManagerTest.java
示例8: testMultiComparatorFilter
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
@Test
public void testMultiComparatorFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try with something complex
Filter filter = ff.and(ff.greater(ff.literal(42), ff.property("int")),
ff.less(ff.literal(12), ff.property("abc")));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(2, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Integer.class, dataSourceField.getType());
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:25,代码来源:ExtractAttributesTest.java
示例9: testBinaryTemporalFilter
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
@Test
public void testBinaryTemporalFilter() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try begins
Filter filter = ff.begins(ff.property("test"), ff.literal("1234"));
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(Integer.class, dataSourceField.getType());
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:ExtractAttributesTest.java
示例10: testIsLike
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
@Test
public void testIsLike() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try isLike
Filter filter = ff.like(ff.property("test"), "abcd1");
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(1, actualFieldnameList.size());
DataSourceAttributeData dataSourceField = actualFieldnameList.get(0);
assertEquals(String.class, dataSourceField.getType());
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:ExtractAttributesTest.java
示例11: testBinarySpatialOperator
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
@Test
public void testBinarySpatialOperator() {
DummyInternalSLDFile2 dummy = new DummyInternalSLDFile2();
StyledLayerDescriptor sld = createTestSLD(dummy);
List<Rule> ruleList = getRuleList(sld);
Rule rule = DefaultSymbols.createNewRule();
// Try bbox
String expectedGeometryFieldName = "test geometry";
Filter filter = ff.bbox(expectedGeometryFieldName, -1.0, 49.0, 2.0, 55.0, "EPSG:4326");
rule.setFilter(filter);
ruleList.clear();
ruleList.add(rule);
ExtractAttributes extract = new ExtractAttributes();
extract.extractDefaultFields(sld);
// Check fields extracted ok
List<String> actualGeometryFields = extract.getGeometryFields();
assertEquals(1, actualGeometryFields.size());
assertEquals(expectedGeometryFieldName, actualGeometryFields.get(0));
List<DataSourceAttributeData> actualFieldnameList = extract.getFields();
assertEquals(0, actualFieldnameList.size());
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:26,代码来源:ExtractAttributesTest.java
示例12: testGetExternalImagesPolygon
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Test method for
* {@link com.sldeditor.common.data.SLDExternalImages#getExternalImages(java.net.URL, org.geotools.styling.StyledLayerDescriptor)}.
*/
@Test
public void testGetExternalImagesPolygon() {
SLDWriterImpl writer = new SLDWriterImpl();
File f = new File("D:/temp/test.png");
URL url = null;
URL resourceLocator = null;
try {
url = f.toURI().toURL();
resourceLocator = new URL(f.getParentFile().toURI().toURL().toExternalForm() + "/");
} catch (MalformedURLException e) {
e.printStackTrace();
}
StyledLayerDescriptor polygonSLD = createTestPolygon(url);
List<String> imageList = SLDExternalImages.getExternalImages(resourceLocator, polygonSLD);
String result = writer.encodeSLD(resourceLocator, polygonSLD);
assertTrue(checkResult(f, result, 3));
assertEquals(3, imageList.size());
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:28,代码来源:SLDExternalImagesTest.java
示例13: checkAttributes
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
@Override
public void checkAttributes(SLDEditorFileInterface editorFile) {
missingFieldList.clear();
ExtractAttributes extract = new ExtractAttributes();
StyledLayerDescriptor sld = editorFile.getSLD();
extract.extractDefaultFields(sld);
List<DataSourceAttributeData> sldFieldList = extract.getFields();
List<DataSourceAttributeData> dataSourceList = editorFile.getSLDData().getFieldList();
for (DataSourceAttributeData sldField : sldFieldList) {
if (!dataSourceList.contains(sldField)) {
missingFieldList.add(sldField.getName());
}
}
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:18,代码来源:VectorToolTest.java
示例14: importLayer
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* 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;
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:43,代码来源:MXDParser.java
示例15: getRenderer
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Gets the renderer.
*
* @param layerName the layer name
* @param minScale the min scale
* @param maxScale the max scale
* @param transparency the transparency
* @param renderElement the render element
* @return the renderer
*/
private StyledLayerDescriptor getRenderer(
String layerName, double minScale, double maxScale, int transparency,
JsonElement renderElement)
{
StyledLayerDescriptor sld = null;
if(renderElement != null)
{
JsonObject renderer = renderElement.getAsJsonObject();
boolean found = false;
for(String rendererType : rendererMap.keySet())
{
JsonElement obj = renderer.get(rendererType);
if(obj != null)
{
EsriRendererInterface esriRenderer = rendererMap.get(rendererType);
sld = esriRenderer.convert(obj.getAsJsonObject(), layerName, minScale, maxScale, transparency);
found = true;
break;
}
}
if(!found)
{
ConsoleManager.getInstance().error(this, "Unsupported renderer : " + SymbolUtils.extractName(renderElement));
}
}
return sld;
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:41,代码来源:MXDParser.java
示例16: encodeSLD
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Encode sld to a string
*
* @param sld the sld
* @return the YSLD string
*/
public String encodeSLD(StyledLayerDescriptor sld)
{
StringWriter out = new StringWriter();
if(sld != null)
{
try {
Ysld.encode(sld, out);
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
return out.toString();
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:21,代码来源:YSLDWriterImpl.java
示例17: exportToSLD
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Export to SLD.
*/
private void exportToSLD() {
SLDWriterInterface sldWriter = SLDWriterFactory.createWriter(SLDOutputFormatEnum.SLD);
for (SLDDataInterface sldData : sldDataList) {
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
String layerName = sldData.getLayerNameWithOutSuffix();
if (sld != null) {
String sldString = sldWriter.encodeSLD(sldData.getResourceLocator(), sld);
String destinationFolder = sldData.getSLDFile().getParent();
File fileToSave = GenerateFilename.findUniqueName(destinationFolder, layerName,
SLDEditorFile.getSLDFileExtension());
String sldFilename = fileToSave.getName();
if (fileToSave.exists()) {
ConsoleManager.getInstance()
.error(this,
Localisation.getField(MapBoxTool.class,
"MapBoxTool.destinationAlreadyExists") + " "
+ sldFilename);
} else {
ConsoleManager.getInstance().information(this,
Localisation.getField(MapBoxTool.class, "MapBoxTool.exportToSLDMsg")
+ " " + sldFilename);
BufferedWriter out;
try {
out = new BufferedWriter(new FileWriter(fileToSave));
out.write(sldString);
out.close();
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
}
}
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:43,代码来源:MapBoxTool.java
示例18: createVectorSLDData
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Creates the vector sld.
*
* @param vectorFile the vector file
* @return the styled layer descriptor
*/
@Override
public SLDDataInterface createVectorSLDData(File vectorFile) {
if (vectorFile == null) {
return null;
}
Map<String, Object> map = null;
try {
map = DataSourceProperties.encodeFilename(vectorFile.toURI().toURL().toString());
} catch (MalformedURLException e) {
ConsoleManager.getInstance().exception(this, e);
return null;
}
StyledLayerDescriptor sld = createSLDData(map, null);
SLDData sldData = null;
if (sld != null) {
File sldFilename = ExternalFilenames.createSLDFilename(vectorFile);
StyleWrapper styleWrapper = new StyleWrapper(sldFilename.getName());
String sldContents = sldWriter.encodeSLD(null, sld);
sldData = new SLDData(styleWrapper, sldContents);
sldData.setSLDFile(sldFilename);
sldData.setReadOnly(false);
}
return sldData;
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:35,代码来源:VectorReader.java
示例19: testStyleDetails
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Test method for {@link com.sldeditor.ui.detail.StyleDetails#StyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.StyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.StyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.StyleDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.StyleDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.StyleDetails#preLoadSymbol()}.
*/
@Test
public void testStyleDetails() {
StyleDetails panel = new StyleDetails();
panel.populate(null);
// Set up test data
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
String expectedNameLayerValue = "named layer test value";
namedLayer.setName(expectedNameLayerValue);
Style style = DefaultSymbols.createNewStyle();
String expectedNameValue = "style test value";
style.setName(expectedNameValue);
namedLayer.addStyle(style);
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
style.featureTypeStyles().add(fts);
sld.layers().add(namedLayer);
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyle(style);
panel.populate(SelectedSymbol.getInstance());
panel.dataChanged(null);
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
assertTrue(expectedNameValue.compareTo(nameField.getStringValue()) == 0);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
assertTrue("".compareTo(nameField.getStringValue()) == 0);
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:44,代码来源:StyleDetailsTest.java
示例20: ScaleSLDData
import org.geotools.styling.StyledLayerDescriptor; //导入依赖的package包/类
/**
* Constructor.
*
* @param sld the sld
* @param sldData the sld data
*/
public ScaleSLDData(StyledLayerDescriptor sld, SLDDataInterface sldData) {
super();
this.sld = sld;
this.sldData = sldData;
this.workspace = this.sldData.getStyle().getWorkspace();
this.name = this.sldData.getLayerName();
}
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:14,代码来源:ScaleSLDData.java
注:本文中的org.geotools.styling.StyledLayerDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论