Revision 38328

View differences:

tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/gpe/GPELibraryExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

  
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2009 {Iver T.I.}   {Task}
26
*/
27
 
28
package org.gvsig.gpe;
29

  
30
import org.gvsig.andami.plugins.Extension;
31

  
32

  
33
/**
34
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
35
 */
36
public class GPELibraryExtension extends Extension{
37
//	private DALGPELibrary lib = null;
38
		
39
	/* (non-Javadoc)
40
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
41
	 */
42
	public void execute(String actionCommand) {
43
		// TODO Auto-generated method stub
44
		
45
	}
46

  
47
	/* (non-Javadoc)
48
	 * @see com.iver.andami.plugins.IExtension#initialize()
49
	 */
50
	public void initialize() {
51
//		lib = new DALGPELibrary();
52
//		lib.initialize();		
53
	}	
54

  
55
	/* (non-Javadoc)
56
	 * @see com.iver.andami.plugins.Extension#postInitialize()
57
	 */
58
	public void postInitialize() {
59
//		lib.postInitialize();		
60
	}
61

  
62
	/* (non-Javadoc)
63
	 * @see com.iver.andami.plugins.IExtension#isEnabled()
64
	 */
65
	public boolean isEnabled() {
66
		return false;
67
	}
68

  
69
	/* (non-Javadoc)
70
	 * @see com.iver.andami.plugins.IExtension#isVisible()
71
	 */
72
	public boolean isVisible() {
73
		return false;
74
	}
75

  
76
}
77

  
0 78

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/SurfaceWriteGml2Operation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.Geometry;
25
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
26
import org.gvsig.fmap.geom.operation.GeometryOperationException;
27
import org.gvsig.fmap.geom.primitive.Surface;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class SurfaceWriteGml2Operation extends WriteGml2Operation{
36
	
37
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
38
	    initializeParams(ctx);
39
        Surface surface = (Surface)geom;
40
        
41
        writerHandler.startPolygon(id, new OrientablePrimitiveCoordinateSequence(surface), srs);
42
        writerHandler.endPolygon();
43
        
44
        return null;
45
	}
46
}
0 47

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/PointWriteGml2Operation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.Geometry;
25
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
26
import org.gvsig.fmap.geom.operation.GeometryOperationException;
27
import org.gvsig.fmap.geom.primitive.Point;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class PointWriteGml2Operation extends WriteGml2Operation{
36
	
37
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
38
	    initializeParams(ctx);
39
		Point point = (Point)geom;
40
				
41
		writerHandler.startPoint(id, new PointCoordinatesSequence(point), srs);
42
		writerHandler.endPoint();
43
		
44
		return null;
45
	}
46
}
0 47

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/MultiCurveWriteGml2Operation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.Geometry;
25
import org.gvsig.fmap.geom.aggregate.MultiCurve;
26
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
27
import org.gvsig.fmap.geom.operation.GeometryOperationException;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class MultiCurveWriteGml2Operation extends WriteGml2Operation{
36
	
37
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
38
	    initializeParams(ctx);
39
        MultiCurve multiCurve = (MultiCurve)geom;
40
        
41
        writerHandler.startMultiLineString(id, srs);
42
        for (int i=0 ; i<multiCurve.getPrimitivesNumber() ; i++){
43
            writerHandler.startLineString(null, new OrientablePrimitiveCoordinateSequence(multiCurve.getCurveAt(i)), srs);
44
            writerHandler.endLineString();
45
        }        
46
        writerHandler.endMultiLineString();
47
        
48
        return null;
49
	}
50
}
0 51

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/PointCoordinatesSequence.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import java.io.IOException;
25

  
26
import org.gvsig.fmap.geom.primitive.Point;
27
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator;
28
import org.gvsig.gpe.lib.api.writer.ICoordinateSequence;
29

  
30

  
31
/**
32
 * @author gvSIG Team
33
 * @version $Id$
34
 *
35
 */
