Hi
I'm not sure if my problem is an user error, a bug or a non-existent
function in GeoTools (2.7).
I want a continuous map in the JMapPanel when the JMapFrame size requires
it.
I use the following code and this works fine with Shape-Files.
Map renderingHints = new HashMap();
renderingHints.put(StreamingRenderer.ADVANCED_PROJECTION_HANDLING_KEY,
Boolean.TRUE);
renderingHints.put(StreamingRenderer.CONTINUOUS_MAP_WRAPPING,
Boolean.TRUE);
renderer.setRendererHints(renderingHints);
My problem is that I want to use a PostGIS database.
If I chance the datasource from Shape-File to PostGIS-table the map doesn´t
continuous.
I use PostgreSQL 9.0 with PostGIS extension.
The map I want to use is the 10m_coastline.shp
(http://www.naturalearthdata.com/). I imported the map to PostGIS.
Can anybody tell me where my mistake is?
Source Code:
import java.awt.RenderingHints;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.map.DefaultMapContext;
import org.geotools.map.MapContext;
import org.geotools.renderer.GTRenderer;
import org.geotools.renderer.lite.StreamingRenderer;
import org.geotools.swing.JMapFrame;
import org.geotools.swing.data.JFileDataStoreChooser;
/**
*
* @author Sven
*/
public class MyMap_1 {
private DataStore dataStore;
public static void main( String[] args ) throws Exception {
MyMap_1 myMap = new MyMap_1();
myMap.connectDB();
myMap.mapS();
}
private void connectDB() {
try {
Map params = new HashMap();
params.put("port", "5432");
params.put("Connection timeout", null);
params.put("passwd", "pw");
params.put("dbtype", "postgis");
params.put("host", "localhost");
params.put("validate connections", null);
params.put("max connections", null);
params.put("Primary key metadata table", null);
params.put("database", "db");
params.put("namespace", null);
params.put("schema", null);
params.put("Loose bbox", null);
params.put("Expose primary keys", null);
params.put("fetch size", null);
params.put("Max open prepared statements", null);
params.put("preparedStatements", null);
params.put("user", "postgres");
params.put("min connections", null);
dataStore = DataStoreFinder.getDataStore(params);
}
catch ( IOException ex ) {
ex.printStackTrace();
Logger.getLogger(MyMap.class.getName()).log(Level.SEVERE, null,
ex);
}
}
private void mapS() {
try {
SimpleFeatureSource sourcePostGIS =
dataStore.getFeatureSource("coastline");
MapContext map = new DefaultMapContext();
map.setTitle("Test Map");
// Add PostGis-Layer
map.addLayer(sourcePostGIS, null);
// Load and Add Shape-Layer
map.addLayer(loadSHP(), null);
GTRenderer renderer = new StreamingRenderer();
renderer.setContext(map);
RenderingHints hints = new
RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
renderer.setJava2DHints(hints);
Map renderingHints = new HashMap();
renderingHints.put(StreamingRenderer.ADVANCED_PROJECTION_HANDLING_KEY,
Boolean.TRUE);
renderingHints.put(StreamingRenderer.CONTINUOUS_MAP_WRAPPING,
Boolean.TRUE);
renderer.setRendererHints(renderingHints);
JMapFrame t = new JMapFrame(map, renderer);
t.enableToolBar(true);
t.enableStatusBar(true);
t.setSize(500, 400);
t.setVisible(true);
}
catch ( Exception e ) {
e.printStackTrace();
}
}
private SimpleFeatureSource loadSHP() {
try {
File file = JFileDataStoreChooser.showOpenFile("shp", null);
if ( file == null ) {
return null;
}
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureSource featureSource = store.getFeatureSource();
return featureSource;
}
catch ( Exception ex ) {
System.out.println("error in loadSHP");
return null;
}
}
}
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/continuous-map-with-PostGIS-datasource-tp5972460p5972460.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users