Revision 47762

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/GeometryManager.java
381 381
     * @param geometryType
382 382
     *            A {@link GeometryType} instance to create {@link Geometry} objects
383 383
     */
384
    public void registerGeometryType(GeometryType geometryType);
384
    public GeometryType registerGeometryType(GeometryType geometryType);
385 385

  
386 386
    /**
387 387
     * <p>
......
669 669
    public GeometryType registerGeometryType(Class geomClass, int type,
670 670
        int subType);
671 671

  
672
    public GeometryType getGeometryType(String typeName) throws GeometryTypeNotSupportedException,
673
        GeometryTypeNotValidException;
674

  
672 675
    /**
673 676
     * <p>
674 677
     * Returns an instance of GeometryType given the Geometry type and the
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.api/src/main/java/org/gvsig/fmap/geom/type/GeometryType.java
23 23
 */
24 24
package org.gvsig.fmap.geom.type;
25 25

  
26
import java.util.Collection;
26 27
import org.gvsig.fmap.geom.Geometry;
27 28
import org.gvsig.fmap.geom.exception.CreateGeometryException;
28 29
import org.gvsig.fmap.geom.operation.GeometryOperation;
......
48 49
     * @return the full name of the geometry type
49 50
     */
50 51
    public String getFullName();
52
    
53
    public GeometryType addAlias(String alias);
54
    
55
    public Collection<String> getAlias();