36
public class PointCoordinatesSequence implements ICoordinateSequence, ICoordinateIterator {
37
    private Point point = null; 
38
    private boolean hasNext = true;
39
    
40
    public PointCoordinatesSequence(Point point) {
41
        super();
42
        this.point = point;
43
    }
44

  
45
    public int getSize() {       
46
        return 1;
47
    }
48

  
49
    public ICoordinateIterator iterator() {
50
        return this;
51
    }
52

  
53
    public boolean hasNext() throws IOException {
54
        if (hasNext){
55
            hasNext = false;
56
            return true;
57
        }
58
        return false;
59
    }
60

  
61
    public int getDimension() {
62
        return point.getDimension();
63
    }
64

  
65
    public void next(double[] buffer) throws IOException {
66
        for (int i=0 ; i<point.getDimension() ; i++){  
67
            buffer[i] = point.getCoordinateAt(i);   
68
        }          
69
    }
70
}
0 71

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/WriteGml2Operation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.GeometryLocator;
25
import org.gvsig.fmap.geom.GeometryManager;
26
import org.gvsig.fmap.geom.operation.GeometryOperation;
27
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
28
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandler;
29

  
30

  
31
/**
32
 * @author gvSIG Team
33
 * @version $Id$
34
 *
35
 */
36
public abstract class WriteGml2Operation extends GeometryOperation {
37
    public static final String NAME = "writeGml2";
38
	protected static GeometryManager geomManager = GeometryLocator.getGeometryManager();
39
    public static final int CODE = geomManager.getGeometryOperationCode(NAME);	
40
	
41
    protected String id = null;
42
    protected IGPEWriterHandler writerHandler;
43
    protected String srs = null;
44
    
45
	public int getOperationIndex() {
46
		return CODE;
47
	}	
48
	
49
	protected void initializeParams(GeometryOperationContext geometryOperationContext){
50
	    writerHandler = (IGPEWriterHandler)geometryOperationContext.getAttribute(WriteGml2OperationContext.ATTRIBUTE_GPEWRITERHANDLER);
51
	    id = (String)geometryOperationContext.getAttribute(WriteGml2OperationContext.ATTRIBUTE_ID);
52
	    srs = (String)geometryOperationContext.getAttribute(WriteGml2OperationContext.ATTRIBUTE_SRS);
53
	}
54

  
55
}
0 56

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/OrientablePrimitiveCoordinateSequence.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import java.awt.geom.PathIterator;
25
import java.io.IOException;
26

  
27
import org.gvsig.fmap.geom.primitive.GeneralPathX;
28
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
29
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator;
30
import org.gvsig.gpe.lib.api.writer.ICoordinateSequence;
31

  
32

  
33
/**
34
 * @author gvSIG Team
35
 * @version $Id$
36
 *
37
 */
38
public class OrientablePrimitiveCoordinateSequence  implements ICoordinateSequence, ICoordinateIterator {
39
    private OrientablePrimitive orientablePrimitive; 
40
    private GeneralPathX generalPathX;
41
    private PathIterator pathIterator;  
42
        
43
    public OrientablePrimitiveCoordinateSequence(
44
        OrientablePrimitive orientablePrimitive) {
45
        super();
46
        this.orientablePrimitive = orientablePrimitive;
47
        this.generalPathX = orientablePrimitive.getGeneralPath();
48
        this.pathIterator = generalPathX.getPathIterator(null);
49
    }
50

  
51
    public boolean hasNext() throws IOException {
52
       return !pathIterator.isDone();
53
    }
54

  
55
    public int getDimension() {
56
        return orientablePrimitive.getDimension();
57
    }
58

  
59
    public void next(double[] buffer) throws IOException {        
60
        pathIterator.currentSegment(buffer);  
61
        pathIterator.next();   
62
    }
63

  
64
    public int getSize() {       
65
        return orientablePrimitive.getNumVertices();
66
    }
67

  
68
    public ICoordinateIterator iterator() {       
69
        return this;
70
    }
71

  
72
}
0 73

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/MultiSurfaceWriteGml2Operation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.Geometry;
25
import org.gvsig.fmap.geom.aggregate.MultiSurface;
26
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
27
import org.gvsig.fmap.geom.operation.GeometryOperationException;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class MultiSurfaceWriteGml2Operation extends WriteGml2Operation{
36
	
37
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
38
	    initializeParams(ctx);
39
        MultiSurface multiSurface = (MultiSurface)geom;
40
        
41
        writerHandler.startMultiPolygon(id, srs);
42
        for (int i=0 ; i<multiSurface.getPrimitivesNumber() ; i++){
43
            writerHandler.startPolygon(null, new OrientablePrimitiveCoordinateSequence(multiSurface.getSurfaceAt(i)), srs);
44
            writerHandler.endPolygon();
45
        }        
46
        writerHandler.endMultiPolygon();
47
        
48
        return null;
49
	}
