AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OSGeo FDO SpatialCondition Error

1 REPLY 1
SOLVED
Reply
Message 1 of 2
fieldguy
535 Views, 1 Reply

OSGeo FDO SpatialCondition Error

I am trying to replicate the code >>in this post<<

but I am getting an error >>"The property "SHAPE" is not in the reader's selected property set"<<.

I can connect to my shp file and obtain all of the features but I want to filter by a user selected rectangle.

 

Does anyone have working code for using a polygon as in "OSGeo.FDO.Filter.SpatialCondition("SHAPE", OSGeo.FDO.Filter.SpatialOperations.SpatialOperations_Inside, gv)?

 

There are samples in the DevBlog but those are using "layers" attached to the current map - that's not what I want.

 

If necessary I can obtain all of the "points" in this case, and determine if the points are within the rectangle, but that is a "worst case" scenario.

 

1 REPLY 1
Message 2 of 2
fieldguy
in reply to: fieldguy

I got this to work - "Geometry" was the key word.

 

 

string shp = "DefaultFileLocation=path and shp file name";
IConnectionManager icm = OSGeo.FDO.ClientServices.FeatureAccessManager.GetConnectionManager();
            OSGeo.FDO.Connections.IConnection ic = icm.CreateConnection("OSGeo.SHP");
            ic.ConnectionString = shp;
            ic.Open();
            OSGeo.FDO.Expression.Identifier id = new OSGeo.FDO.Expression.Identifier("some feature class");
            OSGeo.FDO.Commands.Feature.ISelect sfeat =
                (OSGeo.FDO.Commands.Feature.ISelect)ic.CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_Select);
            sfeat.FeatureClassName = id;
// lower left
            DirectPositionImpl ll = new DirectPositionImpl();
            ll.X = 348237.0;  
            ll.Y = 6139124.0;
// upper right
            DirectPositionImpl ur = new DirectPositionImpl();
            ur.X = 357177.0;
            ur.Y = 6147692.0;
            FgfGeometryFactory fgf = new FgfGeometryFactory();
            IEnvelope env = fgf.CreateEnvelope(ll, ur);
            IGeometry geom = fgf.CreateGeometry(env);
            Byte[] bytearray = fgf.GetFgf(geom);
            OSGeo.FDO.Expression.GeometryValue gv = new OSGeo.FDO.Expression.GeometryValue(bytearray);
            OSGeo.FDO.Filter.Filter newfilter;
            newfilter = new OSGeo.FDO.Filter.SpatialCondition("Geometry", OSGeo.FDO.Filter.SpatialOperations.SpatialOperations_Inside, gv);
            sfeat.SetFilter(newfilter.ToString());
            OSGeo.FDO.Commands.Feature.IFeatureReader fr = sfeat.Execute();
            int featcount = 0;
            while (fr.ReadNext())
            {
                featcount++;
            }// 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report