HOW TO
Instructions provided describe how to use the Java Connector to Project Data. Below you a sample JSP code can be obtained that demonstrates the methods required to perform map projection on-the-fly using the ArcIMS Java Connector.
Note: See the Related Information section below for instructions on setting up the ArcIMS JSP samples.
<FEATURECOORDSYS id="4326" /> <FILTERCOORDSYS id="4326" />Furthermore, ArcIMS only projects layers that have projection information defined for them. By default, only the 'streams' layer in the SantaClara service has projection information defined, with a .prj file. The code below projects the map, but only the 'streams' layer appears in the projected image. While this is enough to demonstrate the concept of projecting data on the fly, it is necessary to add a COORDSYS element to each LAYER to view that layer in this sample.
<LAYER type="featureclass" name="tract" visible="true" id="1"> <DATASET name="sc_tract" type="polygon" workspace="shp_ws-0"/> <COORDSYS id="4326"/>See the ArcXML Programmer's reference help for the element COORDSYS for additional information and additional Projection IDs available.
<%@ page import="com.esri.aims.mtier.io.*, com.esri.aims.mtier.model.map.layer.FeatureLayer, java.lang.Integer" %> <jsp:useBean id="connection" class="com.esri.aims.mtier.io.ConnectionProxy" scope="session" /> <jsp:useBean id="map" class="com.esri.aims.mtier.model.map.Map" scope="session" /> <% //initialize the connection if (connection.getHost() == null){ connection.setHost("localhost"); connection.setPort(5300); connection.setService("SantaClara"); connection.setDisplayMessages(true); map.initMap(connection, 0, true, true, true, true); map.setWidth(500); map.setHeight(350); } int proj = 0; long projId = 0; if(request.getParameter("isProject") != null){ proj = Integer.parseInt(request.getParameter("isProject")); } if(request.getParameter("projId") != null){ projId = Long.parseLong(request.getParameter("projId")); } if(proj == 1 && projId != 0) { // get the current coordinate system com.esri.aims.mtier.model.map.projection.FeatureCoordSys oldFeatCS = map.getFeatureCoordSys(); long oldID = -1; if(oldFeatCS != null) oldID= oldFeatCS.getID(); if (oldID == -1) oldID = map.getInitialFeatureCoordSys().getID(); com.esri.aims.mtier.model.map.projection.FeatureCoordSys featCS = new com.esri.aims.mtier.model.map.projection.FeatureCoordSys(); featCS.setID(projId); com.esri.aims.mtier.model.map.projection.FilterCoordSys filterCS = new com.esri.aims.mtier.model.map.projection.FilterCoordSys(); if (oldID != projId) { filterCS.setID(oldID); map.setFeatureCoordSys(featCS); map.setFilterCoordSys(filterCS); map.refresh(); } filterCS.setID(projId); } map.refresh(); com.esri.aims.mtier.model.envelope.Envelope env = map.getEnvelope(); double minx = env.getMinX(); double miny = env.getMinY(); double maxx = env.getMaxX(); double maxy = env.getMaxY(); %> <html> <head><title>ArcIMS JSP Samples</title></head> <script language="javascript"> function reProject(){ document.Main.isProject.value="1"; document.Main.submit(); } </script> <BODY> <form action="ProjectionTest.jsp" name="Main" id="Main"> <input type="hidden" name="isProject" value="0"> <table border="1" bgcolor="ffb900" cellpadding="10" width="500" align="center"> <tr> <td colspan="2"> <img src="<%= map.getMapOutput().getURL() %>"> </td> </tr> <tr><td colspan=4 align=center> Current Envelope Extents<br> <table border=1> <tr><td width=30></td><td width=30><%=maxy%></td><td width=30></td></tr> <tr><td><%=minx%></td><td></td><td><%=maxx%></td></tr> <tr><td></td><td><%=miny%></td><td></td></tr> </table> </td></tr> <tr> <td> Projection Id�<input type=text name="projId" value="<%if (projId == 0) out.print(4326); else out.print(projId);;%>" size=8> <input type="button" name="Project" value="Project" onClick="reProject();"> <br><br> Sample Projection Ids <br><br> ArcIMS 4.0.1 <br><b>4326</b>��(GCS_WGS_1984) <br><b>26743</b>��(NAD_1927_StatePlane_California_III_FIPS_0403) <br><br> ArcIMS 9.0 <br><b>4326</b>��(GCS_WGS_1984) <br><b>2227</b>��(NAD_1927_StatePlane_California_III_FIPS_0403) </td> </tr> </table> </form> </BODY> </HTML>
Get help from ArcGIS experts
Download the Esri Support App