50
}
0 51

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/CurveWriteGml2Operation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.Geometry;
25
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
26
import org.gvsig.fmap.geom.operation.GeometryOperationException;
27
import org.gvsig.fmap.geom.primitive.Curve;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class CurveWriteGml2Operation extends WriteGml2Operation{
36
	
37
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
38
	    initializeParams(ctx);
39
        Curve curve = (Curve)geom;
40
        
41
        writerHandler.startLineString(id, new OrientablePrimitiveCoordinateSequence(curve), srs);
42
        writerHandler.endLineString();
43
        
44
        return null;
45
	}
46
}
0 47

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/MultiPointWriteGml2Operation.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.Geometry;
25
import org.gvsig.fmap.geom.aggregate.MultiPoint;
26
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
27
import org.gvsig.fmap.geom.operation.GeometryOperationException;
28

  
29

  
30
/**
31
 * @author gvSIG Team
32
 * @version $Id$
33
 *
34
 */
35
public class MultiPointWriteGml2Operation extends WriteGml2Operation{
36
	
37
	public Object invoke(Geometry geom, GeometryOperationContext ctx) throws GeometryOperationException {
38
	    initializeParams(ctx);
39
        MultiPoint multiPoint = (MultiPoint)geom;
40
        
41
        writerHandler.startMultiPoint(id, srs);
42
        for (int i=0 ; i<multiPoint.getPrimitivesNumber() ; i++){
43
            writerHandler.startPoint(null, new PointCoordinatesSequence(multiPoint.getPointAt(i)), srs);
44
            writerHandler.endPoint();
45
        }        
46
        writerHandler.endMultiPoint();
47
        
48
        return null;
49
	}
50
}
0 51

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/geom/operation/writegml2/WriteGml2OperationContext.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.fmap.geom.operation.writegml2;
23

  
24
import org.gvsig.fmap.geom.operation.GeometryOperationContext;
25
import org.gvsig.gpe.lib.api.writer.IGPEWriterHandler;
26

  
27

  
28
/**
29
 * @author gvSIG Team
30
 * @version $Id$
31
 *
32
 */
33
public class WriteGml2OperationContext extends GeometryOperationContext {
34
	public static final String ATTRIBUTE_GPEWRITERHANDLER = "writerHandler";
35
	public static final String ATTRIBUTE_SRS = "srs";
36
    public static final String ATTRIBUTE_ID = "id";
37
    
38
    /**
39
     * @return the srs
40
     */
41
    public String getSrs() {
42
        return (String) super.getAttribute(ATTRIBUTE_SRS);
43
    }
44
    
45
    /**
46
     * @param srs the srs to set
47
     */
48
    public void setSrs(String srs) {
49
        this.setAttribute(ATTRIBUTE_SRS, srs);
50
    }   
51
    
52
    /**
53
     * @return the Id
54
     */
55
    public String getId() {
56
        return (String) super.getAttribute(ATTRIBUTE_ID);
57
    }
58
    
59
    /**
60
     * @param id the id to set
61
     */
62
    public void setId(String id) {
63
        this.setAttribute(ATTRIBUTE_ID, id);
64
    }   
65
    
66
    /**
67
     * @return the writerHandler
68
     */
69
    public IGPEWriterHandler getWriterHandler() {
70
        return (IGPEWriterHandler) super.getAttribute(ATTRIBUTE_GPEWRITERHANDLER);
71
    }
72
    
73
    /**
74
     * @param writerHandler the writerHandler to set
75
     */
76
    public void setWriterHandler(IGPEWriterHandler writerHandler) {
77
        this.setAttribute(ATTRIBUTE_GPEWRITERHANDLER, writerHandler);
78
    } 	
79
}
80

  
0 81

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPEStoreProvider.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.fmap.dal.store.gpe;
29

  
30
import java.io.File;
31
import java.util.Map;
32

  
33
import org.cresques.cts.IProjection;
34

  
35
import org.gvsig.fmap.dal.DALLocator;
36
import org.gvsig.fmap.dal.DataManager;
37
import org.gvsig.fmap.dal.DataServerExplorer;
38
import org.gvsig.fmap.dal.DataStoreParameters;
39
import org.gvsig.fmap.dal.DataTypes;
40
import org.gvsig.fmap.dal.FileHelper;
41
import org.gvsig.fmap.dal.exception.DataException;
42
import org.gvsig.fmap.dal.exception.InitializeException;
43
import org.gvsig.fmap.dal.exception.OpenException;
44
import org.gvsig.fmap.dal.exception.ReadException;
45
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
46
import org.gvsig.fmap.dal.feature.FeatureQuery;
47
import org.gvsig.fmap.dal.feature.FeatureType;
48
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider;
49
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
50
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
51
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
52
import org.gvsig.fmap.dal.resource.exception.ResourceExecuteException;
53
import org.gvsig.fmap.dal.resource.file.FileResource;
54
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
55
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
56
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
57
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
58
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
59
import org.gvsig.fmap.dal.store.gpe.handlers.FmapContentHandler;
60
import org.gvsig.fmap.dal.store.gpe.handlers.FmapErrorHandler;
61
import org.gvsig.fmap.geom.Geometry.TYPES;
62
import org.gvsig.fmap.geom.primitive.Envelope;
63
import org.gvsig.gpe.lib.api.GPELocator;
64
import org.gvsig.gpe.lib.api.GPEManager;
65
import org.gvsig.tools.dynobject.DynObject;
66
import org.gvsig.xmlschema.lib.api.XMLSchemaLocator;
67
import org.gvsig.xmlschema.lib.api.XMLSchemaManager;
68

  
69
/**
70
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
71
 */
