Jump to content
Sign in to follow this  
Guest christian

Mapinfo program to generate LWM

Recommended Posts

Guest

Hi there.Just a while ago I have had initial success in generating LWM rivers and lakes from E00 files (arcinfo export files) using a MapBasic little program por MapInfo.I'll post the source when it's done, but before that I need to clean up the code and the procedures.The thing is that when I've tested for a small area of 107 polygons spanning a couple of cells, it has worked beatifully. But FS has crashed when I tried loading all the information for the region I'm trying to recreate, namely Andalusia, in southern Spain.At first I thought it could be because of concave polygons, but then I've read elsewhere in the forum that LWM shouldn't have too much of a problem with that.My question is... Is there any tool that can help me analyze the saneness of the produced bgl, or even the asm input file?Is there any alternative to dividing in halves until I find the problematic polygon? It's not very fun to restart FS all the time. :-(In the positive side, once I get this one running it should be relatively easy to adapt for other purpouses, like VTP shores and roads. Hopefully I

Share this post


Link to post
Share on other sites
Guest christian

No such program exists.It looks like your asm files are wrong, or your include files are wrong. Could you post an example?Cheers, Christian

Share this post


Link to post
Share on other sites
Guest

Well, I know such program exists because I'm the one writing it! :-DAttached is the code as I left it yesterday night, while testing. Poly2Ex are disabled, and there is no code por more than 6 polys per region. In order for this to work you need to have a table with shapes that are dividid into the the LOD13. This is quite trivial with mapinfo, using a grid table and then using the split command against the initial shapes. I say again, this is not finished code, just a sampler in case it helps people spot the problem. :-)Also attached is a zip file containig the asm that correspond to a smallish area. Don't try to appear in the middle of the area or FS will crash right away. I suggest starting in LEZL and slewing towards it. The spikes are so obvious that you'll see where you have to go :-DAny help much appreciated.Regards,Juan.Argh. Can't attach from within links. I'll put it directly on my webserver.http://lazaro.ddts.net/fssdk/agua.ziphttp://lazaro.ddts.net/fssdk/bg4.MB

Share this post


Link to post
Share on other sites
Guest cwright

Juan, for each polygon inside a LOD13 square there is a limit of 62 points. Here's an example: LWMDataAreaDrawPolygons 1,3,1,13,29 LWMPoly2 35,0,0,0,0 LWMPoint 43,188 LWMPoint 44,188 LWMPoint 49,188 etc..... The number after LWMPoly2 is the number of points in the polygon, in this case 35. If the number exceeds 62 then one of two things will occur:1. When trying to load the scenario you will get the Microsoft error display or2. You will get those enormous spikes! The spikes probably occur because the faulty LWM data has overwritten part of the terrain mesh data. Best regards, Chris

Share this post


Link to post
Share on other sites
Guest

Thanks for your reply, Chris, but I don't think that's the problem. If you have a look at the asm file you will see that there are no polys with more than 62 points. When I said that Poly2Ex were disabled I didn't mean that I was using Poly2 to represent those, but rather that I wasn't painting them at all.On the other hand, for reasons I haven't yet discovered sometimes some points of the LOD13 split shapes actually fall outside the area, so I have to clip to the 0-255 range. As a result, sometimes some points are duplicated. Is This a known cause for a crash?Also, some polygons will actually have to be lines, with three or more points in line, as in (8,255),(10,255),(12,255). Is this a known no-no?Cheers,Juan.

Share this post


Link to post
Share on other sites
Guest

Hi there again. I know this is already a monologue, but I may have found the cause of the problem and I wouldn't like to waste anybody's time by looking at it anymore (at least until I can get home to try it :-) )There is a glitch in my code in that when there are 62 points polygons, LWMDataAreaDrawPolygons lists one less polygon than the ones actually defined. I believe this is consistent with the behaviour seen in FS: Everything looks OK until the point in the stream where it gets "out of sync", and the result is polygons defined with trash data.Here's hoping that that's the case. :-DRegards,Juan.

Share this post


Link to post
Share on other sites

