[mapguide-users] help

saloua wakrim wakrimsaloua.wakrim at gmail.com
Mon May 25 06:14:30 EDT 2009


hi i want get coordinates of the point inserted in map how can i proceed?
thanks on advance

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

> hello! i drw polygones in map and display it i want know how can i get them
> transparent for allowing me see another layers, thanks on advance, i thi,k
> that this will be modification in xml file where i define layer containing
> polygone but how, if you have some idea thanks 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, MgMapmap)
>>>>>
>>>>> {
>>>>> 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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090525/9e09638e/attachment.html


More information about the mapguide-users mailing list