[mapguide-users] re: projection

girish kumar bv girish778 at rediffmail.com
Tue May 19 09:15:17 EDT 2009


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 ;}%>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20090519/be52e58d/attachment.html


More information about the mapguide-users mailing list