[Gvsig_english] Work with geometry
erwan bocher
erwan.bocher at gmail.com
Mon Mar 13 08:45:37 CET 2006
Hi,
A bridge with gvSIG and JUMP it's a powerful idea. We'll be able to
integrate OpenJUMP plugins in gvSIG. I test your method. I'd like to
compile a small document to learn how to develop with gvsig.
Happy to receive gvsig team in Rennes.
Best regards.
R1.
On 3/12/06, Fran Peñarrubia <fpenarru at iver.es> wrote:
>
> Hi Erwan.
>
> I've been watching your tests. Keep going on, they are good and simple
> examples.
>
> About using OpenJump, there are several ways to do that. And it's a good
> exercise to do a bridge between both projects.
>
> Anyway, gvSIG will have a good geoprocessing set of tools in one month or
> so, we hope. Until then, here you are how can be done:
>
> You can do a driver around a FeatureDataSet (wrap it) and operate with
> this FeatureDataSet. gvSIG will work with this new layer like the other
> ones (I didn't try it, but with some little modifications, it should do).
>
> I attach the JumpDriver class, and this is how you can test it:
>
> JumpDriver jumpDriver = new JumpDriver();
> FeatureSchema featureSchema = new FeatureSchema();
> featureSchema.addAttribute("GEOMETRY", AttributeType.GEOMETRY);
>
> FeatureDataset fc = new FeatureDataset(featureSchema);
>
> jumpDriver.setFeatureDataSet(fc);
> FLayer lJump = LayerFactory.createLayer("JumpLayer",
> jumpDriver,ProjectionPool.get("EPSG:23030"));
> mapContext.getLayers().addLayer(lJump);
>
> You will need to do some mapping to avoid return the geometry field.
>
> About SQL language and/or scripting in gvSIG, we can talk in detail in a
> few days :-).
>
> Have fun, and let me know if you can "connect" Jump and gvSIG.
>
> PS: I paste the JumpDriver.java here to avoid problems with antivirus and
> so on:
>
> package jumpBridge;
>
> import java.awt.geom.Rectangle2D;
> import java.io.IOException;
> import java.sql.Types;
> import java.util.Date;
>
> import com.hardcode.gdbms.engine.data.DataSourceFactory;
> import com.hardcode.gdbms.engine.data.driver.DriverException;
> import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
> import com.hardcode.gdbms.engine.data.edition.DataWare;
> import com.hardcode.gdbms.engine.values.Value;
> import com.hardcode.gdbms.engine.values.ValueFactory;
> import com.iver.cit.gvsig.fmap.core.FShape;
> import com.iver.cit.gvsig.fmap.core.IGeometry;
> import com.iver.cit.gvsig.fmap.core.v02.FConverter;
> import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
> import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
> import com.vividsolutions.jump.feature.AttributeType;
> import com.vividsolutions.jump.feature.Feature;
> import com.vividsolutions.jump.feature.FeatureDataset;
>
> public class JumpDriver implements VectorialDriver, ObjectDriver {
>
> private FeatureDataset featDataSet = null;
> public int getShapeType() {
> return FShape.MULTI;
> }
>
> public int getShapeCount() throws IOException {
> return featDataSet.size();
> }
>
> public DriverAttributes getDriverAttributes() {
> return null;
> }
>
> public Rectangle2D getFullExtent() throws IOException {
> return FConverter.convertEnvelopeToRectangle2D(
> featDataSet.getEnvelope());
> }
>
> public IGeometry getShape(int index) throws IOException {
> Feature feat = featDataSet.getFeature(index);
> return FConverter.jts_to_igeometry(feat.getGeometry());
> }
>
> public void reLoad() throws IOException {
> // TODO Auto-generated method stub
>
> }
>
> public String getName() {
> return "JUMP Driver to gvSIG";
> }
>
> public int[] getPrimaryKeys() throws DriverException {
> // TODO Auto-generated method stub
> return null;
> }
>
> public void write(DataWare dataWare) throws DriverException {
> // TODO Auto-generated method stub
>
> }
>
> public void setDataSourceFactory(DataSourceFactory dsf) {
> // TODO Auto-generated method stub
>
> }
>
> public Value getFieldValue(long rowIndex, int fieldId) throws
> DriverException {
> Feature feat = featDataSet.getFeature((int) rowIndex);
> Object att = feat.getAttribute(fieldId);
> Value val = ValueFactory.createNullValue();
> if (att instanceof Integer)
> val = ValueFactory.createValue
> (((Integer)att).intValue());
> if (att instanceof Double)
> val = ValueFactory.createValue
> (((Double)att).doubleValue());
> if (att instanceof Date)
> val = ValueFactory.createValue((Date)att);
> if (att instanceof String)
> val = ValueFactory.createValue((String)att);
>
> return val;
> }
>
> public int getFieldCount() throws DriverException {
> return featDataSet.getFeatureSchema().getAttributeCount();
> }
>
> public String getFieldName(int fieldId) throws DriverException {
> //TODO: Un mapping entre los campos reales y otros
> excluyendo el de tipo
> Geometry
> // para que no aparezca en la tabla
> return featDataSet.getFeatureSchema
> ().getAttributeName(fieldId);
> }
>
> public long getRowCount() throws DriverException {
> return featDataSet.size();
> }
>
> public int getFieldType(int i) throws DriverException {
> AttributeType attType = featDataSet.getFeatureSchema
> ().getAttributeType(i);
> if (attType.toString().equals("INTEGER"))
> return Types.INTEGER;
> if (attType.toString().equals("DOUBLE"))
> return Types.DOUBLE;
> if (attType.toString().equals("DATE"))
> return Types.DATE;
> if (attType.toString().equals("STRING"))
> return Types.VARCHAR;
>
>
> return 0;
> }
>
> public FeatureDataset getFeatureDataSet() {
> return featDataSet;
> }
>
> public void setFeatureDataSet(FeatureDataset featDataSet) {
> this.featDataSet = featDataSet;
> }
>
> }
>
>
> -----Original Message-----
> From: "erwan bocher" <erwan.bocher at gmail.com>
> To: gvsig_internacional at runas.cap.gva.es
> Date: Sun, 12 Mar 2006 14:50:50 +0100
> Subject: [Gvsig_english] Work with geometry
>
> > Hola,
> >
> > I tried to integrate OpenJUMP -Viatoris- geoprocessing menu in gvSIG.
> > First
> > I have create small examples functionalities :
> > list layers
> > list fields layer
> > add shape layer...
> >
> > Now, I'd like to work with geometry. Based on example send by Francisco
> > José
> > Peñarrubia I used JTS library for spatial processing but I don't know
> > how to
> > transform my geometries in a Flayer in gvSIG.
> > To compare in OpenJUMP. My geometry is stored in a feature storing in a
> > featurecollection.
> >
> > If I want to convert a polygon layer to a linearRing layer I use this
> > method
> > :
> >
> > FeatureCollection fc = layer.getFeatureCollectionWrapper(); //layer is
> > the
> > layer selected in OJ
> > FeatureSchema fs = fc.getFeatureSchema(); // Pienso que es el modelo en
> > Fmap
> > ?
> > FeatureCollection resultfc = new FeatureDataset(fc.getFeatureSchema());
> > //The new featureCollection
> >
> > Feature feat;
> >
> > for (Iterator it = fc.iterator(); it.hasNext();){
> > feat = (Feature)it.next(); //feat of layer selected in OJ
> > Geometry geom = feat.getGeometry(); //geometry of feat
> >
> > for (int i = 0; i < feat.getGeometry().getNumGeometries(); i++) { //If
> > they
> > are more than two object in feat
> > Feature newFeat = new BasicFeature(fs);//The new feature
> > FeatureUtil.copyAttributes(feat, newFeat);//Mapping attributes
> > newFeat.setGeometry(geom.getBoundary());//New geometry creation
> > resultfc.add(newFeat);// add new feature in the new featureCollection
> >
> > }
> > }
> > context.getLayerManager().addLayer("Convert",layer.getName()
> > +"_LinearRing"
> > , resultfc);
> > // Add the new featureCollection as a layer in OpenJUMP. The name of
> > the new
> > layer = source layer name + _LinearRing
> >
> >
> > So my questions is:
> >
> > Is it possible to present a method to realise identic work with FMap ?
> >
> >
> > Moreover I'm interested to use GDBMS to create a spatial SQL language
> > as
> > existing in PostGIS but using layers load in gvSIG. However gvSIG works
> > with
> > GDBMS-0.8-SNAPSHOT. Is it planned to integrate the last GDBMS (GDBMS
> > 1.0) ?
> >
> > In attached file you can find my gvSIG examples.
> >
> > Best regards
> >
> > R1.
> >
>
>
> _______________________________________________
> Gvsig_internacional mailing list
> Gvsig_internacional at runas.cap.gva.es
> http://runas.cap.gva.es/mailman/listinfo/gvsig_internacional
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://runas.cap.gva.es/pipermail/gvsig_internacional/attachments/20060313/286073c0/attachment-0001.htm
More information about the Gvsig_internacional
mailing list