Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2006 Autodesk1 EMIA Geospatial Tech Camp and Sales Camp 2008.

Similar presentations


Presentation on theme: "© 2006 Autodesk1 EMIA Geospatial Tech Camp and Sales Camp 2008."— Presentation transcript:

1 © 2006 Autodesk1 EMIA Geospatial Tech Camp and Sales Camp 2008

2 © 2006 Autodesk2 Digging into the Autodesk MapGuide Enterprise API

3 © 2006 Autodesk3 Contents  Feature Class Structure  Inserting and deleting features  Viewer API support for creating geometries

4 © 2006 Autodesk4 Feature Class Structure  Database-table-like structure  Feature class contains properties corresponding to table columns.  Property types:  Geometry  Data  Raster  Object  Identity properties are used to uniquely identify a feature in a feature class. ID GEOM OWNERVALUESIZE Geometry Identity Data

5 © 2006 Autodesk5 MgClassDefinition Class MgClassDefinition  Represent a feature class  Sets class properties  Used to describe or create a new feature class  Important methods  GetProperties()  GetIdentityProperties()  The return type of these two methods is MgPropertyDefinitionCollection

6 © 2006 Autodesk6 MgPropertyDefinition Class MgPropertyDefinitionCollectio n  A collection of property definitions. MgPropertyDefinition  The details of a feature class property.  Has 4 subclasses or types  MgDataPropertyDefinition  MgGeometric…  MgRaster…  MgObject…

7 © 2006 Autodesk7 MgGeometricPropertyDefinition Class MgGeometricPropertyDefiniti on  Defines a geometric property  Important methods  SetHasElevation()  SetHasMeasure()  SetReadOnly()  SetSpatialContextAssociation  SetGeometryTypes() Types of geometric properties  MgFeatureGeometricType  Point – 1  Curve – 2  Surface – 4  Solid – 8

8 © 2006 Autodesk8 MgDataPropertyDefinition Class MgDataPropertyDefinition  Defines a data property  Important methods  SetAutoGeneration()  SetDefaultValue()  SetLength()  SetNullable()  SetPrecision()  SetReadOnly()  SetScale() Types of data properties  MgPropertyType  Double – 5  Int32 – 7  String – 9  …

9 © 2006 Autodesk9 Editing Feature Class  Feature class can be edited.  Three operations  Delete  Update  Insert  Feature editing is carried out on FDO data source Editing Feature Class Update Insert Delete

10 © 2006 Autodesk10 Delete Features, MgDeleteFeatures  Deleting features is performed by MgDeleteFeatures.  Pass in the query string and the name of the feature class on which the deletion will be carried out. MgDeleteFeatures deleteFeatures = new MgDeleteFeatures ("Parcels", "ID=2354"); MgDeleteFeatures deleteFeatures = new MgDeleteFeatures ("Parcels", "ID=2354"); MgDeleteFeatures deleteFeatures = new MgDeleteFeatures ("Parcels", "OWNER LIKE 'JOHN%'"); MgDeleteFeatures deleteFeatures = new MgDeleteFeatures ("Parcels", "OWNER LIKE 'JOHN%'"); MgDeleteFeatures deleteFeatures = new MgDeleteFeatures ("Parcels", "GEOM INTERSECTS GEOMFROMTEXT ('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))')"); MgDeleteFeatures deleteFeatures = new MgDeleteFeatures ("Parcels", "GEOM INTERSECTS GEOMFROMTEXT ('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))')");

11 © 2006 Autodesk11 MgPropertyCollection Class  Holds the property values used to update a feature class.  Must contains the values for the non-nullable properties.  For example, to update a feature class with schema like this, the MgPropertyCollection object must contains these properties.  ID  GEOM  OWNER ID GEOM OWNER VALUE SIZE      PropertiesNullable

12 © 2006 Autodesk12 MgPropertyCollection Class Example on using MgPropertyCollection class  Assume all the properties are nullable and we need to update the feature with these values MgPropertyCollection props = new MgPropertyCollection(); //Convert between MgGeometry and MgByteReader using MgAgfReaderWriter MgAgfReaderWriter agfWriter = new MgAgfReaderWriter(); props.Add(new MgGeometryProperty("GEOM", agfWriter.Write(geom))); props.Add(new MgStringProperty("LOTDIM", "540X400")); props.Add(new MgInt32Property("SQFT", "6600")); props.Add(new MgStringProperty("ZONE", "RES" )); MgPropertyCollection props = new MgPropertyCollection(); //Convert between MgGeometry and MgByteReader using MgAgfReaderWriter MgAgfReaderWriter agfWriter = new MgAgfReaderWriter(); props.Add(new MgGeometryProperty("GEOM", agfWriter.Write(geom))); props.Add(new MgStringProperty("LOTDIM", "540X400")); props.Add(new MgInt32Property("SQFT", "6600")); props.Add(new MgStringProperty("ZONE", "RES" ));

13 © 2006 Autodesk13 Insert Features, MgInsertFeatures  Inserting features is performed by MgInsertFeatures class.  Steps 1. Create an MgPropertyCollection object, which hold the values of a new feature. 2. Passing in the MgPropertyColllection object and the name of the feature class, which is to be inserted. //Variable "properties" is the MgPropertyCollection object MgInsertFeatures insertFeatures = new MgInsertFeatures ("Parcels", properties); //Variable "properties" is the MgPropertyCollection object MgInsertFeatures insertFeatures = new MgInsertFeatures ("Parcels", properties);

