35 |
import java.net.URL; |
import java.net.URL; |
36 |
import java.util.Date; |
import java.util.Date; |
37 |
import java.util.HashMap; |
import java.util.HashMap; |
|
import java.util.Map; |
|
38 |
import java.util.Random; |
import java.util.Random; |
39 |
|
|
40 |
import javax.swing.ImageIcon; |
import javax.swing.ImageIcon; |
44 |
import org.geotools.data.FeatureSource; |
import org.geotools.data.FeatureSource; |
45 |
import org.geotools.feature.FeatureCollection; |
import org.geotools.feature.FeatureCollection; |
46 |
import org.geotools.styling.Style; |
import org.geotools.styling.Style; |
47 |
|
import org.opengis.feature.simple.SimpleFeature; |
48 |
|
import org.opengis.feature.simple.SimpleFeatureType; |
49 |
import org.opengis.feature.type.AttributeDescriptor; |
import org.opengis.feature.type.AttributeDescriptor; |
50 |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
import org.opengis.referencing.crs.CoordinateReferenceSystem; |
51 |
|
|
64 |
public class StyledFS implements StyledFeatureSourceInterface { |
public class StyledFS implements StyledFeatureSourceInterface { |
65 |
private static final Logger LOGGER = Logger.getLogger(StyledFS.class); |
private static final Logger LOGGER = Logger.getLogger(StyledFS.class); |
66 |
|
|
67 |
private final FeatureSource fs; |
private final FeatureSource<SimpleFeatureType, SimpleFeature> fs; |
68 |
|
|
69 |
/** |
/** |
70 |
* A unique ID which identifies the Layer in the Atlas. It's more important |
* A unique ID which identifies the Layer in the Atlas. It's more important |
80 |
|
|
81 |
private File sldFile; |
private File sldFile; |
82 |
|
|
83 |
private HashMap<Integer, AttributeMetaData> map; |
private AttributeMetadataMap map; |
84 |
|
|
85 |
/** |
/** |
86 |
* This class enables a non Atlas context to use the Atlas LayerPanel |
* This class enables a non Atlas context to use the Atlas LayerPanel |
93 |
* may be <code>null</code>. Otherwise the SLD {@link File} to |
* may be <code>null</code>. Otherwise the SLD {@link File} to |
94 |
* import and associate with this {@link StyledFS} |
* import and associate with this {@link StyledFS} |
95 |
*/ |
*/ |
96 |
public StyledFS(FeatureSource fs, File sldFile) { |
public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs, File sldFile) { |
97 |
|
|
98 |
this.fs = fs; |
this.fs = fs; |
99 |
id = StyledFS.class.getSimpleName() |
id = StyledFS.class.getSimpleName() |
101 |
|
|
102 |
this.sldFile = sldFile; |
this.sldFile = sldFile; |
103 |
|
|
104 |
if ((sldFile != null) && (sldFile.exists())) { |
if (sldFile != null && sldFile.exists()) { |
105 |
try { |
try { |
106 |
style = StylingUtil.loadSLD(sldFile)[0]; |
style = StylingUtil.loadSLD(sldFile)[0]; |
107 |
} catch (FileNotFoundException e) { |
} catch (FileNotFoundException e) { |
122 |
} |
} |
123 |
|
|
124 |
/** |
/** |
125 |
* Returnes human readable {@link String} of the CRS natively used by this |
* Returns human readable {@link String} of the CRS natively used by this |
126 |
* {@link DpLayer} |
* {@link DpLayer} |
127 |
* |
* |
128 |
* If crs == null, it will call {@link #getGeoObject()} |
* If CRS == null, it will call {@link #getGeoObject()} |
129 |
* |
* |
130 |
*/ |
*/ |
131 |
public String getCRSString() { |
public String getCRSString() { |
136 |
} |
} |
137 |
|
|
138 |
public CoordinateReferenceSystem getCrs() { |
public CoordinateReferenceSystem getCrs() { |
139 |
return fs.getSchema().getDefaultGeometry().getCoordinateSystem(); |
return fs.getSchema().getCoordinateReferenceSystem(); |
140 |
} |
} |
141 |
|
|
142 |
public Translation getDesc() { |
public Translation getDesc() { |
152 |
} |
} |
153 |
} |
} |
154 |
|
|
155 |
public FeatureSource getGeoObject() { |
public FeatureSource<SimpleFeatureType, SimpleFeature> getGeoObject() { |
156 |
return fs; |
return fs; |
157 |
} |
} |
158 |
|
|
225 |
/** |
/** |
226 |
* |
* |
227 |
*/ |
*/ |
228 |
public Map<Integer, AttributeMetaData> getAttributeMetaDataMap() { |
public AttributeMetadataMap getAttributeMetaDataMap() { |
229 |
if (map == null) { |
if (map == null) { |
230 |
|
|
231 |
map = new HashMap<Integer, AttributeMetaData>(); |
map = new AttributeMetadataMap(); |
232 |
|
|
233 |
// Leaving out the first one, it will be the_geom |
// Leaving out the first one, it will be the_geom |
234 |
for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) { |
for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) { |
235 |
AttributeDescriptor att = fs.getSchema().getAttributeType(i); |
AttributeDescriptor att = fs.getSchema().getDescriptor(i); |
236 |
|
|
237 |
AttributeMetaData attMetaData = new AttributeMetaData(i, att |
AttributeMetaData attMetaData = new AttributeMetaData(i, att |
238 |
.getLocalName()); |
.getLocalName()); |