Revision 35619

View differences:

branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/DefaultCADTool.java
711 711
		// TODO Auto-generated method stub
712 712

  
713 713
	}
714
	
715
	/**
716
     * Create a curve. If there is an
717
     * error return <code>null</code> and add the error
718
     * to the log     
719
     * @return
720
     * The Curve
721
     */
722
    protected Curve createCurve(){      
723
        try {
724
            return (Curve)geomManager.create(TYPES.CURVE, getSubType());           
725
        } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
726
            LOG.error("Error creating curve", new CreateGeometryException(
727
                TYPES.CURVE, getSubType(), e));
728
        }
729
        return null;
730
    }
714 731

  
715 732
	/**
716 733
	 * Create a curve from a GeneralPath. If there is an
......
734 751
	}
735 752

  
736 753
	/**
754
     * Create a surface. If there is an
755
     * error return <code>null</code> and add the error
756
     * to the log    
757
     * @return
758
     * The Surface
759
     */
760
    protected Surface createSurface(){      
761
        try {
762
            return (Surface)geomManager.create(TYPES.SURFACE, getSubType());
763
         
764
        } catch (org.gvsig.fmap.geom.exception.CreateGeometryException e) {
765
            LOG.error("Error creating surface", new CreateGeometryException(
766
                TYPES.SURFACE, getSubType(),
767
                e));
768
        }
769
        return null;
770
    }
771
    
772
	/**
737 773
	 * Create a surface from a GeneralPath. If there is an
738 774
	 * error return <code>null</code> and add the error
739 775
	 * to the log
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/PolylineCADTool.java
129 129
		}
130 130

  
131 131
        Geometry newGeom = null;
132
        int type=getCadToolAdapter().getActiveLayerType();
133
        if (type==Geometry.TYPES.SURFACE){
134
        	newGeom = createSurface(gpx);
132
        int type = getCadToolAdapter().getActiveLayerType();
133
        if ((type == Geometry.TYPES.SURFACE) || (type == Geometry.TYPES.MULTISURFACE)){
134
          	newGeom = createSurface(gpx);
135 135
        }else{
136 136
        	newGeom = createCurve(gpx);
137 137
        }
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/RectangleCADTool.java
56 56
import org.gvsig.fmap.geom.operation.GeometryOperationException;
57 57
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
58 58
import org.gvsig.fmap.geom.primitive.GeneralPathX;
59
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
59 60
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
60 61

  
61 62

  
......
82 83
     * carga previa a la utilizaci?n de la herramienta.
83 84
     */
84 85
    public void init() {
85
    	_fsm = new RectangleCADToolContext(this);
86
        _fsm = new RectangleCADToolContext(this);
86 87
    }
87 88

  
88 89
    /* (non-Javadoc)
......
103 104
     * @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
104 105
     */
105 106
    public void transition(String s) throws CommandException {
106
    	if (!super.changeCommand(s)){
107
    		_fsm.addOption(s);
108
    	}
107
        if (!super.changeCommand(s)){
108
            _fsm.addOption(s);
109
        }
109 110
    }
