Conversion from V0.9 to V2.0

Jul 23, 2008 at 10:12 PM
Hello,

I'm in the process of converting my SharpMap web services from v0.9 to v2.0; using Visual Studio 3.5; a little pain involved.

ORIGINAL CODE - (This one mostly borrowed from Juan Deblo)

ShapeFileProvider sf = null;

try

{

sf = new ShapeFileProvider(filePath);

sf.Open(false);

if (sf.ShapeType != ShapeType.Polygon)

return null;

BoundingBox ext = sf.GetExtents();

IEnumerable<Geometry> geometries = sf.ExecuteGeometryIntersectionQuery(ext);

foreach (Geometry geometry in geometries)

{

Polygon polygon = geometry as SharpMap.Geometries.Polygon;

if (polygon != null)

{

foreach (var vertex in polygon.ExteriorRing.Vertices)

{

string sOutput = vertex.X + ":" + vertex.Y;
"

"
"
"

NEW CODE - NOW STUCK ON THE EXECUTE COMMAND:

SharpMap.Data.Providers.ShapeFile.

ShapeFileProvider sf = null;

 

 

try

 

{

sf =

new SharpMap.Data.Providers.ShapeFile.ShapeFileProvider(filePath, factory);

 

sf.Open();

// (false);

 

 

if (sf.ShapeType != SharpMap.Data.Providers.ShapeFile.ShapeType.Polygon)

 

 

return null;

 

 

IExtents ext = sf.GetExtents();

 

 

List<IGeometry> geometries = new List<IGeometry>();

 

geometries.AddRange(sf.......);



QUESTIONS
1) Suggestions on how to proceed - basically, I need to retrieve coordinates from shapefile
2) A Better approach

I've looked at the latest patch (SharpMapWinFormsDemo), but still struggling.

THANKS......

Jul 25, 2008 at 6:55 PM

Resolved - look at code below:

sf =

new ShapeFileProvider(filePath, gFactory, cFactory);

 

sf.Open();

 

FeatureQueryExpression

query = FeatureQueryExpression.Intersects(sf.GetExtents());

 

 

IFeatureDataReader reader = sf.ExecuteFeatureQuery(query);