Infrastructure Map Server Developer

Reply
New Member
naveen2010
Posts: 2
Registered: ‎06-25-2010
Message 1 of 6 (734 Views)

Help me :- Error on layer.updatefeature

734 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

 

Contributor
studio
Posts: 25
Registered: ‎08-10-2010
Message 2 of 6 (591 Views)

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!

Valued Mentor
jackie.ng
Posts: 273
Registered: ‎10-06-2008
Message 3 of 6 (584 Views)

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

Contributor
studio
Posts: 25
Registered: ‎08-10-2010
Message 4 of 6 (576 Views)

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);

%>

Valued Mentor
jackie.ng
Posts: 273
Registered: ‎10-06-2008
Message 5 of 6 (571 Views)

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

Contributor
studio
Posts: 25
Registered: ‎08-10-2010
Message 6 of 6 (562 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community