ingo@1127: /* ingo@1127: * Copyright (c) 2010 by Intevation GmbH ingo@1127: * ingo@1127: * This program is free software under the LGPL (>=v2.1) ingo@1127: * Read the file LGPL.txt coming with the software for details ingo@1127: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@1127: */ ingo@1127: sascha@894: package de.intevation.gnv.geobackend.sde.datasources; sascha@894: sascha@894: import com.esri.sde.sdk.client.SDEPoint; sascha@894: import com.esri.sde.sdk.client.SeError; sascha@894: import com.esri.sde.sdk.client.SeException; sascha@894: sascha@894: import com.vividsolutions.jts.geom.Coordinate; sascha@894: import com.vividsolutions.jts.geom.Geometry; sascha@894: import com.vividsolutions.jts.geom.LineString; sascha@894: import com.vividsolutions.jts.geom.Point; sascha@894: import com.vividsolutions.jts.geom.Polygon; sascha@894: sascha@894: import org.apache.log4j.Logger; sascha@894: sascha@894: /** sascha@894: * The class ArcSDEUtils fulfills the following purposes: ingo@897: * sascha@894: * @author blume sascha@894: * @author Tim Englich sascha@894: */ sascha@894: public class ArcSDEUtils { sascha@894: sascha@894: /** sascha@894: * Default Logging instance sascha@894: */ sascha@894: private static Logger sLogger = Logger.getLogger(ArcSDEUtils.class); sascha@894: sascha@894: /** sascha@894: * Prints an SEEsception into the Logger of this Class sascha@894: * @param exception sascha@894: */ sascha@894: public static void printError(SeException exception) { sascha@894: sascha@894: SeError error = exception.getSeError(); sascha@894: sascha@894: sLogger.debug("\n ArcSDE Error Number : " + error.getSdeError()); sascha@894: sLogger.debug(" Error Description : " + error.getErrDesc()); sascha@894: sascha@894: int extError = error.getExtError(); sascha@894: if (extError != 0) sascha@894: sLogger.debug(" Extended Error Number : " + extError); sascha@894: sascha@894: String desc = error.getSdeErrMsg(); sascha@894: if (desc != null && desc.length() != 0) sascha@894: sLogger.debug(" Extended Error Description : " + desc); sascha@894: sascha@894: desc = error.getExtErrMsg(); sascha@894: if (desc != null && desc.length() != 0) sascha@894: sLogger.debug(" Extended Error Description : " + desc); sascha@894: sascha@894: sLogger.debug(exception); sascha@894: sascha@894: } sascha@894: sascha@894: /** sascha@894: * Generate an SDEPoint-Array from a given Geometry. sascha@894: * This Method did not put the Holes to the Array. sascha@894: * @param g The Geometry which should be converted. sascha@894: * @return an SDEPoint-Array from a given Ggeometry. sascha@894: */ sascha@894: public SDEPoint[] createPoints(Geometry g) { sascha@894: sLogger.debug("createPoints()"); sascha@894: Coordinate[] coords = null; sascha@894: if (g instanceof Polygon) { sascha@894: coords = ((Polygon) g).getCoordinates(); sascha@894: }else if (g instanceof Point){ sascha@894: coords = ((Point)g).getCoordinates(); sascha@894: }else if (g instanceof LineString){ sascha@894: coords = ((LineString)g).getCoordinates(); sascha@894: }else{ sascha@894: coords = g.getCoordinates(); sascha@894: } sascha@894: sascha@894: if (coords != null){ sascha@894: SDEPoint[] lSDEPoints = new SDEPoint[coords.length]; sascha@894: for (int i = 0; i < coords.length; i++) { sascha@894: lSDEPoints[i] = new SDEPoint(coords[i].x, coords[i].y); sascha@894: } sascha@894: return lSDEPoints; sascha@894: }else{ sascha@894: return null; sascha@894: } sascha@894: } sascha@894: }