Thanks Andrea and Jody for your advice on this. I had to put this work 
aside for a while and only just started looking at it again, but your 
input was much appreciated.

I'm now working with some ZM shapefiles and have a related question 
which I fear may require rather more work on my part. Reading these  in 
the standard way (getting a datastore using FileDataStoreFinder, using 
that to get a FeatureSource then a FeatureCollection and iterating over 
it) I get the Z ordinate if I call getCoordinates() on my geometries and 
look at the z member of each Coordinate.

But what about the M ordinate? com.vividsolutions.jts.geom.Coordinate is 
3D only, so even if the code that reads the shapefiles "knows" about the 
M values (which it must do in a sense if only to skip over the relevant 
bits of the file) it couldn't use this class to store them. The javadoc 
for CoordinateSequence says: "There are some cases in which you might 
want Geometries to store their points using something other than the JTS 
Coordinate class ... one that supports extra attributes like M-values. 
You can do this by implementing the CoordinateSequence and 
CoordinateSequenceFactory interfaces."

They have an example of doing just that in 
com.vividsolutions.jtsexample.geom.ExtendedCoordinate, but clearly some 
extra work would be required to create a shapefile reader that could 
make use of such 4D coordinates. Any pointers as to what code I should 
use/ add to / modify to achieve this?

Thanks

Mark



On 16/07/10 09:47, Andrea Aime wrote:
> Mark Payne ha scritto:
>> So far I tried the following:
>>
>> featureSource = ds.getFeatureSource(FEATURE_TYPE_NAME);
>> DefaultQuery query = new DefaultQuery(DefaultQuery.ALL);
>> Hints hints = new Hints(Hints.COORDINATE_DIMENSION, new Integer(3),
>>                                           Hints.FEATURE_2D, 
>> Boolean.FALSE);
>> query.setHints(hints);
>> featureCollection = featureSource.getFeatures(query);
>>
>> That was the kind of thing you were meaning? I tried the hints that 
>> seemed the most likely from the list that the Hints object provides. 
>> Unfortunately it doesn't seem to make a difference, I just get 
>> features with the X,Y components as before. Does anyone know if I'm 
>> on the right track, or do I need to provide a different 
>> CoordinateSequenceFactory as well?
>
> The code in the stable branches will pick up the 3rd dimension
> only if the crs had 3 axis:
>
> @Override
>     public void encodeGeometryColumn(GeometryDescriptor gatt, int srid,
>             StringBuffer sql) {
>         CoordinateReferenceSystem crs = 
> gatt.getCoordinateReferenceSystem();
>         int dimensions = crs == null ? 2 : crs.getCoordinateSystem()
>                 .getDimension();
>         sql.append("encode(");
>         if (dimensions > 2) {
>             sql.append("asEWKB(");
>             encodeColumnName(gatt.getLocalName(), sql);
>         } else {
>             sql.append("asBinary(");
>             sql.append("force_2d(");
>             encodeColumnName(gatt.getLocalName(), sql);
>             sql.append(")");
>         }
>         sql.append(",'XDR'),'base64')");
>     }
>
> On trunk I've recently (two days ago?) made it use EWKB always,
> which means it should pull all the ordinates, but even
> that is not fully correct, as it does not respect the FORCE2D
> hint.
>
> Actually, the SQLDialect methods should be modified so that they
> get the hints otherwise it's not possible to implement things
> properly.
>
> I don't have time to look into this, do you? A patch on the
> code and an extension to the JDBC3DTest to check support for
> FORCE2D would be most welcomed
>
> Cheers
> Andrea
>
>
>


-- 
Mark Payne
Development Engineer

Tel: +44 (0) 131 447 4200          Address: SeeByte Ltd.
Support Tel: +44 (0) 131 510 4200           Level 7, Orchard Brae House
USA Tel (UK Hours): +1 (619) 241 4393       30 Queensferry Road
Fax: +44 (0) 131 447 4911                   Edinburgh, EH4 2HS
Web: http://www.seebyte.com                 Scotland, UK

| This message is confidential and may be privileged. If it is
| not for you please inform us then delete it. If the content is
| not about the business of the company or its clients then the
| message is neither from nor sanctioned by SeeByte Limited which is
| a company registered in Scotland (reg. number SC194014) with its
| registered office at the address stated above.


------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to