Autodesk Infrastructure Map Server(AIMS) API Training content : Part-6

By Daniel Du

This is second half of feature service, we will discuss updating, deleting and creating features with feature service.

A feature class contains one or more features. Each feature has a geometry that defines the spatial representation of the feature.Features will also generally have one or more properties that provide additional information. Feature class is a database-table-like structure, it contains properties corresponding to table columns. The properties can be geometry type, data type, raster type or object type. The most commonly used ones are geometry property and various data properties.  MgClassDefinition or MgPropertyDefinition classes are used to describe the schema of feature class.

To create a feature class, we need to build up the schema first by creating a MgClassDefinition and populate the property definition collection and add them to a MgPropertyDefinitionCollection which can be get from MgClassDefinition.GetProperties() method, next step is to create and set up schema with MgFeatureSchema class and the physical storage format. In AIMS, we can create file based schema like SDF, SHP file or SQLite.

Once the schema of feature source is created, we can add/delete/update some records(features) into it with MgInsertFeatures/MgDeleteFeatures/MgUpdateFeatures commands.  These commands accept MgPropertyCollection as parameter. MgPropertyCollection holds the property value used to update/insert a feature class. Finally we MUST call MgFeatureService.UpdateFeatures() to execute the commands(insert/delete/update) and commit the changes into feature source.

Let’s consider such a scenario, a user draws a feature(point, line or polygon)in browser with mouse and we’d like to save it into feature source. Firstly we need to get the coordinates of the feature, this process is called digitizing, it can be done with Ajax Viewer API or Fusion viewer API, please refer to this post for example of digitizing in fusion viewer.  After we getting the coordinate value of each vertex, we can create the geometry with MgGeometryFactory class.

If you examine the feature service API, you will notice that the constructor of MgGeometryProperty class need a parameter with MgByteReader type. In AIMS API, a geometry has 3 representations:

  1. MgGeometry and its subclasses, it can be  created with MgGeometryFactory;
  2. MyByteReader, which is used by feature service API;
  3. AGF(Autodesk Geometry Format) text, it is a superset of WKT(Well known text);

The conversion between these 3 representations can be done by MgAgfReaderWriter or MgWktReaderWriter:

image

 

Following graph demos the process of inserting a feature into class, it can be found in Web Extension API reference. Please read this graph from bottom to top.

image

 

OK, now please find the attached PPT for more information about this chapter.

Download EN_AIMS_API_Chapter_6


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading