Hello,
Im currently using the MemoryFeatureCollection to show in memory features on
map but I have some problems adding an empty layer to mapContext. I don't know
whether it should be a feature or if it is a bug. I created a FeatureType and
then a MemoryFeatureCollection for that. Im using GeoTools version 2.5.2 and
its swing components. After adding the layer to map I got exceptions:
First (creating a MapLayer using the FeatureCollection):
MapContext context =
String ATTRIBUTE_REFID = "refid";
SimpleFeatureType myType = DataUtilities.createType("MyName",
"id:0,geom:Point:srid=4326,name:String," + ATTRIBUTE_REFID + ":String");
FeatureCollection myFeatureCollection = new MemoryFeatureCollection(myType);
Style style = ...
mapContext.addLayer(0, new DefaultMapLayer(myFeatureCollection, style, "My
Layer");
I get the following Exception using the
java.lang.NullPointerException
at
org.geotools.gui.swing.map.map2d.stream.JStreamSelectMap.createStyle(JStreamSelectMap.java:203)
at
org.geotools.gui.swing.map.map2d.stream.JStreamSelectMap.addSelectableLayerNU(JStreamSelectMap.java:470)
at
org.geotools.gui.swing.map.map2d.stream.JStreamSelectMap.addSelectableLayer(JStreamSelectMap.java:501)
I guess the main problem is the DefaultFeatureType.EMPTY creation in
CollectionDataStore.
Second (creating a MapLayer using the DataStore):
I tried creating a MemoryDataStore with called the createSchema Method to get
an empty layer to map. BUT if using the zoom to layer method in layer entry
in Table of Contents an other exception was thrown:
MemoryDataStore m_ds = new MemoryDataStore(myFeatureCollection);
FeatureSource m_fs = null;
try {
// define the type for the collection in datastore to avoid
creating a CollectionDatastore within DefaultMapLayer with emptytype ->
Exeptions occures
m_ds.createSchema(myType);
String typeName = myType.getTypeName();
m_fs = m_ds.getFeatureSource(typeName);
}
catch(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// should never happen
if (m_fs == null)
return;
MapLayer myLayer = new DefaultMapLayer(m_fs, style, "My Layer");
Exceptions:
java.lang.NullPointerException
at com.vividsolutions.jts.geom.Envelope.init(Envelope.java:254)
at com.vividsolutions.jts.geom.Envelope.<init>(Envelope.java:186)
at
org.geotools.geometry.jts.ReferencedEnvelope.<init>(ReferencedEnvelope.java:203)
at org.geotools.map.DefaultMapLayer.getBounds(DefaultMapLayer.java:406)
at
org.geotools.map.DefaultMapContext.getLayerBounds(DefaultMapContext.java:560)
I guess the MemoryDataStore getBounds(Query query) should have a behaviour like
in CollectionDataStore getBoundsInternal :
ReferencedEnvelope envelope = new ReferencedEnvelope(
featureType.getCoordinateReferenceSystem() );
If the FeatureType is well defined it would work very well except creating a
MapLayer like described above.
Thank you for any advice. Does anybody use the kind of Collections /
DataStores ? Should a create a ticket in JIRA?
Frank Gasdorf
__________________________________________________________________
Deutschlands größte Online-Videothek schenkt Ihnen 12.000 Videos!*
http://entertainment.web.de/de/entertainment/maxdome/index.html
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel