Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/sde/datasources/ArcSDEUtils.java @ 1145:dfe1ac687c7f tip
added tags
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:16:15 +0200 |
parents | ebeb56428409 |
children |
line wrap: on
line source
/* * Copyright (c) 2010 by Intevation GmbH * * This program is free software under the LGPL (>=v2.1) * Read the file LGPL.txt coming with the software for details * or visit http://www.gnu.org/licenses/ if it does not exist. */ package de.intevation.gnv.geobackend.sde.datasources; import com.esri.sde.sdk.client.SDEPoint; import com.esri.sde.sdk.client.SeError; import com.esri.sde.sdk.client.SeException; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Polygon; import org.apache.log4j.Logger; /** * The class <code>ArcSDEUtils</code> fulfills the following purposes: * * @author blume * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> */ public class ArcSDEUtils { /** * Default Logging instance */ private static Logger sLogger = Logger.getLogger(ArcSDEUtils.class); /** * Prints an SEEsception into the Logger of this Class * @param exception */ public static void printError(SeException exception) { SeError error = exception.getSeError(); sLogger.debug("\n ArcSDE Error Number : " + error.getSdeError()); sLogger.debug(" Error Description : " + error.getErrDesc()); int extError = error.getExtError(); if (extError != 0) sLogger.debug(" Extended Error Number : " + extError); String desc = error.getSdeErrMsg(); if (desc != null && desc.length() != 0) sLogger.debug(" Extended Error Description : " + desc); desc = error.getExtErrMsg(); if (desc != null && desc.length() != 0) sLogger.debug(" Extended Error Description : " + desc); sLogger.debug(exception); } /** * Generate an SDEPoint-Array from a given Geometry. * This Method did not put the Holes to the Array. * @param g The Geometry which should be converted. * @return an SDEPoint-Array from a given Ggeometry. */ public SDEPoint[] createPoints(Geometry g) { sLogger.debug("createPoints()"); Coordinate[] coords = null; if (g instanceof Polygon) { coords = ((Polygon) g).getCoordinates(); }else if (g instanceof Point){ coords = ((Point)g).getCoordinates(); }else if (g instanceof LineString){ coords = ((LineString)g).getCoordinates(); }else{ coords = g.getCoordinates(); } if (coords != null){ SDEPoint[] lSDEPoints = new SDEPoint[coords.length]; for (int i = 0; i < coords.length; i++) { lSDEPoints[i] = new SDEPoint(coords[i].x, coords[i].y); } return lSDEPoints; }else{ return null; } } }