Hi Juan.I only looked at your code for about 30 minutes... and I don't consider it any waste of time, as we all learn from the problems we share here. As you've discovered, the point count was thrown off, in this case by the erroneous number of polygons. I sometimes get errors when I have 1 less point than needed, as well. Same results ( spikes and holes ). An interesting program might be one that checks for the number of polys and the number of points within polys.The LWMs are very forgiving as to shape, but if the perimeter's vectorline crosses itself, you'll have errors. Apparently redundant points have no effect, and that's a good discovery. 2 point polys ( lines ) are permitted... I use them with transparent 'flattens' to remesh coastal areas. 1 point is forbidden ( at least as far as I can tell ).A suggestion. The terrain engine draws in bands starting in the north and moving to the south, not only for Cells , but for Areas within cells as well. The area palcement in the datastream is very forgiving, but optimally, you may want to sort the Areas within the Cell, just like the Cells themselves are sorted in their index. I know you understand the Cell sorting, as you have done it perfectly. This Area sorting may affect framerates for complex BGLs. I like your program's results. Streams and small rivers are much improved, and the smaller lakes and ponds are a welcome sight. Please keep in touch so we can see the results, and your program's progress!Dick

Share this post


Link to post
Share on other sites
Guest christian

Hi Toledo'No such program exists' should read 'no tool that checks the sanity of bglc files exists'!I myself have started to write a program like yours a few months ago, a plugin for ArcGIS 8, so it should be quite similar to yours. I only started and then became a bit bored with coding for FS2002, since I've been doing that for over a year now. I'm currently working on the quake2 source code and per pixel lighting and stencil volume shadows which is far more exciting. Also my spare time is very sparse at the moment.I would be very interested in your code, the major problem that puts me off to continue is the coastlines. You have to come up with some algorithm that converts the coastlines into water polygons. That's not really trivial as far as I can see. (unless you draw them yourself, but an automatic process would be great...). Also, my data is very accurate, and I suspect that it's too much for FS2002, so I'd have to downsamle it somehow. Not easy either, because there are so many roads and streams in my data set, it's just not funny...Cheers, Christian

Share this post


Link to post
Share on other sites
Guest

Hi everyone.Yesterday I fixed the obvious bugs in the code and I managed to produce the bgl for the full region (actually it is still missing a bit in the western side, but it's mostly there)The links I posted are updated. The mapbasic program is still quick and dirty, but works. Besides the asm file, I've also posted the output bgl file in http://lazaro.ddts.net/fssdk/agua.bglThere is obviously still things to solve to be happy about it. The main ones are excluding the default river banks and puny streams of the default scenery. I'll be trying the program that I've seen around for that. Then I'll need to create another program to create the new shorelines. There are places where I'm not entirely happy, though. For the most part, the rivers look OK as mesh clinging (-9999) polygons, but the lakes and reservoirs do not. I would need to have those flattened to the correct height, but I don't have the DEM data. I don't suppose there isn't any easy way to do that, is there? Christian, regarding the issue of the reworked shores... I don't have Arcinfo, but I would suppose it has at least as much functionality as MapInfo (I believe it has more). The nice thing about working with these environments is that you can use all their power to process the data. The way I would go about that is first creating a big rectangle region encompassing both land and water. Then you can use the split function to split the region using the shore line as the cutting object. Now you have two objects, one representing water, the other, land. This can now be worked using the same procedures as with rivers and lakes. Split using the LOD13 grid and run the mapbasic program.As I said, if it's of any help to you, you can have a look at my mapbasic program in the link abouve to bg4.MB.Dick, first let me thank you for your tutorials and macros. Your work has been most helpful. Regarding the cleanliness of the generated ASM, I have to say I'm cheap and dirty, and I'm not really counting on going much further than something that works for me. Even though it's not stated yet, I'll license the scripts as GPL so that everybody can feel free to take it from there to suit their needs or to a polished program. Until now FPS don't seem to be an issue with my machine (Mobile PIII 1Ghz, 256Mb, i813), so it's OK with me.Cheers, everyone.Juan.

Share this post


Link to post
Share on other sites
Guest christian

Hi Juan>Christian, regarding the issue of the reworked shores... I >don't have Arcinfo, but I would suppose it has at least as >much functionality as MapInfo (I believe it has more). The >nice thing about working with these environments is that you >can use all their power to process the data. The way I would >go about that is first creating a big rectangle region >encompassing both land and water. Then you can use the split >function to split the region using the shore line as the >cutting object. Now you have two objects, one representing >water, the other, land. This can now be worked using the >same procedures as with rivers and lakes. Split using the >LOD13 grid and run the mapbasic program. This is what I was thinking of doing, but I thought a bit ahead also. It would be nice to use the existing landcover scenery (I have a custom one for NZ) and only cover land areas up. Also islands can be a bit of a problem. And I still have to work out how to resample my data so it's a bit coarser.I'll have a look at your code at some stage...Cheers, Christian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...