• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk MapGuide Enterprise Developer

    Reply
    New Member
    naveen2010
    Posts: 2
    Registered: ‎06-25-2010

    Help me :- Error on layer.updatefeature

    676 Views, 5 Replies
    06-27-2010 10:49 PM

    I m new in mapguide 2010, i want to filter on layer data which connected with oracle db. Kindly somebody help me about this.

     

    MgFeatureCommandCollection updateCommands = new MgFeatureCommandCollection();

    updateCommands.Add (new MgDeleteFeatures ("Point", "clientid like '2%'"));

    layer = map.GetLayers().GetItem("Point");

    layer.UpdateFeatures(commands);

    layer.Visible = true;
    layer.ForceRefresh();


    Above code throwing "null" Error on this: layer.updatefeature.


    Please somebody help me......

     

    Thanks  in Advance

     

    Please use plain text.
    Contributor
    studio
    Posts: 25
    Registered: ‎08-10-2010

    Re: Help me :- Error on layer.updatefeature

    11-16-2010 06:58 AM in reply to: naveen2010

    I've got the same problem: did you solve it?!

    My code is in Java, and is a bit different:

     

    MgDeleteFeatures deleteFeature1 = new MgDeleteFeatures("area","nome='primo'");
    MgFeatureCommandCollection commands = new MgFeatureCommandCollection();
    commands.Add(deleteFeature1);
    MgLayer layer = (MgLayer)map.GetLayers().GetItem("area");
    layer.UpdateFeatures(commands);

     

    I think there is something wrong on the last string but I don't understand what.

    I'm working on MGOS 2.2, with bundled configuration with Java.

     

    Thanks in advance if you can help me!

    Please use plain text.
    Mentor
    Posts: 238
    Registered: ‎10-06-2008

    Re: Help me :- Error on layer.updatefeature

    11-17-2010 02:55 PM in reply to: naveen2010

    How did you create your map?

     

    Like this?

     

    MgMap map = new MgMap();

     

    Or this?

     

    MgSiteConnection conn = new MgSiteConnection();

    ...

    MgMap map = new MgMap(conn);

     

     

     

    MgLayer.UpdateFeatures() requires that the MgMap be created with the second constructor

     

    - Jackie

    Please use plain text.
    Contributor
    studio
    Posts: 25
    Registered: ‎08-10-2010

    Re: Help me :- Error on layer.updatefeature

    11-18-2010 02:28 AM in reply to: naveen2010

    I've modified the entire file in this way (see following rows) and now it works. But what is the difference for open a map between:

    MgMap map = new MgMap();

    and

    MgMap map = new MgMap(conn);

    ???

     

    Many thanks for your help.

     

    Here the code that works for me. I put some comment:

     

    <%

    String sessionId = request.getParameter("SESSION");

    String mapName = request.getParameter("MAPNAME");

    String realpath = getServletContext().getRealPath("/");

    // Initialize web tier with the site configuration file.  The config

    // file should be in the same folder as this script.

    String configPath =  realpath + "webconfig.ini";

    MapGuideJavaApi.MgInitializeWebTier( configPath );

    // Get the user information using the session id,

    // and set up a connection to the site server.

    MgUserInformation userInfo = new MgUserInformation(sessionId);

    MgSiteConnection siteConnection = new MgSiteConnection();

    siteConnection.Open(userInfo);

    MgSite site = new MgSite();

    site.Open(userInfo);

    // Get an instance of the required service(s).

    MgResourceService resourceService=(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);

    MgFeatureService featureService=(MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
     

     

    //WHICH IS THE DIFFERENCE??

    //MgMap map = new MgMap(siteConnection);

    MgMap map = new MgMap();

    map.Open(resourceService, mapName);


     //I'VE TRIED TO IDENTIFY THE RESOURCE IN THIS WAY BUT IT DOESN'T WORK:

    //String featureSourceName = "Session:" + sessionId + "//prova_basic/Data/area.FeatureSource";

    //MgResourceIdentifier fdo = new MgResourceIdentifier(featureSourceName);
    //BUT IN THIS WAY IT WORKS: THERE IS SOME DIFFERENCE??

    MgResourceIdentifier fdo = new MgResourceIdentifier("Library://prova_basic/Data/area.FeatureSource");

     

    //Specify the property values

    MgPropertyCollection properties = new MgPropertyCollection();

    MgAgfReaderWriter agfWriter = new MgAgfReaderWriter();

    properties.Add(new MgStringProperty("nome", nome));

    MgUpdateFeatures updateFeature1 = new MgUpdateFeatures("area", properties, "nome='secondo'");

    MgFeatureCommandCollection commands = new MgFeatureCommandCollection();

    commands.Add(updateFeature1);

    //To commit:

    MgLayer layer = (MgLayer)map.GetLayers().GetItem("area");

    featureService.UpdateFeatures(fdo, commands, false);

    %>

    Please use plain text.
    Mentor
    Posts: 238
    Registered: ‎10-06-2008

    Re: Help me :- Error on layer.updatefeature

    11-18-2010 03:20 PM in reply to: naveen2010

    The new MgMap constructor was introduced to enable a whole set of convenience methods without needing to pass the needed MgFeatureService or MgResourceService parameters, as the map will get these services from the MgSiteConnection you pass into the constructor

     

    Of course if you invoke the normal MgMap constructor and try to use these methods, there is no MgSiteConnection to grab th needed services from, hence the somewhat cryptic error.

     

    See: http://trac.osgeo.org/mapguide/wiki/MapGuideRfc9

     

    On the code you just posted: 

     

    MgResourceIdentifiers are just like URLs or file paths, the thing they point to must already exist. In the case of your session-based feature source, you need to have either copied or created a feature source at the specified resource id beforehand, otherwise you're just querying a feature source that is not there.

     

    - Jackie

    Please use plain text.
    Contributor
    studio
    Posts: 25
    Registered: ‎08-10-2010

    Re: Help me :- Error on layer.updatefeature

    11-19-2010 06:27 AM in reply to: naveen2010

    Ok, thanks for your advice.

    At next,

     

    Riccardo

    Please use plain text.