1、地球模型Earth(Globle):这个球并不会画出来,它的作用就是提供椭球体模型的参数,然后计算出变换矩阵,这样以来,顶点数据通过这样的变换就能以球体的模式加以显示了!
2、图层:
常用的图层类包括TiledImageLayer,MercatorTiledImageLayer,还有RenderableLayer。前两个图层主要用来加载地图服务,WMS,WMTS等,RenderableLayer的作用主要是绘制图形,物体!
所以,我们的任务分为两大部分:加载地图服务和绘制图形要素!
一、加载地图服务
加载服务的关键在于生成正确的url,然后发出相应的请求,因为是切片服务,需要设置层级(makeLevels),然后生成url(URLBuilder),解决问题的重点在于查看实际发出的请求,对于WMS服务,会先发出getCapabilities的请求,然后再发出getMap的请求。
二、绘制图形要素
关键部分为layer,render,symbol。
render中包含了要绘制的基本要素,点(Point),线(Polyline),面(Polygon)等!
测试用例
import java.util.Arrays;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.layers.RenderableLayer;
import gov.nasa.worldwind.render.BasicShapeAttributes;
import gov.nasa.worldwind.render.Material;
import gov.nasa.worldwind.render.Polygon;
import gov.nasa.worldwind.render.ShapeAttributes;
import gov.nasa.worldwind.util.BasicDragger;
import gov.nasa.worldwindx.examples.ApplicationTemplate;
public class MyPolygon extends ApplicationTemplate
{
protected static class AppFrame extends ApplicationTemplate.AppFrame
{
protected static final String SURFACE_POLYGON_IMAGE_PATH = "gov/nasa/worldwindx/examples/images/georss.png";
public AppFrame()
{
// Add a basic dragger to the World Window's select listeners to enable shape dragging.
this.getWwd().addSelectListener(new BasicDragger((this.getWwd())));
// Create a layer of shapes to drag.
this.makeShapes();
}
protected void makeShapes()
{
RenderableLayer layer = new RenderableLayer();
layer.setName("Polygon");
// polygon over china.
ShapeAttributes attrs = new BasicShapeAttributes();
attrs.setOutlineMaterial(Material.RED);
attrs.setInteriorOpacity(0.5);
attrs.setOutlineOpacity(0.8);
attrs.setOutlineWidth(3);
attrs.setImageSource(SURFACE_POLYGON_IMAGE_PATH);
attrs.setImageScale(0.5);
attrs.setInteriorMaterial(Material.YELLOW);
double originLat = 38;
double originLon = 120;
Iterable<Position> positions = Arrays.asList(
Position.fromDegrees(originLat + 5.0, originLon + 2.5, 100),
Position.fromDegrees(originLat + 5.0, originLon - 2.5,100),
Position.fromDegrees(originLat + 2.5, originLon - 5.0,100),
Position.fromDegrees(originLat - 2.5, originLon - 5.0,100),
Position.fromDegrees(originLat - 5.0, originLon - 2.5,100),
Position.fromDegrees(originLat - 5.0, originLon + 2.5,100),
Position.fromDegrees(originLat - 2.5, originLon + 5.0,100),
Position.fromDegrees(originLat + 2.5, originLon + 5.0,100),
Position.fromDegrees(originLat + 5.0, originLon + 2.5,100)
);
Polygon polygon = new Polygon(positions);
polygon.setAttributes(attrs);
layer.addRenderable(polygon);
insertBeforeCompass(this.getWwd(), layer);
}
}
public static void main(String[] args)
{
ApplicationTemplate.start("World Wind Dragging Shapes", AppFrame.class);
}
}