72
public class GPEStoreProvider extends AbstractFeatureStoreProvider implements
73
ResourceConsumer {
74
    public static final String NAME = "GPE";
75
    public static final String DESCRIPTION = "GPE file";
76
    public static final String METADATA_DEFINITION_NAME = NAME;
77

  
78
    protected File m_Fich;
79
    protected boolean isOpen = false;
80
    //private GPEStoreParameters gpeParams;
81
    private ResourceProvider gpeResource;
82

  
83
    //Managers to manage the parsing process
84
    protected GPEManager gpeManager = null;
85
    protected XMLSchemaManager xmlSchemaManager = null;
86

  
87
    //The content handler and the error handler
88
    protected FmapContentHandler contentHandler;
89
    protected FmapErrorHandler errorHandler;
90

  
91
    public GPEStoreProvider(DataStoreParameters params,
92
        DataStoreProviderServices storeServices)
93
    throws InitializeException {
94
        this(params, storeServices, FileHelper
95
            .newMetadataContainer(METADATA_DEFINITION_NAME));
96
    }   
97

  
98
    protected GPEStoreProvider(DataStoreParameters params,
99
        DataStoreProviderServices storeServices, DynObject metadata)
100
    throws InitializeException {
101

  
102
        super(params, storeServices, metadata);
103

  
104
        this.setDynValue("Envelope", params.getDynValue("Envelope"));
105

  
106
        gpeManager = GPELocator.getGPEManager();
107
        xmlSchemaManager = XMLSchemaLocator.getXMLSchemaManager();		
108

  
109
        retrieveFile();
110
        gpeResource = this.createResource(FileResource.NAME,
111
            new Object[] { m_Fich.getAbsolutePath() });
112
        gpeResource.addConsumer(this);
113
        this.initFeatureType();
114
    }
115

  
116
    protected void retrieveFile() throws InitializeException{
117
        m_Fich = getGPEParameters().getFile();
118
    }
119

  
120
    protected void initFeatureType() throws InitializeException {
121
        try {
122

  
123
            this.open();
124
        } catch (DataException e) {
125
            throw new InitializeException(this.getProviderName(), e);
126
        }
127
    }
128

  
129
    private GPEStoreParameters getGPEParameters() {
130
        return (GPEStoreParameters) this.getParameters();
131
    }
132

  
133
    /* (non-Javadoc)
134
     * @see org.gvsig.fmap.dal.resource.spi.ResourceConsumer#closeResourceRequested(org.gvsig.fmap.dal.resource.spi.ResourceProvider)
135
     */
136
    public boolean closeResourceRequested(ResourceProvider resource) {
137
        // TODO Auto-generated method stub
138
        return false;
139
    }
140

  
141
    /* (non-Javadoc)
142
     * @see org.gvsig.fmap.dal.resource.spi.ResourceConsumer#resourceChanged(org.gvsig.fmap.dal.resource.spi.ResourceProvider)
143
     */
144
    public void resourceChanged(ResourceProvider resource) {
145
        // TODO Auto-generated method stub
146

  
147
    }
148

  
149
    /* (non-Javadoc)
150
     * @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#canWriteGeometry(int)
151
     */
152
    public boolean canWriteGeometry(int geometryType, int geometrySubtype)
153
    throws DataException {
154
        // TODO Auto-generated method stub
155
        return false;
156
    }
157

  
158
    /* (non-Javadoc)
159
     * @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createNewOID()
160
     */
161
    public Object createNewOID() {
162
        return contentHandler.createNewOID();
163
    }
164

  
165
    /* (non-Javadoc)
166
     * @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createSet(org.gvsig.fmap.dal.feature.FeatureQuery)
167
     */
168
    public FeatureSetProvider createSet(FeatureQuery query)
169
    throws DataException {
170
        return new GPESetProvider(this, query);
171
    }
172

  
173
    protected FeatureProvider internalGetFeatureProviderByReference(
174
        FeatureReferenceProviderServices reference) throws DataException {
175
        return internalGetFeatureProviderByReference(reference,
176
            this
177
            .getFeatureStore()
178
            .getDefaultFeatureType());
179
    }
180

  
181
    public FeatureProvider internalGetFeatureProviderByReference(
182
        FeatureReferenceProviderServices reference, FeatureType featureType)
183
    throws DataException {
184
        Map featureSet = contentHandler.getFeatureSet();
185
        if (featureSet.containsKey(reference.getOID())){
186
            return (FeatureProvider)featureSet.get(reference.getOID());
187
        }
188
        return null;
189
    }
190

  
191
    FeatureProvider getFeatureProviderByIndex(Long index, FeatureType fType)
192
    throws DataException {
193
        Map featureSet = contentHandler.getFeatureSet();
194
        if (featureSet.containsKey(index)){
195
            return (FeatureProvider)featureSet.get(index);
196
        }        
197
        return null;
198
    }
199

  
200
    public void resourcesBegin() throws ResourceExecuteException {
201
        // Nothing to do
202
    }
203

  
204
    public void resourcesEnd() {
205
        // Nothing to do
206
    }
207

  
208
    /* (non-Javadoc)
209
     * @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#getFeatureReferenceOIDType()
210
     */
211
    public int getOIDType() {
212
        return DataTypes.STRING;
213
    }
214

  
215
    /* (non-Javadoc)
216
     * @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#getName()
217
     */
218
    public String getProviderName() {
219
        return NAME;
220
    }
221

  
222
    /* (non-Javadoc)
223
     * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getSourceId()
224
     */
225
    public Object getSourceId() {
226
        return getGPEParameters().getFile();
227
    }
228

  
229
    public String getName() {
230
        String name = this.getGPEParameters().getFile().getName();
231
        int n = name.lastIndexOf(".");
232
        if( n<1 ) {
233
            return name;
234
        }
235
        return name.substring(0, n);
236
    }
237

  
238
    public String getFullName() {
239
        return this.getGPEParameters().getFile().getAbsolutePath();
240
    }
241

  
242
    /* (non-Javadoc)
243
     * @see org.gvsig.fmap.dal.spi.DataStoreProvider#open()
244
     */
245
    public void open() throws OpenException {
246
        if (isOpen) {
247
            return;
248
        }
249
        try {
250
            errorHandler = new FmapErrorHandler();
251
            contentHandler = new FmapContentHandler(errorHandler,
252
                getStoreServices(), this, m_Fich,
253
                getSRS(),
254
                getGeometryType());
255
            if (getStoreServices().getDefaultFeatureType() != null){
256
                contentHandler.setFeatureType(getStoreServices().getDefaultFeatureType().getEditable());
257
            }
258
            contentHandler.setEnvelope((Envelope)getDynValue("Envelope"));
259
            isOpen = true;
260
            gpeManager.parse(contentHandler, errorHandler, m_Fich.toURI());			
261
        } catch (Exception e) {
262
            throw new OpenException("Imposible create a parser",e);
263
        }
264
    }
265

  
266
    protected IProjection getSRS(){
267
        return getGPEParameters().getCRS();
268
    }	
269

  
270
    protected int getGeometryType() {
271
        return TYPES.GEOMETRY;
272
    }
273

  
274
    /* (non-Javadoc)
275
     * @see org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider#createSet(org.gvsig.fmap.dal.feature.FeatureQuery, org.gvsig.fmap.dal.feature.FeatureType)
276
     */
277
    public FeatureSetProvider createSet(FeatureQuery query,
278
        FeatureType featureType) throws DataException {
279
        return new GPESetProvider(this, query, featureType);
280
    }
281

  
282
    public long getFeatureCount() throws DataException {		
283
        return contentHandler.getFeaturesCount();
284
    }
285

  
286
    /* (non-Javadoc)
287
     * @see org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider#getEnvelope()
288
     */
289
    public Envelope getEnvelope() throws DataException {
290
        this.open();
291
        return (Envelope) this.getDynValue("Envelope");
292
    }
293

  
294
    public void setEnvelope(Envelope envelope) {
295
        this.setDynValue("Envelope", envelope);
296
    }
297

  
298
    public ResourceProvider getResource() {
299
        return gpeResource;
300
    }
301

  
302
    public DataServerExplorer getExplorer() throws ReadException,
303
    ValidateDataParametersException {
304
        DataManager manager = DALLocator.getDataManager();
305
        FilesystemServerExplorerParameters params;
306
        try {
307
            params = (FilesystemServerExplorerParameters) manager
308
            .createServerExplorerParameters(FilesystemServerExplorer.NAME);
309
            params.setRoot(this.getGPEParameters().getFile().getParent());
310
            return manager.createServerExplorer(params);
311
        } catch (DataException e) {
312
            throw new ReadException(this.getProviderName(), e);
313
        } catch (ValidateDataParametersException e) {
314
            // TODO Auto-generated catch block
315
            throw new ReadException(this.getProviderName(), e);
316
        }
317
    }
318

  
319
    /**
320
     * @return the contentHandler
321
     */
322
    public FmapContentHandler getContentHandler() {
323
        return contentHandler;
324
    }
325

  
326
    /**
327
     * @return the errorHandler
328
     */
329
    public FmapErrorHandler getErrorHandler() {
330
        return errorHandler;
331
    }
332

  
333
}
0 334

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/GPEStoreParameters.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.fmap.dal.store.gpe;
29

  
30
import java.io.File;
31

  
32
import org.cresques.cts.IProjection;
33

  
34
import org.gvsig.fmap.dal.DataStoreParameters;
35
import org.gvsig.fmap.dal.FileHelper;
36
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
37
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
38
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
39
import org.gvsig.fmap.geom.primitive.Envelope;
40
import org.gvsig.tools.dynobject.DelegatedDynObject;
41
import org.gvsig.tools.dynobject.DynStruct;
42

  
43
/**
44
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
45
 */
