World Wind Java uses the Iconlayer layer class to represent points and multipoint data, using Renderablelayer layers to represent line and polygon data, and a layer can only correspond to a set of shape files. World Wind Java first uses the Shapefileloader class to complete the read and load of the shape file, and then creates the Renderablelayer through the Createlayerfromsource method. Finally, the created layer is added to the layers. The source code is as follows:
/** * Method Name: Addshapedata; * Method Description: Add local shape file; * Parameter: @param filePath: File path * parameter: @param filename: filename * parameter: @param Layertitle: Layer Name * parameter: @param maxactivealtitude: Layer Visible Highest Viewpoint * parameter: @param minactivealtitude: Layer visible Lowest Viewpoint * Parameter: @return * return type: boolean; * Creator: James; * Creation time: 2014-11-25 pm 5:19:48; * @throws */public boolean addshapedata (String FilePath, String Filena Me,string Layertitle, double maxactivealtitude,double minactivealtitude) {Boolean result = False;try{shapefileloader Pshapefileloader = new Shapefileloader ();p Shapelayer = Pshapefileloader.createlayerfromsource (filePath+ fileName +). SHP ");p Shapelayer.setname (layertitle);//Set layer name Pshapelayer.setmaxactivealtitude (maxactivealtitude); Pshapelayer.setminactivealtitude (Minactivealtitude); Worldwindowglcanvas.getmodel (). GetLayers (). Add (PShapeLayer );//Add Layer tree node Pvectornode.add (new Defaultmutabletreenode (layertitle));p Layertree.updateui (); result = true;} catch (Exception e) {//Todo:handle exceptionSystem.out.println (E.getmessage ());} ReturnResult;}
As shown in the following:
Liushuo_whu posted on 2014-11-25 18:42:13 original link
Go World Wind Java Development Five-read local shp files