[mapguide-users] re: projection

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Wed May 20 03:46:49 EDT 2009


You just have to change the ll84Wkt to the new map WKT.
For good measure, you should also change the string "LL84",
but I don't think it is required.

You can read the map WKT directly from the MapDefinition XML.
You can also read the WKT from a FeatureSource, using the SpatialContext 
information.

If you have data in LL84 and a map in UTM, data should be re-projected 
automatically by
MapGuide, meaning that you don't have to change anything.

Regards, Kenneth Skovhede, GEOGRAF A/S



girish kumar bv skrev:
> Hi all,
>
> i am using projected coordinate system in my new map how to change the 
> below code to accomodate this. Instead of ll84 i am using wgs84 and UTM
>
> <%--
>   -This file contains methods to create a temporary feature source and 
> a temporary layer.
>  
> --%>
> <%@ page contentType="text/html; charset=UTF-8" %>
> <%@ page import="org.osgeo.mapguide.*" %>
> <%@ page import="java.util.*" %>
> <%@ page import="java.io.*" %>
> <%@ page import="javax.xml.parsers.*" %>
> <%@ page import="javax.xml.transform.*" %>
> <%@ page import="javax.xml.transform.dom.*" %>
> <%@ page import="javax.xml.transform.stream.*" %>
> <%@ page import="org.w3c.dom.*" %>
>
> <%!
> // Create a temporary Feature Source to store the parcel marker locations.
>
>
>
> void CreatePropertyMarkerFeatureSource(MgFeatureService 
> featureService, MgResourceIdentifier parcelMarkerDataResId) throws 
> MgException
> {
>     String ll84Wkt = "GEOGCS["LL84",DATUM["WGS_1984",SPHEROID["WGS 
> 84",6378137,298.25722293287],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["Degrees",1]]";
>
>     MgClassDefinition propertyMarkerClass = new MgClassDefinition();
>     propertyMarkerClass.SetName("PropertyMarker");
>     MgPropertyDefinitionCollection properties = 
> propertyMarkerClass.GetProperties();
>
>     MgDataPropertyDefinition idProperty = new 
> MgDataPropertyDefinition("ID");
>     idProperty.SetDataType(MgPropertyType.Int32);
>     idProperty.SetReadOnly(true);
>     idProperty.SetNullable(false);
>     idProperty.SetAutoGeneration(true);
>     properties.Add(idProperty);
>
>     MgDataPropertyDefinition PropIdProperty = new 
> MgDataPropertyDefinition("PROPERTY_ID");
>     PropIdProperty.SetDataType(MgPropertyType.String);
>     PropIdProperty.SetLength(512);
>     properties.Add(PropIdProperty);
>    
>     MgDataPropertyDefinition ImageProperty = new 
> MgDataPropertyDefinition("IMAGE");
>     ImageProperty.SetDataType(MgPropertyType.String);
>     ImageProperty.SetLength(512);
>     properties.Add(ImageProperty);
>   
>
>     MgGeometricPropertyDefinition locationProperty = new 
> MgGeometricPropertyDefinition("Location");
>     locationProperty.SetGeometryTypes(MgGeometryType.Polygon);
>     locationProperty.SetHasElevation(false);
>     locationProperty.SetHasMeasure(false);
>     locationProperty.SetReadOnly(false);
>     locationProperty.SetSpatialContextAssociation("LL84");
>     properties.Add(locationProperty);
>    
>    
>     MgDataPropertyDefinition OwnerNameProperty = new 
> MgDataPropertyDefinition("OWNER_NAME");
>     OwnerNameProperty.SetDataType(MgPropertyType.String);
>     OwnerNameProperty.SetLength(512);
>     properties.Add(OwnerNameProperty);
>    
>
>     MgPropertyDefinitionCollection idProperties = 
> propertyMarkerClass.GetIdentityProperties();
>     idProperties.Add(idProperty);
>
>     propertyMarkerClass.SetDefaultGeometryPropertyName("Location");
>
>     MgFeatureSchema propertyMarkerSchema = new MgFeatureSchema();
>     propertyMarkerSchema.SetName("PropertyMarkerSchema");
>     propertyMarkerSchema.GetClasses().Add(propertyMarkerClass);
>
>     MgCreateSdfParams sdfParams = new MgCreateSdfParams("LL84", 
> ll84Wkt, propertyMarkerSchema);
>
>     featureService.CreateFeatureSource(parcelMarkerDataResId, sdfParams);
> }
>
> // Create a temporary Layer to display the parcel markers.
>
> MgLayer CreatePropertyMarkerLayer(MgResourceService resourceService, 
> MgResourceIdentifier parcelMarkerDataResId, String sessionId) throws 
> MgException, Exception
> {
>     // Load the ParcelMarker layer definition template into
>     // a JSP DOM object, find the "ResourceId" element, and
>     // modify it's content to reference the temporary
>     // feature source.
>    
>
>     DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
>     DocumentBuilder builder = factory.newDocumentBuilder();
>     Document document = builder.parse(new 
> File(getServletContext().getRealPath("/") + "xyz"  + File.separator + 
> "propertymarker.xml"));
>     NodeList nodes = document.getElementsByTagName("ResourceId");
>     Node resNode = nodes.item(0);
>     Node resContent = 
> document.createTextNode(parcelMarkerDataResId.ToString());
>     resNode.appendChild(resContent);
>
>     // write the modified layer XML definition into a byte stream
>     //
>     TransformerFactory tFactory = TransformerFactory.newInstance();
>     Transformer transformer = tFactory.newTransformer();
>     ByteArrayOutputStream bos = new ByteArrayOutputStream();
>     DOMSource source = new DOMSource(document);
>     StreamResult result = new StreamResult(bos);
>     transformer.transform(source, result);
>
>     // Save the updated layer definition to the session repository 
> using the
>     // ResourceService object.
>
>     byte[] layerDefinition = bos.toByteArray();
>     MgByteSource byteSource = new MgByteSource(layerDefinition, 
> layerDefinition.length);
>     byteSource.SetMimeType(MgMimeType.Xml);
>
>     MgResourceIdentifier tempLayerResId = new 
> MgResourceIdentifier("Session:" + sessionId + 
> "//PropertyMarker.LayerDefinition");
>
>     resourceService.SetResource(tempLayerResId, 
> byteSource.GetReader(), null);
>
>     // Create an MgLayer object based on the new layer definition
>     // and return it to the caller.
>
>     MgLayer propertyMarkerLayer = new MgLayer(tempLayerResId, 
> resourceService);
>     propertyMarkerLayer .SetName("PropertyMarker");
>     propertyMarkerLayer .SetLegendLabel("Property Marker");
>     propertyMarkerLayer .SetDisplayInLegend(true);
>     propertyMarkerLayer .SetSelectable(true);
>
>     return propertyMarkerLayer ;
> }
> %>
>
>
> <http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline.htm@Middle?> 
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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/20090520/0a1b2392/attachment.html


More information about the mapguide-users mailing list