51 56

  
52 57
    /**
53 58
     * @return the type of the geometry. It is a constant value that has to be
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/DefaultGeometryLibrary.java
57 57
import org.gvsig.fmap.geom.jts.operation.fromwkb.FromWKB;
58 58
import org.gvsig.fmap.geom.jts.operation.fromwkt.FromWKT;
59 59
import org.gvsig.fmap.geom.jts.operation.tojts.ToJTS;
60
import org.gvsig.fmap.geom.jts.operation.towkb.ToOGCWKB;
60 61
import org.gvsig.fmap.geom.jts.operation.towkb.ToPostGISEWKB;
61
import org.gvsig.fmap.geom.jts.operation.towkb.ToOGCWKB;
62 62
import org.gvsig.fmap.geom.jts.operation.towkt.ToWKT;
63 63
import org.gvsig.fmap.geom.jts.persistence.GeometryPersistenceFactory;
64 64
import org.gvsig.fmap.geom.jts.persistence.GeometryTypePersistenceFactory;
......
168 168
        geometryManager.registerGeometryType(Geometry3DM.class, "Geometry3DM", TYPES.GEOMETRY, SUBTYPES.GEOM3DM);
169 169

  
170 170
        // Register points in 2D
171
        geometryManager.registerGeometryType(new Point2DGeometryType());
171
        geometryManager.registerGeometryType(new Point2DGeometryType())
172
            .addAlias("point")
173
        ;
172 174
//        geometryManager.registerGeometryType(Point2D.class, "Point2D", TYPES.POINT, SUBTYPES.GEOM2D);
173
        geometryManager.registerGeometryType(Point2DM.class, "Point2DM", TYPES.POINT, SUBTYPES.GEOM2DM);
175
        geometryManager.registerGeometryType(Point2DM.class, "Point2DM", TYPES.POINT, SUBTYPES.GEOM2DM)
176
            .addAlias("point m")
177
            .addAlias("pointm")
178
        ;
174 179

  
175 180
        // Register curves in 2D
176
        geometryManager.registerGeometryType(Line2D.class, "Line2D", TYPES.LINE, SUBTYPES.GEOM2D, TYPES.CURVE);
181
        geometryManager.registerGeometryType(Line2D.class, "Line2D", TYPES.LINE, SUBTYPES.GEOM2D, TYPES.CURVE)
182
            .addAlias("line")
183
            .addAlias("linestring")
184
        ;
177 185
        geometryManager.registerGeometryType(Line2D.class, "Curve2D", TYPES.CURVE, SUBTYPES.GEOM2D, TYPES.CURVE);
178 186
        geometryManager.registerGeometryType(Arc2D.class, "Arc2D", TYPES.ARC, SUBTYPES.GEOM2D, TYPES.CURVE);
179 187
        geometryManager.registerGeometryType(Spline2D.class, "Spline2D", TYPES.SPLINE, SUBTYPES.GEOM2D, TYPES.CURVE);
......
191 199
        geometryManager.registerGeometryType(EllipticArc2D.class, "EllipticArc2D", TYPES.ELLIPTICARC, SUBTYPES.GEOM2D, TYPES.SURFACE);
192 200

  
193 201
        // Register curves in 2DM
194
        geometryManager.registerGeometryType(Line2DM.class, "Line2DM", TYPES.LINE, SUBTYPES.GEOM2DM, TYPES.CURVE);
202
        geometryManager.registerGeometryType(Line2DM.class, "Line2DM", TYPES.LINE, SUBTYPES.GEOM2DM, TYPES.CURVE)
203
            .addAlias("line m")
204
            .addAlias("linem")
205
            .addAlias("linestring m")
206
            .addAlias("linestringm")
207
        ;
195 208
        geometryManager.registerGeometryType(Line2DM.class, "Curve2DM", TYPES.CURVE, SUBTYPES.GEOM2DM, TYPES.CURVE);
196 209
        geometryManager.registerGeometryType(Spline2DM.class, "Spline2DM", TYPES.SPLINE, SUBTYPES.GEOM2DM, TYPES.CURVE);
197 210

  
......
204 217
        // Register multigeometries in 2D
205 218
//        geometryManager.registerGeometryType(BaseMultiPrimitive2D.class, "MultiPrimitive2D", TYPES.AGGREGATE,
206 219
//            SUBTYPES.GEOM2D);
207
        geometryManager.registerGeometryType(MultiPoint2D.class, "MultiPoint2D", TYPES.MULTIPOINT, SUBTYPES.GEOM2D, TYPES.AGGREGATE);
220
        geometryManager.registerGeometryType(MultiPoint2D.class, "MultiPoint2D", TYPES.MULTIPOINT, SUBTYPES.GEOM2D, TYPES.AGGREGATE)
221
            .addAlias("multipoint");
208 222
        geometryManager.registerGeometryType(DefaultMultiCurve.class, "MultiCurve", TYPES.MULTICURVE, SUBTYPES.GEOM2D, TYPES.AGGREGATE);
209
        geometryManager.registerGeometryType(MultiLine2D.class, "MultiLine2D", TYPES.MULTILINE, SUBTYPES.GEOM2D, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE});
223
        geometryManager.registerGeometryType(MultiLine2D.class, "MultiLine2D", TYPES.MULTILINE, SUBTYPES.GEOM2D, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE})
224
            .addAlias("multiline")
225
            .addAlias("multilinestring")
226
        ;
210 227
        geometryManager.registerGeometryType(DefaultMultiSurface.class, "MultiSurface", TYPES.MULTISURFACE, SUBTYPES.GEOM2D, TYPES.AGGREGATE);
211
        geometryManager.registerGeometryType(MultiPolygon2D.class, "MultiPolygon2D", TYPES.MULTIPOLYGON, SUBTYPES.GEOM2D, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE});
228
        geometryManager.registerGeometryType(MultiPolygon2D.class, "MultiPolygon2D", TYPES.MULTIPOLYGON, SUBTYPES.GEOM2D, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE})
229
            .addAlias("multipolygon")
230
        ;
212 231

  
213 232
        // Register multigeometries in 2DM
214
        geometryManager.registerGeometryType(MultiPoint2DM.class, "MultiPoint2DM", TYPES.MULTIPOINT, SUBTYPES.GEOM2DM, TYPES.AGGREGATE);
233
        geometryManager.registerGeometryType(MultiPoint2DM.class, "MultiPoint2DM", TYPES.MULTIPOINT, SUBTYPES.GEOM2DM, TYPES.AGGREGATE)
234
            .addAlias("multipoint m")
235
            .addAlias("multipointm")
236
        ;
215 237
        geometryManager.registerGeometryType(DefaultMultiCurve.class, "MultiCurve", TYPES.MULTICURVE, SUBTYPES.GEOM2DM, TYPES.AGGREGATE);
216
        geometryManager.registerGeometryType(MultiLine2DM.class, "MultiLine2DM", TYPES.MULTILINE, SUBTYPES.GEOM2DM, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE});
238
        geometryManager.registerGeometryType(MultiLine2DM.class, "MultiLine2DM", TYPES.MULTILINE, SUBTYPES.GEOM2DM, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE})
239
            .addAlias("multiline m")
240
            .addAlias("multilinem")
241
            .addAlias("multilinestring m")
242
            .addAlias("multilinestringm")
243
        ;;
217 244
        geometryManager.registerGeometryType(DefaultMultiSurface.class, "MultiSurface", TYPES.MULTISURFACE, SUBTYPES.GEOM2DM, TYPES.AGGREGATE);
218
        geometryManager.registerGeometryType(MultiPolygon2DM.class, "MultiPolygon2DM", TYPES.MULTIPOLYGON, SUBTYPES.GEOM2DM, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE});
245
        geometryManager.registerGeometryType(MultiPolygon2DM.class, "MultiPolygon2DM", TYPES.MULTIPOLYGON, SUBTYPES.GEOM2DM, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE})
246
            .addAlias("multipolygon m")
247
            .addAlias("multipolygonm")
248
        ;
219 249

  
220 250
        // Register the geometries in 3D
221 251
        geometryManager.registerGeometryType(DefaultNullGeometry.class, TYPES.NULL, SUBTYPES.GEOM3D);
222 252

  
223 253
        // Register points in 3D
224
        geometryManager.registerGeometryType(new Point3DGeometryType());
254
        geometryManager.registerGeometryType(new Point3DGeometryType())
255
            .addAlias("point z")
256
        ;
225 257
//        geometryManager.registerGeometryType(Point3D.class, "Point3D", TYPES.POINT, SUBTYPES.GEOM3D);
226
        geometryManager.registerGeometryType(Point3DM.class, "Point3DM", TYPES.POINT, SUBTYPES.GEOM3DM);
258
        geometryManager.registerGeometryType(Point3DM.class, "Point3DM", TYPES.POINT, SUBTYPES.GEOM3DM)
259
            .addAlias("point zm")
260
            .addAlias("pointzm")
261
        ;
227 262

  
228 263
        // Register curves in 3D
229
        geometryManager.registerGeometryType(Line3D.class, "Line3D", TYPES.LINE, SUBTYPES.GEOM3D, TYPES.CURVE);
264
        geometryManager.registerGeometryType(Line3D.class, "Line3D", TYPES.LINE, SUBTYPES.GEOM3D, TYPES.CURVE)
265
            .addAlias("line z")
266
            .addAlias("linez")
267
            .addAlias("linestring z")
268
            .addAlias("linestringz")
269
        ;
230 270
        geometryManager.registerGeometryType(Line3D.class, "Curve3D", TYPES.CURVE, SUBTYPES.GEOM3D, TYPES.CURVE);
231 271
        geometryManager.registerGeometryType(Arc2DZ.class, "Arc3D", TYPES.ARC, SUBTYPES.GEOM3D, TYPES.CURVE);
232 272
        geometryManager.registerGeometryType(Spline3D.class, "Spline3D", TYPES.SPLINE, SUBTYPES.GEOM3D, TYPES.CURVE);
......
245 285
        geometryManager.registerGeometryType(EllipticArc2DZ.class, "EllipticArc3D", TYPES.ELLIPTICARC, SUBTYPES.GEOM3D, TYPES.SURFACE);
246 286

  
247 287
        // Register curves in 3DM
248
        geometryManager.registerGeometryType(Line3DM.class, "Line3DM", TYPES.LINE, SUBTYPES.GEOM3DM, TYPES.CURVE);
288
        geometryManager.registerGeometryType(Line3DM.class, "Line3DM", TYPES.LINE, SUBTYPES.GEOM3DM, TYPES.CURVE)
289
            .addAlias("line zm")
290
            .addAlias("linezm")
291
            .addAlias("linestring zm")
292
            .addAlias("linestringzm")
293
        ;
249 294
        geometryManager.registerGeometryType(Line3DM.class, "Curve3DM", TYPES.CURVE, SUBTYPES.GEOM3DM, TYPES.CURVE);
250 295
        geometryManager.registerGeometryType(Spline3DM.class, "Spline3DM", TYPES.SPLINE, SUBTYPES.GEOM3DM, TYPES.CURVE);
251 296

  
......
257 302

  
258 303

  
259 304
        // Register multigeometries in 3D
260
        geometryManager.registerGeometryType(MultiPoint3D.class, "MultiPoint3D", TYPES.MULTIPOINT, SUBTYPES.GEOM3D, TYPES.AGGREGATE);
305
        geometryManager.registerGeometryType(MultiPoint3D.class, "MultiPoint3D", TYPES.MULTIPOINT, SUBTYPES.GEOM3D, TYPES.AGGREGATE)
306
            .addAlias("multipoint z")
307
            .addAlias("multipointz")
308
        ;
261 309
        geometryManager.registerGeometryType(DefaultMultiCurve.class, "MultiCurve", TYPES.MULTICURVE, SUBTYPES.GEOM3D, TYPES.AGGREGATE);
262
        geometryManager.registerGeometryType(MultiLine3D.class, "MultiLine3D", TYPES.MULTILINE, SUBTYPES.GEOM3D, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE});
310
        geometryManager.registerGeometryType(MultiLine3D.class, "MultiLine3D", TYPES.MULTILINE, SUBTYPES.GEOM3D, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE})
311
            .addAlias("multiline z")
312
            .addAlias("multilinez")
313
            .addAlias("multilinestring z")
314
            .addAlias("multilinestringz")
315
        ;
263 316
        geometryManager.registerGeometryType(DefaultMultiSurface.class, "MultiSurface", TYPES.MULTISURFACE, SUBTYPES.GEOM3D, TYPES.AGGREGATE);
264
        geometryManager.registerGeometryType(MultiPolygon3D.class, "MultiPolygon3D", TYPES.MULTIPOLYGON, SUBTYPES.GEOM3D, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE});
317
        geometryManager.registerGeometryType(MultiPolygon3D.class, "MultiPolygon3D", TYPES.MULTIPOLYGON, SUBTYPES.GEOM3D, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE})
318
            .addAlias("multipolygon z")
319
            .addAlias("multipolygonz")
320
        ;
265 321

  
266 322
        // Register multigeometries in 3DM
267
        geometryManager.registerGeometryType(MultiPoint3DM.class, "MultiPoint3DM", TYPES.MULTIPOINT, SUBTYPES.GEOM3DM, TYPES.AGGREGATE);
323
        geometryManager.registerGeometryType(MultiPoint3DM.class, "MultiPoint3DM", TYPES.MULTIPOINT, SUBTYPES.GEOM3DM, TYPES.AGGREGATE)
324
            .addAlias("multipoint zm")
325
            .addAlias("multipointzm")
326
        ;
268 327
        geometryManager.registerGeometryType(DefaultMultiCurve.class, "MultiCurve", TYPES.MULTICURVE, SUBTYPES.GEOM3DM, TYPES.AGGREGATE);
269
        geometryManager.registerGeometryType(MultiLine3DM.class, "MultiLine3DM", TYPES.MULTILINE, SUBTYPES.GEOM3DM, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE});
328
        geometryManager.registerGeometryType(MultiLine3DM.class, "MultiLine3DM", TYPES.MULTILINE, SUBTYPES.GEOM3DM, new int[]{TYPES.AGGREGATE, TYPES.MULTICURVE})
329
            .addAlias("multiline zm")
330
            .addAlias("multilinezm")
331
            .addAlias("multilinestring zm")
332
            .addAlias("multilinestringzm")
333
        ;
270 334
        geometryManager.registerGeometryType(DefaultMultiSurface.class, "MultiSurface", TYPES.MULTISURFACE, SUBTYPES.GEOM3DM, TYPES.AGGREGATE);
271
        geometryManager.registerGeometryType(MultiPolygon3DM.class, "MultiPolygon3DM", TYPES.MULTIPOLYGON, SUBTYPES.GEOM3DM, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE});
335
        geometryManager.registerGeometryType(MultiPolygon3DM.class, "MultiPolygon3DM", TYPES.MULTIPOLYGON, SUBTYPES.GEOM3DM, new int[]{TYPES.AGGREGATE, TYPES.MULTISURFACE})
336
            .addAlias("multipolygon zm")
337
            .addAlias("multipolygonzm")
338
        ;
272 339
        
273 340
        
274 341
        // Register complex
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/DefaultGeometryManager.java
132 132
     * hash key to obtain an instance of GeometryType holding the
133 133
     * operations associated to the class org.gvsig.fmap.geom.primitive.Point2D.
134 134
     */
