[mapguide-users] switching to Maestro 5 API

mika at digikartta.net mika at digikartta.net
Tue Nov 26 06:44:17 PST 2013


Thanks Jackie,
that helped.

Another question relating to the same field.

Constructing features and inserting them into feature source. I'll try 
to cut irrelevant part out of this. I can't figure out how to do this. I 
guess the actual insert would go like this.

IInsertFeatures ins = 
(IInsertFeatures)conn.CreateCommand((int)CommandType.InsertFeature);
                                 ins.FeatureSourceId = "xxx";
                                 ins.ClassName = "yyy";
                                 ins.Execute();

But how would I "bind" and construct the "propertycollection" for that? 
Any examples?

This is a snippet from my old method.
- mika -


     public int insertRoutes(MgResourceIdentifier mri, List<Feature> 
routes)
     {
         int inserted = 0;
         MgFeatureCommandCollection commands = new 
MgFeatureCommandCollection();
         MgFeatureService mfs = this.featSrvc;
         MgPropertyCollection insertedFeatures;
         MgAgfReaderWriter agfRW = new MgAgfReaderWriter();
         foreach (Feature route in routes)
         {
             MgPropertyCollection routeCol = new MgPropertyCollection();
             MgGeometryFactory geometryFactory = new 
MgGeometryFactory();
             if (route.geometry.type == "MultiPoint")
             {
                 MgPointCollection pointCol = new MgPointCollection();
                 MgPoint uusipiste = 
geometryFactory.CreatePoint(geometryFactory.CreateCoordinateXY((double)route.geometry.coordinates[0][0], 
(double)route.geometry.coordinates[0][1]));
                 pointCol.Add(uusipiste);
                 MgMultiPoint uudetpisteet = 
geometryFactory.CreateMultiPoint(pointCol);
                 //MgPoint uusipiste = 
geometryFactory.CreatePoint(geometryFactory.CreateCoordinateXY((double)route.geometry.coordinates[0][0], 
(double)route.geometry.coordinates[0][1]));
                 MgByteReader agf = agfRW.Write(uudetpisteet);
                 MgGeometryProperty geom = new 
MgGeometryProperty("Geom", agf);
                 MgInt32Property reitinid = new 
MgInt32Property("kohteetid", route.properties.routeid);
                 MgInt32Property reitinosanid = new 
MgInt32Property("routepartid", route.properties.routepartid);
                 MgStringProperty type = new MgStringProperty("type", 
route.properties.type);
                 MgInt32Property angle = new MgInt32Property("angle", 
(int)Math.Round(route.properties.angle, 0));
                 MgStringProperty symbol = new 
MgStringProperty("symbol", route.properties.symbol);
                 routeCol.Add(geom);
                 routeCol.Add(reitinid);
                 routeCol.Add(reitinosanid);
                 routeCol.Add(type);
                 routeCol.Add(angle);
                 routeCol.Add(symbol);
                 string fclassName = 
"schema_routelines:dim_routepoints";
                 MgInsertFeatures insertFeatures = new 
MgInsertFeatures(fclassName, routeCol);
                 commands.Add(insertFeatures);
             }
             else if (route.geometry.type == "LineString")
             {

             }
         }
         if (commands.Count > 0)
         {
             insertedFeatures = mfs.UpdateFeatures(mri, commands, 
false);
             inserted = insertedFeatures.Count;
         }
         return inserted;
     }



Jackie Ng kirjoitti 2013-11-25 06:52:
> The Maestro SDK contains everything you need to build an application 
> on top
> of the Maestro API:
>
>  - The Maestro API assemblies
>  - The full API reference + basic developer's guide in a CHM document
>  - Some desktop/web sample applications using the Maestro API
>  - A ProviderTemplate utility to build your own LocalNative 
> connection
> provider that wraps your specific version of the official .net 
> MapGuide API.
>
> You can download the Maestro SDK from the same download page as 
> Maestro
> itself: http://trac.osgeo.org/mapguide/wiki/maestro/Downloads
>
> To answer your question specifically:
>
> Use the CreateCommand() of the IServerConnection to create a 
> IDeleteFeatures
> command:
>
>      public void ClearDataSource(IServerConnection conn, String
> dataSourceId, String featureName)
>      {
>          IDeleteFeatures deleteCmd =
> (IDeleteFeatures)conn.CreateCommand(CommandType.DeleteFeatures);
>          deleteCmd.FeatureSourceId = dataSourceId;
>          deleteCmd.ClassName = featureName;
>          deleteCmd.Filter = "ID >= 0";
>          int nDeleted = deleteCmd.Execute();
>      }
>
> Note that support for IDeleteFeatures varies on the implementation of
> IServerConnection. For example, the HTTP one that wraps the mapagent 
> won't
> support CRUD operations, but the ones that wrap the official MapGuide 
> API
> and mg-desktop do support CRUD operations. You can programmatically 
> check
> support for such commands via the capabilities of the 
> IServerConnection
>
> - Jackie
>
>
>
> --
> View this message in context:
> 
> http://osgeo-org.1560.x6.nabble.com/switching-to-Maestro-5-API-tp5090710p5090931.html
> Sent from the MapGuide Users mailing list archive at Nabble.com.
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users


More information about the mapguide-users mailing list