46
public class GPEStoreParameters extends AbstractDataParameters implements
47
DataStoreParameters, FilesystemStoreParameters {
48

  
49
    public static final String PARAMETERS_DEFINITION_NAME = "GPEStoreParameters";
50

  
51
    private static final String FILE_PARAMETER_NAME = "File";
52
    private static final String CRS_PARAMETER_NAME = "CRS";
53
    private static final String ENVELOPE_PARAMETER_NAME = "Envelope";
54

  
55
    private DelegatedDynObject parameters;
56

  
57
    public GPEStoreParameters() {
58
        this(PARAMETERS_DEFINITION_NAME);
59
    }
60

  
61
    protected GPEStoreParameters(String parametersDefinitionName) {
62
        this(parametersDefinitionName, GPEStoreProvider.NAME);
63
    }
64

  
65
    public GPEStoreParameters(String parametersDefinitionName, String name) {
66
        super();
67
        this.parameters = (DelegatedDynObject) FileHelper.newParameters(parametersDefinitionName);
68
        this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, name);       
69
    }
70

  
71
    protected static void registerParametersDefinition(){ 
72
        DynStruct dynStruct = FileHelper.registerParametersDefinition(
73
            GPEStoreParameters.PARAMETERS_DEFINITION_NAME,
74
            GPEStoreParameters.class, "GPEParameters.xml");
75
        dynStruct.addDynFieldObject("Envelope").setClassOfValue(Envelope.class).setMandatory(false);
76
    }
