You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sis.apache.org by Marc Le Bihan <ml...@gmail.com> on 2015/11/11 09:01:12 UTC

Where is the feature geometric type stored ?

Hello,

    There’s an object called DefaultFeatureType that is used by methods to create a Dense or Sparse feature.
    But what is the feature member that stores the geometric kind of this feature ? Point, Line, Polygon, etc.

    I see this code in ShapefileByteReader:completeFeature(Feature) method, reading a value used only locally but not stored :
    
int iShapeType = getByteBuffer().getInt();

ShapeTypeEnum type = ShapeTypeEnum.get(iShapeType);

if (type == null)
    throw new InvalidShapefileFormatException(MessageFormat.format("The shapefile feature type {0} doesn''t match to any known feature type.", featuresType));

switch (type) {
    case Point:
        loadPointFeature(feature);
        break;

    case Polygon:
        loadPolygonFeature(feature);
        break;

    case PolyLine:
        loadPolylineFeature(feature);
        break;

    default:
        throw new InvalidShapefileFormatException("Unsupported shapefile type: " + iShapeType);
}


ShapeTypeEnum leads to an exhaustive list of values : NullShape, Point, PolyLine,  Polygon, MultiPoint,  PointZ, PolyLineZ, PolygonZ, MultiPointZ, PointM, PolyLineM, PolygonM, MultiPointM, MultiPatch, and maybe its more than needed.
Another enumeration more neutral exists somewhere in the org.opengis package for the features ?

When I give you a feature instance, today, how do you react on its geometric type ?

Regards,

Marc Le Bihan

Re: Where is the feature geometric type stored ?

Posted by Martin Desruisseaux <ma...@geomatys.com>.
Le 11/11/15 09:01, Marc Le Bihan a écrit :
>     There’s an object called DefaultFeatureType that is used by methods to create a Dense or Sparse feature.
>     But what is the feature member that stores the geometric kind of this feature ? Point, Line, Polygon, etc.

It does not necessarily needs to be stored since users can perform
"instanceof" check on the property value. If nevertheless there is a
need to store this information in an explicit place, then we can use the
Attribute.characteristics() map. But it may be safer to abstain (at
least for now) if it does not bring new information compared to
"instanceof" checks.


> ShapeTypeEnum leads to an exhaustive list of values : NullShape, Point, PolyLine,  Polygon, MultiPoint,  PointZ, PolyLineZ, PolygonZ, MultiPointZ, PointM, PolyLineM, PolygonM, MultiPointM, MultiPatch, and maybe its more than needed.
> Another enumeration more neutral exists somewhere in the org.opengis package for the features ?

There is no more neutral list at this time. The OGC/ISO standards tend
to rely more on class types rather than type enumeration, so it would
rather have a "Point" interface, a "Polygon" interface, etc. The same
approach applies to many other domains like metadata types, coordinate
system types, etc. It is very rare that OGC/ISO uses an enumeration for
specifying a class type. Consequently I would suggest to keep
ShapeTypeEnum as internal to the Shapefile data store implementation,
unless we can identify a case where it is needed outside the internal
implementation.


> When I give you a feature instance, today, how do you react on its geometric type ?

If have not looked deeply at ESRI's API yet. But with Java2D for
instance (java.awt.geom), we usually do not need to know the subtype.
The base class or interface provides the abstract methods needed for a
lot of cases (test if a point is inside the geometry, test if the
geometry intersects a rectangle, get an iterator over the line segments
that make the geometry, etc.) and the polymorphism of Java language does
its work. In the relatively rare cases where we need methods available
only in a specific subtype, we make "if (geom instanceof SomeType)"
checks and casts.

By the way, I just had a new look in ESRI API javadoc and found the
following classes. I didn't saw them before, so it seems to me that they
are quite new:

  * Geometry.GeometryType [1] seems to overlap with our ShapeTypeEnum
  * OperatorImportFromESRIShape [2] (while it is not yet clear to me how
    to use it)
  * OperatorExportToESRIShape [3]

Would it be worth to make some experiments with OperatorImportFromESRIShape?

    Martin


[1] http://esri.github.io/geometry-api-java/javadoc/com/esri/core/geometry/Geometry.GeometryType.html
[2] http://esri.github.io/geometry-api-java/javadoc/com/esri/core/geometry/OperatorImportFromESRIShape.html
[3] http://esri.github.io/geometry-api-java/javadoc/com/esri/core/geometry/OperatorExportToESRIShape.html