001: /*
002: * Geotools2 - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002, Geotools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package org.geotools.arcsde.gce;
018:
019: import java.awt.Dimension;
020:
021: import org.geotools.geometry.jts.ReferencedEnvelope;
022: import org.opengis.referencing.crs.CoordinateReferenceSystem;
023:
024: import com.esri.sde.sdk.client.SDEPoint;
025: import com.esri.sde.sdk.client.SeExtent;
026:
027: /**
028: * Represents one level in an ArcSDE pyramid. Holds information about a given pyramid level, like
029: * resolution, x/y offsets, number of tiles high/wide, total pixel size and total envelope covered by
030: * this level.
031: *
032: * @author sfarber
033: *
034: */
035: public class ArcSDEPyramidLevel {
036: private int pyramidLevel, xOffset, yOffset, xTiles, yTiles;
037:
038: private double xRes, yRes;
039:
040: private ReferencedEnvelope envelope;
041:
042: public Dimension size;
043:
044: public ArcSDEPyramidLevel(int level, SeExtent extent,
045: CoordinateReferenceSystem crs, SDEPoint offset, int xTiles,
046: int yTiles, Dimension size) {
047: this .pyramidLevel = level;
048: this .xRes = (extent.getMaxX() - extent.getMinX()) / size.width;
049: this .yRes = (extent.getMaxY() - extent.getMinY()) / size.height;
050: this .envelope = new ReferencedEnvelope(extent.getMinX(), extent
051: .getMaxX(), extent.getMinY(), extent.getMaxY(), crs);
052: if (offset != null) {
053: this .xOffset = (int) offset.getX();
054: this .yOffset = (int) offset.getY();
055: }
056: this .xTiles = xTiles;
057: this .yTiles = yTiles;
058: this .size = size;
059: }
060:
061: /**
062: * @return Which level in the pyramid this object represents
063: */
064: public int getLevel() {
065: return pyramidLevel;
066: }
067:
068: /**
069: * @return The X and Y resolution in units/pixel for pixels at this level
070: */
071: public double getXRes() {
072: return xRes;
073: }
074:
075: /**
076: * @return The X and Y resolution in units/pixel for pixels at this level
077: */
078: public double getYRes() {
079: return yRes;
080: }
081:
082: /**
083: * @return DOCUMENT ME!!!
084: */
085: public int getXOffset() {
086: return xOffset;
087: }
088:
089: /**
090: * @return DOCUMENT ME!!!
091: */
092: public int getYOffset() {
093: return yOffset;
094: }
095:
096: /**
097: * @return The total number of tiles covering the width of this level
098: */
099: public int getNumTilesWide() {
100: return xTiles;
101: }
102:
103: /**
104: * @return The total number of tiles covering the height of this level
105: */
106: public int getNumTilesHigh() {
107: return yTiles;
108: }
109:
110: /**
111: * @return The geographical area covered by this level of the pyramid
112: */
113: public ReferencedEnvelope getEnvelope() {
114: return new ReferencedEnvelope(this .envelope);
115: }
116:
117: public String toString() {
118: return "[level: " + pyramidLevel + " xRes: " + xRes
119: + " yRes: " + yRes + " xOffset: " + xOffset
120: + " yOffset: " + yOffset + " extent: " + envelope
121: + " tilesWide: " + xTiles + " tilesHigh: " + yTiles
122: + "]";
123: }
124: }
|