bilaldursun1 / nettopologysuite

Automatically exported from code.google.com/p/nettopologysuite
0 stars 0 forks source link

The NetTopologySuite.IO.GeoTools class method ShapeFile.GetGeometryType(IGeometry geom) will always returns ShapeGeometryType.PointZM making all shapefile geometry GeometryZM. #173

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem? (see attached sample project)
1. Declare some features using NetTopologySuite.Feature. Use 
NetTopologySuite.Geometries.Point with GeoAPI.Geometries.Coordinate(x,y) as 
GeoAPI.Geometries.IGeometry and NetTopologySuite.Features.IAttributesTable.
sample code:
 List<NetTopologySuite.Features.Feature> features = new List<NetTopologySuite.Features.Feature> ();
                NetTopologySuite.Geometries.Point pt = new NetTopologySuite.Geometries.Point(new GeoAPI.Geometries.Coordinate(-91.0454, 32.5907));
                NetTopologySuite.Features.AttributesTable attr = new NetTopologySuite.Features.AttributesTable();
                attr.AddAttribute("FirstName", "John");
                attr.AddAttribute("LastName", "Doe");
                features.Add(new NetTopologySuite.Features.Feature(pt, attr));

2. Write the List<NetTopologySuite.Feature> to shapefile using 
ShapeFileDataWriter
code sample:
       NetTopologySuite.IO.ShapefileDataWriter shpWriter = new NetTopologySuite.IO.ShapefileDataWriter("path to file", features[0].Geometry.Factory);
                shpWriter.Header = NetTopologySuite.IO.ShapefileDataWriter.GetHeader(features[0], features.Count);
                shpWriter.Write(features);

3. Inspect the output file to see it is of PointZM type.

What is the expected output?
A Shapefile of Point geometry
What do you see instead?
A shapefile of PointZM

What version of the product are you using? 1.13.1.0
On what operating system? Windows 7 Professional

Please provide any additional information below.

Thank you,
Aerokneeus@gmail.com

Original issue reported on code.google.com by aerokne...@gmail.com on 22 Jan 2014 at 3:09

Attachments:

GoogleCodeExporter commented 9 years ago
This is by design if you use CoordinateArraySequenceFactory to create your 
points.
You need to use DotSpatialAffineCoordinateSequenceFactory to circumvent 
creation of PointZM shapefiles.

see:
http://code.google.com/p/nettopologysuite/source/browse/trunk/NetTopologySuite.S
amples.Console/Tests/IO/ShapefileWriteTest.cs

Original comment by felix.ob...@netcologne.de on 22 Jan 2014 at 3:58

GoogleCodeExporter commented 9 years ago
Thanks for the quick response felix. I have corrected the code and attached it 
as a reference.

 Using the NetTopologySuite.Geometries.Implementation.DotSpatialAffineCoordinateSequenceFactory.Instance allowed me to create the  GeoAPI.Geometries.ICoordinateSequence by setting the size and ordinates CSFactory.Create(1, GeoAPI.Geometries.Ordinates.XY). Then I was able to set the values of the ordinates using the ICoordinateSequence.SetOrdinate(). Once the sequence was setup, I used the GeoAPI.Geometries.IGeometryFactory to create the IGeometry point using the sequence.

Now the exported shapefile is of the correct shapetype and dimension.

Thanks again for the assist.

Original comment by aerokne...@gmail.com on 22 Jan 2014 at 6:02

Attachments:

GoogleCodeExporter commented 9 years ago
Hello,

I was looking for the same code but this is not working for me. The shapefile 
get created but doesen't get open with arcgis or not get added to mapguide 
maestro.

Original comment by shraddha...@gmail.com on 9 Dec 2014 at 9:38