135
    private final Map geometryTypeName = new HashMap();
135
    private final Map<String, GeometryType> geometryTypeName = new HashMap();
136 136

  
137 137
    /**
138 138
     * Matrix of geometry types by type (row) and subtype (column). This matrix
......
340 340
    }
341 341

  
342 342
    @Override
343
    public void registerGeometryType(GeometryType geometryType) {
343
    public GeometryType registerGeometryType(GeometryType geometryType) {
344 344
        int offsettedType = geometryType.getType() + GEOMETRY_TYPE_OFFSET;
345 345
        if (offsettedType >= geometryTypes.length || geometryType.getSubType() >= geometryTypes[0].length) {
346 346

  
......
361 361

  
362 362
        geometryTypes[offsettedType][geometryType.getSubType()] = geometryType;
363 363
        geometryTypeName.put(geometryType.getName(), geometryType);
364
        return geometryType;
364 365
    }
365 366

  
366 367
    @Override
......
369 370
    }
370 371

  
371 372
    @Override
373
    public GeometryType getGeometryType(String typeName) throws GeometryTypeNotSupportedException,
374
        GeometryTypeNotValidException {
375
        for (Map.Entry<String, GeometryType> entry : geometryTypeName.entrySet()) {
376
            String key = entry.getKey();
377
            GeometryType geomType = entry.getValue();
378
            if(StringUtils.equalsIgnoreCase(typeName, key)){
379
                return geomType;
380
            }
381
            if(geomType != null) {
382
                for (String alias : geomType.getAlias()) {
383
                    if(StringUtils.equalsIgnoreCase(typeName, alias)){
384
                        return geomType;
385
                    }
386
                }
387
            }
388
        }
389
        return null;
390
    }
391
    
392
   @Override
372 393
    public GeometryType getGeometryType(int type, int subType) throws GeometryTypeNotSupportedException,
373 394
        GeometryTypeNotValidException {
374 395

  
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/DefaultGeometryType.java
24 24
package org.gvsig.fmap.geom.jts;
25 25

  
26 26
import java.lang.reflect.Constructor;
27
import java.util.Collection;
28
import java.util.Collections;
29
import java.util.HashSet;
27 30
import java.util.Objects;
31
import java.util.Set;
28 32

  
29 33
import org.gvsig.fmap.geom.Geometry;
30 34
import org.gvsig.fmap.geom.GeometryManager;
31 35
import org.gvsig.fmap.geom.exception.CreateGeometryException;
32 36
import org.gvsig.fmap.geom.type.AbstractGeometryType;
33 37
import org.gvsig.fmap.geom.type.GeometryType;
38
import org.gvsig.tools.dataTypes.DataType;
34 39

  
35 40
/**
36 41
 * @author gvSIG Team
......
80 85
    private Constructor constructorWithGeometryType = null;
81 86
    private Constructor constructorWithoutParameters = null;
82 87
    private final Object[] parameters = {this};
88
    
89
    private Set<String> alias;
83 90

  
84 91
    /**
85 92
     * This constructor is used by the {@link GeometryManager} when it register
......
277 284
        return hash;
278 285
    }
279 286

  
287
    @Override
288
    public GeometryType addAlias(String alias) {
289
        if (this.alias == null) {
290
            this.alias = new HashSet<>();
291
        }
292
        this.alias.add(alias);
293
        return this;
294
    }
295

  
296
    @Override
297
    public Collection<String> getAlias() {
298
        if (this.alias == null) {
299
            return Collections.EMPTY_LIST;
300
        }
301
        return Collections.unmodifiableCollection(this.alias);
302
    }
303

  
304

  
280 305
}

Also available in: Unified diff