グリッド レイヤ オーバーレイの例
以下のコードは、GridLayer オーバーレイを作成し、それを名前付きマップに対するリクエストの中で使用する方法を示しています。
CustomInflectionCollection を使用して、各屈折点に対して色を指定していることに注意してください。
または、最初の色と最後の色、および屈折点の数を指定して、ComputedInflectionCollection を使用することができます。指定された数の屈折点で均等に色が変化します。
GridLayer 要素の説明については、「GridLayer の要素」を参照してください。
public class RenderNamedMapWithGridLayerOverlay {
public static void main(String[] args) {
try {
MappingServiceInterface mapping = Preference.getServiceinterface();
Point mapCenter = BuildGeometry.buildPoint("mapinfo:coordsys 12, 62, 7, 0.0", 0, 0, null);
MapView mapView = MappingView.getZoomAndCenterMapView(mapCenter,MappingUtility.buildDistance(19000, DistanceUnit.KILOMETER));
NamedTable namedTable = new NamedTable();
namedTable.setName("/Samples/NamedTables/WorldcapTable");
Distance cellWidth = MappingUtility.buildDistance(50, DistanceUnit.MILE);
IDWInterpolator interpolator = new IDWInterpolator();
interpolator.setAggregationMethod(AggregationMethod.AVERAGE);
interpolator.setExponent(2);
interpolator.setMaxPoints(25);
interpolator.setSearchRadius(100);
CustomInflectionCollection inflectionCollection = new CustomInflectionCollection();
inflectionCollection.setInflectionMethod(InflectionMethod.EQUAL_COUNT);
inflectionCollection.setRoundBy(0.1);
InflectionColorBinList inBinList = new InflectionColorBinList();
InflectionColorBin red = new InflectionColorBin();
red.setColor("RED");
inBinList.getInflectionColorBin().add(red);
InflectionColorBin yellow = new InflectionColorBin();
yellow.setColor("YELLOW");
inBinList.getInflectionColorBin().add(yellow);
InflectionColorBin green = new InflectionColorBin();
green.setColor("GREEN");
inBinList.getInflectionColorBin().add(green);
InflectionColorBin rgb = new InflectionColorBin();
rgb.setColor("rgb(0,255,255)");
inBinList.getInflectionColorBin().add(rgb);
InflectionColorBin blue = new InflectionColorBin();
blue.setColor("BLUE");
inBinList.getInflectionColorBin().add(blue);
inflectionCollection.setInflectionColorBinList(inBinList);
//Creating GridEnvelope
List<Pos> pointList = new ArrayList<Pos>(2);
pointList.add(BuildGeometry.buildPos(-1.6190368438028984E7, -5501153.098687401, null));
pointList.add(BuildGeometry.buildPos(1.6606614137907444E7, 6743291.671893631, null));
Envelope gridEnvelope = BuildGeometry.buildEnvelope("mapinfo:coordsys 12, 62, 7, 0.0", pointList);
//Creating GridLayer
Layer gridLayer = MappingUtility.buildGridLayer(namedTable, null, cellWidth, "Cap_Pop", "Obj", interpolator, inflectionCollection, gridEnvelope);
RenderNamedMapWithOverlayRequest request = MappingServiceRequestBuilder.createRenderNamedMapOverlayRequest
("RenderNamedMapWithGridLayerOverlay","/Samples/NamedMaps/WorldMap", mapView, gridLayer);
RenderNamedMapWithOverlayResponse response = mapping.renderNamedMapWithOverlay(request);
PrintMappingResponse.printRenderNamedMapWithOverlayResponse(response);
}
catch (ServiceException se) {
PrintMappingResponse.printError(se);
}
catch (Exception e) {
e.printStackTrace();
}
}
}