Revision 5829
Added by ben leinfelder over 13 years ago
SpatialDocument.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package edu.ucsb.nceas.metacat.spatial; |
24 | 24 |
|
25 |
import java.io.File; |
|
26 |
|
|
27 | 25 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
28 | 26 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
29 | 27 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
... | ... | |
38 | 36 |
import com.vividsolutions.jts.geom.GeometryFactory; |
39 | 37 |
import com.vividsolutions.jts.geom.PrecisionModel; |
40 | 38 |
|
41 |
import org.geotools.feature.AttributeType; |
|
42 |
import org.geotools.feature.AttributeTypeFactory; |
|
43 |
import org.geotools.feature.Feature; |
|
44 |
import org.geotools.feature.FeatureType; |
|
45 |
import org.geotools.feature.FeatureTypeFactory; |
|
46 |
import org.geotools.feature.SchemaException; |
|
39 |
import org.geotools.feature.simple.SimpleFeatureBuilder; |
|
40 |
import org.opengis.feature.simple.SimpleFeature; |
|
41 |
import org.opengis.feature.simple.SimpleFeatureType; |
|
47 | 42 |
|
48 | 43 |
import java.sql.ResultSet; |
49 | 44 |
import java.sql.PreparedStatement; |
... | ... | |
215 | 210 |
* Returns a geotools (multi)polygon feature with geometry plus attributes |
216 | 211 |
* ready to be inserted into our spatial dataset cache |
217 | 212 |
*/ |
218 |
public Feature getPolygonFeature() { |
|
213 |
public SimpleFeature getPolygonFeature() {
|
|
219 | 214 |
// Get polygon feature type |
220 |
FeatureType polyType = featureSchema.getPolygonFeatureType(); |
|
215 |
SimpleFeatureType polyType = featureSchema.getPolygonFeatureType();
|
|
221 | 216 |
|
222 | 217 |
MultiPolygon theGeom = getPolygonGeometry(); |
223 | 218 |
if (theGeom == null) |
... | ... | |
225 | 220 |
|
226 | 221 |
// Populate the feature schema |
227 | 222 |
try { |
228 |
Feature polyFeature = polyType.create(new Object[]{ |
|
229 |
theGeom, |
|
230 |
this.docid, |
|
231 |
getUrl(this.docid), |
|
232 |
this.title }); |
|
223 |
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(polyType); |
|
224 |
builder.addAll( |
|
225 |
new Object[]{ |
|
226 |
theGeom, |
|
227 |
this.docid, |
|
228 |
getUrl(this.docid), |
|
229 |
this.title } |
|
230 |
); |
|
231 |
SimpleFeature polyFeature = builder.buildFeature(this.docid); |
|
233 | 232 |
return polyFeature; |
234 |
} catch (org.geotools.feature.IllegalAttributeException e) {
|
|
235 |
log.error("!!!!!!! org.geotools.feature.IllegalAttributeException");
|
|
233 |
} catch (Exception e) { |
|
234 |
log.error("Problem getting polygon feature: " + e.getMessage());
|
|
236 | 235 |
return null; |
237 | 236 |
} |
238 | 237 |
} |
... | ... | |
242 | 241 |
* ready to be inserted into our spatial dataset cache |
243 | 242 |
* |
244 | 243 |
*/ |
245 |
public Feature getPointFeature() { |
|
244 |
public SimpleFeature getPointFeature() {
|
|
246 | 245 |
// Get polygon feature type |
247 |
FeatureType pointType = featureSchema.getPointFeatureType(); |
|
246 |
SimpleFeatureType pointType = featureSchema.getPointFeatureType();
|
|
248 | 247 |
|
249 | 248 |
MultiPoint theGeom = getPointGeometry(); |
250 | 249 |
if (theGeom == null) |
... | ... | |
252 | 251 |
|
253 | 252 |
// Populate the feature schema |
254 | 253 |
try { |
255 |
Feature pointFeature = pointType.create(new Object[]{ |
|
256 |
theGeom, |
|
257 |
this.docid, |
|
258 |
getUrl(this.docid), |
|
259 |
this.title }); |
|
254 |
SimpleFeatureBuilder builder = new SimpleFeatureBuilder(pointType); |
|
255 |
builder.addAll( |
|
256 |
new Object[]{ |
|
257 |
theGeom, |
|
258 |
this.docid, |
|
259 |
getUrl(this.docid), |
|
260 |
this.title } |
|
261 |
); |
|
262 |
SimpleFeature pointFeature = builder.buildFeature(this.docid); |
|
260 | 263 |
return pointFeature; |
261 |
} catch (org.geotools.feature.IllegalAttributeException e) {
|
|
262 |
log.error("!!!!!!! org.geotools.feature.IllegalAttributeException");
|
|
264 |
} catch (Exception e) { |
|
265 |
log.error("Problem getting point feature: " + e.getMessage());
|
|
263 | 266 |
return null; |
264 | 267 |
} |
265 | 268 |
} |
Also available in: Unified diff
geoserver upgrade:
-remove embedded geoserver
-include geotools api and update spatial harvesting
-include simple template for using maps in skin (openlayers now, not mapbuilder)