77

  
78
    protected DelegatedDynObject getDelegatedDynObject() {
79
        return parameters;
80
    }
81

  
82
    public String getDataStoreName() {
83
        return GPEStoreProvider.NAME;
84
    }
85

  
86
    public String getDescription() {
87
        return GPEStoreProvider.DESCRIPTION;
88
    }
89

  
90
    public boolean isValid() {
91
        return (this.getFile() != null);
92
    }
93

  
94
    public File getFile() {
95
        return (File) this.getDynValue(FILE_PARAMETER_NAME);
96
    }
97

  
98
    public void setFile(File file) {
99
        this.setDynValue(FILE_PARAMETER_NAME, file);
100
    }	
101

  
102
    public String getFileName() {
103
        return this.getFile().getAbsolutePath();
104
    }
105

  
106
    public void setFileName(String fileName) {
107
        this.setDynValue(FILE_PARAMETER_NAME, fileName);
108
    }
109

  
110
    public IProjection getCRS() {
111
        return (IProjection) this.getDynValue(CRS_PARAMETER_NAME);
112
    }
113

  
114
    public void setCRS(IProjection srs) {
115
        this.setDynValue(CRS_PARAMETER_NAME, srs);
116
    }
117

  
118
    public void setCRS(String srs) {
119
        this.setDynValue(CRS_PARAMETER_NAME, srs);
120
    }
