ThinkGeo.com    |     Documentation    |     Premium Support

Oracle Spatial

Dear All,


I have a map in oracle geometry tables , I need to display  the map in an ASP web application and give the users the ability to modify the map objects (adding, removing or changing) the object location or shape as well as changing its attributes. will some body advisde if this is possible in Map Suite and how with sample code would be perfect ..


 


Thanks in advance,


Ali



Hi,


Oracle spatial is preferred, if shapefile can do it then it is ok ..


 


Thank you


 



Ali,



Welcome to the community, hope you enjoy the learning and sharing here!



We support editing on both shape file and Oracle database, the editing codes are similar. Here is the link where you can find a sample how to do the editing on ShapeFile.


gis.thinkgeo.com/Support/Dis...fault.aspx




Also, here is some sample code how to update the map object's attributes.




      ShapeFileFeatureSource mapShapeFeatureSource = new ShapeFileFeatureSource(MapPath("~/SampleData/world/cntry02.shp"), ShapeFileReadWriteMode.ReadWrite);
                mapShapeFeatureSource.Open();
                Feature newFeature = mapShapeFeatureSource.GetFeatureById("1", new string[] { "CNTRY_NAME" });
                newFeature.ColumnValues["CNTRY_NAME"] = "MyNewName";
                mapShapeFeatureSource.BeginTransaction();
                mapShapeFeatureSource.UpdateFeature(newFeature);
                mapShapeFeatureSource.CommitTransaction();
                mapShapeFeatureSource.Close();

Thanks,


Ben



Dear Ben, 
 Thank you very much for your repley, is there any sample code for oracle spacial editing/drawing? 
  
 thank you 





 


Ali,


Here is the code how to load map from an oracle database and how to add new feature to it. You can see the code is almost the same as editing a shape file.



// Display the Oracle data on map
private void LoadAnOracleVectorLyer()
{
string connectString = "User ID=userId;Password=password;Data Source=192.168.0.167/orcl;";
OracleFeatureLayer oracleLayer = new OracleFeatureLayer(connectString, "USSTATES", "RECID");
oracleLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
oracleLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Map1.StaticOverlay.Layers.Add("oracleLayer", oracleLayer);
}

// Edit a new feature on the Oracle layer
OracleFeatureLayer oracleLayer = (OracleFeatureLayer)Map1.StaticOverlay.Layers["oracleLayer"];
Feature newFeature = new Feature("Polygon((0 0,10 10,10 0,0 0))");
newFeature.ColumnValues.Add("STATE_NAME", "NewState");
oracleLayer.Open();
oracleLayer.FeatureSource.BeginTransaction();
oracleLayer.FeatureSource.AddFeature(newFeature);
oracleLayer.FeatureSource.CommitTransaction();
oracleLayer.FeatureSource.Close();

New Feature Added to the Oracle database



Also, please have a look at the following post where you can find an update assembly about OracleFeatureLayer, in which we have a known bug fixed.


gis.thinkgeo.com/Support/Dis...fault.aspx


Thanks,


Ben


 




Hi Ben, 
  
 I rried your code but i am get "Object reference not set to an object" on the map? I am using oracle XE and data from the mvdemo provided by oracle … 
  
 Thank you 


Ali,


1, A customer mentioned that he found we didn't support Oracle Express Edition because of the Get_WKB method. please have a look at this post for detail.

gis.thinkgeo.com/Support/Dis...fault.aspx


2, If you have a chance to try it in a standard Oracle, could you make sure the sample you tested includes the geometry data? also please make sure you are using the correct table name and geometry column name in the codes (they should have the correct cases).


We will also make the exception message more descriptive, which will save you much time to find the reason.


Thanks,


Ben