110 111

  
111 112
    /**
......
126 127
        } else if (status == "Rectangle.SecondPointOrSquare") {
127 128
            lastPoint = new Point2D.Double(x, y);
128 129

  
129
            GeneralPathX elShape = new GeneralPathX();
130
            elShape.moveTo(firstPoint.getX(), firstPoint.getY());
131
            elShape.lineTo(lastPoint.getX(), firstPoint.getY());
132
            elShape.lineTo(lastPoint.getX(), lastPoint.getY());
133
            elShape.lineTo(firstPoint.getX(), lastPoint.getY());
134
            //elShape.lineTo(firstPoint.getX(), firstPoint.getY());
135
            elShape.closePath();
136
            int type=getCadToolAdapter().getActiveLayerType();
137
            if (type==Geometry.TYPES.SURFACE){
138
            	insertAndSelectGeometry(createSurface(elShape));
130
            OrientablePrimitive orientablePrimitive;
131
            int type = getCadToolAdapter().getActiveLayerType();
132
            if ((type == Geometry.TYPES.CURVE) || (type == Geometry.TYPES.MULTICURVE)){
133
                orientablePrimitive = createCurve();              
139 134
            }else{
140
            	insertAndSelectGeometry(createCurve(elShape));
141
            }
135
                orientablePrimitive = createSurface();
136
            }            
137
            
138
            orientablePrimitive.addMoveToVertex(createPoint(firstPoint.getX(), firstPoint.getY()));
139
            orientablePrimitive.addVertex(createPoint(lastPoint.getX(), firstPoint.getY()));
140
            orientablePrimitive.addVertex(createPoint(lastPoint.getX(), lastPoint.getY()));
141
            orientablePrimitive.addVertex(createPoint(firstPoint.getX(), lastPoint.getY()));            
142
            orientablePrimitive.closePrimitive();
143
                     
144
            insertAndSelectGeometry(orientablePrimitive);               
145
          
142 146
            firstPoint = (Point2D) lastPoint.clone();
143 147
        } else if (status == "Rectangle.SecondPointSquare") {
144 148
            lastPoint = new Point2D.Double(x, y);
145 149

  
146
            GeneralPathX elShape = new GeneralPathX();
147
            elShape.moveTo(firstPoint.getX(), firstPoint.getY());
148
            elShape.lineTo(lastPoint.getX(), firstPoint.getY());
150
            OrientablePrimitive orientablePrimitive;
151
            int type = getCadToolAdapter().getActiveLayerType();
152
            if ((type == Geometry.TYPES.CURVE) || (type == Geometry.TYPES.MULTICURVE)){
153
                orientablePrimitive = createCurve();              
154
            }else{
155
                orientablePrimitive = createSurface();
156
            }
149 157

  
158
            orientablePrimitive.addMoveToVertex(createPoint(firstPoint.getX(), firstPoint.getY()));
159
            orientablePrimitive.addVertex(createPoint(lastPoint.getX(), firstPoint.getY()));
160

  
150 161
            if (((lastPoint.getY() <= firstPoint.getY()) &&
151
                    (lastPoint.getX() <= firstPoint.getX())) ||
152
                    ((lastPoint.getY() > firstPoint.getY()) &&
162
                (lastPoint.getX() <= firstPoint.getX())) ||
163
                ((lastPoint.getY() > firstPoint.getY()) &&
153 164
                    (lastPoint.getX() > firstPoint.getX()))) {
154
                elShape.lineTo(lastPoint.getX(),
155
                    firstPoint.getY() + (lastPoint.getX() - firstPoint.getX()));
156
                elShape.lineTo(firstPoint.getX(),
157
                    firstPoint.getY() + (lastPoint.getX() - firstPoint.getX()));
165
                orientablePrimitive.addVertex(createPoint(lastPoint.getX(),
166
                    firstPoint.getY() + (lastPoint.getX() - firstPoint.getX())));
167
                orientablePrimitive.addVertex(createPoint(firstPoint.getX(),
168
                    firstPoint.getY() + (lastPoint.getX() - firstPoint.getX())));
158 169
            } else {
159
                elShape.lineTo(lastPoint.getX(),
160
                    firstPoint.getY() - (lastPoint.getX() - firstPoint.getX()));
161
                elShape.lineTo(firstPoint.getX(),
162
                    firstPoint.getY() - (lastPoint.getX() - firstPoint.getX()));
170
                orientablePrimitive.addVertex(createPoint(lastPoint.getX(),
171
                    firstPoint.getY() - (lastPoint.getX() - firstPoint.getX())));
172
                orientablePrimitive.addVertex(createPoint(firstPoint.getX(),
173
                    firstPoint.getY() - (lastPoint.getX() - firstPoint.getX())));
163 174
            }
175
            orientablePrimitive.closePrimitive();
164 176

  
165
            //elShape.lineTo(firstPoint.getX(), firstPoint.getY());
166
            elShape.closePath();
167
            int type=getCadToolAdapter().getActiveLayerType();
168
            if (type==Geometry.TYPES.SURFACE){
169
            	insertAndSelectGeometry(createSurface(elShape));
170
            }else{
171
            	insertAndSelectGeometry(createCurve(elShape));
172
            }
177
            insertAndSelectGeometry(orientablePrimitive);            	
178

  
173 179
            firstPoint = (Point2D) lastPoint.clone();
174 180
        }
175 181
    }
......
190 196

  
191 197
        if (status == "Rectangle.SecondPointOrSquare") {
192 198
            GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
193
                    4);
199
                4);
194 200
            elShape.moveTo(firstPoint.getX(), firstPoint.getY());
195 201
            elShape.lineTo(x, firstPoint.getY());
196 202
            elShape.lineTo(x, y);
197 203
            elShape.lineTo(firstPoint.getX(), y);
198 204
            elShape.lineTo(firstPoint.getX(), firstPoint.getY());
199
       
200
        	renderer.draw(createCurve(elShape), mapControlManager.getGeometrySelectionSymbol());
205

  
206
            renderer.draw(createCurve(elShape), mapControlManager.getGeometrySelectionSymbol());
201 207
        } else if (status == "Rectangle.SecondPointSquare") {
202 208
            GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
203
                    4);
209
                4);
204 210
            elShape.moveTo(firstPoint.getX(), firstPoint.getY());
205 211
            elShape.lineTo(x, firstPoint.getY());
206 212

  
207 213
            if (((y <= firstPoint.getY()) && (x <= firstPoint.getX())) ||
208
                    ((y > firstPoint.getY()) && (x > firstPoint.getX()))) {
214
                ((y > firstPoint.getY()) && (x > firstPoint.getX()))) {
209 215
                elShape.lineTo(x, firstPoint.getY() + (x - firstPoint.getX()));
210 216
                elShape.lineTo(firstPoint.getX(),
211 217
                    firstPoint.getY() + (x - firstPoint.getX()));
......
216 222
                    firstPoint.getY() - (x - firstPoint.getX()));
217 223
                elShape.lineTo(firstPoint.getX(), firstPoint.getY());
218 224
            }
219
       		renderer.draw(createCurve(elShape), mapControlManager.getGeometrySelectionSymbol());
225
            renderer.draw(createCurve(elShape), mapControlManager.getGeometrySelectionSymbol());
220 226
        }
221 227
    }
222 228

  
......
243 249
    public void addValue(double d) {
244 250
    }
245 251

  
246
	public String getName() {
247
		return PluginServices.getText(this,"rectangle_");
248
	}
252
    public String getName() {
253
        return PluginServices.getText(this,"rectangle_");
254
    }
249 255

  
250
	public String toString() {
251
		return "_rectangle";
252
	}
253
	public boolean isApplicable(int shapeType) {
254
		switch (shapeType) {
255
		case Geometry.TYPES.POINT:
256
		case Geometry.TYPES.MULTIPOINT:
257
			return false;
258
		}
259
		return true;
260
	}
256
    public String toString() {
257
        return "_rectangle";
258
    }
259
    public boolean isApplicable(int shapeType) {
260
        switch (shapeType) {
261
        case Geometry.TYPES.POINT:
262
        case Geometry.TYPES.MULTIPOINT:
263
            return false;
264
        }
265
        return true;
266
    }
261 267
}
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/PolygonCADTool.java
50 50
import org.gvsig.editing.gui.cad.tools.smc.PolygonCADToolContext;
51 51
import org.gvsig.editing.gui.cad.tools.smc.PolygonCADToolContext.PolygonCADToolState;
52 52
import org.gvsig.fmap.geom.Geometry;
53
import org.gvsig.fmap.geom.primitive.GeneralPathX;
53
import org.gvsig.fmap.geom.primitive.OrientablePrimitive;
54 54
import org.gvsig.fmap.geom.util.UtilFunctions;
55 55
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
56 56

  
......
221 221
        double initangle = UtilFunctions.getAngle(center, point);
222 222
        Point2D antPoint = p1;
223 223
        Point2D antInter = null;
224
        //Point2D firstPoint= null;
225 224
        double an = (Math.PI * 2) / numLines;
226
        GeneralPathX elShape = new GeneralPathX();
227
        boolean firstTime=true;
225
        boolean firstTime = true;
226
               
227
        int type = getCadToolAdapter().getActiveLayerType();
228
        OrientablePrimitive orientablePrimitive = null;
229
        if ((type == Geometry.TYPES.CURVE) || (type == Geometry.TYPES.MULTICURVE)){
230
            orientablePrimitive = createCurve();            
231
        }else{
232
            orientablePrimitive = createSurface();
233
        }        
234
        
228 235
        for (int i = numLines-1; i >= 0 ; i--) {
229 236
            Point2D p2 = UtilFunctions.getPoint(center, (an * i) + initangle,
230 237
                    radio);
......
237 244
            if (antInter != null) {
238 245

  
239 246
                if (firstTime){
240
                	elShape.moveTo(antInter.getX(), antInter.getY());
241
                	//firstPoint=new Point2D.Double(antInter.getX(), antInter.getY());
247
                    orientablePrimitive.addMoveToVertex(createPoint(antInter.getX(), antInter.getY()));                	
242 248
                	firstTime=false;
243 249
                }
244
                elShape.lineTo(inter.getX(), inter.getY());
245

  
250
                orientablePrimitive.addVertex(createPoint(inter.getX(), inter.getY()));
246 251
            }
247 252

  
248 253
            antInter = inter;
249 254
            antPoint = p2;
250 255
        }
251
        //elShape.lineTo(firstPoint.getX(),firstPoint.getY());
252
        elShape.closePath();
253
        int type=getCadToolAdapter().getActiveLayerType();
254
        Geometry shape=null;
255
        if (type==Geometry.TYPES.SURFACE){
256
        	shape = createSurface(elShape);
257
        }else{
258
        	shape = createCurve(elShape);
259
        }
260
        return shape;
256
        orientablePrimitive.closePrimitive();
257
       
258
        return orientablePrimitive;
261 259
    }
262 260

  
263 261
    /**
......
275 273
        double initangle = UtilFunctions.getAngle(center, point);
276 274
        Point2D antPoint = p1;
277 275
        //Point2D firstPoint= null;
278
        double an = (Math.PI * 2) / numLines;
279
        GeneralPathX elShape = new GeneralPathX();
276
        double an = (Math.PI * 2) / numLines;       
280 277
        boolean firstTime=true;
281 278

  
279
        int type = getCadToolAdapter().getActiveLayerType();
280
        OrientablePrimitive orientablePrimitive = null;
281
        if ((type == Geometry.TYPES.CURVE) || (type == Geometry.TYPES.MULTICURVE)){
282
            orientablePrimitive = createCurve();            
283
        }else{
284
            orientablePrimitive = createSurface();
285
        }        
286
        
282 287
        for (int i = numLines-1; i > 0; i--) {
283 288
            Point2D p2 = UtilFunctions.getPoint(center, (an * i) + initangle,
284 289
                    radio);
285 290

  
286 291
            if (firstTime){
287
            	 elShape.moveTo(antPoint.getX(), antPoint.getY());
288
            	 //firstPoint=new Point2D.Double(antPoint.getX(), antPoint.getY());
289
            	 firstTime=false;
292
                orientablePrimitive.addMoveToVertex(createPoint(antPoint.getX(), antPoint.getY()));            	
293
            	firstTime=false;
290 294
            }
291 295

  
292
            elShape.lineTo(p2.getX(), p2.getY());
296
            orientablePrimitive.addVertex(createPoint(p2.getX(), p2.getY()));
293 297

  
294 298
            antPoint = p2;
295 299
        }
296
        //elShape.lineTo(firstPoint.getX(),firstPoint.getY());
297
        elShape.closePath();
298
        int type=getCadToolAdapter().getActiveLayerType();
299
        Geometry shape=null;
300
        if (type==Geometry.TYPES.SURFACE){
301
        	shape = createSurface(elShape);
302
        }else{
303
        	shape = createCurve(elShape);
304
        }
305
        return shape;
300
        orientablePrimitive.closePrimitive();
301

  
302
        return orientablePrimitive;
306 303
    }
304
    
307 305
    /**
308 306
     * Devuelve la geometr?a con el poligono regular circunscrito a la
309 307
     * circunferencia formada por el punto central y el radio que se froma
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/LineCADTool.java
40 40
 */
