リビジョン 07327852
| learn/java/javafx/HelloMap/src/hellomap/MapModel.java | ||
|---|---|---|
|
PolylineShape shape = (PolylineShape) reader.next();
|
||
|
int numRead = 0;
|
||
|
while (shape != null) {
|
||
|
MapPolyline mapPolyline = new MapPolyline(projection);
|
||
|
mapPolyline.setGcsPolyline(shape);
|
||
|
shapes.add(mapPolyline);
|
||
|
logger.log(Level.FINER, "shape#{0} class {1} numOfParts {2}", new Object[]{numRead, shape.getClass().getName(), shape.getNumberOfParts()});
|
||
|
for (int i = 0; i < shape.getNumberOfParts(); i++) {
|
||
|
MapPolyline mapPolyline = new MapPolyline(projection);
|
||
|
mapPolyline.setGcsPolyline(shape, i);
|
||
|
shapes.add(mapPolyline);
|
||
|
}
|
||
|
shape = (PolylineShape) reader.next();
|
||
|
numRead++;
|
||
|
}
|
||
|
logger.log(Level.INFO, "Read {0} shapes from a shapefile '{1}'", new Object[]{numRead, shapeFile});
|
||
|
logger.log(Level.INFO, "Read {0} shapes from a shapefile {1} of shape type {2}",
|
||
|
new Object[]{numRead, shapeFile.getName(), header.getShapeType()});
|
||
|
} catch (IOException ex) {
|
||
|
throw new UncheckedIOException(ex);
|
||
|
}
|
||
| learn/java/javafx/HelloMap/src/hellomap/MapPolyline.java | ||
|---|---|---|
|
public class MapPolyline {
|
||
|
|
||
|
private PolylineShape gcsShape;
|
||
|
private int partsIndex;
|
||
|
private double[] xPoints;
|
||
|
private double[] yPoints;
|
||
|
private Function<PointData, Point2D> projection;
|
||
| ... | ... | |
|
* GCS(地理座標系)で定義されたポリラインを受け取りPCS(投影座標系)のポリラインを保持する。
|
||
|
*
|
||
|
* @param gcsShape シェープファイルのポリライン
|
||
|
* @param part マルチパートの何番目か
|
||
|
*/
|
||
|
public void setGcsPolyline(PolylineShape gcsShape) {
|
||
|
public void setGcsPolyline(PolylineShape gcsShape, int part) {
|
||
|
this.gcsShape = gcsShape;
|
||
|
xPoints = new double[gcsShape.getNumberOfPoints()];
|
||
|
yPoints = new double[gcsShape.getNumberOfPoints()];
|
||
|
partsIndex = part;
|
||
|
int numPoints = gcsShape.getPointsOfPart(part).length;
|
||
|
xPoints = new double[numPoints];
|
||
|
yPoints = new double[numPoints];
|
||
|
project();
|
||
|
}
|
||
|
|
||
| ... | ... | |
|
* 保持するGCSのポリラインから、保持する投影変換を行う。
|
||
|
*/
|
||
|
public void project() {
|
||
|
PointData[] gcsPoints = gcsShape.getPoints();
|
||
|
PointData[] gcsPoints = gcsShape.getPointsOfPart(partsIndex);
|
||
|
int numPoints = gcsPoints.length;
|
||
|
for (int i = 0; i < numPoints; i++) {
|
||
|
Point2D pcsPoint = project(gcsPoints[i]);
|
||
マルチパートのPolylineデータに対応