121

  
122
    public Envelope getEnvelope() {
123
        return (Envelope) this.getDynValue(ENVELOPE_PARAMETER_NAME);
124
    }
125

  
126
    public void setEnvelope(Envelope envelope) {
127
        this.setDynValue(ENVELOPE_PARAMETER_NAME, envelope);
128
    }
129
}
0 130

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/handlers/FmapErrorHandler.java
1
package org.gvsig.fmap.dal.store.gpe.handlers;
2

  
3
import org.gvsig.gpe.lib.impl.parser.GPEErrorHandler;
4

  
5
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6
 *
7
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
22
 *
23
 * For more information, contact:
24
 *
25
 *  Generalitat Valenciana
26
 *   Conselleria d'Infraestructures i Transport
27
 *   Av. Blasco Ib??ez, 50
28
 *   46010 VALENCIA
29
 *   SPAIN
30
 *
31
 *      +34 963862235
32
 *   gvsig@gva.es
33
 *      www.gvsig.gva.es
34
 *
35
 *    or
36
 *
37
 *   IVER T.I. S.A
38
 *   Salamanca 50
39
 *   46005 Valencia
40
 *   Spain
41
 *
42
 *   +34 963163400
43
 *   dac@iver.es
44
 */
45
/* CVS MESSAGES:
46
 *
47
 * $Id$
48
 * $Log$
49
 *
50
 */
51
/**
52
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
53
 */
54
public class FmapErrorHandler extends GPEErrorHandler{
55

  
56
}
0 57

  
tags/v2_0_0_Build_2047/extensions/extGPE-gvSIG/extGPE-gvSIG/src/org/gvsig/fmap/dal/store/gpe/handlers/FmapContentHandler.java
1
package org.gvsig.fmap.dal.store.gpe.handlers;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.util.ArrayList;
6
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.List;
9
import java.util.Map;
10

  
11
import org.cresques.cts.IProjection;
12
import org.jfree.util.Log;
13
import org.slf4j.Logger;
14
import org.slf4j.LoggerFactory;
15

  
16
import org.gvsig.fmap.dal.DataTypes;
17
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
18
import org.gvsig.fmap.dal.feature.EditableFeatureType;
19
import org.gvsig.fmap.dal.feature.Feature;
20
import org.gvsig.fmap.dal.feature.FeatureType;
21
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider;
22
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
23
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
24
import org.gvsig.fmap.dal.store.gpe.GPEStoreProvider;
25
import org.gvsig.fmap.dal.store.gpe.model.GPEElement;
26
import org.gvsig.fmap.dal.store.gpe.model.GPEFeature;
27
import org.gvsig.fmap.geom.Geometry;
28
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
29
import org.gvsig.fmap.geom.Geometry.TYPES;
30
import org.gvsig.fmap.geom.GeometryLocator;
31
import org.gvsig.fmap.geom.GeometryManager;
32
import org.gvsig.fmap.geom.aggregate.MultiCurve;
33
import org.gvsig.fmap.geom.aggregate.MultiPoint;
34
import org.gvsig.fmap.geom.aggregate.MultiPrimitive;
35
import org.gvsig.fmap.geom.aggregate.MultiSurface;
36
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
37
import org.gvsig.fmap.geom.exception.CreateGeometryException;
38
import org.gvsig.fmap.geom.primitive.Curve;
39
import org.gvsig.fmap.geom.primitive.Envelope;
40
import org.gvsig.fmap.geom.primitive.GeneralPathX;
41
import org.gvsig.fmap.geom.primitive.Point;
42
import org.gvsig.fmap.geom.primitive.Primitive;
43
import org.gvsig.fmap.geom.primitive.Surface;
44
import org.gvsig.gpe.lib.api.parser.IAttributesIterator;
45
import org.gvsig.gpe.lib.api.parser.ICoordinateIterator;
46
import org.gvsig.gpe.lib.api.parser.IGPEErrorHandler;
47
import org.gvsig.gpe.lib.impl.parser.GPEContentHandler;
48
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
49
 *
