[mapguide-users] help

saloua wakrim wakrimsaloua.wakrim at gmail.com
Thu May 28 05:42:18 EDT 2009


hi kenneth! did you know what does" id" in <layer id=255.....> returned by
selection xml mean? cause when i got the XmlSelection from map and i use it
for getting layers it contains i've error wich say that layers is nothing
but the selection is nt i've verifyed it the selection i got from map is not
empty but the layers are nothing, so i think that can be caused by the "id"
in <layer id=255.....> returned by the selection if that mean the session
for example cause me when i create layer i do it with
"library://......mapdefinition" and not "Session//....mapdefinition" so i
think that if the id on <layer id=255.....> means the session used by user i
think that layer contained on selection won't be known, but i'm not sure
please if you have some idea tell it me, thanks a lot on advance.

2009/5/26 saloua wakrim <wakrimsaloua.wakrim at gmail.com>

> hi! thanks alot for your help, i found exemple in phpsamples explaining how
> to get features from XMLSelection, i tried use it today, but i've prob wich
> i don't understand:
>
> i've prob with use the xml selection wich i get after user clic on
> polygone, this is javascript function i use to get selection:(i write it in
> textfiel and read it by Request.Form:
>   function test()
>     {
>
>  k= document.formulaire.classe.value=carte.GetMapFrame().GetSelectionXML();
>
>
>     }
> for get this selection i use this code
>  selectionXml = getValue("classe")
>
>   Private Function getValue(ByVal champ As String) As String
>         ' récupère la valeur du champ [champ] de la requête postée
>         ' qq chose ?
>         If Request.Form(champ) Is Nothing Then Return ""
>         ' on récupère la ou les valeurs du champ
>         Dim valeurs() As String = Request.Form.GetValues(champ)
>         Dim valeur As String = ""
>         Dim i As Integer
>         For i = 0 To valeurs.Length - 1
>             valeur += valeurs(i)
>         Next
>         valeur = Server.UrlDecode(valeur)
>         Return valeur
>     End Function
> after user clic on polygone and get xml selection , i use this code for
> filter and identify polygone ID:
>  Public Sub getselectionpartiel(ByVal map As MgMap, ByVal resourceService
> As MgResourceService, ByVal XmlSel As String)
>
>
>         Dim k = 0
>            If ((XmlSel <> Nothing) And (XmlSel <> "")) Then
>
>             Dim selection As New MgSelection(map, XmlSel)
>             Dim Layers As MgReadOnlyLayerCollection = selection.GetLayers()
>
>             If Not Layers.GetCount = 1 Then
>                 Response.Write("More than one object was selected")
>                 Exit Sub
>             End If
>
>
>
>
>             Response.Write("calques selectionnés")
>
>
>         End If
>     End Sub
>  and i call this function like that:
>     getselectionpartiel(map, resourceSrvc, selectionXml)
> it gives me this error:
> "La référence d'objet n'est pas définie à une instance d'un objet." in the
> line:
> (the object reference is not associated to the object instance)
>     If Not Layers.GetCount = 1 Then
> i think that Layers is empty but when i display "selectionXml" by using:
> Response.Write(selectionXml) it gives me the correct selection!!!
> if you have some idea about the error i do,please tell it me, thanks a lot
> on advance
>
> 2009/5/26 Kenneth Skovhede, GEOGRAF A/S <ks at geograf.dk>
>
>  The keyword for this is base64 encoding, see:
>> http://lists.osgeo.org/pipermail/mapguide-users/2008-February/011245.html
>> and
>> http://www.mail-archive.com/mapguide-users@lists.osgeo.org/msg03312.html
>>
>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>
>>
>>
>> saloua wakrim skrev:
>>
>> i resolved coordinates point prob and transparency layer, now i want
>> identify polygone wich i draw on map by user clic, i use GetSelectionXml()
>> when user select polygone, this function gives me:
>>
>> <?xml version="1.0" encoding="UTF-8"?><FeatureSet><Layer
>> id="d610b562-ffff-ffff-8002-0016356155d0"><Class
>> id="BufferLayerSchema:BufferClass"><ID>GQAAAA==</ID></Class></Layer></FeatureSet>
>>
>> i want understand how can i identify polygone (id polygone) by this
>> description i think that i must use
>> <ID>GQAAAA==</ID> cause i've remarked that all what it changes when i
>> select another polygone, but i don't see the relation with
>> <ID>GQAAAA==</ID> end the ID wich i associate to my polygone when i create
>> it.there is any relation?? thanks a lot on advance.
>>
>> 2009/5/20 Kenneth Skovhede, GEOGRAF A/S <ks at geograf.dk>
>>
>>> UNIT is the coordinate system unit, eg. degrees, meters or inches.
>>>
>>> If the layers and map have the correct coordinate systems assigned,
>>> MapGuide will automatically convert the data to display correctly,
>>> so you get the correct map.
>>>
>>> You do not have to work with the projection string manually.
>>> Beware of trying to calculate coordinates manually based on the UNIT,
>>> because
>>> projections are not always compatible just because the use the same UNIT.
>>> Instead, use the MgCoordinateSystem classes to convert points from one
>>> projection to another.
>>>
>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>
>>>
>>>
>>>
>>> saloua wakrim skrev:
>>>
>>> but please if you know what that UNIT means in coordinates System say it
>>> me:
>>>
>>>
>>> <
>>> CoordinateSystem>GEOGCS["WGS84 Lat/Long's, Degrees, -180 ==>
>>> +180",DATUM["D_WGS_1984",SPHEROID["World_Geodetic_System_of_1984",6378137,298.257222932867]],PRIMEM["Greenwich",0],
>>> *UNIT*["Degree",0.017453292519943295]]</CoordinateSystem> cause i want
>>> draw polygone representing view of cam (dome) and it must be proportional to
>>> the real view of cam, and my layer must be added to map with another layer
>>> wich contains cams so i must know wich units is used on map(m, km, cm) or
>>> what? that what i do that i convert (m) to unit by this code:
>>>
>>> MgCoordinateSystemFactory
>>> csFactory = new MgCoordinateSystemFactory(); MgCoordinateSystem srs =
>>> csFactory.Create(map.GetMapSRS()); MgCoordinateSystemMeasure mesure =
>>> new MgCoordinateSystemMeasure(srs);
>>>
>>> distanceunits = pointa.Distance(pointb, mesure);
>>>
>>> Response.Write(
>>> "distance entre les deux points du calque en unit‚: "+distanceunits.ToString());
>>>
>>>
>>> distancemeters = srs.ConvertCoordinateSystemUnitsToMeters(distanceunits);
>>> but i don't know if this layer (wich contains polygone) will be
>>> compatible with another layer or not? if you don't understand me say it me
>>> please. thanks or advance, i ask you cause i remark that you master more
>>> than onother mapguide developpers mapguide, thanks on advance.
>>>
>>> 2009/5/19 Kenneth Skovhede, GEOGRAF A/S <ks at geograf.dk>
>>>
>>>> There is an example for MgCreateSdfParams() in the
>>>> "buffer.(php|aspx|jsp)" file in the folder
>>>> C:\program
>>>> files\MapGuideOpenSource2.0\WebServerExtensions\www\mapviewer(php|net|java)
>>>>
>>>> It also shows how to set the coordinate system.
>>>> If your data has the correct projection, MapGuide will convert it to fit
>>>> the map projection.
>>>> If that does not work, you have to manually convert the items, which is
>>>> not a trivial procedure.
>>>>
>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>
>>>>
>>>>
>>>>
>>>> saloua wakrim skrev:
>>>>
>>>> hi! did you know lease how MgCreateSdfParams() works and what attributes
>>>> i must give it cause ii think that the prob i have is coordinates i use for
>>>> inserting polygone or line or point wich are not compatibl with map
>>>> cordinates
>>>>
>>>> 2009/5/11, Kenneth Skovhede, GEOGRAF A/S <ks at geograf.dk>:
>>>>>
>>>>> Yes, that looks right.
>>>>>
>>>>> You must also refresh the map (refresh/pan/zoom/etc.) in the browser
>>>>> via javascript.
>>>>>
>>>>> In addition to my other suggestions, you can also check the error log
>>>>> for messages.
>>>>>
>>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> saloua wakrim skrev:
>>>>>
>>>>> hi! please i want know if this code is that what all i must do for
>>>>> adding new layer to map and see it in viewer frame or i must do some
>>>>> relation with the feature source i create in my code?? thanks on advance
>>>>>
>>>>>
>>>>> myLayer =
>>>>> New MgLayer(layerDefId, resourceSrvc)
>>>>>
>>>>> myLayer.SetName(myLayerName)
>>>>>
>>>>> myLayer.SetLegendLabel(myLayerName)
>>>>>
>>>>> myLayer.SetDisplayInLegend(
>>>>> True)
>>>>>
>>>>> myLayer.SetSelectable(
>>>>> False)
>>>>>
>>>>> map.GetLayers().Insert(0, myLayer)
>>>>>
>>>>> myLayer.ForceRefresh()
>>>>> map.Save(resourceSrvc)
>>>>>
>>>>>
>>>>> 2009/5/10 Kenneth Skovhede, GEOGRAF A/S <ks at geograf.dk>
>>>>>
>>>>>> The code looks alright.
>>>>>> Do you refresh the map afterwards?
>>>>>> What is in the "insertResults" ?
>>>>>> (There can be a hidden error, due to a bug in MapGuide)
>>>>>> Are you sure that the LayerDefinition matches the FeatureSource?
>>>>>> Try to create the FeatureSource and LayerDefinition in "Library://"
>>>>>> instead,
>>>>>> so you can examine the layer from Studio/Maestro.
>>>>>>
>>>>>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> saloua wakrim skrev:
>>>>>>
>>>>>>  i try the following code for displaying layer wich contains line in
>>>>>> map, so i digitize a line, create temporary feature for this line, create a
>>>>>> layer wich contains it and add it to the map. it doesn't give me some error
>>>>>> but  i can see the line in the map (i can draw it). Please help me. the code
>>>>>> is following:
>>>>>>
>>>>>>
>>>>>>
>>>>>> String
>>>>>> dataSource = "Session:" + sessionid1 + "//" + myLayerName +
>>>>>> ".FeatureSource"; MgResourceIdentifier dataSourceId = new
>>>>>> MgResourceIdentifier(dataSource); MgFeatureService featureSrvc = (
>>>>>> MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
>>>>>> if (DoesLayerExist(myLayerName, map) == false)
>>>>>>
>>>>>> {
>>>>>>
>>>>>>
>>>>>> //create Feature Source MgClassDefinition myClassDef = new
>>>>>> MgClassDefinition();
>>>>>>
>>>>>> myClassDef.SetName(myLayerName);
>>>>>>
>>>>>> myClassDef.SetDescription(myLayerName +
>>>>>> " Feature Source");
>>>>>>
>>>>>> myClassDef.SetDefaultGeometryPropertyName(
>>>>>> "SHPGEOM"); MgDataPropertyDefinition prop = new
>>>>>> MgDataPropertyDefinition("KEY");
>>>>>>
>>>>>> prop.SetDataType(
>>>>>> MgPropertyType.Int32);
>>>>>>
>>>>>> prop.SetAutoGeneration(
>>>>>> true);
>>>>>>
>>>>>> prop.SetReadOnly(
>>>>>> true);
>>>>>>
>>>>>> myClassDef.GetIdentityProperties().Add(prop);
>>>>>>
>>>>>> myClassDef.GetProperties().Add(prop);
>>>>>>
>>>>>> prop =
>>>>>> new MgDataPropertyDefinition("ID");
>>>>>>
>>>>>> prop.SetDataType(
>>>>>> MgPropertyType.Int32);
>>>>>>
>>>>>> myClassDef.GetProperties().Add(prop);
>>>>>> MgGeometricPropertyDefinition geomProp = new
>>>>>> MgGeometricPropertyDefinition("SHPGEOM");
>>>>>>
>>>>>> geomProp.SetGeometryTypes(
>>>>>> MgFeatureGeometricType.Curve);
>>>>>>
>>>>>> myClassDef.GetProperties().Add(geomProp);
>>>>>> MgFeatureSchema schema = new MgFeatureSchema(myLayerName + "Schema",
>>>>>> myLayerName + "SchemaDesc");
>>>>>>
>>>>>> schema.GetClasses().Add(myClassDef);
>>>>>> MgCreateSdfParams sdfParams = new MgCreateSdfParams("MGA-56 (GDA94 /
>>>>>> MGA zone 56)", map.GetMapSRS(), schema);
>>>>>>
>>>>>> featureSrvc.CreateFeatureSource(dataSourceId, sdfParams);
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> //create layer //String layerDef = "Session:" + sessionid1 + "//" +
>>>>>> myLayerName + ".LayerDefinition"; MgResourceIdentifier layerDefId =
>>>>>> new MgResourceIdentifier(
>>>>>> "Library://essaicalque/Redline.LayerDefinition");
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> MgByteSource content = new MgByteSource(@"C:\Program
>>>>>> Files\MapGuideOpenSource\WebServerExtensions\www\essaiselect2\Layerdef.xml");
>>>>>>
>>>>>>
>>>>>> resourceSrvc.SetResource(layerDefId, content.GetReader(),
>>>>>> null); //code enlev‚ d'ici: ajouter layer resource … la carte //il
>>>>>> faut ajouter l'autre code: add layer resource to map //DOMDocument
>>>>>> domdoc = new DOMdocument(); MgLayerresult=add_layer_resource_to_map(layerDefId,resourceSrvc,myLayerName,myLayerName,map);
>>>>>>
>>>>>>
>>>>>> }
>>>>>> MgInsertFeatures insertFeatures = new MgInsertFeatures(myLayerName,
>>>>>> makeLine("1", x0, y0, x1, y1)); MgFeatureCommandCollection commands =
>>>>>> new MgFeatureCommandCollection();
>>>>>>
>>>>>> commands.Add(insertFeatures);
>>>>>> int commandIndex = commands.IndexOf(insertFeatures);
>>>>>> MgPropertyCollection insertResults;
>>>>>>
>>>>>> insertResults = featureSrvc.UpdateFeatures(dataSourceId, commands,
>>>>>> false); MgLayer myLayer1 = map.GetLayers().GetItem(myLayerName) as
>>>>>> MgLayer;
>>>>>>
>>>>>> myLayer1.ForceRefresh();
>>>>>>
>>>>>>
>>>>>> //commands.Add(new MgInsertFeatures(myLayerName,makeLine("1", x0, y0,
>>>>>> x1, y1)));
>>>>>>
>>>>>>
>>>>>>
>>>>>> map.Save(resourceSrvc);
>>>>>>
>>>>>>
>>>>>>
>>>>>> <
>>>>>> script runat=server> Boolean result; MgPropertyCollection makeLine(
>>>>>> String Name, Double x0, Double y0, Double x1, Double y1)
>>>>>>
>>>>>> {
>>>>>> MgPropertyCollection PropertyCollection = new MgPropertyCollection();
>>>>>> MgInt32Property nameProperty = new MgInt32Property("ID", 1);
>>>>>>
>>>>>> PropertyCollection.Add(nameProperty);
>>>>>> MgWktReaderWriter wktReaderWriter = new MgWktReaderWriter();
>>>>>> MgAgfReaderWriter agfReaderWriter = new MgAgfReaderWriter();
>>>>>> MgGeometry geometry = wktReaderWriter.Read("LINESTRING XY (" + x0 + "
>>>>>> " + y0 + "," + x1 + " " + y1 + ")") as MgLineString; //MgGeometry
>>>>>> geometry = wktReaderWriter.Read("LINESTRING(3 4,10 50,20 25)") as
>>>>>> MgLineString; MgByteReader geometryByteReader =
>>>>>> agfReaderWriter.Write(geometry); MgGeometryProperty geometryProperty
>>>>>> = new MgGeometryProperty("SHPGEOM", geometryByteReader);
>>>>>>
>>>>>> PropertyCollection.Add(geometryProperty);
>>>>>> return PropertyCollection;
>>>>>>
>>>>>> }
>>>>>>
>>>>>> Boolean
>>>>>> DoesLayerExist(String LayerName, MgMap Map)
>>>>>>
>>>>>> {
>>>>>> MgLayerCollection layers = Map.GetLayers();
>>>>>>
>>>>>> result = (layers.Contains(myLayerName));
>>>>>> return result;
>>>>>>
>>>>>> }
>>>>>> MgLayer add_layer_resource_to_map(MgResourceIdentifierlayerresourceid,
>>>>>> MgResourceService rs, String layername, String layerlegendlabel,
>>>>>> MgMap map)
>>>>>>
>>>>>> {
>>>>>> MgLayer myLayer = new MgLayer(layerresourceid, rs);
>>>>>>
>>>>>> myLayer.SetName(layername);
>>>>>>
>>>>>> myLayer.SetLegendLabel(layerlegendlabel);
>>>>>>
>>>>>> myLayer.SetDisplayInLegend(
>>>>>> true);
>>>>>>
>>>>>> myLayer.SetSelectable(
>>>>>> true);
>>>>>>
>>>>>>
>>>>>> if (!map.GetLayers().Contains(layername))
>>>>>>
>>>>>> {
>>>>>>
>>>>>> map.GetLayers().Insert(0, myLayer);
>>>>>>
>>>>>> }
>>>>>>
>>>>>> myLayer.SetVisible(
>>>>>> true);
>>>>>>
>>>>>> myLayer.ForceRefresh();
>>>>>>
>>>>>> map.Save(resourceSrvc);
>>>>>> return myLayer;
>>>>>>
>>>>>> }
>>>>>>
>>>>>> </
>>>>>> script>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------
>>>>>>
>>>>>> _______________________________________________
>>>>>> mapguide-users mailing listmapguide-users at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> mapguide-users mailing list
>>>>>> mapguide-users at lists.osgeo.org
>>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>>
>>>>>>
>>>>> ------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> mapguide-users mailing listmapguide-users at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> mapguide-users mailing list
>>>>> mapguide-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>>
>>>>>
>>>> ------------------------------
>>>>
>>>> _______________________________________________
>>>> mapguide-users mailing listmapguide-users at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>
>>>>
>>>> _______________________________________________
>>>> mapguide-users mailing list
>>>> mapguide-users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>
>>>>
>>> ------------------------------
>>>
>>> _______________________________________________
>>> mapguide-users mailing listmapguide-users at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>> ------------------------------
>>
>> _______________________________________________
>> mapguide-users mailing listmapguide-users at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/mapguide-users
>>
>>
>> _______________________________________________
>> mapguide-users mailing list
>> mapguide-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090528/1a722aef/attachment.html


More information about the mapguide-users mailing list