diff --git a/list.txt b/list.txt index 9c55ee4e..b2f5bc27 100644 --- a/list.txt +++ b/list.txt @@ -1,4 +1,4 @@ -#src\main\resources\egovframework\egovProps\globals.properties +src\main\resources\egovframework\egovProps\globals.properties #src\main\java\geoinfo\regi\manageList\ManageExcelUploadProc01Controller.java #src\main\webapp\WEB-INF\views\web\input\excel_step00.jsp #src\main\webapp\WEB-INF\views\web\input\excel_step31.jsp diff --git a/pom.xml b/pom.xml index 8832b7e9..368a1328 100644 --- a/pom.xml +++ b/pom.xml @@ -15,15 +15,17 @@ - 1.7 - 3.2.4.RELEASE - 1.7.3 - 1.6.6 - 3.0.3 - - 4.0.9.RELEASE - 3.5.0 - + 1.7 + 3.2.4.RELEASE + 1.7.3 + 1.6.6 + 3.0.3 + + 4.0.9.RELEASE + 3.5.0 + + 11.0 + 1.13 @@ -487,114 +489,126 @@ -     org.geotools -     gt-main -     11.0 + org.geotools + gt-main + ${geotools.version} -     org.geotools -     gt-opengis -     11.0 + org.geotools + gt-opengis + ${geotools.version} -     org.geotools -     gt-referencing -     11.0 + org.geotools + gt-referencing + ${geotools.version} -     org.geotools -     gt-epsg-hsql - 11.0 + org.geotools + gt-epsg-hsql + ${geotools.version} -     org.geotools -     gt-cql - 11.0 + org.geotools + gt-cql + ${geotools.version} -     org.geotools -     gt-data -     11.0 + org.geotools + gt-data + ${geotools.version} -     org.geotools -     gt-api -     11.0 + org.geotools + gt-api + ${geotools.version} -     org.geotools -     gt-metadata -     11.0 + org.geotools + gt-metadata + ${geotools.version} -     org.geotools -     gt-xml - 11.0 + org.geotools + gt-xml + ${geotools.version} -     org.geotools -     gt-swing - 11.0 + org.geotools + gt-swing + ${geotools.version} -     org.geotools -     gt-render - 11.0 + org.geotools + gt-render + ${geotools.version} org.geotools gt-shapefile - 11.0 + ${geotools.version} org.geotools.xsd gt-xsd-sld - 11.0 - + ${geotools.version} + org.geotools gt-geojson - 11.0 + ${geotools.version} org.geotools gt-process - 11.0 + ${geotools.version} - + org.geotools gt-jdbc - 11.0 + ${geotools.version} + + + org.geotools.jdbc + gt-jdbc-postgis + ${geotools.version} + + + org.geotools.jdbc + gt-jdbc-oracle + ${geotools.version} + + + org.geotools.jdbc + gt-jdbc-h2 + ${geotools.version} + + + org.geotools.jdbc + gt-jdbc-mysql + ${geotools.version} + + + org.geotools.jdbc + gt-jdbc-db2 + ${geotools.version} + + + org.geotools.jdbc + gt-jdbc-sqlserver + ${geotools.version} + + + com.vividsolutions + jts + ${jts.version} + + + + org.geotools + gt-wms + ${geotools.version} - - org.geotools.jdbc - gt-jdbc-postgis 11.0 - - - org.geotools.jdbc - gt-jdbc-oracle 11.0 - - - org.geotools.jdbc - gt-jdbc-h2 11.0 - - - org.geotools.jdbc - gt-jdbc-mysql 11.0 - - - org.geotools.jdbc - gt-jdbc-db2 11.0 - - - org.geotools.jdbc - gt-jdbc-sqlserver 11.0 - - - com.vividsolutions - jts - 1.13 - diff --git a/src/main/java/geoinfo/map/coordSearch/MapCoordSearchController.java b/src/main/java/geoinfo/map/coordSearch/MapCoordSearchController.java index 46dae259..b717e8d8 100644 --- a/src/main/java/geoinfo/map/coordSearch/MapCoordSearchController.java +++ b/src/main/java/geoinfo/map/coordSearch/MapCoordSearchController.java @@ -9,7 +9,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jfree.util.Log; import org.osgeo.proj4j.CRSFactory; import org.osgeo.proj4j.CoordinateReferenceSystem; import org.osgeo.proj4j.CoordinateTransform; @@ -27,8 +26,6 @@ import com.jhlabs.map.proj.Projection; import com.jhlabs.map.proj.ProjectionFactory; import egovframework.com.cmm.service.EgovProperties; -import egovframework.com.json.JSONArray; -import egovframework.com.json.JSONObject; import egovframework.rte.psl.dataaccess.util.EgovMap; import geoinfo.com.GeoinfoCommon; import geoinfo.map.coordSearch.service.MapCoordSearchService; diff --git a/src/main/java/geoinfo/map/left/MapLeftController.java b/src/main/java/geoinfo/map/left/MapLeftController.java index 6401e300..cd2f9f52 100644 --- a/src/main/java/geoinfo/map/left/MapLeftController.java +++ b/src/main/java/geoinfo/map/left/MapLeftController.java @@ -30,12 +30,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.jfree.util.Log; -import org.osgeo.proj4j.CRSFactory; -import org.osgeo.proj4j.CoordinateReferenceSystem; -import org.osgeo.proj4j.CoordinateTransform; -import org.osgeo.proj4j.CoordinateTransformFactory; -import org.osgeo.proj4j.Proj4jException; -import org.osgeo.proj4j.ProjCoordinate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; diff --git a/src/main/java/geoinfo/map/myMap/AVList.java b/src/main/java/geoinfo/map/myMap/AVList.java deleted file mode 100644 index c94d1c3d..00000000 --- a/src/main/java/geoinfo/map/myMap/AVList.java +++ /dev/null @@ -1,304 +0,0 @@ -package geoinfo.map.myMap; - -import java.awt.Color; -import java.net.URL; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -public class AVList { - private HashMap avList; - - public AVList() - { - this.avList = new HashMap(); - } - - public synchronized Object getValue(String key) - { - if ((key == null) || (key.trim().equals(""))) - { - throw new IllegalArgumentException("AVList :: Key is NULL."); - } - - return this.avList.get(key); - } - - public synchronized Collection getValues() - { - return this.avList.values(); - } - - public synchronized Set> getEntries() - { - return this.avList.entrySet(); - } - - public synchronized Object setValue(String key, Object value) - { - if ((key == null) || (key.trim().equals(""))) - { - throw new IllegalArgumentException("AVList :: Key is NULL."); - } - - return this.avList.put(key, value); - } - - public synchronized AVList setValues(AVList list) - { - if (list == null) - { - throw new IllegalArgumentException("AVList :: AVList is NULL."); - } - - Set> entries = list.getEntries(); - for (Entry entry : entries) - { - setValue((String)entry.getKey(), entry.getValue()); - } - - return this; - } - - public synchronized boolean hasKey(String key) - { - if ((key == null) || (key.trim().equals(""))) - { - throw new IllegalArgumentException("AVList :: Key is NULL."); - } - - return this.avList.containsKey(key); - } - - public synchronized Object removeKey(String key) - { - if ((key == null) || (key.trim().equals(""))) - { - throw new IllegalArgumentException("AVList :: Key is NULL."); - } - - return hasKey(key) ? this.avList.remove(key) : null; - } - - public synchronized AVList copy() - { - AVList clone = new AVList(); - - if (this.avList != null) - { - clone.avList.putAll(this.avList); - } - - return clone; - } - - public synchronized AVList clearList() - { - this.avList.clear(); - return this; - } - - public synchronized String getStringValue(String key, String defaultValue) - { - String v = getStringValue(key); - return v != null ? v : defaultValue; - } - - public synchronized String getStringValue(String key) - { - try - { - return getValue(key).toString(); } catch (Exception e) { - } - return null; - } - - public synchronized Integer getIntegerValue(String key, Integer defaultValue) - { - Integer v = getIntegerValue(key); - return v != null ? v : defaultValue; - } - - public synchronized Integer getIntegerValue(String key) - { - try - { - Object o = getValue(key); - if (o == null) { - return null; - } - if ((o instanceof Integer)) { - return (Integer)o; - } - String v = getStringValue(key); - if (v == null) { - return null; - } - Double d = Double.valueOf(Double.parseDouble(v)); - return Integer.valueOf(d.intValue()); - } catch (Exception e) { - } - return null; - } - - public synchronized Long getLongValue(String key, Long defaultValue) - { - Long v = getLongValue(key); - return v != null ? v : defaultValue; - } - - public synchronized Long getLongValue(String key) - { - try { - Object o = getValue(key); - if (o == null) { - return null; - } - if ((o instanceof Long)) { - return (Long)o; - } - String v = getStringValue(key); - if (v == null) { - return null; - } - Double d = Double.valueOf(Double.parseDouble(v)); - return Long.valueOf(d.longValue()); - } - catch (Exception e) { - e.printStackTrace(); - }return null; - } - - public synchronized Double getDoubleValue(String key, Double defaultValue) - { - Double v = getDoubleValue(key); - return v != null ? v : defaultValue; - } - - public synchronized Double getDoubleValue(String key) - { - try - { - Object o = getValue(key); - if (o == null) { - return null; - } - if ((o instanceof Double)) { - return (Double)o; - } - String v = getStringValue(key); - if (v == null) { - return null; - } - return Double.valueOf(Double.parseDouble(v)); - } catch (Exception e) { - } - return null; - } - - public synchronized Boolean getBooleanValue(String key, Boolean defaultValue) - { - Boolean v = getBooleanValue(key); - return v != null ? v : defaultValue; - } - - public synchronized Boolean getBooleanValue(String key) - { - try { - Object o = getValue(key); - if (o == null) { - return null; - } - if ((o instanceof Boolean)) { - return (Boolean)o; - } - String v = getStringValue(key); - if (v == null) { - return null; - } - return Boolean.valueOf(Boolean.parseBoolean(v)); - } catch (Exception e) { - } - return null; - } - - public synchronized Date getDateValue(String key, Date defaultValue) - { - Date v = getDateValue(key); - return v != null ? v : defaultValue; - } - - public synchronized Date getDateValue(String key) { - try { - Object o = getValue(key); - if (o == null) { - return null; - } - if ((o instanceof Date)) { - return (Date)o; - } - Long v = getLongValue(key); - if (v == null) { - return null; - } - return new Date(v.longValue()); - } catch (Exception e) { - } - return null; - } - - public synchronized URL getURLValue(String key) - { - try - { - Object o = getValue(key); - if (o == null) { - return null; - } - if ((o instanceof URL)) { - return (URL)o; - } - String v = getStringValue(key); - if (v == null) { - return null; - } - if (v.length() != v.lastIndexOf("/") + 1) { - v = v.concat("/"); - } - - return new URL(v); - } catch (Exception e) { - } - return null; - } - - public synchronized Color getColorValue(String key) - { - try - { - Object o = getValue(key); - if (o == null) { - return null; - } - if ((o instanceof Color)) { - return (Color)o; - } - String v = getStringValue(key); - if (v == null) { - return null; - } - return Color.decode(v); - } catch (Exception e) { - } - return null; - } - - public synchronized Color getColorValue(String key, Color defaultValue) - { - Color v = getColorValue(key); - return v != null ? v : defaultValue; - } -} diff --git a/src/main/java/geoinfo/map/myMap/AWTLabelUtil.java b/src/main/java/geoinfo/map/myMap/AWTLabelUtil.java deleted file mode 100644 index de9a452c..00000000 --- a/src/main/java/geoinfo/map/myMap/AWTLabelUtil.java +++ /dev/null @@ -1,507 +0,0 @@ -package geoinfo.map.myMap; - -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.Line2D; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.util.Arrays; -import java.util.Vector; - -public class AWTLabelUtil { - public static Point2D getLabelPositionMBR(LabelInfo labelInfo) { - Point2D mbrPoint = AWTLabelUtil.getCrossLineCenter(labelInfo.generalPath, new Point2D.Double(labelInfo.generalPath.getBounds().getCenterX(), labelInfo.generalPath.getBounds().getCenterY())); - if (mbrPoint == null) { - return new Point2D.Double(labelInfo.polygon.getCentroid().getX(), labelInfo.polygon.getCentroid().getY()); - } - return mbrPoint; - } - - public static Point2D getLabelPosition(LabelInfo labelInfo, Point2D point) { - Point2D labelPoint = AWTLabelUtil.getCrossLineCenter(labelInfo.generalPath, new Point2D.Double(point.getX(), point.getY())); - if (labelPoint == null) { - return point; - } - return labelPoint; - } - - public static boolean isContainLabel(LabelInfo labelInfo, Point2D center, double rotation) { - AffineTransform transform = AWTLabelUtil.getPolygonAlignTextTransform(labelInfo, center, rotation); - Rectangle2D labelBound = labelInfo.labelPainter.getFullLabelBounds(); - Point2D.Double UL = new Point2D.Double(labelBound.getMinX(), labelBound.getMinY()); - Point2D.Double UR = new Point2D.Double(labelBound.getMaxX(), labelBound.getMinY()); - Point2D.Double LL = new Point2D.Double(labelBound.getMinX(), labelBound.getMaxY()); - Point2D.Double LR = new Point2D.Double(labelBound.getMaxX(), labelBound.getMaxY()); - transform.transform(UL, UL); - transform.transform(UR, UR); - transform.transform(LL, LL); - transform.transform(LR, LR); - if (!labelInfo.generalPath.contains(UL)) { - return false; - } - if (!labelInfo.generalPath.contains(UR)) { - return false; - } - if (!labelInfo.generalPath.contains(LL)) { - return false; - } - return labelInfo.generalPath.contains(LR); - } - - public static boolean isContainLabel(LabelInfo labelInfo, AffineTransform transform) { - Rectangle2D labelBound = labelInfo.labelPainter.getFullLabelBounds(); - Point2D.Double UL = new Point2D.Double(labelBound.getMinX(), labelBound.getMinY()); - Point2D.Double UR = new Point2D.Double(labelBound.getMaxX(), labelBound.getMinY()); - Point2D.Double LL = new Point2D.Double(labelBound.getMinX(), labelBound.getMaxY()); - Point2D.Double LR = new Point2D.Double(labelBound.getMaxX(), labelBound.getMaxY()); - transform.transform(UL, UL); - transform.transform(UR, UR); - transform.transform(LL, LL); - transform.transform(LR, LR); - if (!labelInfo.generalPath.contains(UL)) { - return false; - } - if (!labelInfo.generalPath.contains(UR)) { - return false; - } - if (!labelInfo.generalPath.contains(LL)) { - return false; - } - return labelInfo.generalPath.contains(LR); - } - - public static boolean refineLabelPositionQuadrant(LabelInfo labelInfo, double rotation) { - double rectX = labelInfo.generalPath.getBounds2D().getX(); - double rectY = labelInfo.generalPath.getBounds2D().getY(); - double width = labelInfo.generalPath.getBounds2D().getWidth() / 4.0; - double height = labelInfo.generalPath.getBounds2D().getHeight() / 4.0; - Point2D[] rePoints = new Point2D[]{new Point2D.Double(rectX + width, rectY + height), new Point2D.Double(rectX + width * 3.0, rectY + height), new Point2D.Double(rectX + width, rectY + height * 3.0), new Point2D.Double(rectX + width * 3.0, rectY + height * 3.0)}; - int i = 0; - while (i < 4) { - rePoints[i] = AWTLabelUtil.getLabelPosition(labelInfo, rePoints[i]); - if (AWTLabelUtil.isContainLabel(labelInfo, rePoints[i], rotation)) { - labelInfo.center = rePoints[i]; - return true; - } - ++i; - } - return false; - } - - public static AffineTransform getPolygonAlignTextTransform(LabelInfo labelInfo, Point2D center, double rotation) { - AffineTransform transform = new AffineTransform(); - transform.translate(center.getX(), center.getY()); - if (Double.isNaN(rotation) || Double.isInfinite(rotation)) { - rotation = 0.0; - } - transform.rotate(rotation); - Rectangle2D textBounds = labelInfo.labelPainter.getLabelBounds(); - double displacementX = labelInfo.anchorX * -textBounds.getWidth() + labelInfo.displacementX; - double displacementY = labelInfo.anchorY * textBounds.getHeight() - labelInfo.displacementY - textBounds.getHeight() + labelInfo.labelPainter.getLineHeight(); - transform.translate(displacementX, displacementY); - return transform; - } - - public static void setLabelRotationORTHO(LabelInfo labelInfo) { - Vector hPoints = AWTLabelUtil.getIntersectPoints(labelInfo.generalPath, labelInfo.center, 0.0); - Vector vPoints = AWTLabelUtil.getIntersectPoints(labelInfo.generalPath, labelInfo.center, 1.5707963267948966); - Line2D hLine = AWTLabelUtil.getIntersectLineH(hPoints, labelInfo.center); - Line2D vLine = AWTLabelUtil.getIntersectLineV(vPoints, labelInfo.center); - if (hLine.getBounds().getWidth() > vLine.getBounds().getHeight()) { - labelInfo.rCenter = labelInfo.center; - labelInfo.rotation = 0.0; - } else { - labelInfo.rCenter = new Point2D.Double(vLine.getX1(), (vLine.getY1() + vLine.getY2()) / 2.0); - labelInfo.rotation = -1.5707963267948966; - } - } - - public static void setLabelRotationMBR(LabelInfo labelInfo) { - labelInfo.rotation = Math.toRadians(AWTLabelUtil.calcMainAngle(labelInfo.generalPath)); - KLISLabelUtil pUtil = new KLISLabelUtil(labelInfo.polygon); - if (pUtil.isConvex()) { - labelInfo.rCenter = AWTLabelUtil.getConvexCenter(labelInfo.generalPath, labelInfo.center, labelInfo.rotation); - } else { - Point2D rCenter = pUtil.GetMIC_ex(); - if (rCenter == null) { - labelInfo.rCenter = AWTLabelUtil.getOptimalCenter(labelInfo.generalPath, labelInfo.center); - } else if (pUtil.hasParabola() == 0) { - labelInfo.rCenter = AWTLabelUtil.getConvexCenter(labelInfo.generalPath, labelInfo.center, labelInfo.rotation); - } else { - Vector points = AWTLabelUtil.getIntersectPoints(labelInfo.generalPath, labelInfo.center, labelInfo.rotation); - double dist = Point2D.distance(points.get(0).getX(), points.get(0).getY(), points.get(1).getX(), points.get(1).getY()); - if (pUtil.getMaxRadius() * 10.0 < dist && pUtil.getMaxRadius() > labelInfo.labelPainter.getFullLabelBounds().getHeight() * 5.0) { - labelInfo.rCenter = AWTLabelUtil.getOptimalCenter(labelInfo.generalPath, labelInfo.center); - } else { - Vector rpoints = AWTLabelUtil.getIntersectPoints(labelInfo.generalPath, labelInfo.center, labelInfo.rotation + 1.5707963267948966); - Vector rpoints_v = AWTLabelUtil.getIntersectPoints(labelInfo.generalPath, rCenter, labelInfo.rotation + 1.5707963267948966); - Vector rpoints_h = AWTLabelUtil.getIntersectPoints(labelInfo.generalPath, rCenter, labelInfo.rotation); - if (rpoints_v.size() == 2 && rpoints.size() == 2 && rpoints_h.size() == 2) { - double diff; - double dist0 = Point2D.distance(rpoints.get(0).getX(), rpoints.get(0).getY(), rpoints.get(1).getX(), rpoints.get(1).getY()); - double dist_v = Point2D.distance(rpoints_v.get(0).getX(), rpoints_v.get(0).getY(), rpoints_v.get(1).getX(), rpoints_v.get(1).getY()); - double dist_h = Point2D.distance(rpoints_h.get(0).getX(), rpoints_h.get(0).getY(), rpoints_h.get(1).getX(), rpoints_h.get(1).getY()); - double d = diff = dist0 >= dist_v ? dist_v / dist0 : dist0 / dist_v; - if (diff > 0.8 && dist_v * 5.0 < dist_h && pUtil.edgeDiffCounts() % 2 != 1) { - rCenter = AWTLabelUtil.getConvexCenter(labelInfo.generalPath, labelInfo.center, labelInfo.rotation); - } - } - labelInfo.rCenter = rCenter; - } - } - } - } - - private static Point2D getConvexCenter(GeneralPath generalPath, Point2D center, double rotation) { - Vector points = AWTLabelUtil.getIntersectPoints(generalPath, center, rotation); - Line2D line = AWTLabelUtil.getIntersectLineHV(points, center); - if (line == null) { - return center; - } - return new Point2D.Double((line.getX1() + line.getX2()) / 2.0, (line.getY1() + line.getY2()) / 2.0); - } - - private static Point2D getOptimalCenter(GeneralPath generalPath, Point2D center) { - double dist; - Point2D endPt; - Point2D startPt; - Vector points; - double angle; - Point2D.Double rCenter = new Point2D.Double(center.getX(), center.getY()); - Point2D initStartPt = null; - Point2D initEndPt = null; - double maxDist = 0.0; - int i = -5; - while (i < 7) { - angle = Math.PI * (double)i / 12.0; - points = AWTLabelUtil.getIntersectPoints(generalPath, rCenter, angle); - int j = 0; - while (j < points.size() - 1) { - startPt = points.get(j); - endPt = points.get(j + 1); - if (!(startPt.getX() < ((Point2D)rCenter).getX() && ((Point2D)rCenter).getX() > endPt.getX() || startPt.getY() > ((Point2D)rCenter).getY() && ((Point2D)rCenter).getY() < endPt.getY() || !((dist = Point2D.distance(startPt.getX(), startPt.getY(), endPt.getX(), endPt.getY())) >= maxDist))) { - maxDist = dist; - if (initStartPt == null || initEndPt == null) { - initStartPt = new Point2D.Double(startPt.getX(), startPt.getY()); - initEndPt = new Point2D.Double(endPt.getX(), endPt.getY()); - } else { - initStartPt.setLocation(startPt); - initEndPt.setLocation(endPt); - } - } - ++j; - } - if (initStartPt == null || initEndPt == null) { - return center; - } - ((Point2D)rCenter).setLocation((initStartPt.getX() + initEndPt.getX()) / 2.0, (initStartPt.getY() + initEndPt.getY()) / 2.0); - ++i; - ++i; - } - angle = AWTLabelUtil.calcMainAngle(generalPath); - points = AWTLabelUtil.getIntersectPoints(generalPath, rCenter, Math.toRadians(angle)); - double minDist = Double.MAX_VALUE; - int j = 0; - while (j < points.size() - 1) { - startPt = points.get(j); - endPt = points.get(j + 1); - if (!(startPt.getX() < ((Point2D)rCenter).getX() && ((Point2D)rCenter).getX() > endPt.getX() || startPt.getY() > ((Point2D)rCenter).getY() && ((Point2D)rCenter).getY() < endPt.getY() || !((dist = Point2D.distance(startPt.getX(), startPt.getY(), endPt.getX(), endPt.getY())) < minDist))) { - minDist = dist; - initStartPt = new Point2D.Double(startPt.getX(), startPt.getY()); - initEndPt = new Point2D.Double(endPt.getX(), endPt.getY()); - } - ++j; - } - double d = generalPath.getBounds2D().getHeight() > generalPath.getBounds2D().getWidth() ? generalPath.getBounds2D().getHeight() : generalPath.getBounds2D().getWidth(); - if (maxDist * 10.0 < d) { - return center; - } - return new Point2D.Double((initStartPt.getX() + initEndPt.getX()) / 2.0, (initStartPt.getY() + initEndPt.getY()) / 2.0); - } - - private static Line2D getIntersectLineHV(Vector points, Point2D point) { - if (points.size() < 2) { - return null; - } - Line2D.Double maxLine = null; - double maxDist = 0.0; - int i = 0; - while (i < points.size() - 1) { - Point2D sp1 = points.get(i); - Point2D sp2 = points.get(i + 1); - if (Math.min(sp1.getX(), sp2.getX()) <= point.getX() && point.getX() <= Math.max(sp1.getX(), sp2.getX()) && Math.min(sp1.getY(), sp2.getY()) <= point.getY() && point.getY() <= Math.max(sp1.getY(), sp2.getY())) { - return new Line2D.Double(sp1, sp2); - } - double currentDist = sp1.distance(sp2); - if (maxDist < currentDist) { - maxDist = currentDist; - maxLine = new Line2D.Double(sp1, sp2); - } - ++i; - } - return null; - } - - private static double calcMainAngle(GeneralPath path) { - double[] lineLength = AWTLabelUtil.calcAngleFactor(path); - int maxIndex = 0; - double maxLength = lineLength[0]; - int i = 1; - while (i < lineLength.length) { - if (maxLength < lineLength[i]) { - maxIndex = i; - maxLength = lineLength[i]; - } - ++i; - } - int angle = maxIndex * 10; - if (angle > 90) { - return angle - 180; - } - return angle; - } - - private static double[] calcAngleFactor(GeneralPath path) { - double[] lineLength = new double[18]; - double[] startCoords = new double[6]; - double[] currentCoords = new double[6]; - int type = -1; - double subAngle = 0.0; - PathIterator pathIter = path.getPathIterator(new AffineTransform()); - while (!pathIter.isDone()) { - type = pathIter.currentSegment(currentCoords); - if (type != 0 && type == 1 && startCoords[0] != currentCoords[0] && startCoords[1] != currentCoords[1]) { - subAngle = AWTLabelUtil.getAbsoluteAngle(startCoords[0], startCoords[1], currentCoords[0], currentCoords[1]); - int index = (int)(subAngle >= 175.0 ? 0.0 : (subAngle + 5.0) / 10.0); - double dist = Point2D.distance(startCoords[0], startCoords[1], currentCoords[0], currentCoords[1]); - lineLength[index] = lineLength[index] + dist; - } - startCoords = Arrays.copyOf(currentCoords, currentCoords.length); - pathIter.next(); - } - return lineLength; - } - - private static Point2D getCrossLineCenter(GeneralPath path, Point2D point) { - Vector hPoints = AWTLabelUtil.getIntersectPoints(path, point, 0.0); - Vector vPoints = AWTLabelUtil.getIntersectPoints(path, point, 1.5707963267948966); - Vector hLines = AWTLabelUtil.getContainLines(path, hPoints); - Vector vLines = AWTLabelUtil.getContainLines(path, vPoints); - double maxHDist = 0.0; - Line2D maxHLine = null; - double dist = 0.0; - for (Line2D line : hLines) { - dist = Math.abs(line.getX1() - line.getX2()); - if (!(maxHDist < dist)) continue; - maxHDist = dist; - maxHLine = line; - } - double maxVDist = 0.0; - Line2D maxVLine = null; - for (Line2D line : vLines) { - point = new Point2D.Double(line.getX1(), (line.getY1() + line.getY2()) / 2.0); - hPoints = AWTLabelUtil.getIntersectPoints(path, point, 0.0); - if ((line = AWTLabelUtil.getIntersectLineH(hPoints, point)) == null || !(maxVDist < (dist = Math.abs(line.getX1() - line.getX2())))) continue; - maxVDist = dist; - maxVLine = line; - } - if (maxHLine == null && maxVLine == null) { - return null; - } - if (maxHLine == null) { - return AWTLabelUtil.refineLineCenterV(path, maxVLine); - } - if (maxVLine == null) { - return AWTLabelUtil.refineLineCenterH(path, maxHLine); - } - if (maxHDist > maxVDist) { - return AWTLabelUtil.refineLineCenterH(path, maxHLine); - } - return AWTLabelUtil.refineLineCenterV(path, maxVLine); - } - - private static Point2D refineLineCenterV(GeneralPath path, Line2D line) { - return new Point2D.Double((line.getX1() + line.getX2()) / 2.0, line.getY1()); - } - - private static Point2D refineLineCenterH(GeneralPath path, Line2D line) { - Point2D.Double center = new Point2D.Double((line.getX1() + line.getX2()) / 2.0, line.getY1()); - Vector vPoints = AWTLabelUtil.getIntersectPoints(path, center, 1.5707963267948966); - Line2D vLine = AWTLabelUtil.getIntersectLineV(vPoints, center); - if (vLine == null) { - return center; - } - return new Point2D.Double(vLine.getX1(), (vLine.getY1() + vLine.getY2()) / 2.0); - } - - private static Line2D getIntersectLineH(Vector points, Point2D point) { - if (points.size() < 2) { - return null; - } - int i = 0; - while (i < points.size() - 1) { - Point2D sp1 = points.get(i); - Point2D sp2 = points.get(i + 1); - if (Math.min(sp1.getX(), sp2.getX()) <= point.getX() && point.getX() <= Math.max(sp1.getX(), sp2.getX())) { - return new Line2D.Double(sp1, sp2); - } - ++i; - } - return null; - } - - private static Line2D getIntersectLineV(Vector points, Point2D point) { - if (points.size() < 2) { - return null; - } - int i = 0; - while (i < points.size() - 1) { - Point2D sp1 = points.get(i); - Point2D sp2 = points.get(i + 1); - if (Math.min(sp1.getY(), sp2.getY()) <= point.getY() && point.getY() <= Math.max(sp1.getY(), sp2.getY())) { - return new Line2D.Double(sp1, sp2); - } - ++i; - } - return null; - } - - private static Vector getContainLines(GeneralPath path, Vector points) { - if (points.size() < 2) { - return new Vector(); - } - Vector lines = new Vector(); - int i = 0; - while (i < points.size() - 1) { - double cy; - double cx; - Point2D sp1 = points.get(i); - Point2D sp2 = points.get(i + 1); - if (sp1.getX() == sp2.getX()) { - cx = sp1.getX(); - cy = (sp1.getY() + sp2.getY()) / 2.0; - } else { - cx = (sp1.getX() + sp2.getX()) / 2.0; - cy = sp1.getY(); - } - if (path.contains(cx, cy)) { - lines.add(new Line2D.Double(sp1, sp2)); - } - ++i; - } - return lines; - } - - private static Vector getIntersectPoints(GeneralPath path, Point2D point, double angle) { - Vector holder = new Vector(); - Line2D baseLine = AWTLabelUtil.getBoundCuttingLine(path.getBounds2D(), point, angle); - double a1 = Math.tan(angle); - double b1 = point.getY() - a1 * point.getX(); - double[] startCoords = new double[6]; - double[] currentCoords = new double[6]; - int type = -1; - double subAngle = 0.0; - PathIterator pathIter = path.getPathIterator(new AffineTransform()); - while (!pathIter.isDone()) { - type = pathIter.currentSegment(currentCoords); - if (type != 0 && type == 1 && startCoords[0] != currentCoords[0] && startCoords[1] != currentCoords[1] && angle != (subAngle = AWTLabelUtil.getAngle(startCoords[0], startCoords[1], currentCoords[0], currentCoords[1])) && baseLine.intersectsLine(startCoords[0], startCoords[1], currentCoords[0], currentCoords[1])) { - double y; - double x; - double a2 = Math.tan(subAngle); - double b2 = currentCoords[1] - a2 * currentCoords[0]; - if (angle == 1.5707963267948966) { - x = point.getX(); - y = a2 * x + b2; - } else if (subAngle == 1.5707963267948966) { - x = currentCoords[0]; - y = a1 * x + b1; - } else { - x = (b2 - b1) / (a1 - a2); - y = (a1 * b2 - a2 * b1) / (a1 - a2); - } - AWTLabelUtil.addPointBySort(holder, new Point2D.Double(x, y)); - } - startCoords = Arrays.copyOf(currentCoords, currentCoords.length); - pathIter.next(); - } - return holder; - } - - private static void addPointBySort(Vector holder, Point2D point) { - boolean inserted = false; - int i = 0; - while (i < holder.size()) { - Point2D current_point = holder.get(i); - if (point.getX() < current_point.getX()) { - holder.add(i, point); - inserted = true; - break; - } - if (point.getX() == current_point.getX() && point.getY() < current_point.getY()) { - holder.add(i, point); - inserted = true; - break; - } - ++i; - } - if (!inserted) { - holder.add(point); - } - } - - private static Line2D getBoundCuttingLine(Rectangle2D bound, Point2D point, double angle) { - double minx = bound.getMinX() - 10.0; - double miny = bound.getMinY() - 10.0; - double maxx = bound.getMaxX() + 10.0; - double maxy = bound.getMaxY() + 10.0; - Line2D.Double line = angle == 1.5707963267948966 ? new Line2D.Double(point.getX(), miny, point.getX(), maxy) : (angle == 0.0 ? new Line2D.Double(minx, point.getY(), maxx, point.getY()) : new Line2D.Double(minx, point.getY() - (point.getX() - minx) * Math.tan(angle), maxx, point.getY() + (maxx - point.getX()) * Math.tan(angle))); - return line; - } - - private static double getAngle(double x1, double y1, double x2, double y2) { - Point2D.Double pt = new Point2D.Double(x2 - x1, y2 - y1); - if (((Point2D)pt).getX() == 0.0 && ((Point2D)pt).getY() == 0.0) { - return 0.0; - } - if (((Point2D)pt).getY() == 0.0) { - if (((Point2D)pt).getX() > 0.0) { - return 0.0; - } - return Math.PI; - } - if (((Point2D)pt).getX() == 0.0) { - if (((Point2D)pt).getY() > 0.0) { - return 1.5707963267948966; - } - return 4.71238898038469; - } - if (((Point2D)pt).getX() > 0.0) { - if (((Point2D)pt).getY() > 0.0) { - return Math.atan(((Point2D)pt).getY() / ((Point2D)pt).getX()); - } - return Math.atan(((Point2D)pt).getY() / ((Point2D)pt).getX()) + Math.PI * 2; - } - return Math.atan(((Point2D)pt).getY() / ((Point2D)pt).getX()) + Math.PI; - } - - private static double getAbsoluteAngle(double x1, double y1, double x2, double y2) { - if (y1 == y2) { - return 0.0; - } - if (x1 == x2) { - return 90.0; - } - boolean excessRightAngle = false; - if (x1 > x2 && y1 < y2 || x1 < x2 && y1 > y2) { - excessRightAngle = true; - } - double base = Math.abs(x1 - x2); - double height = Math.abs(y1 - y2); - double r_angle = Math.atan(height / base); - if (excessRightAngle) { - return Math.toDegrees(Math.PI - r_angle); - } - return Math.toDegrees(r_angle); - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/AbstractService.java b/src/main/java/geoinfo/map/myMap/AbstractService.java deleted file mode 100644 index 74953258..00000000 --- a/src/main/java/geoinfo/map/myMap/AbstractService.java +++ /dev/null @@ -1,30 +0,0 @@ -package geoinfo.map.myMap; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -public abstract class AbstractService -extends HttpServlet { - private static final long serialVersionUID = 2014061020172321L; - - public abstract Object parseQuery(HttpServletRequest var1) throws Exception; - - public abstract String doProcess(String var1); - - public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException { - super.service(arg0, arg1); - } - - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - super.doGet(req, resp); - } - - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - super.doPost(req, resp); - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/AttributeList.java b/src/main/java/geoinfo/map/myMap/AttributeList.java deleted file mode 100644 index 05b654ca..00000000 --- a/src/main/java/geoinfo/map/myMap/AttributeList.java +++ /dev/null @@ -1,83 +0,0 @@ -package geoinfo.map.myMap; - -import java.lang.reflect.Array; -import java.util.AbstractList; - -public class AttributeList extends AbstractList -{ - final Object ARRAY; - final int OFFSET; - final int LEN; - final int SIZE; - final int START; - final int END; - final int STEP; - - public AttributeList(Object array) - { - this(array, 0, 1); - } - - public AttributeList(Object array, int offset, int len) { - this(array, offset, len, 0, Array.getLength(array)); - } - - public AttributeList(Object array, int offset, int len, int start, int end) { - this.START = start; - this.END = end; - this.ARRAY = array; - this.OFFSET = offset; - this.LEN = len; - this.SIZE = (Math.abs(this.START - this.END) / this.LEN); - this.STEP = (this.START < this.END ? this.LEN : -this.LEN); - - if (!this.ARRAY.getClass().isArray()) { - throw new IllegalArgumentException("Provided argument was not an array"); - } - if (Array.getLength(this.ARRAY) % this.LEN != 0) - throw new IllegalArgumentException( - "You have requested Coordiantes of " + this.LEN + " ordinates. " + - "This is inconsistent with an array of length " + Array.getLength(this.ARRAY)); - } - - public Object get(int index) - { - rangeCheck(index); - return Array.get(this.ARRAY, this.START + this.STEP * index + this.OFFSET); - } - - public double getDouble(int index) { - rangeCheck(index); - return Array.getDouble(this.ARRAY, this.START + this.STEP * index + this.OFFSET); - } - public String getString(int index) { - rangeCheck(index); - return Array.get(this.ARRAY, this.START + this.STEP * index + this.OFFSET).toString(); - } - public double[] toDoubleArray() { - double[] array = new double[size()]; - for (int i = 0; i < size(); i++) { - array[i] = getDouble(i); - } - return array; - } - public Object[] toObjectArray() { - Object[] array = new Object[size()]; - for (int i = 0; i < size(); i++) { - array[i] = get(i); - } - return array; - } - - private void rangeCheck(int index) - { - if (index >= this.SIZE) - throw new IndexOutOfBoundsException( - "Index: " + index + ", Size: " + this.SIZE); - } - - public int size() - { - return this.SIZE; - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/CRSMngr.java b/src/main/java/geoinfo/map/myMap/CRSMngr.java deleted file mode 100644 index 55406e41..00000000 --- a/src/main/java/geoinfo/map/myMap/CRSMngr.java +++ /dev/null @@ -1,305 +0,0 @@ -package geoinfo.map.myMap; - -import java.util.Iterator; -import org.geotools.factory.GeoTools; -import org.geotools.factory.Hints; -import org.geotools.referencing.CRS; -import org.geotools.referencing.ReferencingFactoryFinder; -import org.geotools.util.NameFactory; -import org.opengis.referencing.NoSuchAuthorityCodeException; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opengis.util.GenericName; - -public class CRSMngr -{ - private static final O2CRSFactory crsFactory = new O2CRSFactory(); - private static final O2CRSOverrideFactory overrideFactory = new O2CRSOverrideFactory(); - - static - { - System.setProperty("org.geotools.referencing.forceXY", "true"); - Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.valueOf(true)); - GeoTools.fireConfigurationChanged(); - - ReferencingFactoryFinder.addAuthorityFactory(crsFactory); - ReferencingFactoryFinder.addAuthorityFactory(overrideFactory); - } - - public static CoordinateReferenceSystem getCRS(Integer code) - { - return getCRS(String.valueOf(code), true); - } - - public static CoordinateReferenceSystem getCRS(String code) { - return getCRS(code, true); - } - - public static CoordinateReferenceSystem getCRS(String code, boolean useEPSG) - { - try { - code = code.trim(); - - GenericName name = NameFactory.create(code); - if ((name.scope().name() == null) && (useEPSG)) { - code = "EPSG:" + code; - } - - return CRS.decode(code, true); - } catch (Exception e) { - LogMngr.getInstance().logError("[CRS]", "CRS [" + code + "] is not exist."); - }return null; - } - - public static CoordinateReferenceSystem getLayerCRS(int srid, boolean useEPSG) - throws Exception - { - CoordinateReferenceSystem crs = null; - try - { - crs = crsFactory.getCRS(srid); - - return overrideFactory.createCoordinateReferenceSystem(CRS.toSRS(crs)); - } - catch (Exception e) - { - if (crs != null) { - return crs; - } - - LogMngr.getInstance().logError("[CRS]", "SRID [" + srid + "] is not exist."); - - if (useEPSG) { - try - { - LogMngr.getInstance().logInfo("[CRS]", "Try to find SRID from EPSG [EPSG:" + srid + "]"); - return CRS.decode("EPSG:" + srid, true); - } catch (Exception e2) { - LogMngr.getInstance().logError("[CRS]", "SRID [EPSG:" + srid + "] is not exist."); - } - } - } - - throw new NoSuchAuthorityCodeException("Not exists authority or code", "LayerCRS", String.valueOf(srid)); - } - - private static void updateLayerCRS() - throws Exception - { - Map map = ServerContext.getMap(); - synchronized (map) - { - Iterator iter = map.getAllLayers().iterator(); - while (iter.hasNext()) { - Layer layer = (Layer)iter.next(); - layer.updateCRS(); - } - } - } - - private static void updateLayerCRS(CoordinateReferenceSystem targetCRS) - throws Exception - { - Map map = ServerContext.getMap(); - synchronized (map) - { - Iterator iter = map.getAllLayers().iterator(); - while (iter.hasNext()) { - Layer layer = (Layer)iter.next(); - - if (CRS.toSRS(layer.getCRS()).equalsIgnoreCase(CRS.toSRS(targetCRS))) - layer.updateCRS(); - } - } - } - - private static void updateLayerCRS(String code) - throws Exception - { - Map map = ServerContext.getMap(); - synchronized (map) - { - Iterator iter = map.getAllLayers().iterator(); - while (iter.hasNext()) { - Layer layer = (Layer)iter.next(); - - if (CRS.toSRS(layer.getCRS()).equalsIgnoreCase(code)) - layer.updateCRS(); - } - } - } - - public static void insertBasicCRS(int srid, String auth, String code, String wkt) - throws Exception - { - insertBasicCRS(srid, auth, code, wkt, false); - } - - public static void insertBasicCRS(int srid, String auth, String code, String wkt, boolean write) - throws Exception - { - CoordinateReferenceSystem crs = null; - try { - crs = crsFactory.parseWKT(auth, code, wkt); - } catch (Exception e) { - throw new Exception("CoordinateReferenceSystem is not valid."); - } - - crsFactory.insertCRS(srid, auth, code, crs, write); - } - - public static void updateBasicCRS(int srid, String auth, String code, String wkt) throws Exception - { - updateBasicCRS(srid, auth, code, wkt, false); - } - - public static void updateBasicCRS(int srid, String auth, String code, String wkt, boolean write) - throws Exception - { - CoordinateReferenceSystem crs = null; - try { - crs = crsFactory.parseWKT(auth, code, wkt); - } catch (Exception e) { - throw new IllegalArgumentException("CoordinateReferenceSystem is not valid."); - } - - crsFactory.updateCRS(srid, auth, code, crs, write); - - updateLayerCRS(crs); - } - - public static void removeBasicCRS(int srid) throws Exception - { - removeBasicCRS(srid, false); - } - - public static void removeBasicCRS(int srid, boolean write) - throws Exception - { - CoordinateReferenceSystem crs = crsFactory.getCRS(srid); - - if (isUsedByLayer(crs)) { - throw new IllegalArgumentException("SRID [" + srid + "] is used by Layer."); - } - - crsFactory.removeCRS(srid, write); - } - - public static void insertOverrideCRS(String auth, String code, String wkt) - throws Exception - { - insertOverrideCRS(auth, code, wkt, false); - } - - public static void insertOverrideCRS(String auth, String code, String wkt, boolean write) - throws Exception - { - CoordinateReferenceSystem crs = null; - try { - crs = overrideFactory.parseWKT(auth, code, wkt); - } catch (Exception e) { - throw new Exception("CoordinateReferenceSystem is not valid."); - } - - overrideFactory.insertCRS(auth, code, crs, write); - } - - public static void updateOverrideCRS(String auth, String code, String wkt) throws Exception - { - updateOverrideCRS(auth, code, wkt, false); - } - - public static void updateOverrideCRS(String auth, String code, String wkt, boolean write) - throws Exception - { - CoordinateReferenceSystem crs = null; - try { - crs = overrideFactory.parseWKT(auth, code, wkt); - } catch (Exception e) { - throw new IllegalArgumentException("CoordinateReferenceSystem is not valid."); - } - - overrideFactory.updateCRS(auth, code, crs, write); - - String crsKey = auth.trim().toUpperCase() + ":" + code.trim().toUpperCase(); - updateLayerCRS(crsKey); - } - - public static void removeOverrideCRS(String auth, String code) - throws Exception - { - removeOverrideCRS(auth, code, false); - } - - public static void removeOverrideCRS(String auth, String code, boolean write) - throws Exception - { - CoordinateReferenceSystem crs = overrideFactory.getCRS(auth, code); - String crsKey = auth.trim().toUpperCase() + ":" + code.trim().toUpperCase(); - - if (isUsedByLayer(crs)) { - throw new IllegalArgumentException("CODE [Authority:" + auth + "] or [Code:" + code + "] is used by Layer."); - } - - overrideFactory.removeCRS(auth, code, write); - - updateLayerCRS(crsKey); - } - - private static boolean isUsedByLayer(String code) - throws Exception - { - try - { - Iterator iter = ServerContext.getMap().getAllLayers().iterator(); - while (iter.hasNext()) { - Layer layer = (Layer)iter.next(); - - if (CRS.toSRS(layer.getCRS()).equalsIgnoreCase(code)) - return true; - } - } - catch (Exception e) - { - LogMngr.getInstance().logError("[CRS]", "isUsedByLayer Fail [CODE:" + code + "] :: " + e); - throw e; - } - - return false; - } - - private static boolean isUsedByLayer(CoordinateReferenceSystem targetCRS) throws Exception - { - try - { - Iterator iter = ServerContext.getMap().getAllLayers().iterator(); - while (iter.hasNext()) { - Layer layer = (Layer)iter.next(); - - if (CRS.equalsIgnoreMetadata(layer.getCRS(), targetCRS)) - return true; - } - } - catch (Exception e) - { - LogMngr.getInstance().logError("[CRS]", "isUsedByLayer Fail [CODE:" + targetCRS + "] :: " + e); - throw e; - } - - return false; - } - - public static void reloadServiceCRS(boolean updateLayer) throws Exception - { - crsFactory.initCrsDefinitions(); - LogMngr.getInstance().logInfo("[CRS]", "Success to Reload BasicCRS"); - overrideFactory.initCrsDefinitions(); - LogMngr.getInstance().logInfo("[CRS]", "Success to Reload OverrideCRS"); - - if (updateLayer) - try { - updateLayerCRS(); - } catch (Exception e) { - LogMngr.getInstance().logError("[CRS]", "Fail to Update Layer CRS :: " + e.getMessage()); - } - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/CacheFormat.java b/src/main/java/geoinfo/map/myMap/CacheFormat.java deleted file mode 100644 index 9beabaa5..00000000 --- a/src/main/java/geoinfo/map/myMap/CacheFormat.java +++ /dev/null @@ -1,31 +0,0 @@ -package geoinfo.map.myMap; - -public class CacheFormat { - int width = 256; - int height = 256; - String format = "png"; - - public int getWidth() { - return this.width; - } - - public int getHeight() { - return this.height; - } - - public String getFormat() { - return this.format; - } - - public void setWidth(int width) { - this.width = width; - } - - public void setHeight(int height) { - this.height = height; - } - - public void setFormat(String format) { - this.format = format; - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/CacheLevel.java b/src/main/java/geoinfo/map/myMap/CacheLevel.java deleted file mode 100644 index 261bf99e..00000000 --- a/src/main/java/geoinfo/map/myMap/CacheLevel.java +++ /dev/null @@ -1,70 +0,0 @@ -package geoinfo.map.myMap; - -import java.io.File; -import javax.management.modelmbean.XMLParseException; -import org.geotools.geometry.jts.ReferencedEnvelope; - -public class CacheLevel { - private CacheLevelSet levelSet; - private final int level; - private Double resolution; - private Double scaleDenominator; - - public CacheLevel(Integer lv, Double res, Double scale) throws Exception { - this.level = lv; - this.resolution = res; - this.scaleDenominator = scale; - if (this.resolution == null && this.scaleDenominator == null) { - throw new XMLParseException(" Attribute value [RESOLUTION or SCALE] is null. LEVEL [" + this.level + "]"); - } - } - - public int getLevel() { - return this.level; - } - - public Double getResolution() { - return this.resolution; - } - - public Double getScale() { - return this.scaleDenominator; - } - - public ReferencedEnvelope getBBox() { - return this.levelSet.getBBox(); - } - - public int getCacheSizeW() { - return this.levelSet.getCacheSizeW(); - } - - public int getCacheSizeH() { - return this.levelSet.getCacheSizeH(); - } - - public File getCachePath() { - return new File(this.levelSet.getCacheDir(), "/" + this.level); - } - - public String getCacheFormat() { - return this.levelSet.getCacheFormat(); - } - - public String getLayerName() { - return this.levelSet.getLayerName(); - } - - public String getLayerStyle() { - return this.levelSet.getLayerStyle(); - } - - public void refineCacheLevel(CacheLevelSet lSet) throws Exception { - this.levelSet = lSet; - if (this.resolution == null) { - this.resolution = lSet.calResolution(this.scaleDenominator); - } else if (this.scaleDenominator == null) { - this.scaleDenominator = lSet.calScaleDenominator(this.resolution); - } - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/CacheLevelSet.java b/src/main/java/geoinfo/map/myMap/CacheLevelSet.java deleted file mode 100644 index 80be97c1..00000000 --- a/src/main/java/geoinfo/map/myMap/CacheLevelSet.java +++ /dev/null @@ -1,94 +0,0 @@ -package geoinfo.map.myMap; - -import java.io.File; -import java.util.TreeMap; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.referencing.crs.GeographicCRS; - -public class CacheLevelSet { - private final double dpi = 90.7142857142857; - private final double OGC_DEGREE_TO_METER = 111319.49079327358; - private final double OGC_INCH_TO_METER = 0.0254; - private final boolean isTopLeft = false; - private ImgCacheLayer cacheLayer; - private TreeMap levelSet = new TreeMap(); - - public CacheLevelSet copy() throws Exception { - CacheLevelSet copy = new CacheLevelSet(); - for (CacheLevel lvl : this.levelSet.values()) { - CacheLevel level = new CacheLevel(Integer.valueOf(lvl.getLevel()), lvl.getResolution(), lvl.getScale()); - copy.addLevel(level); - } - return copy; - } - - public void addLevel(CacheLevel lvl) { - this.levelSet.put(lvl.getLevel(), lvl); - } - - public CacheLevel getLevel(double res) { - CacheLevel level = null; - for (CacheLevel lvl : this.levelSet.values()) { - if (level == null) { - level = lvl; - continue; - } - if (!(Math.abs(level.getResolution() - res) > Math.abs(lvl.getResolution() - res))) continue; - level = lvl; - } - return level; - } - - public ReferencedEnvelope getBBox() { - return this.cacheLayer.getBBox(); - } - - public int getCacheSizeW() { - return this.cacheLayer.getCacheSizeW(); - } - - public int getCacheSizeH() { - return this.cacheLayer.getCacheSizeH(); - } - - public File getCacheDir() { - return this.cacheLayer.getCacheDir(); - } - - public String getCacheFormat() { - return this.cacheLayer.getCacheFormat(); - } - - public String getLayerName() { - return this.cacheLayer.getLayerName(); - } - - public String getLayerStyle() { - return this.cacheLayer.getLayerStyle(); - } - - public boolean isTopLeft() { - return false; - } - - public double calScaleDenominator(double res) { - if (this.cacheLayer.getBBox().getCoordinateReferenceSystem() instanceof GeographicCRS) { - return res * 111319.49079327358 / 2.8000000000000003E-4; - } - return res / 2.8000000000000003E-4; - } - - public double calResolution(double scale) { - if (this.cacheLayer.getBBox().getCoordinateReferenceSystem() instanceof GeographicCRS) { - return scale * 2.8000000000000003E-4 * 8.983152841195214E-6; - } - return scale * 2.8000000000000003E-4; - } - - public void refindCacheLevelSet(ImgCacheLayer clayer) throws Exception { - this.cacheLayer = clayer; - for (CacheLevel level : this.levelSet.values()) { - level.refineCacheLevel(this); - } - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/CategorizeBinding110.java b/src/main/java/geoinfo/map/myMap/CategorizeBinding110.java deleted file mode 100644 index 436de768..00000000 --- a/src/main/java/geoinfo/map/myMap/CategorizeBinding110.java +++ /dev/null @@ -1,80 +0,0 @@ -package geoinfo.map.myMap; - -import java.awt.Color; -import java.util.List; -import javax.xml.namespace.QName; -import org.geotools.se.v1_1.SE; -import org.geotools.styling.ColorMap; -import org.geotools.styling.ColorMapEntry; -import org.geotools.styling.StyleFactory; -import org.geotools.xml.AbstractComplexBinding; -import org.geotools.xml.ElementInstance; -import org.geotools.xml.InstanceComponent; -import org.geotools.xml.Node; -import org.opengis.filter.FilterFactory; - -public class CategorizeBinding110 extends AbstractComplexBinding -{ - StyleFactory styleFactory; - FilterFactory filterFactory; - - public CategorizeBinding110(StyleFactory styleFactory, FilterFactory filterFactory) - { - this.styleFactory = styleFactory; - this.filterFactory = filterFactory; - } - - public QName getTarget() - { - return SE.Categorize; - } - - public Class getType() - { - return ColorMap.class; - } - - public Object parse(ElementInstance instance, Node node, Object value) - throws Exception - { - ColorMap map = this.styleFactory.createColorMap(); - - String type = (String)node.getAttributeValue("type"); - if ((type == null) || (type.equalsIgnoreCase("intervals"))) - map.setType(2); - else { - map.setType(3); - } - - List children = node.getChildren(); - int i = 0; - while (!"Threshold".equals(((Node)children.get(i)).getComponent().getName())) { - i++; - } - - while (i < children.size()) { - ColorMapEntry entry = this.styleFactory.createColorMapEntry(); - - double quantity = Double.parseDouble(((Node)children.get(i)).getValue().toString()); - entry.setQuantity(this.filterFactory.literal(quantity)); - - if (i + 1 >= children.size()) { - throw new IllegalArgumentException("Incorrectly specified color map Threshold/Value pair"); - } - - String colorStr = ((Node)children.get(i + 1)).getValue().toString(); - Color color = ServerUtil.getColorFromHex(colorStr); - - double opacity = color.getAlpha() / 255.0D; - - entry.setOpacity(this.filterFactory.literal(String.format("%.2f", new Object[] { Double.valueOf(opacity) }))); - entry.setColor(this.filterFactory.literal(ServerUtil.getHexFromColor(color))); - - map.addColorMapEntry(entry); - - i += 2; - } - - return map; - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/ConnJDBC.java b/src/main/java/geoinfo/map/myMap/ConnJDBC.java deleted file mode 100644 index 358229f4..00000000 --- a/src/main/java/geoinfo/map/myMap/ConnJDBC.java +++ /dev/null @@ -1,69 +0,0 @@ -package geoinfo.map.myMap; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.util.HashMap; - -public abstract class ConnJDBC { - protected Connection connection = null; - - public ConnJDBC() { - DriverManager.setLoginTimeout(5); - } - - public Connection openConn() throws Exception { - if (this.connection != null) { - return this.connection; - } - HashMap map = ServerConfiguration.getInstance().getConfMap(); - String sURL = this.getJDBCUrl(); - String user = (String)map.get("conf.xml.map.user"); - String passwd = (String)map.get("conf.xml.map.passwd"); - try { - Class.forName(this.getDriverClassName()); - } - catch (Exception e) { - LogMngr.getInstance().logError("[DB]", "Can't register JDBC Driver :: " + e.getMessage()); - throw new Exception("Can't register JDBC Driver :: " + e.getMessage()); - } - try { - LogMngr.getInstance().logDebug("[DB]", "Open Connection :: " + sURL + ", " + user + ", " + passwd); - this.connection = DriverManager.getConnection(sURL, user, passwd); - } - catch (SQLException e) { - LogMngr.getInstance().logError("[DB]", "Open Connection Fail :: " + e.getMessage()); - throw new SQLException("Open Connection Fail :: " + e.getMessage()); - } - return this.connection; - } - - public void closeConn() { - if (this.connection != null) { - try { - if (!this.connection.isClosed()) { - this.connection.close(); - } - this.connection = null; - } - catch (SQLException e) { - this.connection = null; - LogMngr.getInstance().logError("[DB]", "Close Connection Fail :: " + e.getMessage()); - } - } - } - - public String getJDBCUrl() throws Exception { - HashMap map = ServerConfiguration.getInstance().getConfMap(); - String host = (String)map.get("conf.xml.map.host"); - String port = (String)map.get("conf.xml.map.port"); - String database = (String)map.get("conf.xml.map.database"); - return this.getJDBCUrl(host, Integer.valueOf(port), database); - } - - public abstract String getDriverClassName(); - - public abstract String getJDBCUrl(String var1, Integer var2, String var3); - - public abstract FieldSQL getFieldSQL(); -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/ConnMngr.java b/src/main/java/geoinfo/map/myMap/ConnMngr.java deleted file mode 100644 index 23a634b8..00000000 --- a/src/main/java/geoinfo/map/myMap/ConnMngr.java +++ /dev/null @@ -1,87 +0,0 @@ -package geoinfo.map.myMap; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.HashMap; - -public class ConnMngr -{ - private static ConnMngr instance = null; - private ConnJDBC connJDBC = null; - - public static ConnMngr getInstance() - { - if (instance == null) { - instance = new ConnMngr(); - } - return instance; - } - - public ConnJDBC getConnObj(String dbType) throws Exception - { - if ((dbType != null) && (dbType.toLowerCase().equals("oracle"))) - return new ConnOracle(); - - LogMngr.getInstance().logError("[DB]", "Database type [" + dbType + "] is not support."); - throw new NullPointerException("Database type [" + dbType + "] is not support."); - } - - public ConnJDBC getConnObj(O2DSFactory.DBMSType dbType) - throws Exception - { - if ((dbType != null) && (dbType == O2DSFactory.DBMSType.ORACLE)) - return new ConnOracle(); - LogMngr.getInstance().logError("[DB]", "Database type [" + dbType + "] is not support."); - throw new NullPointerException("Database type [" + dbType + "] is not support."); - } - - public Connection openConn() - throws Exception - { - HashMap map = ServerConfiguration.getInstance().getConfMap(); - - String dbType = (String)map.get("conf.xml.map.dbtype"); - dbType = dbType.trim(); - - if ((dbType != null) && (dbType.toLowerCase().equals("oracle"))) { - this.connJDBC = new ConnOracle(); - } else { - LogMngr.getInstance().logError("[DB]", "Database type [" + dbType + "] is not support."); - throw new NullPointerException("Database type [" + dbType + "] is not support."); - } - - return this.connJDBC.openConn(); - } - - public void closeConn() { - if (this.connJDBC != null) - this.connJDBC.closeConn(); - } - - public void closeSafe(Statement st) - { - if (st == null) { - return; - } - try - { - st.close(); - } catch (SQLException localSQLException) { - } - } - - public void closeSafe(ResultSet rs) { - if (rs == null) { - return; - } - try - { - rs.close(); - } - catch (SQLException localSQLException) - { - } - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/ConnOracle.java b/src/main/java/geoinfo/map/myMap/ConnOracle.java deleted file mode 100644 index 39f1c998..00000000 --- a/src/main/java/geoinfo/map/myMap/ConnOracle.java +++ /dev/null @@ -1,33 +0,0 @@ -package geoinfo.map.myMap; - -import java.util.HashMap; - -public class ConnOracle extends ConnJDBC -{ - public String getDriverClassName() - { - return "oracle.jdbc.driver.OracleDriver"; - } - - public String getJDBCUrl(String host, Integer port, String database) - { - String sURL = "jdbc:oracle:thin:@"; - sURL = sURL + host + ":" + port + ":" + database; - - return sURL; - } - - public FieldSQL getFieldSQL() - { - HashMap fields = new HashMap(); - fields.put(FieldSQL.FieldType.GEOMETRY, "SDO_GEOMETRY"); - fields.put(FieldSQL.FieldType.CHARACTER, "VARCHAR2"); - fields.put(FieldSQL.FieldType.NUMERIC, "NUMBER"); - fields.put(FieldSQL.FieldType.BOOLEAN, "CHAR(1)"); - fields.put(FieldSQL.FieldType.DATE, "DATE"); - fields.put(FieldSQL.FieldType.BLOB, "BLOB"); - fields.put(FieldSQL.FieldType.UNKNOWN, "VARCHAR2(100)"); - - return new FieldSQL(O2DSFactory.DBMSType.ORACLE, fields, false); - } -} diff --git a/src/main/java/geoinfo/map/myMap/ContentDataStoreRefinder.java b/src/main/java/geoinfo/map/myMap/ContentDataStoreRefinder.java deleted file mode 100644 index 622ba802..00000000 --- a/src/main/java/geoinfo/map/myMap/ContentDataStoreRefinder.java +++ /dev/null @@ -1,238 +0,0 @@ -package geoinfo.map.myMap; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; // Map.Entry 대신 HashMap 사용을 명시 -import java.util.Map; - -import org.geotools.data.Transaction; -import org.geotools.data.shapefile.ShapefileDataStore; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.data.store.ContentDataStore; -import org.geotools.data.store.ContentEntry; // ContentEntry는 여전히 사용될 수 있습니다. -import org.geotools.data.store.ContentFeatureSource; -import org.geotools.data.store.ContentState; -import org.geotools.feature.AttributeTypeBuilder; -import org.geotools.feature.simple.SimpleFeatureTypeBuilder; -import org.geotools.jdbc.AutoGeneratedPrimaryKeyColumn; -import org.geotools.jdbc.JDBCDataStore; // JDBCDataStore로 캐스팅하여 더 명확하게 사용 -import org.geotools.jdbc.JDBCState; // JDBCState는 여전히 사용될 수 있습니다. -import org.geotools.jdbc.NonIncrementingPrimaryKeyColumn; -import org.geotools.jdbc.NullPrimaryKey; -import org.geotools.jdbc.PrimaryKey; -import org.geotools.jdbc.PrimaryKeyColumn; -import org.geotools.jdbc.SequencedPrimaryKeyColumn; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -public class ContentDataStoreRefinder { - - /** - * JDBC DataStore의 FeatureType 스키마를 재구성합니다. - * 주의: 이 메서드는 GeoTools의 내부 구조에 깊이 의존하므로, - * GeoTools 버전 업데이트 시 호환성 문제가 발생할 수 있습니다. - * 가능한 경우, JDBCDataStore.createSchema()를 통해 새로운 스키마를 - * 생성하거나 기존 데이터를 새 스키마로 마이그레이션하는 것을 권장합니다. - * - * @param dataStore 재구성할 JDBC DataStore - * @param typeName 대상 FeatureType의 이름 - * @return 재구성된 ContentFeatureSource - * @throws IOException - */ - public static synchronized ContentFeatureSource refindJDBCFeatureSource(ContentDataStore dataStore, String typeName) throws IOException { - ContentFeatureSource cfs = dataStore.getFeatureSource(typeName); - SimpleFeatureType featureType = cfs.getSchema(); - - SimpleFeatureTypeBuilder tBuilder = new SimpleFeatureTypeBuilder(); - tBuilder.init(featureType); - tBuilder.setName(featureType.getTypeName().toUpperCase()); // 대문자로 FeatureType 이름 설정 - - AttributeTypeBuilder aBuilder = new AttributeTypeBuilder(); - for (AttributeDescriptor attr : featureType.getAttributeDescriptors()) { - tBuilder.remove(attr.getLocalName()); // 기존 속성 제거 (이름 변경을 위해) - - aBuilder.init(attr); // 기존 속성으로 초기화 - // 사용자 데이터 복사 (attr.getUserData()는 Map를 반환) - for (Map.Entry entry : attr.getUserData().entrySet()) { - aBuilder.addUserData(entry.getKey(), entry.getValue()); - } - // 속성 이름을 대문자로 변경하여 추가 - tBuilder.add(aBuilder.buildDescriptor(attr.getLocalName().toUpperCase())); - } - - SimpleFeatureType nFeatureType = tBuilder.buildFeatureType(); - nFeatureType.getUserData().putAll(featureType.getUserData()); // FeatureType의 사용자 데이터 복사 - - // --- JDBCDataStore의 내부 상태 직접 조작은 매우 위험하며, GeoTools 버전 업데이트 시 깨질 수 있습니다. --- - // JDBCState는 JDBCDataStore 내부에서 관리되는 상태 객체입니다. - // ContentEntry를 새로 생성하여 상태를 주입하는 방식은 GeoTools의 일반적인 사용 패턴이 아닙니다. - // 대신, JDBCDataStore가 스키마를 관리하는 방식을 따르는 것이 좋습니다. - - // 여기서는 기존 로직의 의도를 최대한 살리려고 노력하지만, - // 이 부분은 GeoTools 11.3에서 안전하게 작동하지 않을 수 있습니다. - // 이상적으로는 JDBCDataStore.createSchema(nFeatureType)를 호출하여 - // 새로운 스키마를 등록하는 것이 더 안전한 방법입니다. - - // 기존 로직의 문제점: ContentDataStore.entries 필드는 protected이거나 private일 수 있어 직접 접근 불가. - // ContentEntry 및 ContentState의 내부 조작 역시 권장되지 않음. - // PrimaryKey 관련 로직도 JDBCDataStore의 createSchema 시점에 함께 정의되는 것이 일반적. - - // 임시 해결책 (기존 로직의 의도 최대한 유지): - // ContentEntry를 다시 생성하는 대신, 기존 FeatureSource의 Entry를 가져와 상태를 업데이트하는 시도 - // 이 또한 GeoTools 내부 구현에 의존하므로 불안정할 수 있습니다. - ContentEntry existingEntry = cfs.getEntry(); - ContentState state = existingEntry.getState(Transaction.AUTO_COMMIT); // 기존 Entry의 상태 가져오기 - - if (state instanceof JDBCState) { - JDBCState jdbcState = (JDBCState) state; - jdbcState.setFeatureType(nFeatureType); // 새 FeatureType 설정 - - // PrimaryKey 로직: 기존의 PrimaryKey 정보를 가져와 새로운 FeatureType에 맞게 조정 - // 이 부분은 JDBCDataStore의 JDBCState가 PrimaryKey를 어떻게 관리하는지에 따라 달라집니다. - // GeoTools의 jdbc 모듈 소스 코드를 직접 확인하는 것이 가장 정확합니다. - PrimaryKey oldPK = jdbcState.getPrimaryKey(); // 이전 PrimaryKey 가져오기 - ArrayList nColumns = new ArrayList<>(); // PrimaryKeyColumn 타입으로 명시 - - if (oldPK != null) { - for (PrimaryKeyColumn column : oldPK.getColumns()) { - String newColumnName = column.getName().toUpperCase(); // 컬럼 이름도 대문자로 - - if (column instanceof AutoGeneratedPrimaryKeyColumn) { - nColumns.add(new AutoGeneratedPrimaryKeyColumn(newColumnName, column.getType())); - } else if (column instanceof SequencedPrimaryKeyColumn) { - nColumns.add(new SequencedPrimaryKeyColumn(newColumnName, column.getType(), ((SequencedPrimaryKeyColumn) column).getSequenceName())); - } else if (column instanceof NonIncrementingPrimaryKeyColumn) { - nColumns.add(new NonIncrementingPrimaryKeyColumn(newColumnName, column.getType())); - } - // 다른 PrimaryKeyColumn 타입이 있다면 여기에 추가 - } - } - - if (nColumns.isEmpty()) { - jdbcState.setPrimaryKey(new NullPrimaryKey(nFeatureType.getTypeName())); - } else { - jdbcState.setPrimaryKey(new PrimaryKey(nFeatureType.getTypeName(), nColumns)); - } - } else { - // JDBCState가 아닌 경우 (예: 다른 DataStore 구현체) - // 혹은 기존의 ContentEntry가 JDBCState를 반환하지 않는 경우 - // 이 부분은 JDBC DataStore에 특화된 로직입니다. - throw new IllegalArgumentException("Provided dataStore is not a JDBCDataStore or does not manage JDBCState correctly."); - } - - // dataStore.entries.put()와 같은 직접적인 필드 접근은 제거했습니다. - // 대신, 스키마 변경이 ContentDataStore에 반영되도록 노력해야 합니다. - // ContentDataStore는 FeatureType 변경을 내부적으로 처리하는 메커니즘을 가질 수 있습니다. - // 이 코드가 제대로 작동하려면 DataStore의 refresh 또는 reload 메커니즘을 찾아야 합니다. - // 아니면 새로운 DataStore 인스턴스를 생성해야 합니다. - - // 여기서는 변경된 스키마로 새로운 FeatureSource를 얻으려는 시도입니다. - // 하지만 기존 DataStore가 스키마 변경을 즉시 반영하지 않을 수 있습니다. - return (ContentFeatureSource) dataStore.getFeatureSource(nFeatureType.getName()); // 변경된 이름으로 FeatureSource 요청 - } - - /** - * ShapefileDataStore의 FeatureType 스키마를 재구성합니다. - * JDBCDataStore와 마찬가지로 내부 필드 접근은 피하고, - * 스키마 변경을 ShapefileDataStore가 처리할 수 있도록 해야 합니다. - * Shapefile의 특성상, 스키마 변경은 파일 자체의 변경을 의미하며, - * 이는 DataStore 레벨에서 간단히 `setFeatureType`으로 처리하기 어렵습니다. - * 일반적으로 Shapefile의 스키마 변경은 새 Shapefile을 생성하는 방식으로 이루어집니다. - * - * @param dataStore 재구성할 ShapefileDataStore - * @return 재구성된 ShapefileDataStore - * @throws IOException - */ - public static synchronized ShapefileDataStore refindShapefileDataStore(ShapefileDataStore dataStore) throws IOException { - // ShapefileDataStore는 ContentDataStore를 상속하지만, JDBC와는 다르게 스키마를 다룹니다. - // Shapefile은 파일 기반이므로, SimpleFeatureType 변경은 파일의 구조 변경을 의미합니다. - // DataStore의 내부 상태를 직접 변경하는 것은 Shapefile에서는 매우 위험하고 잘못된 접근입니다. - // 일반적으로 Shapefile의 스키마 변경은 새 Shapefile을 생성하고 데이터를 마이그레이션하는 방식으로 이루어집니다. - - // 따라서 이 메서드는 GeoTools의 ShapefileDataStore의 동작 방식과 맞지 않습니다. - // 만약 FeatureType의 속성 이름만 대문자로 바꾸는 것이 목적이라면, - // FeatureCollection을 읽어서 새로운 FeatureCollection을 만들 때 속성 이름을 변경하거나, - // ShapefileDataStore를 다시 로드하는 방식으로 접근해야 합니다. - - // 기존 로직의 의도를 최대한 살려 보지만, 실제 작동을 보장하기 어렵습니다. - SimpleFeatureSource cfs = dataStore.getFeatureSource(); // 기본 FeatureSource 가져오기 - SimpleFeatureType featureType = cfs.getSchema(); - - SimpleFeatureTypeBuilder tBuilder = new SimpleFeatureTypeBuilder(); - tBuilder.init(featureType); - tBuilder.setName(featureType.getTypeName().toUpperCase()); - - AttributeTypeBuilder aBuilder = new AttributeTypeBuilder(); - for (AttributeDescriptor attr : featureType.getAttributeDescriptors()) { - tBuilder.remove(attr.getLocalName()); - aBuilder.init(attr); - for (Map.Entry entry : attr.getUserData().entrySet()) { // Map.Entry 타입 명시 - aBuilder.addUserData(entry.getKey(), entry.getValue()); - } - tBuilder.add(aBuilder.buildDescriptor(attr.getLocalName().toUpperCase())); - } - - SimpleFeatureType nFeatureType = tBuilder.buildFeatureType(); - nFeatureType.getUserData().putAll(featureType.getUserData()); - - // --- ShapefileDataStore의 내부 상태 직접 조작도 매우 위험합니다. --- - // ShapefileDataStore는 ContentDataStore를 상속하지만, - // 그 내부 ContentEntry/ContentState를 직접 조작하는 것은 지원되지 않습니다. - // Shapefile은 read-only로 열려있을 경우 스키마를 변경할 수 없습니다. - // write-access로 열었을 경우에도 setFeatureType으로 스키마를 변경하는 것은 - // 파일 자체의 스키마를 바꾸는 것이므로 매우 복잡한 과정이 필요합니다. - - // 이 부분은 GeoTools의 `ShapefileDataStore`가 설계된 방식과 맞지 않으므로, - // 이 코드가 제대로 작동하기 어렵습니다. - // Shapefile의 스키마 변경은 일반적으로 새 Shapefile을 생성하고 데이터를 다시 쓰는 방식으로 이루어집니다. - - // 주석 처리: 이 부분은 GeoTools의 안정적인 API를 사용하지 않으므로, 작동하지 않을 수 있습니다. - /* - ContentEntry entry = new ContentEntry(dataStore, nFeatureType.getName()); - ContentState state = entry.getState(Transaction.AUTO_COMMIT); - state.setFeatureType(nFeatureType); - dataStore.entries.put(entry.getName(), entry); // 이 줄은 컴파일 에러 발생 가능 - dataStore.entries.put(cfs.getEntry().getName(), entry); // 이 줄은 컴파일 에러 발생 가능 - */ - - // 대신, 여기서는 새로운 FeatureType을 바탕으로 DataStore를 다시 로드하거나 - // 아예 새로운 Shapefile을 생성하는 것을 고려해야 합니다. - // 이 메서드는 기존 ShapefileDataStore의 스키마를 "재정의"하는 것이므로, - // 실제 Shapefile 파일의 스키마는 변경되지 않을 수 있습니다. - // ShapefileDataStore는 스키마를 변경하는 API를 직접적으로 제공하지 않습니다. - - System.err.println("Warning: refindShapefileDataStore attempts to modify internal state of ShapefileDataStore, which is generally not supported for schema changes. Consider creating a new Shapefile with the desired schema."); - return dataStore; // 원본 DataStore를 반환 (실제 스키마 변경이 이루어지지 않을 수 있음) - } - - /** - * SimpleFeatureSource의 CRS(좌표 참조 시스템)를 변경합니다. - * ContentFeatureSource인 경우에만 내부 상태를 업데이트합니다. - * - * @param featureSource CRS를 변경할 SimpleFeatureSource - * @param crs 새로운 CoordinateReferenceSystem - * @return CRS가 변경된 SimpleFeatureSource (원본 객체 또는 새로운 객체일 수 있음) - * @throws IOException - */ - public static synchronized SimpleFeatureSource changeCRSFeatureSource(SimpleFeatureSource featureSource, CoordinateReferenceSystem crs) throws IOException { - if (featureSource instanceof ContentFeatureSource) { - SimpleFeatureType currentType = featureSource.getSchema(); - // SimpleFeatureTypeBuilder.retype는 기존 FeatureType을 기반으로 새로운 CRS를 가진 FeatureType을 생성합니다. - SimpleFeatureType newType = SimpleFeatureTypeBuilder.retype(currentType, crs); - - // ContentFeatureSource의 Entry를 통해 내부 상태를 업데이트합니다. - // 이 방식은 ContentDataStore의 구현에 따라 작동하거나 작동하지 않을 수 있습니다. - // 특히 Shapefile의 경우, 파일 자체의 CRS가 변경되지 않는 이상 이 방식은 메타데이터만 변경할 수 있습니다. - // 실제 데이터의 CRS 변환은 FeatureCollection을 통해 TransforingFeatureSource를 사용해야 합니다. - ((ContentFeatureSource) featureSource).getEntry().getState(Transaction.AUTO_COMMIT).setFeatureType(newType); - } else { - // ContentFeatureSource가 아닌 다른 SimpleFeatureSource 구현체인 경우 - // (예: PostGISDataStore의 SimpleFeatureSource 등) - // 해당 DataStore의 특정 메서드를 통해 CRS를 변경해야 할 수 있습니다. - // 또는 TransformingFeatureSource를 사용하여 CRS 변환을 수행하는 것이 더 일반적입니다. - System.err.println("Warning: changeCRSFeatureSource is designed for ContentFeatureSource. For other types, consider using a TransformingFeatureSource or DataStore specific methods."); - } - return featureSource; - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/CoordinateAccess.java b/src/main/java/geoinfo/map/myMap/CoordinateAccess.java deleted file mode 100644 index 3f8a01c1..00000000 --- a/src/main/java/geoinfo/map/myMap/CoordinateAccess.java +++ /dev/null @@ -1,34 +0,0 @@ -package geoinfo.map.myMap; - -import com.vividsolutions.jts.geom.CoordinateSequence; - -public abstract interface CoordinateAccess extends CoordinateSequence -{ - public abstract int getDimension(); - - public abstract int getNumAttributes(); - - public abstract double getOrdinate(int paramInt1, int paramInt2); - - public abstract Object getAttribute(int paramInt1, int paramInt2); - - public abstract void setOrdinate(int paramInt1, int paramInt2, double paramDouble); - - public abstract void setAttribute(int paramInt1, int paramInt2, Object paramObject); - - public abstract double[] toOrdinateArray(int paramInt); - - public abstract Object[] toAttributeArray(int paramInt); - - public abstract void setOrdinateArray(int paramInt, double[] paramArrayOfDouble); - - public abstract void setAttributeArray(int paramInt, Object paramObject); - - public abstract double[][] toOrdinateArrays(); - - public abstract Object[] toAttributeArrays(); - - public abstract void setCoordinateArrays(double[][] paramArrayOfDouble, Object[] paramArrayOfObject); - - public abstract void setAt(int paramInt, double[] paramArrayOfDouble, Object[] paramArrayOfObject); -} diff --git a/src/main/java/geoinfo/map/myMap/CoordinateAccessFactory.java b/src/main/java/geoinfo/map/myMap/CoordinateAccessFactory.java deleted file mode 100644 index 690b9ff5..00000000 --- a/src/main/java/geoinfo/map/myMap/CoordinateAccessFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package geoinfo.map.myMap; - -import com.vividsolutions.jts.geom.CoordinateSequenceFactory; - -public abstract interface CoordinateAccessFactory extends CoordinateSequenceFactory -{ - public abstract CoordinateAccess create(double[][] paramArrayOfDouble, Object[] paramArrayOfObject); - - public abstract int getDimension(); - - public abstract int getNumAttributes(); -} diff --git a/src/main/java/geoinfo/map/myMap/Coordinates.java b/src/main/java/geoinfo/map/myMap/Coordinates.java deleted file mode 100644 index 7b63f38d..00000000 --- a/src/main/java/geoinfo/map/myMap/Coordinates.java +++ /dev/null @@ -1,255 +0,0 @@ -package geoinfo.map.myMap; - -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.CoordinateSequence; -import com.vividsolutions.jts.geom.CoordinateSequenceFactory; -import com.vividsolutions.jts.geom.CoordinateSequences; -import com.vividsolutions.jts.geom.PrecisionModel; -import java.io.PrintStream; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.NumberFormat; -import java.util.List; - -public class Coordinates -{ - public static CoordinateSequence subList(CoordinateSequenceFactory factory, CoordinateSequence sequence, int fromIndex, int toIndex) - { - if ((fromIndex == 0) && (toIndex == sequence.size())) { - return sequence; - } - - if ((sequence instanceof List)) { - List sublist = ((List)sequence).subList(fromIndex, toIndex); - - if ((sublist instanceof CoordinateSequence)) { - return (CoordinateSequence)sublist; - } - } - - if ((sequence instanceof CoordinateAccess)) { - CoordinateAccess access = (CoordinateAccess)sequence; - double[][] coordArray = access.toOrdinateArrays(); - Object[] attributeArray = access.toAttributeArrays(); - - double[][] subCoordArray = new double[access.getDimension()][]; - Object[][] subAttributeArray = new Object[access.getNumAttributes()][]; - - for (int i = 0; i < access.getDimension(); i++) { - subCoordArray[i] = new OrdinateList(coordArray[i], 0, 1, - fromIndex, toIndex).toDoubleArray(); - } - - for (int i = 0; i < access.getNumAttributes(); i++) { - subAttributeArray[i] = new AttributeList(attributeArray[i], 0, - 1, fromIndex, toIndex).toObjectArray(); - } - - System.out.println("subCoordArray.length = " + subCoordArray.length); - System.out.println("subCoordArray: "); - System.out.print("X "); - - for (int p = 0; p < subCoordArray[0].length; p++) { - System.out.print(subCoordArray[0][p] + " "); - } - System.out.print("\nY "); - - for (int p = 0; p < subCoordArray[1].length; p++) { - System.out.print(subCoordArray[1][p] + " "); - } - System.out.println(""); - - System.out.println("subAttributeArray.length = " + - subAttributeArray.length); - System.out.println("subAttributeArray: "); - System.out.print("Z "); - - for (int p = 0; p < subAttributeArray[0].length; p++) { - System.out.print(subAttributeArray[0][p] + " "); - } - System.out.print("\nT "); - - for (int p = 0; p < subAttributeArray[1].length; p++) { - System.out.print(subAttributeArray[1][p] + " "); - } - System.out.println(""); - - CoordinateAccess c = ((CoordinateAccessFactory)factory) - .create(subCoordArray, subAttributeArray); - - return c; - } - - int size = toIndex - fromIndex; - CoordinateSequence newSeq = factory.create(size, sequence.getDimension()); - //CoordinateSequences.copy(sequence, fromIndex, newSeq, 0, size); - System.out.println("에러: CoordinateSequences.copy(sequence, fromIndex, newSeq, 0, size);"); - return newSeq; - } - - public static CoordinateSequence reverse(CoordinateSequenceFactory factory, CoordinateSequence sequence) - { - if ((sequence instanceof CoordinateAccess)) { - CoordinateAccess access = (CoordinateAccess)sequence; - double[][] coordArray = access.toOrdinateArrays(); - Object[] attributeArray = access.toAttributeArrays(); - - double[][] subCoordArray = new double[access.getDimension()][]; - Object[][] subAttributeArray = new Object[access.getNumAttributes()][]; - - for (int i = 0; i < access.getDimension(); i++) { - subCoordArray[i] = new OrdinateList(coordArray[i], 0, 1, - access.size() - 1, -1).toDoubleArray(); - } - - for (int i = 0; i < access.getNumAttributes(); i++) { - subAttributeArray[i] = new AttributeList(attributeArray[i], 0, - 1, access.size() - 1, -1).toObjectArray(); - } - - CoordinateAccess c = ((CoordinateAccessFactory)factory) - .create(subCoordArray, subAttributeArray); - - return c; - } - - CoordinateSequence revSeq = factory.create(sequence); - CoordinateSequences.reverse(revSeq); - return revSeq; - } - - public static String toString(CoordinateSequence cs, int coordinate, NumberFormat nf) - { - StringBuffer buf = new StringBuffer(); - append(buf, cs, coordinate, nf); - - return buf.toString(); - } - - public static void append(StringBuffer buf, CoordinateSequence cs, int coordinate, NumberFormat nf) - { - if ((cs instanceof CoordinateAccess)) { - CoordinateAccess ca = (CoordinateAccess)cs; - append(buf, ca, coordinate, LEN(ca), nf); - } else { - append(buf, cs, coordinate, LEN(cs), nf); - } - } - - public static void append(StringBuffer buf, CoordinateSequence cs, int coordinate, int LEN, NumberFormat nf) - { - Coordinate c = cs.getCoordinate(coordinate); - buf.append(nf.format(c.x)); - buf.append(" "); - buf.append(nf.format(c.y)); - - if (LEN == 3) { - buf.append(" "); - buf.append(nf.format(c.z)); - } - } - - public static void append(StringBuffer buf, CoordinateAccess ca, int coordinate, int LEN, NumberFormat nf) - { - buf.append(nf.format(ca.getOrdinate(coordinate, 0))); - - for (int i = 1; i < LEN; i++) { - buf.append(" "); - buf.append(nf.format(ca.getOrdinate(coordinate, i))); - } - } - - public static int LEN(CoordinateSequence cs) { - return D(cs) + L(cs); - } - - public static int D(CoordinateSequence cs) { - if ((cs instanceof CoordinateAccess)) { - return ((CoordinateAccess)cs).getDimension(); - } - - if (cs.size() > 0) { - return Double.isNaN(cs.getCoordinate(0).z) ? 2 : 3; - } - - return 3; - } - - public static int L(CoordinateSequence cs) { - if ((cs instanceof CoordinateAccess)) { - return ((CoordinateAccess)cs).getNumAttributes(); - } - - return 0; - } - - public static NumberFormat format(PrecisionModel pm) { - DecimalFormatSymbols symbols = new DecimalFormatSymbols(); - symbols.setNaN("NaN"); - - DecimalFormat f = new DecimalFormat(); - f.setDecimalFormatSymbols(symbols); - - if (pm == null) { - f.setMaximumFractionDigits(0); - - return f; - } - - f.setMinimumFractionDigits(0); - f.setMaximumFractionDigits(pm.getMaximumSignificantDigits()); - - return f; - } - - public static String toString(CoordinateSequence cs, PrecisionModel pm) { - StringBuffer buf = new StringBuffer(); - append(buf, cs, format(pm)); - - return buf.toString(); - } - - public static void append(StringBuffer buf, CoordinateSequence cs, NumberFormat nf) - { - if ((cs instanceof CoordinateAccess)) { - append(buf, (CoordinateAccess)cs, nf); - } else { - int LEN = LEN(cs); - - if (cs.size() == 0) { - return; - } - - append(buf, cs, 0, LEN, nf); - - if (cs.size() == 1) { - return; - } - - for (int i = 1; i < cs.size(); i++) { - buf.append(", "); - append(buf, cs, i, LEN, nf); - } - } - } - - public static void append(StringBuffer buf, CoordinateAccess ca, NumberFormat nf) - { - int LEN = LEN(ca); - - if (ca.size() == 0) { - return; - } - - append(buf, ca, 0, LEN, nf); - - if (ca.size() == 1) { - return; - } - - for (int i = 1; i < ca.size(); i++) { - buf.append(", "); - append(buf, ca, i, LEN, nf); - } - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/EncryptUtil.java b/src/main/java/geoinfo/map/myMap/EncryptUtil.java deleted file mode 100644 index 172a9402..00000000 --- a/src/main/java/geoinfo/map/myMap/EncryptUtil.java +++ /dev/null @@ -1,68 +0,0 @@ -package geoinfo.map.myMap; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.GeneralSecurityException; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.KeyException; -import java.security.NoSuchAlgorithmException; -import javax.crypto.BadPaddingException; -import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; -import org.geotools.data.Base64; - -public class EncryptUtil -{ - private static final String characterEncoding = "UTF-8"; - private static final String cipherTransformation = "AES/CBC/PKCS5Padding"; - private static final String aesEncryptionAlgorithm = "AES"; - public static final String ENCRYPTIONKEY = "wldhxn"; - - private static byte[] decrypt(byte[] cipherText, byte[] key, byte[] initialVector) - throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException - { - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - SecretKeySpec secretKeySpecy = new SecretKeySpec(key, "AES"); - IvParameterSpec ivParameterSpec = new IvParameterSpec(initialVector); - cipher.init(2, secretKeySpecy, ivParameterSpec); - cipherText = cipher.doFinal(cipherText); - return cipherText; - } - - private static byte[] encrypt(byte[] plainText, byte[] key, byte[] initialVector) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException - { - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES"); - IvParameterSpec ivParameterSpec = new IvParameterSpec(initialVector); - cipher.init(1, secretKeySpec, ivParameterSpec); - plainText = cipher.doFinal(plainText); - return plainText; - } - - private static byte[] getKeyBytes(String key) throws UnsupportedEncodingException { - byte[] keyBytes = new byte[16]; - byte[] parameterKeyBytes = key.getBytes("UTF-8"); - System.arraycopy(parameterKeyBytes, 0, keyBytes, 0, Math.min(parameterKeyBytes.length, keyBytes.length)); - return keyBytes; - } - - public static String encrypt(String plainText, String key) - throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException - { - byte[] plainTextbytes = plainText.getBytes("UTF-8"); - byte[] keyBytes = getKeyBytes(key); - return Base64.encodeBytes(encrypt(plainTextbytes, keyBytes, keyBytes)); - } - - public static String decrypt(String encryptedText, String key) - throws KeyException, GeneralSecurityException, GeneralSecurityException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, IOException - { - byte[] cipheredBytes = Base64.decode(encryptedText); - byte[] keyBytes = getKeyBytes(key); - return new String(decrypt(cipheredBytes, keyBytes, keyBytes), "UTF-8"); - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/ExFeatureLayer.java b/src/main/java/geoinfo/map/myMap/ExFeatureLayer.java deleted file mode 100644 index 831b93b6..00000000 --- a/src/main/java/geoinfo/map/myMap/ExFeatureLayer.java +++ /dev/null @@ -1,20 +0,0 @@ -package geoinfo.map.myMap; - -import org.geotools.data.FeatureSource; -import org.geotools.map.FeatureLayer; -import org.geotools.styling.Style; - -public class ExFeatureLayer -extends FeatureLayer { - public ExFeatureLayer(FeatureSource featureSource, Style style) { - super(featureSource, style); - } - - public boolean isWrapTileTextLayer() { - return ((MapStyle)this.getStyle()).isWrapTileTextStyle(); - } - - public double getWrapTileText() { - return ((MapStyle)this.getStyle()).getWrapTileText(); - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/ExO2ImgLayer.java b/src/main/java/geoinfo/map/myMap/ExO2ImgLayer.java deleted file mode 100644 index ef1b32e2..00000000 --- a/src/main/java/geoinfo/map/myMap/ExO2ImgLayer.java +++ /dev/null @@ -1,52 +0,0 @@ -package geoinfo.map.myMap; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.map.DirectLayer; -import org.geotools.map.MapContent; -import org.geotools.map.MapViewport; -import org.geotools.referencing.CRS; - -public class ExO2ImgLayer extends DirectLayer -{ - private O2ImgLayer imgLayer; - private ReferencedEnvelope WMS_BBOX; - private int WMS_WIDTH; - private int WMS_HEIGHT; - - public ExO2ImgLayer(O2ImgLayer layer, AVList params) - throws Exception - { - this.imgLayer = layer; - - this.WMS_BBOX = ((ReferencedEnvelope)params.getValue("request.wms.bbox")); - - if (!CRS.equalsIgnoreMetadata( - layer.getCRS(), - this.WMS_BBOX.getCoordinateReferenceSystem())) { - this.WMS_BBOX = this.WMS_BBOX.transform(layer.getCRS(), true); - } - - this.WMS_WIDTH = params.getIntegerValue("request.wms.width").intValue(); - this.WMS_HEIGHT = params.getIntegerValue("request.wms.height").intValue(); - } - - public ReferencedEnvelope getBounds() - { - return this.imgLayer.getBBox(); - } - - public void draw(Graphics2D graphics, MapContent map, MapViewport viewport) - { - try - { - BufferedImage img = O2LayerUtil.getMap(this.imgLayer.getLevelSet(), this.WMS_BBOX, this.WMS_WIDTH, this.WMS_HEIGHT); - graphics.drawImage(img, null, 0, 0); - } - catch (Exception e) - { - LogMngr.getInstance().logError("[RENDER]", "Fail to render O2ImgLayer :: " + e); - } - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/ExWMSLayer.java b/src/main/java/geoinfo/map/myMap/ExWMSLayer.java deleted file mode 100644 index adee63bc..00000000 --- a/src/main/java/geoinfo/map/myMap/ExWMSLayer.java +++ /dev/null @@ -1,152 +0,0 @@ -package geoinfo.map.myMap; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.net.MalformedURLException; -import java.net.URL; -import javax.imageio.ImageIO; -import org.geotools.data.ows.HTTPResponse; -import org.geotools.data.ows.SimpleHttpClient; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.map.DirectLayer; -import org.geotools.map.MapContent; -import org.geotools.map.MapViewport; -import org.geotools.referencing.CRS; -import org.geotools.styling.StyledLayerDescriptor; - -public class ExWMSLayer extends DirectLayer -{ - final String WMS_LAYERS; - ReferencedEnvelope WMS_BBOX; - int WMS_WIDTH; - int WMS_HEIGHT; - final String WMS_FORMAT; - final String WMS_SERVICE; - final String WMS_VERSION; - final String WMS_REQUEST; - final boolean WMS_TRANSPARENT; - final Color WMS_BGCOLOR; - final String WMS_STYLES; - final StyledLayerDescriptor WMS_SLD; - private final URL layerURL; - private final ReferencedEnvelope layerBounds; - - public ExWMSLayer(LinkLayer layer, AVList params) - throws Exception - { - if ((layer == null) || (params == null)) { - throw new IllegalArgumentException("WMS request parameter is null."); - } - - this.layerBounds = layer.getBBox(); - this.layerURL = layer.getServiceURL(); - this.WMS_LAYERS = layer.getServiceLayerNames(); - - this.WMS_BBOX = ((ReferencedEnvelope)params.getValue("request.wms.bbox")); - - if (!CRS.equalsIgnoreMetadata(this.layerBounds.getCoordinateReferenceSystem(), - this.WMS_BBOX.getCoordinateReferenceSystem())) { - this.WMS_BBOX = this.WMS_BBOX.transform(this.layerBounds.getCoordinateReferenceSystem(), true); - } - this.WMS_WIDTH = params.getIntegerValue("request.wms.width").intValue(); - this.WMS_HEIGHT = params.getIntegerValue("request.wms.height").intValue(); - - this.WMS_SERVICE = params.getStringValue("request.wms.service", "WMS"); - this.WMS_FORMAT = params.getStringValue("request.wms.format", "image/jpeg"); - this.WMS_VERSION = params.getStringValue("request.wms.version", "1.3.0"); - this.WMS_REQUEST = params.getStringValue("request.wms.request", "GetMap"); - this.WMS_TRANSPARENT = params.getBooleanValue("request.wms.transparent", Boolean.valueOf(false)).booleanValue(); - this.WMS_BGCOLOR = params.getColorValue("request.wms.bgcolor", Color.WHITE); - - if (ServerUtil.isNullString(params.getStringValue("request.wms.styles"))) - { - String[] layerNames = this.WMS_LAYERS.split(","); - if (layerNames.length == 1) { - this.WMS_STYLES = ""; - } else { - String styles = ""; - for (int i = 1; i < layerNames.length; i++) { - styles = styles.concat(","); - } - this.WMS_STYLES = styles; - } - } - else - { - String styleStr = params.getStringValue("request.wms.styles"); - - String[] layerNames = this.WMS_LAYERS.split(","); - if (layerNames.length == 1) { - this.WMS_STYLES = styleStr; - } else { - String styles = styleStr; - for (int i = 1; i < layerNames.length; i++) { - styles = styles.concat(","); - styles = styles.concat(styleStr); - } - this.WMS_STYLES = styles; - } - - } - - this.WMS_SLD = ((StyledLayerDescriptor)params.getValue("request.wms.sld")); - } - - private URL getRequest() throws MalformedURLException - { - StringBuffer sb = new StringBuffer(); - - sb.append("?"); - sb.append("SERVICE=").append(this.WMS_SERVICE).append("&"); - sb.append("VERSION=").append(this.WMS_VERSION).append("&"); - sb.append("REQUEST=").append(this.WMS_REQUEST).append("&"); - - sb.append("LAYERS=").append(this.WMS_LAYERS).append("&"); - sb.append("STYLES=").append(this.WMS_STYLES).append("&"); - - if (this.WMS_VERSION.compareTo("1.3.0") >= 0) - sb.append("CRS=").append(this.WMS_BBOX.getCoordinateReferenceSystem().getIdentifiers().toArray()[0]).append("&"); - else { - sb.append("SRS=").append(this.WMS_BBOX.getCoordinateReferenceSystem().getIdentifiers().toArray()[0]).append("&"); - } - - sb.append("BBOX=").append(this.WMS_BBOX.getMinX()).append(",").append(this.WMS_BBOX.getMinY()).append(",") - .append(this.WMS_BBOX.getMaxX()).append(",").append(this.WMS_BBOX.getMaxY()).append("&"); - - sb.append("WIDTH=").append(this.WMS_WIDTH).append("&"); - sb.append("HEIGHT=").append(this.WMS_HEIGHT).append("&"); - - sb.append("FORMAT=").append(this.WMS_FORMAT).append("&"); - sb.append("TRANSPARENT=").append(this.WMS_TRANSPARENT).append("&"); - - sb.append("BGCOLOR=").append(ServerUtil.getHexFromColor(this.WMS_BGCOLOR)); - - return new URL(this.layerURL, sb.toString()); - } - - public void draw(Graphics2D graphics, MapContent map, MapViewport viewport) - { - try - { - URL url = getRequest(); - - SimpleHttpClient client = new SimpleHttpClient(); - HTTPResponse reponse = client.get(url); - - BufferedImage image = ImageIO.read(reponse.getResponseStream()); - - graphics.drawImage(image, 0, 0, null); - } - catch (Exception e) - { - LogMngr.getInstance().logError("[RENDER]", - "Fail to render WMSLayer :: " + e); - } - } - - public ReferencedEnvelope getBounds() - { - return this.layerBounds; - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/ExtractRasterStyleVisitor.java b/src/main/java/geoinfo/map/myMap/ExtractRasterStyleVisitor.java deleted file mode 100644 index 31f9caa8..00000000 --- a/src/main/java/geoinfo/map/myMap/ExtractRasterStyleVisitor.java +++ /dev/null @@ -1,56 +0,0 @@ -package geoinfo.map.myMap; - -import java.util.List; -import java.util.Stack; -import org.geotools.styling.RasterSymbolizerImpl; -import org.geotools.styling.Rule; -import org.geotools.styling.StyleFactory; -import org.geotools.styling.Symbolizer; -import org.geotools.styling.visitor.DuplicatingStyleVisitor; -import org.opengis.filter.Filter; -import org.opengis.style.Description; -import org.opengis.style.GraphicLegend; - -public class ExtractRasterStyleVisitor extends DuplicatingStyleVisitor -{ - public void visit(Rule rule) - { - Rule copy = this.sf.createRule(); - - Symbolizer[] symsCopy = rule.getSymbolizers(); - for (int i = 0; i < symsCopy.length; i++) - { - if ((symsCopy[i] instanceof RasterSymbolizerImpl)) { - copy.symbolizers().add(copy(symsCopy[i])); - } - - } - - Filter filterCopy = null; - if (rule.getFilter() != null) { - Filter filter = rule.getFilter(); - filterCopy = copy(filter); - } - copy.setFilter(filterCopy); - - copy.setElseFilter(rule.isElseFilter()); - - copy.setMaxScaleDenominator(rule.getMaxScaleDenominator()); - copy.setMinScaleDenominator(rule.getMinScaleDenominator()); - - GraphicLegend legendCopy = rule.getLegend(); - if (legendCopy != null) { - copy.setLegend(legendCopy); - } - - Description descCopy = rule.getDescription(); - copy.setDescription(copy(descCopy)); - - copy.setName(rule.getName()); - - if ((this.STRICT) && (!copy.equals(rule))) { - throw new IllegalStateException("Was unable to duplicate provided Rule:" + rule); - } - this.pages.push(copy); - } -} \ No newline at end of file diff --git a/src/main/java/geoinfo/map/myMap/FeatureLayer.java b/src/main/java/geoinfo/map/myMap/FeatureLayer.java deleted file mode 100644 index 9a44c7e6..00000000 --- a/src/main/java/geoinfo/map/myMap/FeatureLayer.java +++ /dev/null @@ -1,342 +0,0 @@ -package geoinfo.map.myMap; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.concurrent.ConcurrentHashMap; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.geotools.referencing.CRS; -import org.geotools.styling.NamedLayer; -import org.geotools.styling.NamedStyle; -import org.geotools.styling.Style; -import org.geotools.styling.StyleVisitor; -import org.geotools.styling.StyledLayer; -import org.geotools.styling.StyledLayerDescriptor; -import org.geotools.styling.UserLayer; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.filter.Filter; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -public class FeatureLayer -extends Layer { - private final String sourceName; - private ReferencedEnvelope bbox; - private ConcurrentHashMap styleStore = new ConcurrentHashMap(); - private Style currentStyle; - private ConcurrentHashMap renderStyles = new ConcurrentHashMap(); - - public FeatureLayer(AVList params) throws Exception { - super(params); - StyledLayerDescriptor sld; - String sVal = params.getStringValue("conf.service.ref.source"); - this.sourceName = sVal = sVal.trim().toUpperCase(); - SimpleFeatureSource featureSource = O2DSMngr.getFeatureSource((LayerFactory.LayerType)this.getLayerType(), (String)this.getServerName(), (String)this.getSourceName()); - this.bbox = featureSource.getBounds(); - if (params.getValue("conf.service.sld") == null) { - Style style = StyleMngr.getDefaultUserStyle((LayerFactory.LayerType)this.getLayerType(), (String)this.getServerName(), (String)this.getSourceName(), (String)this.getName()); - this.setCurrentStyle(style); - LogMngr.getInstance().logDebug("[LAYER]", "Set Style Use Default :: [Map:" + ServerContext.getMap().getName() + "/Layer:" + this.getName() + "]"); - } else { - sld = (StyledLayerDescriptor)params.getValue("conf.service.sld"); - this.initServiceStyle(sld, false); - LogMngr.getInstance().logDebug("[LAYER]", "Set Style From DB :: [Map:" + ServerContext.getMap().getName() + "/Layer:" + this.getName() + "]"); - } - LogMngr.getInstance().logDebug("[LAYER]", "Default Style Name Is [" + this.getCurrentStyle().getName() + "] :: [Map:" + ServerContext.getMap().getName() + "/Layer:" + this.getName() + "]"); - sld = StyleMngr.readServiceSLD((String)this.getName()); - if (sld != null) { - this.initServiceStyle(sld, false); - LogMngr.getInstance().logDebug("[LAYER]", "Override Style From SLD FILE :: [Map:" + ServerContext.getMap().getName() + "/Layer:" + this.getName() + "]"); - LogMngr.getInstance().logDebug("[LAYER]", "Default Style Name Is [" + this.getCurrentStyle().getName() + "] :: [Map:" + ServerContext.getMap().getName() + "/Layer:" + this.getName() + "]"); - } - try { - if (this.isUseCache().booleanValue()) { - O2DSMngr.putMemoryFeatureSource((LayerFactory.LayerType)this.getLayerType(), (String)this.getServerName(), (String)this.getSourceName(), (Filter)Filter.INCLUDE); - LogMngr.getInstance().logDebug("[LAYER]", "Now use memery DataStore :: [Map:" + ServerContext.getMap().getName() + "/Layer:" + this.getName() + "]"); - } - } - catch (Exception e) { - LogMngr.getInstance().logDebug("[LAYER]", "Fail to make memery DataStore. Now use common DataStore :: [Map:" + ServerContext.getMap().getName() + "/Layer:" + this.getName() + "]"); - } - } - - public synchronized void reloadServiceStyle() { - StyledLayerDescriptor sld = StyleMngr.readServiceSLD((String)this.getName()); - if (sld != null) { - this.initServiceStyle(sld, false); - LogMngr.getInstance().logDebug("[LAYER]", "Reload Style From SLD FILE :: [Map:" + this.getMapName() + "/Layer:" + this.getName() + "]"); - LogMngr.getInstance().logDebug("[LAYER]", "Default Style Name Is [" + this.getCurrentStyle().getName() + "] :: [Map:" + this.getMapName() + "/Layer:" + this.getName() + "]"); - } - } - - public synchronized void initServiceStyle(StyledLayerDescriptor sld, boolean write) { - Style defaultStyle = null; - ConcurrentHashMap tempStore = new ConcurrentHashMap(); - for (StyledLayer styledLayer : sld.layers()) { - if (!ServerUtil.isNullString((String)styledLayer.getName()) && !styledLayer.getName().equalsIgnoreCase(this.getName())) continue; - Iterator