001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
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 net.refractions.udig.catalog;
018:
019: import java.net.URI;
020:
021: import org.eclipse.jface.resource.ImageDescriptor;
022: import org.geotools.geometry.jts.ReferencedEnvelope;
023: import org.opengis.referencing.crs.CoordinateReferenceSystem;
024:
025: import com.vividsolutions.jts.geom.Envelope;
026:
027: /**
028: * Represents a bean style metadata accessor for metadata about a geoResource.
029: * <p>
030: * The methods within this class must be non-blocking. This class, and sub-classes represent cached
031: * versions of the metadata about a particular service.
032: * </p>
033: * <p>
034: * Much of this interface is based on Dublin Core and the RDF application profile.
035: * </p>
036: * <p>
037: * Any changes to this content will be communicate by an event by the assocaited GeoResource.
038: * </p>
039: *
040: * @author David Zwiers, Refractions Research
041: * @since 0.6
042: */
043: public class IGeoResourceInfo {
044:
045: protected String title, description, name;
046: protected String[] keywords;
047: protected URI schema;
048: protected ImageDescriptor icon;
049: protected ReferencedEnvelope bounds;
050:
051: protected IGeoResourceInfo() {
052: // for over-riding
053: }
054:
055: public IGeoResourceInfo(String title, String name,
056: String description, URI schema, Envelope bounds,
057: CoordinateReferenceSystem crs, String[] keywords,
058: ImageDescriptor icon) {
059: this .title = title;
060: this .description = description;
061: this .name = name;
062: int i = 0;
063: if (keywords != null)
064: i = keywords.length;
065: String[] k = new String[i];
066: if (keywords != null)
067: System.arraycopy(keywords, 0, k, 0, k.length);
068: this .keywords = k;
069: this .schema = schema;
070: this .icon = icon;
071: this .bounds = new ReferencedEnvelope(bounds, crs);
072: }
073:
074: /**
075: * Returns the resource's title
076: *
077: * @return Readble title (in current local)
078: */
079: public String getTitle() {
080: return title;
081: }
082:
083: /**
084: * Returns the keywords assocaited with this resource
085: * <p>
086: * Known Mappings:
087: * <ul>
088: * <li> Maps to Dublin Core's Subject element
089: * </ul>
090: * </p>
091: *
092: * @return Keywords for use with search, or <code>null</code> unavailable.
093: */
094: public String[] getKeywords() { // aka Subject
095: int i = 0;
096: if (keywords != null)
097: i = keywords.length;
098: String[] k = new String[i];
099: if (keywords != null)
100: System.arraycopy(keywords, 0, k, 0, k.length);
101: return k;
102: }
103:
104: /**
105: * Returns the resource's description.
106: * <p>
107: * Known Mappings:
108: * <ul>
109: * <li>WFS GetCapabilities description
110: * <li>WMS GetCapabilities description
111: * </ul>
112: * </p>
113: *
114: * @return description of resource, or <code>null</code> if unavailable
115: */
116: public String getDescription() {
117: return description;
118: }
119:
120: /**
121: * Returns the xml schema namespace for this resource type.
122: * <p>
123: * Known Mappings:
124: * <ul>
125: * <li>Dublin Code Format element
126: * </ul>
127: * </p>
128: *
129: * @return namespace, used with getName() to identify resource
130: */
131: public URI getSchema() { // aka namespace
132: return schema;
133: }
134:
135: /**
136: * Returns the name of the data ... such as the typeName or LayerName.
137: * <p>
138: * Known Mappings:
139: * <ul>
140: * <li>WFS typeName
141: * <li>Database table name
142: * <li>WMS layer name
143: * </ul>
144: * </p>
145: *
146: * @return name of the data, used with getSchema() to identify resource
147: */
148: public String getName() { // aka layer/type name
149: return name;
150: }
151:
152: /**
153: * Base symbology (with out decorators) representing this resource.
154: * <p>
155: * The ImageDescriptor returned should conform the the Eclipse User Interface Guidelines (16x16
156: * image with a 16x15 glyph centered).
157: * </p>
158: * <p>
159: * This plug-in provides default based on resource type:
160: *
161: * <pre><code>
162: * <b>return</b> ISharedImages.getImagesDescriptor( IGeoResoruce );
163: * </code></pre>
164: *
165: * <ul>
166: * <p>
167: * Any LabelProvider should use the default image, a label decorator should be used to pick up
168: * these images in a separate thread. This allows resources like WMS to make blocking request of
169: * an external service.
170: * </p>
171: *
172: * @return ImageDescriptor symbolizing this resource
173: */
174: public ImageDescriptor getIcon() {
175: return icon;
176: }
177:
178: /**
179: * Returns the BBox of the resource if one exists, The null envelope otherwise.
180: * <p>
181: * The bounds are returned in (ie should be reprojected to) Lat Long:
182: * <ul>
183: * <li>DefaultGeographicCRS.WGS84
184: * <li>EPSG:4369 (LatLong NAD83)
185: * <li>ESPG 4326 (another LatLong)
186: * </ul>
187: * </p>
188: * <p>
189: * Known Mappings:
190: * <ul>
191: * <li>1st part of the Dublin Core Coverage
192: * </ul>
193: * </p>
194: * <p>
195: * </p>
196: *
197: * @return Lat Long bounding box of the resource
198: */
199: public ReferencedEnvelope getBounds() { // part of Coverage
200: return bounds;
201: }
202:
203: /**
204: * Returns the CRS of the resource if one exists, null otherwise.
205: * <p>
206: * Known Mappings:
207: * <ul>
208: * <li>2nd part of the Dublin Core Coverage
209: * </ul>
210: * </p>
211: *
212: * @return CRS of the resource, or <code>null</code> if unknown.
213: */
214: public CoordinateReferenceSystem getCRS() { // part of Coverage
215: return getBounds().getCoordinateReferenceSystem();
216: }
217: }
|