15 |
15 |
|
16 |
16 |
import com.iver.cit.gvsig.fmap.DriverException;
|
17 |
17 |
import com.iver.cit.gvsig.fmap.core.FShape;
|
18 |
|
import com.iver.cit.gvsig.fmap.core.IGeometry;
|
19 |
18 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
|
20 |
|
import com.iver.cit.gvsig.fmap.drivers.jdbc.postgis.PostGisDriver;
|
|
19 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
|
21 |
20 |
import com.iver.cit.gvsig.fmap.drivers.raster.CmsRasterDriver;
|
22 |
21 |
import com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver;
|
23 |
22 |
import com.iver.cit.gvsig.fmap.layers.FLayer;
|
24 |
23 |
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
|
25 |
24 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
|
|
25 |
import com.iver.cit.gvsig.fmap.layers.ISpatialDB;
|
26 |
26 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
|
27 |
27 |
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter;
|
28 |
28 |
import com.iver.cit.gvsig.fmap.rendering.Legend;
|
... | ... | |
76 |
76 |
*
|
77 |
77 |
* $Id$
|
78 |
78 |
* $Log$
|
79 |
|
* Revision 1.2 2006-09-08 09:27:34 jorpiell
|
|
79 |
* Revision 1.3 2006-09-08 10:50:05 jorpiell
|
|
80 |
* A?adida la opci?n de generar una capa POSTGIS
|
|
81 |
*
|
|
82 |
* Revision 1.2 2006/09/08 09:27:34 jorpiell
|
80 |
83 |
* A?adida la exportaci?n de postgis
|
81 |
84 |
*
|
82 |
85 |
* Revision 1.1 2006/09/08 08:58:53 jorpiell
|
... | ... | |
102 |
105 |
if (lyrVect.getSource().getDriver() instanceof IndexedShpDriver){
|
103 |
106 |
mapLayer = new MapServer.ShpLayer();
|
104 |
107 |
initShpLayer(lyrVect,mapLayer);
|
105 |
|
}else if(lyrVect.getSource().getDriver() instanceof PostGisDriver){
|
|
108 |
}else if(lyrVect.getSource() instanceof ISpatialDB){
|
106 |
109 |
mapLayer = new MapServer.PostgisLayer();
|
107 |
110 |
initPostgisLayer(lyrVect,
|
108 |
111 |
(PostgisLayer)mapLayer);
|
... | ... | |
178 |
181 |
}
|
179 |
182 |
|
180 |
183 |
private void initPostgisLayer(FLyrVect lyrVect,MapServer.PostgisLayer mapLayer) throws LayerException{
|
181 |
|
PostGisDriver driver = (PostGisDriver)lyrVect.getSource().getDriver();
|
182 |
|
mapLayer.type = getPostgisLayerType(driver);
|
|
184 |
DBLayerDefinition layerDef =((ISpatialDB)lyrVect.getSource()).getLyrDef();
|
|
185 |
mapLayer.type = getShpType(layerDef.getShapeType());
|
183 |
186 |
try {
|
184 |
|
mapLayer.data = "the_geom from " + getLayerName(lyrVect.getName());
|
185 |
|
String user = driver.getConnection().getMetaData().getUserName();
|
186 |
|
String pass = "";
|
187 |
|
String host = getPostgisHost(driver.getConnection().getMetaData().getURL());
|
188 |
|
String dbname = driver.getConnection().getCatalog();
|
189 |
|
String port = getPostgisPort(driver.getConnection().getMetaData().getURL());
|
|
187 |
mapLayer.data = layerDef.getFieldGeometry() + " from " + getLayerName(lyrVect.getName());
|
|
188 |
String user = layerDef.getConnection().getMetaData().getUserName();
|
|
189 |
String pass = null;
|
|
190 |
String host = getPostgisHost(layerDef.getConnection().getMetaData().getURL());
|
|
191 |
String dbname = layerDef.getConnection().getCatalog();
|
|
192 |
String port = getPostgisPort(layerDef.getConnection().getMetaData().getURL());
|
190 |
193 |
mapLayer.setConnParams(user, pass, host, dbname, port);
|
191 |
194 |
} catch (SQLException e) {
|
192 |
195 |
throw new LayerException(LayerException.EXC_NO_POSTGIS_PARAMS,e.getMessage());
|
... | ... | |
226 |
229 |
//jdbc:postgresql://sercartlin:5432/carto_300k
|
227 |
230 |
String[] s = url.split(":");
|
228 |
231 |
return s[3].split("/")[0];
|
229 |
|
}
|
230 |
|
|
231 |
|
private String getPostgisLayerType(PostGisDriver driver) throws LayerException{
|
232 |
|
try {
|
233 |
|
return getShpType(driver.getShapeType());
|
234 |
|
} catch (Exception e) {
|
235 |
|
throw new LayerException(LayerException.EXC_POSTGIS_DRIVER,e.getMessage());
|
236 |
|
}
|
237 |
|
}
|
|
232 |
}
|
238 |
233 |
|
239 |
234 |
/**
|
240 |
235 |
* Gets the geometry type from a shape
|