01: package org.geotools.referencing.example;
02:
03: import java.net.URI;
04: import java.util.ArrayList;
05: import java.util.HashMap;
06: import java.util.Map;
07:
08: import javax.units.NonSI;
09: import javax.units.SI;
10: import javax.units.Unit;
11:
12: import org.geotools.measure.Units;
13: import org.geotools.metadata.iso.citation.Citations;
14: import org.geotools.parameter.DefaultParameterDescriptor;
15: import org.geotools.parameter.DefaultParameterDescriptorGroup;
16: import org.opengis.metadata.Identifier;
17: import org.opengis.parameter.GeneralParameterValue;
18: import org.opengis.parameter.ParameterValue;
19: import org.opengis.util.CodeList;
20:
21: public class ParameterExample {
22:
23: public static void main(String[] args) {
24: final DefaultParameterDescriptor RANGE = new DefaultParameterDescriptor(
25: "Range", 15.0, -30.0, +40.0, null);
26:
27: System.out.println(RANGE.getMinimumValue().compareTo(
28: new Double(2)));
29: System.out.println(RANGE.getMaximumValue().compareTo(
30: new Double(20)));
31:
32: Identifier name = RANGE.getName();
33: System.out.println(name);
34:
35: ParameterValue value = (ParameterValue) RANGE.createValue();
36: value.setValue(2.0); // good
37:
38: value.setValue(20.0); // invalid
39: value.setValue(2); // invalid
40:
41: final DefaultParameterDescriptor STATUS = new DefaultParameterDescriptor(
42: "Status", Status.GOOD);
43: ParameterValue status = (ParameterValue) STATUS.createValue();
44:
45: final DefaultParameterDescriptor LIMIT = new DefaultParameterDescriptor(
46: Citations.GEOTOOLS, "Limit", Double.class, null, null,
47: null, null, SI.METER.divide(SI.SECOND), true);
48:
49: final DefaultParameterDescriptor PREFIX = new DefaultParameterDescriptor(
50: Citations.GEOTOOLS, "Perfix", String.class, null, null,
51: null, null, null, true);
52: final DefaultParameterDescriptor NAMESPACE = new DefaultParameterDescriptor(
53: Citations.GEOTOOLS, "Namespace", URI.class, null, null,
54: null, null, null, true);
55:
56: final DefaultParameterDescriptorGroup REFERENCES = new DefaultParameterDescriptorGroup(
57: Citations.GEOTOOLS, "Referneces",
58: new DefaultParameterDescriptor[] { PREFIX, NAMESPACE });
59:
60: Map metadata = new HashMap();
61: metadata.put("authority", System.getProperties().get(
62: "user.name"));
63: metadata.put("name", "References2");
64: metadata.put("alias", "References II");
65: final DefaultParameterDescriptorGroup REFERENCES2 = new DefaultParameterDescriptorGroup(
66: metadata, 0, Integer.MAX_VALUE,
67: new DefaultParameterDescriptor[] { PREFIX, NAMESPACE });
68:
69: }
70:
71: static class Status extends CodeList {
72: private static final long serialVersionUID = 0L;
73: static ArrayList values = new ArrayList();
74: static Status GOOD = new Status("GOOD");
75: static Status BAD = new Status("BAD");
76: static Status UGLY = new Status("UGLY");
77:
78: private Status(String name) {
79: super (name, values);
80: }
81:
82: public CodeList[] family() {
83: return (Status[]) values.toArray(new Status[values.size()]);
84: }
85: }
86: }
|