/*********************************************************************** Copyright © 2006 ESRI All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions. You may freely redistribute and use this sample code, with or without modification, provided you include the original copyright notice and use restrictions. Disclaimer: THE SAMPLE CODE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESRI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, 92373 USA email: contracts@esri.com ***********************************************************************/ /************************************************************************* This Java sample demonstrates usage of ArcSDE API for Geocoding. It will not execute successfully until the user supplies valid ArcSDE Server details such as server name, port number, database name, user, pwd, and valid data, if required. **************************************************************************/ package com.esri.sde.devhelp.geocoding; import com.esri.sde.sdk.client.*; import com.esri.sde.devhelp.geocoding.locatorUtil; public class SingleLocate { public static void main(String[] args) { System.out.println("Connecting to SDE..."); try { //**Warning: please modify appropriately to suit your application ** String server = "", dbName = "", user = "", pwd = ""; int portNum = 0; SeConnection conn = new SeConnection(server, portNum, dbName, user, pwd); String ssaName = "locssa"; String locName = "RedlandsStreets"; SeLocator locator = new SeLocator(conn, locName); locator.setSingleProperty("WriteXYCoordFields", "True"); locator.setSingleProperty("WriteReferenceIDField", "True"); locator.setSingleProperty("WriteStandardizedAddressField", "True"); String[] addressArr = {"380 New York St", "92373"}; SeSSA ssa = locator.locateSingle(addressArr); SeRow row = ssa.fetch(); SeShape shape = row.getShape(0); String Status = row.getString(1); Short Score = row.getShort(2); String Side = row.getString(3); Double X = row.getDouble(4); Double Y = row.getDouble(5); String Stan_addr = row.getString(6); Integer Ref_ID = row.getInteger(7); System.out.print("Status: " + Status + "\t-- "); //Type status description: switch (Status.charAt(0)) { case 'M': System.out.println("Matched"); break; case 'U': System.out.println("Unmatched (not successfully matched)"); break; case 'T': System.out.println( "Tie (two candidates that were valid matches had the same score)"); break; case 'I': System.out.println("rematched Interactively (not yet implemented... right now the interactive matcher sets the status to M)"); break; } System.out.println("Score: " + Score); System.out.println("Side: " + Side); System.out.println("X: " + X); System.out.println("Y: " + Y); System.out.println("Stan_addr: " + Stan_addr); System.out.println("Ref_ID: " + Ref_ID); // Close the connection conn.close(); System.out.println("Connection closed."); } catch(SeException e) { SeError err = e.getSeError(); System.out.println("Error # : " + err.getSdeError() + " --> " + err.getErrDesc()); System.out.println("Extended Error # : " + err.getExtError() + " --> " + err.getExtErrMsg()); e.printStackTrace(); } } }