Revision 49
org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.proj4j/src/main/java/org/gvsig/proj/proj4j/DefaultCoordinateReferenceSystem.java | ||
---|---|---|
100 | 100 |
return getReference() + "(" + getDefinition() + ")"; |
101 | 101 |
} |
102 | 102 |
|
103 |
public CoordinateReferenceSystem createGeographic() { |
|
104 |
org.osgeo.proj4j.CoordinateReferenceSystem geographic = |
|
105 |
crs.createGeographic(); |
|
106 |
return new DefaultCoordinateReferenceSystem(getAuthorityName(), "GEO-" |
|
107 |
+ geographic.getDatum().getCode(), geographic); |
|
108 |
} |
|
109 |
|
|
103 | 110 |
// /** |
104 | 111 |
// * Transforms coordinates in lat/lon to this projection. |
105 | 112 |
// * |
org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/cts/DefaultIProjection.java | ||
---|---|---|
35 | 35 |
import org.gvsig.proj.CoordinateReferenceSystem; |
36 | 36 |
import org.gvsig.proj.CoordinateReferenceSystemLocator; |
37 | 37 |
import org.gvsig.proj.CoordinateReferenceSystemNotFoundException; |
38 |
import org.gvsig.proj.CoordinateTransformation; |
|
38 | 39 |
|
39 | 40 |
/** |
40 | 41 |
* Java Map CoordinateReferenceSystem Library based implementation. It works |
... | ... | |
73 | 74 |
} |
74 | 75 |
|
75 | 76 |
public IDatum getDatum() { |
76 |
throw new UnsupportedOperationException("Not implemented"); |
|
77 |
return new IDatum() { |
|
78 |
|
|
79 |
public double getEIFlattening() { |
|
80 |
return 297.0d; |
|
81 |
} |
|
82 |
|
|
83 |
public double getESemiMajorAxis() { |
|
84 |
return 6378388.0d; |
|
85 |
} |
|
86 |
|
|
87 |
}; |
|
77 | 88 |
} |
78 | 89 |
|
79 | 90 |
public Point2D createPoint(double x, double y) { |
... | ... | |
105 | 116 |
} |
106 | 117 |
|
107 | 118 |
public Point2D toGeo(Point2D pt) { |
108 |
// DefaultProjection geographic = projection.
|
|
119 |
CoordinateReferenceSystem geographic = crs.createGeographic();
|
|
109 | 120 |
|
110 |
throw new UnsupportedOperationException("Not implemented"); |
|
111 |
// double[] coords = new double[] { pt.getX(), pt.getY() }; |
|
112 |
// getProjection().inverseTransform(coords); |
|
113 |
// return new Point2D.Double(coords[0], coords[1]); |
|
121 |
CoordinateTransformation transfToGeo = |
|
122 |
crs.getTransformation(geographic); |
|
123 |
|
|
124 |
// throw new UnsupportedOperationException("Not implemented"); |
|
125 |
double[] coords = new double[] { pt.getX(), pt.getY() }; |
|
126 |
transfToGeo.convert(coords); |
|
127 |
return new Point2D.Double(coords[0], coords[1]); |
|
114 | 128 |
} |
115 | 129 |
|
116 | 130 |
public Point2D fromGeo(Point2D gPt, Point2D mPt) { |
117 |
throw new UnsupportedOperationException("Not implemented"); |
|
118 |
// double[] coords = new double[] { gPt.getX(), gPt.getY() }; |
|
119 |
// getProjection().inverseTransform(coords); |
|
120 |
// mPt.setLocation(coords[0], coords[1]); |
|
121 |
// return mPt; |
|
131 |
CoordinateReferenceSystem geographic = crs.createGeographic(); |
|
132 |
|
|
133 |
CoordinateTransformation transfFromGeo = |
|
134 |
geographic.getTransformation(crs); |
|
135 |
|
|
136 |
double[] coords = new double[] { gPt.getX(), gPt.getY() }; |
|
137 |
transfFromGeo.convert(coords); |
|
138 |
mPt.setLocation(coords[0], coords[1]); |
|
139 |
return mPt; |
|
122 | 140 |
} |
123 | 141 |
|
124 | 142 |
public double getScale(double minX, double maxX, double width, double dpi) { |
org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/cts/DefaultICoordTrans.java | ||
---|---|---|
73 | 73 |
public Point2D convert(Point2D ptOrig, Point2D ptDest) { |
74 | 74 |
double[] coords = new double[] { ptOrig.getX(), ptOrig.getY() }; |
75 | 75 |
transformation.convert(coords); |
76 |
if (ptDest == null) { |
|
77 |
ptDest = new Point2D.Double(); |
|
78 |
} |
|
76 | 79 |
ptDest.setLocation(coords[0], coords[1]); |
77 | 80 |
return ptDest; |
78 | 81 |
} |
org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/CoordinateReferenceSystem.java | ||
---|---|---|
93 | 93 |
*/ |
94 | 94 |
boolean isProjected(); |
95 | 95 |
|
96 |
/** |
|
97 |
* Creates a geographic (unprojected) {@link CoordinateReferenceSystem} |
|
98 |
* based on the {@link Datum} of this CRS. |
|
99 |
* This is useful for defining {@link CoordinateTransform}s |
|
100 |
* to and from geographic coordinate systems, |
|
101 |
* where no datum transformation is required. |
|
102 |
* The {@link Units} of the geographic CRS are set to {@link Units#DEGREES}. |
|
103 |
* |
|
104 |
* @return a geographic CoordinateReferenceSystem based on the datum of this |
|
105 |
* CRS |
|
106 |
*/ |
|
107 |
public CoordinateReferenceSystem createGeographic(); |
|
108 |
|
|
96 | 109 |
} |
Also available in: Unified diff