41 41
package org.gvsig.editing.gui.cad.tools;
42 42

  
43
import java.awt.Image;
44 43
import java.awt.event.InputEvent;
45 44
import java.awt.geom.Point2D;
46 45

  
......
49 48
import org.gvsig.editing.gui.cad.exception.CommandException;
50 49
import org.gvsig.editing.gui.cad.tools.smc.LineCADToolContext;
51 50
import org.gvsig.editing.gui.cad.tools.smc.LineCADToolContext.LineCADToolState;
52
import org.gvsig.editing.layers.VectorialLayerEdited;
53 51
import org.gvsig.fmap.geom.Geometry;
54 52
import org.gvsig.fmap.geom.primitive.GeneralPathX;
55 53
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
......
215 213
	public boolean isApplicable(int shapeType) {
216 214
		switch (shapeType) {
217 215
		case Geometry.TYPES.POINT:
216
	    case Geometry.TYPES.MULTIPOINT:
218 217
		case Geometry.TYPES.SURFACE:
219
		case Geometry.TYPES.MULTIPOINT:
218
		case Geometry.TYPES.MULTISURFACE:
219

  
220 220
			return false;
221 221
		}
222 222
		return true;
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/toolListeners/snapping/snappers/IntersectionPointSnapper.java
50 50

  
51 51
    private Point2D intersects(Geometry g1, Geometry g2, Point2D point,
52 52
            double tolerance) {
53
    	com.vividsolutions.jts.geom.Geometry g1JTS=Converter.geometryToJts(g1);
54
    	com.vividsolutions.jts.geom.Geometry g2JTS=Converter.geometryToJts(g2);
53
    	com.vividsolutions.jts.geom.Geometry g1JTS = Converter.geometryToJts(g1);
54
    	com.vividsolutions.jts.geom.Geometry g2JTS = Converter.geometryToJts(g2);
55
    	//If there is a topology error don't intersects
56
    	if ((g1JTS == null) || (g2JTS == null)){
57
    	    return null;
58
    	}
55 59
    	if (g1JTS.getNumPoints()>maxPointsGeom || g2JTS.getNumPoints()>maxPointsGeom){
56 60
    		return null;
57 61
    	}
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/shp/utils/SHPPoint.java
61 61
 * @author Vicente Caballero Navarro
62 62
 */
63 63
public class SHPPoint implements SHPShape {
64
	private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
65
	private static final Logger logger = LoggerFactory.getLogger(SHPPoint.class);
66
	private int m_type;
67
	private Point point;
68
	private double z;
64
    private static final GeometryManager geomManager = GeometryLocator.getGeometryManager();
65
    private static final Logger logger = LoggerFactory.getLogger(SHPPoint.class);
66
    private int m_type;
67
    private Point point;
68
    private double z;
69 69

  
70
	/**
71
	 * Crea un nuevo SHPPoint.
72
	 *
73
	 * @param type DOCUMENT ME!
74
	 *
75
	 * @throws ShapefileException DOCUMENT ME!
76
	 */
77
	public SHPPoint(int type)  {
78
		if ((type != SHP.POINT2D) &&
79
				(type != SHP.POINTM) &&
80
				(type != SHP.POINT3D)) { // 2d, 2d+m, 3d+m
81
//			throw new ShapefileException("No es un punto 1,11 ni 21");
82
		}
70
    /**
71
     * Crea un nuevo SHPPoint.
72
     *
73
     * @param type DOCUMENT ME!
74
     *
75
     * @throws ShapefileException DOCUMENT ME!
76
     */
77
    public SHPPoint(int type)  {
78
        if ((type != SHP.POINT2D) &&
79
            (type != SHP.POINTM) &&
80
            (type != SHP.POINT3D)) { // 2d, 2d+m, 3d+m
81
            //			throw new ShapefileException("No es un punto 1,11 ni 21");
82
        }
83 83

  
84
		m_type = type;
85
	}
84
        m_type = type;
85
    }
86 86

  
87
	/**
88
	 * Crea un nuevo SHPPoint.
89
	 */
90
	public SHPPoint() {
91
		m_type = SHP.POINT2D; //2d
92
	}
87
    /**
88
     * Crea un nuevo SHPPoint.
89
     */
90
    public SHPPoint() {
91
        m_type = SHP.POINT2D; //2d
92
    }
93 93

  
94
	/**
95
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#getShapeType()
96
	 */
97
	public int getShapeType() {
98
		return m_type;
99
	}
94
    /**
95
     * @see com.iver.cit.gvsig.fmap.shp.SHPShape#getShapeType()
96
     */
97
    public int getShapeType() {
98
        return m_type;
99
    }
100 100

  
101
	/**
102
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#read(MappedByteBuffer, int)
103
	 */
104
	public Geometry read(MappedByteBuffer buffer, int type) {
105
		double x = buffer.getDouble();
106
		double y = buffer.getDouble();
107
		double z = Double.NaN;
101
    /**
102
     * @see com.iver.cit.gvsig.fmap.shp.SHPShape#read(MappedByteBuffer, int)
103
     */
104
    public Geometry read(MappedByteBuffer buffer, int type) {
105
        double x = buffer.getDouble();
106
        double y = buffer.getDouble();
107
        double z = Double.NaN;
108 108

  
109
		if (m_type == SHP.POINTM) {
110
			buffer.getDouble();
111
		}
109
        if (m_type == SHP.POINTM) {
110
            buffer.getDouble();
111
        }
112 112

  
113
		if (m_type == SHP.POINT3D) {
114
			z = buffer.getDouble();
115
			Point point;
116
			try {
117
				point = geomManager.createPoint(x, y, SUBTYPES.GEOM3D);
118
				point.setCoordinateAt(2, z);
119
				return point;
120
			     //FIXME que hacems con esto
121
			} catch (CreateGeometryException e) {
122
				logger.error("Error creating a point", e);
123
			}			
124
		}
125
		try {
126
			return geomManager.createPoint(x, y, SUBTYPES.GEOM2D);
127
		} catch (CreateGeometryException e) {
128
			logger.error("Error creating a point", e);
129
		}
130
		return null;
131
	}
113
        if (m_type == SHP.POINT3D) {
114
            z = buffer.getDouble();
115
            Point point;
116
            try {
117
                point = geomManager.createPoint(x, y, SUBTYPES.GEOM3D);
118
                point.setCoordinateAt(2, z);
119
                return point;
120
                //FIXME que hacems con esto
121
            } catch (CreateGeometryException e) {
122
                logger.error("Error creating a point", e);
123
            }			
124
        }
125
        try {
126
            return geomManager.createPoint(x, y, SUBTYPES.GEOM2D);
127
        } catch (CreateGeometryException e) {
128
            logger.error("Error creating a point", e);
129
        }
130
        return null;
131
    }
132 132

  
133
	/**
134
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#write(ByteBuffer, IGeometry)
135
	 */
136
	public void write(ByteBuffer buffer, Geometry geometry) {
137
		//FPoint2D p2d = ((FPoint2D) geometry.getShape());
138
		///obtainsPoints(geometry.getGeneralPathXIterator());
139
		buffer.putDouble(point.getX());
140
		buffer.putDouble(point.getY());
133
    /**
134
     * @see com.iver.cit.gvsig.fmap.shp.SHPShape#write(ByteBuffer, IGeometry)
135
     */
136
    public void write(ByteBuffer buffer, Geometry geometry) {
137
        buffer.putDouble(point.getX());
138
        buffer.putDouble(point.getY());
141 139

  
142
		  if (m_type == SHP.POINT3D) {
143
		   if (Double.isNaN(z)) { // nan means not defined
144
		       buffer.putDouble(0.0);
145
		   } else {
146
		       buffer.putDouble(z);
147
		   }
148
		   }
149
		   if ((m_type == SHP.POINT3D) ||
150
		           (m_type == SHP.POINTM)) {
151
		       buffer.putDouble(-10E40); //M
152
		   }
140
        if ((m_type == SHP.POINT3D) ||  (m_type == SHP.POINTM)){
141
            if (Double.isNaN(z)) { // nan means not defined
142
                buffer.putDouble(0.0);
143
            } else {
144
                buffer.putDouble(z);
145
            }
146
        }
147
    }
153 148

  
154
	}
149
    /**
150
     * @see com.iver.cit.gvsig.fmap.shp.SHPShape#getLength(int)
151
     */
152
    public int getLength(Geometry fgeometry) {
153
        int length;
155 154

  
156
	/**
157
	 * @see com.iver.cit.gvsig.fmap.shp.SHPShape#getLength(int)
158
	 */
159
	public int getLength(Geometry fgeometry) {
160
		int length;
155
        if (m_type == SHP.POINT2D) {
156
            length = 20;
157
        } else if (m_type == SHP.POINTM || m_type == SHP.POINT3D) {
158
            length = 28;
159
        } else {
160
            throw new IllegalStateException("Expected ShapeType of Point, got" +
161
                m_type);
162
        }
161 163

  
162
		if (m_type == SHP.POINT2D) {
163
			length = 20;
164
		} else if (m_type == SHP.POINTM || m_type == SHP.POINT3D) {
165
			length = 28;
166
		} else {
167
			throw new IllegalStateException("Expected ShapeType of Point, got" +
168
				m_type);
169
		}
164
        return length;
165
    }
170 166

  
171
		return length;
172
	}
167
    /**
168
     * @see com.iver.cit.gvsig.fmap.drivers.shp.write.SHPShape#obtainsPoints(com.iver.cit.gvsig.fmap.core.GeneralPathXIterator)
169
     */
170
    public void obtainsPoints(Geometry g) {
171
        if (m_type == SHP.POINTM || m_type == SHP.POINT3D){
172
            z = ((Point)g).getCoordinateAt(2);
173
        }
174
        PathIterator theIterator = g.getPathIterator(null); //polyLine.getPathIterator(null, flatness);
175
        double[] theData = new double[6];
173 176

  
174
	/**
175
	 * @see com.iver.cit.gvsig.fmap.drivers.shp.write.SHPShape#obtainsPoints(com.iver.cit.gvsig.fmap.core.GeneralPathXIterator)
176
	 */
177
	public void obtainsPoints(Geometry g) {
178
		if (SHP.POINT3D == m_type){
179
			z=((Point)g).getCoordinateAt(2);
180
		}
181
		PathIterator theIterator = g.getPathIterator(null); //polyLine.getPathIterator(null, flatness);
182
		double[] theData = new double[6];
177
        while (!theIterator.isDone()) {
178
            //while not done
179
            //			int theType = theIterator.currentSegment(theData);
180
            theIterator.currentSegment(theData);
183 181

  
184
		while (!theIterator.isDone()) {
185
			//while not done
186
//			int theType = theIterator.currentSegment(theData);
187
			theIterator.currentSegment(theData);
182
            try {
183
                point = geomManager.createPoint(theData[0], theData[1], SUBTYPES.GEOM2D);
184
            } catch (CreateGeometryException e) {
185
                logger.error("Error creating a point", e);
186
            }
188 187

  
189
			try {
190
				point = geomManager.createPoint(theData[0], theData[1], SUBTYPES.GEOM2D);
191
			} catch (CreateGeometryException e) {
192
				logger.error("Error creating a point", e);
193
			}
194

  
195
			theIterator.next();
196
		} //end while loop
197
	}
198
//	public void setFlatness(double flatness) {
199
//	//	this.flatness=flatness;
200
//	}
188
            theIterator.next();
189
        } //end while loop
190
    }
191
    //	public void setFlatness(double flatness) {
192
    //	//	this.flatness=flatness;
193
    //	}
201 194
}
branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/impl/Envelope2D.java
45 45
	
46 46
	public Envelope2D() {
47 47
		super();
48
		min = new Point2D(0, 0);
49
		max = new Point2D(0, 0);
48
		min = new Point2D(0.0, 0.0);
49
		max = new Point2D(0.0, 0.0);
50 50
	}
51 51

  
52 52
	public Envelope2D(Point min, Point max) {

Also available in: Unified diff