![]() |
|
|||||||
| Development Help Help for building applications or diagnosing problems with WWJ |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Mar 2008
Posts: 9
![]() |
Hi,
I posted yesterday about displaying polylines, and I have resolved those problems and I can easily get polylines to display. Thank you all for helping. However, now I have another problem, that is the polylines do not always seem to be continuous between the points in the polyline, rather there are gaps in the polylines. I know I saw a post on this topic before, and I tried those solutions (which worked for one of my lines but not all). I attached a clip of what I have. Anyway, if you look at the line to the far left you will see a gap, and if you look at the line on the far right you will see a gap. Notice that the line in the bottom is fine. There is also a sphere in the middle (something else). Can anyone help? Here is the code: ArrayList<Position> latLongs = new ArrayList<Position>(); Coordinate[] coords=geo.getCoordinates(); for(int i=0; i<coords.length;i++){ Coordinate c = coords[i]; latLongs.add(Position.fromDegrees(c.y, c.x, 0)); } Polyline line = new Polyline(latLongs); line.setFollowTerrain(true); line.setAntiAliasHint(Polyline.ANTIALIAS _NICEST); line.setColor(Color.BLUE); double size=1; if(nameR.contains("River")) size=2; line.setLineWidth(size); line.setPathType(Polyline.LINEAR); |
|
|
|
|
|
#2 |
|
Super Moderator
Join Date: Nov 2006
Location: Mojave & Oxnard California
Posts: 2,623
![]() |
You have done a very good job including WW in your larger app.
One thing you could try is moving line.setFollowTerrain(true); after line.setPathType(Polyline.LINEAR); If you put you code in a code block for your posts it would be easier to follow. It is good you got the polylines to display. From your previous thread you have changed the code considerably to match the way it is done in WWJ. There are a few questions on the way you have done this you could answer. 1. Did you create a layer for your polylines? You previously had RenderableLayer rl = new RenderableLayer(); It would be nice if it was that easy. Did you have a problem with "wwd"? 2. Do you have a separate block for each polyline? For more than one polyline I have used line1, line2, line3, etc.. |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2008
Posts: 9
![]() |
Hi,
Thanks for replying so quickly, this has been a very useful board for me. To answer the questions, I do have the layer created. I just did not list that code as it works fine and I figured there is no need to list it. That said, if it would make it easier I will include all the polyline related code, so one can follow how I made the lines display. I will put this below. I also tried moving the setFollowTerrain option after the setPathType and setAntiAliasHint and that did not solve the problem. Although there are three rivers shown, there are many small polylines per river. So, I am wondering if this has anything to do with it. There several geometries being used here for each long polyline, so basically what I was doing is attaching polylines together to form one large line representing a river. Would it make more sense to save the points from all the geometries and make it only one polyline per river? I tried that yesterday, but I had some problems as this created an odd appearing image with points in the polyline attaching to points along the polyline that should not have been connected to those given points (i got a weird triangular looking object forming with the end points connecting). Here is the code, maybe in more complete form: //load the file here if(sd.getHydrologicalFile().contains(".s hp")){ L List<Map>hydroData=ShapeFileLoader.Shape FileLoader(new File( FeralContextBuilder.PathToData+sd.getHyd rologicalFile())); Iterator<Map> ih = hydroData.iterator(); Map<String,List<Position>> riverData = new HashMap<String,List<Position>>(); while(ih.hasNext()){ Map<String,Object>data = ih.next(); Geometry geo = (Geometry)data.get("the_geom"); String nameR = (String)data.get("GNIS_Name"); if(!dischargeData.containsKey(nameR)) continue; ArrayList<Position> latLongs = new ArrayList<Position>() Coordinate[] coords=geo.getCoordinates(); for(int i=0; i<coords.length;i++){ Coordinate c = coords[i]; latLongs.add(Position.fromDegrees(c.y, c.x, 0)); } Polyline line = new Polyline(latLongs); //create polyline line.setAntiAliasHint(Polyline.ANTIALIAS _NICEST); line.setColor(Color.BLUE); ///set color double size=1; //set size if(nameR.contains("River")) size=2; line.setLineWidth(size); line.setPathType(Polyline.LINEAR); line.setFollowTerrain(true); RenderableLayer rl = new RenderableLayer(); //layer rl.addRenderable(line); canvas.getModel().getLayers().add(rl); //add layer canvas.redraw(); //redraw WW } } |
|
|
|
|
|
#4 | |
|
Super Moderator
Join Date: Nov 2006
Location: Mojave & Oxnard California
Posts: 2,623
![]() |
Quote:
line.setPathType(Polyline.LINEAR); For "LINEAR" it will go from point to point. If there is terrain that is higher between these points the line will be broken, this may be the problem. There was a thread with posts about "offset" for a polyline to set the line just above the terrain, I don't remember where that thread was. Maybe if you do a search in this forum for "polyline offset" it can be found. Most of what I have done with polylines has been with GPS data where the altitude error from the signal can vary, on or near the terrain I have added 30M but still near buildings, hills, etc. it still breaks the line as the altitude from the GPS with the weaker or reflected signal can be below the terrain. 2. You can add points to the polyline so saving all the points to one file is not necessary. Look at the GridLines or whatever that example is, it shows an interesting way to draw many polylines. 3. With just one polyline the last point from the first set of data will connect to the first point of your second line. That is probably the reason for "weird triangular looking object forming with the end points connecting". For GPS data I have the lat,lon,alt, id, etc., the id determines the "line" (path) that the point will be a part of. Click the "quote" on this or any other post that has the code in a code block to see how you can put yours in a code block, otherwise the leading spaces will be clipped. It is similar to this [cod-] put code here [/cod-] note that the e must replace the -, this was just for the example. Code:
if(id.equals("N11813")){
points3.add(Position.fromDegrees(loc[0], loc[1], loc[2]));
this.path3.setPositions(this.points3);
this.path3.setFollowTerrain(false);
this.path3.setPathType(Polyline.LINEAR);
this.path3.setColor(Color.RED);
this.path3.setLineWidth(6);
The example mentioned above in 0.3.0 is: GlobalGridAboveSurface.java from the name "AboveSurface" it may have the code you need to offset your polylines above the surface. In 0.5.0 it may be MGRSGraticule.java I have made so many changes to get things to run the way I need trying to run this just gives the error: Code:
Exception in thread "main" java.lang.SecurityException: class "gov.nasa.worldwind.examples.ApplicationTemplate$AppFrame"'s signer information does not match signer information of other classes in the same package Last edited by nlneilson; 06-07-2008 at 05:02 AM. |
|
|
|
|
|
|
#5 |
|
Super Moderator
Join Date: Nov 2006
Location: Mojave & Oxnard California
Posts: 2,623
![]() |
Look at:
render.Polyline.java line 43 "private double offset = 0;" line 167 "public void setOffset(double offset)" You could try this, it works for me. line.setOffset(20); |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Polylines are too slow... | adrianboimvaser | Development Help | 9 | 12-18-2007 02:54 PM |
| CountryBoundariesLayer broken? | Joao Fonseca | Development Help | 1 | 11-04-2007 07:40 PM |
| The Case of the Invisible(?) Polylines | Trudy | Development Help | 3 | 10-18-2007 06:42 PM |
| Antialiased polylines | maemigh | Development Help | 4 | 08-22-2007 02:25 PM |
| USGS Urban Area Otho it's broken | defconx | Bug Reports | 2 | 04-27-2005 12:02 AM |