50
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
51
 *
52
 * This program is free software; you can redistribute it and/or
53
 * modify it under the terms of the GNU General Public License
54
 * as published by the Free Software Foundation; either version 2
55
 * of the License, or (at your option) any later version.
56
 *
57
 * This program is distributed in the hope that it will be useful,
58
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
59
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
60
 * GNU General Public License for more details.
61
 *
62
 * You should have received a copy of the GNU General Public License
63
 * along with this program; if not, write to the Free Software
64
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
65
 *
66
 * For more information, contact:
67
 *
68
 *  Generalitat Valenciana
69
 *   Conselleria d'Infraestructures i Transport
70
 *   Av. Blasco Ib??ez, 50
71
 *   46010 VALENCIA
72
 *   SPAIN
73
 *
74
 *      +34 963862235
75
 *   gvsig@gva.es
76
 *      www.gvsig.gva.es
77
 *
78
 *    or
79
 *
80
 *   IVER T.I. S.A
81
 *   Salamanca 50
82
 *   46005 Valencia
83
 *   Spain
84
 *
85
 *   +34 963163400
86
 *   dac@iver.es
87
 */
88
/* CVS MESSAGES:
89
 *
90
 * $Id$
91
 * $Log$
92
 *
93
 */
94
/**
95
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
96
 */
97
public class FmapContentHandler extends GPEContentHandler {
98
    private static final Logger LOG = LoggerFactory.getLogger(FmapContentHandler.class);
99

  
100
    private HashMap featureSet = null;
101
    private EditableFeatureType featureType = null;
102
    private FeatureStoreProviderServices store = null;
103
    private GPEStoreProvider storeProvider = null;
104
    private GeometryManager geomManager = GeometryLocator.getGeometryManager();
105
    private int featureId = 0;
106
    private Envelope envelope = null;
107
    private File file = null;
108
    private IProjection srs = null;
109
    private int geometryType = 0;
110

  
111
    public FmapContentHandler(IGPEErrorHandler errorHandler, FeatureStoreProviderServices store,
112
        GPEStoreProvider storeProvider, File file, IProjection srs, int geometryType) {
113
        super();
114
        setErrorHandler(errorHandler);
115
        this.store = store;
116
        this.storeProvider = storeProvider;
117
        this.file = file;
118
        this.srs = srs;
119
        this.geometryType = geometryType;
120
    }
121

  
122
    public int getFeaturesCount(){
123
        return featureSet.size();
124
    }
125

  
126
    public Feature getFeatureAt(int index){
127
        return (Feature)featureSet.get(new Integer(index));
128
    }
129

  
130
    public EditableFeatureType getFeatureType(){
131
        return featureType;
132
    }
133

  
134

  
135
    /**
136
     * @return the featureSet
137
     */
138
    public HashMap getFeatureSet() {
139
        return featureSet;
140
    }
141

  
142
    /*
143
     * (non-Javadoc)
144
     * @see org.gvsig.gpe.parser.GPEContentHandler#startLayer(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.gvsig.gpe.parser.IAttributesIterator, java.lang.Object, java.lang.Object)
145
     */
146
    public Object startLayer(String id, String namespace, String name,
147
        String description, String srs, IAttributesIterator iterator, Object parentLayer, Object box) {
148
        if (featureSet == null){
149
            featureSet = new HashMap();
150
        }
151
        if (envelope == null){
152
            try {
153
                envelope = geomManager.createEnvelope(SUBTYPES.GEOM2D);
154
            } catch (CreateEnvelopeException e) {
155
                Log.error("Error creating the envelope", e);
156
            }
157
        }
158
        return featureSet;
159
    }
160

  
161
    /*
162
     * (non-Javadoc)
163
     * @see org.gvsig.gpe.IGPEContentHandler#endLayer(java.lang.Object)
164
     */
165
    public void endLayer(Object layer) {
166
        if (featureType == null){
167
            createFeatureType(null);
168
        }
169
        storeProvider.setEnvelope(envelope);
170
    }
171

  
172
    /*
173
     * (non-Javadoc)
174
     * @see org.gvsig.gpe.parser.GPEContentHandler#startPoint(java.lang.String, org.gvsig.gpe.parser.ICoordinateIterator, java.lang.String)
175
     */
176
    public Object startPoint(String id, ICoordinateIterator coords, String srs) {
177
        return createPoint(coords);
178
    }
179

  
180
    private Point createPoint(ICoordinateIterator coords){
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff