Hi all,
I'm relative new to Geotools. I'm implementing a kind of GPS navigator;
I have a shapefile with the digital map of my city which is loaded in
mapContext, and a maplayer representing the moving vehicle.
The following is the creation of the map:
try {
map = new DefaultMapContext(crs);
URL url = new URL("file://./micro/shapes/sections.shp");
store= new ShapefileDataStore(url);
featureSource = store.getFeatureSource();
File sld2 = new File("./micro/slds/stileSectionsBello2.sld");
Style ss = createFromSLD(sld2);
map.addLayer(featureSource,ss);
/*creating gps vehicleLayer*/
try {
store = (ShapefileDataStore) csv2shp.csv2shp(fileVehicle2,"GPS
location");
} catch (Exception e) {e.printStackTrace();}
// Add gps shapefile to map context
featureSource = store.getFeatureSource();
File sld3 = new File("./micro/slds/stileLocationGPS.sld");
Style sl2 = createFromSLD(sld3);
map.addLayer(featureSource,sl2);
/*end creating vehicleLayer*/
/*... adding in the same way other shapefiles...*/
mapPane = new JMapPane();
JMapFrame finestraMappa = new JMapFrame();
StreamingRenderer renderer = new StreamingRenderer();
renderer.setContext(map);
mapPane.setRenderer(renderer);
mapPane.setRepaint(true);
//adding zoomin and zoomout tools
JButton zoomInBtn = new JButton(new ZoomInAction(mapPane));
mapPane.add(zoomInBtn);
JButton zoomOutBtn = new JButton(new ZoomOutAction(mapPane));
mapPane.add(zoomOutBtn);
mapPane.setMapContext(map);
finestraMappa.add(mapPane);
}
catch(Exception e){e.printStackTrace();}
I have two problems:
1. I got the following exception, and I don't realize where and why it
happens
14-mar-2011 14.51.42 org.geotools.renderer.lite.StreamingRenderer
fireErrorEvent
GRAVE: null
java.lang.NullPointerException at
org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1845)
at
org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:755)
at org.geotools.swing.RenderingExecutor
$Task.call(RenderingExecutor.java:149)
at org.geotools.swing.RenderingExecutor
$Task.call(RenderingExecutor.java:105)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
2. The other problem I have is about the map visualization: each time
the vehicle changes position, the relative shapefile is updated with a
transaction which modifies the geometry value, and the map too must be
updated with the new vehicle position. The problem is that the map is
flashing, it disappears and it appears again. Obviously I don't like
this. Any suggestion?
Any kind of help is greatly appreciated.
Francesca
--
Francesca Martelli, Computer Science Ph.D.
Algorithms and Computational Mathematics Group, IIT - CNR, Pisa
Phone: +39 050 315 3191 (office), +39 050 315 2333 (fax)
http://www.iit.cnr.it/francesca.martelli/
email: [email protected]
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users