14 © 2006 Autodesk14 Commit Edits to Feature Class  Edits of deleting, updating, and inserting need to be committed to the feature class.  It’s done by MgFeatureCommandCollection class.  Feature commands are executed in the order they are added to the MgFeatureCommandCollection object.  The execution can be a transaction for the supported FDO data providers. MgMap map = new MgMap(); map.Open(resService, "Sheboygan"); MgResourceService resService = (MgResourceService)siteConnection.CreateService(MgServiceType.Reso urceService); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); commands.Add(deleteFeatures); commands.Add(updateFeatures); commands.Add(insertFeatures); MgLayer layer = map.GetLayers().GetItem("Parcels“); layer.UpdateFeatures(commands); MgMap map = new MgMap(); map.Open(resService, "Sheboygan"); MgResourceService resService = (MgResourceService)siteConnection.CreateService(MgServiceType.Reso urceService); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); commands.Add(deleteFeatures); commands.Add(updateFeatures); commands.Add(insertFeatures); MgLayer layer = map.GetLayers().GetItem("Parcels“); layer.UpdateFeatures(commands);

15 © 2006 Autodesk15 Create Geometries  Features contain geometries, which the geographic presentation of the real world entities.  Geometries can be created dynamically during the execution of MapGuide applications.  With the help of view API, geometries can be drawn with mouse in browser. IDOWNERVALUESIZE GEOM

16 © 2006 Autodesk16 MgGeometryFactory Class  Constructs geometry objects such points, line strings (polyline), and polygons.  Doesn’t examine geometric validity. You as the developer need to verify the legitimacy of the geometry. MgGeometryFactory geoFactory = new MgGeometryFactory(); MgCoordinateCollection coordCol = new MgCoordinateCollection(); for (int i = 0; i < num; i++) { MgCoordinate coord = geoFactory.CreateCoordinateXY(x[i], y[i]); coordCol.Add(coord); } MgLinearRing outRing = geoFactory.CreateLinearRing(coordCol); MgPolygon polygon = geoFactory.CreatePolygon(outRing, null); MgGeometryFactory geoFactory = new MgGeometryFactory(); MgCoordinateCollection coordCol = new MgCoordinateCollection(); for (int i = 0; i < num; i++) { MgCoordinate coord = geoFactory.CreateCoordinateXY(x[i], y[i]); coordCol.Add(coord); } MgLinearRing outRing = geoFactory.CreateLinearRing(coordCol); MgPolygon polygon = geoFactory.CreatePolygon(outRing, null);

17 © 2006 Autodesk17 Map Viewer Frames  Map viewer has a set of frames.  Frame set is in hierarchical relationship.  Each frame has its own API methods.  You need to invoke the function in the proper frame.  For example Viewer Frame Structure //From taskPaneFrame to refresh map parent.parent.mapFrame.Refresh(); //From sbFrame to refresh map parent.mapFrame.Refresh(); //From taskPaneFrame to refresh map parent.parent.mapFrame.Refresh(); //From sbFrame to refresh map parent.mapFrame.Refresh();

18 © 2006 Autodesk18 Map Frame APIs Map frame has methods  Digitize new geometries  Polygon  Polyline  Circle  Rectangle  Line  Point  Retrieve map information  Layers  Map center/scale  Map size  Selection  Convert units  Screen to map

19 © 2006 Autodesk19 Digitize Geometries  Map frame APIs provide methods to digitize new geometries.  To digitize polygons, 1. Write an event handler to take the finished polygon. 2. Pass the event handler as the parameter to invoke DigitizePolygon(). //Event handler function OnPolygonDigitized(poly) { ShowResults(FormatLineResults(poly)); } function DigitizePolygon() { parent.ViewerFrame.GetMapFrame().DigitizePolygon( OnPolygonDigitized); } //Event handler function OnPolygonDigitized(poly) { ShowResults(FormatLineResults(poly)); } function DigitizePolygon() { parent.ViewerFrame.GetMapFrame().DigitizePolygon( OnPolygonDigitized); }

20 © 2006 Autodesk20 Create Polygon with View API  Users can draw a geometry like polygon in browser with viewer API.  The drawing can be submitted to MapGuide applications to construct an MgPolygon object. function DigitizePolygon() { parent.parent.mapFrame.DigitizePolygon (OnPolygonDigitized); } function OnPolygonDigitized(poly) { FormatLineResultsForParser(poly); } function FormatLineResultsForParser(line) { str = line.Count + "~"; for(var i = 0; i < line.Count; i++) { pt = line.Point(i); str += pt.X + "!" + pt.Y + "_"; } document.getElementById("coordinates").value = str; } function DigitizePolygon() { parent.parent.mapFrame.DigitizePolygon (OnPolygonDigitized); } function OnPolygonDigitized(poly) { FormatLineResultsForParser(poly); } function FormatLineResultsForParser(line) { str = line.Count + "~"; for(var i = 0; i < line.Count; i++) { pt = line.Point(i); str += pt.X + "!" + pt.Y + "_"; } document.getElementById("coordinates").value = str; }

21 © 2006 Autodesk21 Questions & Answers

22 © 2006 Autodesk22


Download ppt "© 2006 Autodesk1 EMIA Geospatial Tech Camp and Sales Camp 2008."

Similar presentations


Ads by Google