Scaled Maps

wm.chatman

Well-Known Member
Licensed User
Longtime User
just a question.

does this need to be placed in a Sub Globals or can I place into FormLoad also?

Dim startedTrackingFlag ' flag that tells that a new tracking session has begun
Dim tracking_in_progress ' flag that tells if tracking is in progress or not

thanks

William
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
these two functions would also be of interest. I think I would be able to add into the Main App. Adding the two Forms would be no Problem. But, I know I would need Help with the code. I been working on this for some time now. What do you think?

some code works some does not yet. My Problem is to fig where to put some.


Best regards.

William
 

Attachments

  • LoadSavePos.JPG
    LoadSavePos.JPG
    20 KB · Views: 267
Last edited:

derez

Expert
Licensed User
Longtime User
William

I was answering Sarah on the question of "how to translate real coordinates to x-y pixels on the map", and by the way added the code for copying from the image of the map to the screen.

The code is not something that you can copy and paste into klaus's application, and sorry, i have no intention to try and do it.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
Post #22 was just a thought, nothing else. I will forget about it.
the other had been only a question. I will stop posting in this Thread.

Sorry I mixt in.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Hi Sarah,

The converting routines are already in the ScaledMaps program:
If you look at the lines 1479-1493.
B4X:
[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Long_X(long)[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Return [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]((long-MapLong10)/ScaleX+[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080].5[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Lat_Y(lat)[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Return [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Int[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]((lat-MapLat10)/ScaleY+[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080].5[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]X_Long(x)[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] MapLong10+(x-ScreenX+ImageX)*ScaleX[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
 
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Y_Lat(y)[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]  Return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] MapLat10+(y-ScreenY+ImageY)*ScaleY[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

For example the routine Sub Long_X(long) converts the physical map long value to the x coordinate of the map's image in pixels.
long - MapLong0 = distance of the long coordinate from the left border of the map in physical units
(long - MapLong10)/ScaleX = distance of the x coordinate from the left border of the map's image in pixels
Int((long-MapLong10)/ScaleX+.5) rounds to an integer value

The routine Sub X_Long(x) converts the screen x coordinate to the physical long coordinate on the map.
x-ScreenX = distance of x from the screen left border, in pixels
x-ScreenX+ImageX = distance of x from the map's image left border, in pixels
(x-ScreenX+ImageX)*ScaleX = distance of long from the map's image left border, in physical units
MapLong10+(x-ScreenX+ImageX)*ScaleX = long in physical units

Screen is the display surface on the form.

MapLong10 = value of the left border of the map image, in physical units
ImageX = value of the left border of the screen, in pixels (the map image is bigger than the screen)
ScreenX = distance between the form's and the screen's left borders, in pixels

You'll find more information in the http://www.b4x.com/forum/tutorials/5191-graphics-tutorial.html in the Vector graphics chapter in the Show scaled image topic.

Best regards.
 

SarahWard

Banned
Hi David

Thank you for the code. Am I correct in thinking what you are doing is repositioning the map itself, rather than the 'trail' line?
 

SarahWard

Banned
Klaus!

You are a hero! You already wrote the code. Thank you!

(I have read the graphics tutorial although I am familiar with most of these methods from using VB.)

Best wishes for the new year

sarah
 

derez

Expert
Licensed User
Longtime User
Sarah

Yes,
3. The map drawn on the form is a moving map, the present position is the center of the form

The application is used for off-road navigation, and the map itself is moved so the actual position is in the center of the form.

The trail you see in the picture is done later by drawing on the map, after translating the lat-long to map coordinates. (it is used for adding roads to "old" maps).

I also use real time trail by "laying eggs" - drawing a small circle every few gps readings, storing the array of coordinates, and re-drawing them every cycle. This of course requires memory and time, so I limit the drawing to those that are within the frame of the screen.
 

Put Claude

Active Member
Licensed User
Longtime User
ScaledMaps from Klaus

Hi Klaus,

YES, a killer source, to learn from!
What is realy missing, is the heading and meters of every line, then it is ideal for navigation purpose on the water ( I integrated this in my code and it is no big deal to do so), and beginners have a direct use for it.

Respect,

Claude Belgium
 

klaus

Expert
Licensed User
Longtime User
Hi Claude,

Thank you for your kind comment.

I'm on the way to add GPS support to the program with memorizing the GPS points, displaying them on a map and saving them in a file.

What exactly do you mean with:
'What is realy missing, is the heading and meters of every line' ?
What would you like to see displayed and where and how ?

When you select a point on a memorized line, the coordinates of the point are displayed, and with the 2 small blue arrows you can step to the next or previous point.

Best regards.
 

wm.chatman

Well-Known Member
Licensed User
Longtime User
Hi

Yes, I know I stated that there will not be another post in this Section. But, I have to Retract my Statement.

I am not the brightest bulb. I hate myself because of this. Had I the wisdom this Killer App would already have the missing functions, that are still needed.
Since we do not have the knowledge, we cant share the source code.
I wish I could share!

Edit: 21 JAN 10 / 2052

Klaus, that sounds GREAT!!!!!!

:sign0060::sign0060::sign0060::sign0060::sign0060::sign0060:

Best regards.

William
 
Last edited:

mjcoon

Well-Known Member
Licensed User
I'm on the way to add GPS support to the program with memorizing the GPS points, displaying them on a map and saving them in a file.

Hi Klaus, I shall be very interested in this development. Will the file be in KML format? I have been writing some code to write KML using XML.dll, both using XmlWriter (for initial file) and XmlDocument (for subsequent edit). I put in some styles so that lines can be drawn in multiple colours (there's an example output at http://www.mjcoon.plus.com/2009-10-nn.kml). You are very welcome to this code if wished. I have not submitted it as a "My creation" because it is rather specific for my purposes!

Regards, Mike.
 

klaus

Expert
Licensed User
Longtime User
Hi Mike,

For the moment, the file format is a simple text format of the ScaledMap program, but I intend to add KML export and import.

I have already done it in another GPS program simply by writing and parsing text files. But your code using the XML libraries does interest me.

Best regards.
 

mjcoon

Well-Known Member
Licensed User
... But your code using the XML libraries does interest me.

OK, I've attached it in case it should be useful in the future. Sorry that the structure shows lots of evidence of its development from a text-output approach to writing the KML too. Please let me know if any explanation/justifications are needed (I'm parsimonious with the comments!)...

HTH, Mike.
 

Attachments

  • GPSU2KML.sbp
    29 KB · Views: 260

mjcoon

Well-Known Member
Licensed User
... But your code using the XML libraries does interest me.

Hi again Klaus, I've discovered that I downloaded a KML.dll last month. But the zip doesn't include a Help so I have no idea what thread it came from or who the author is. I gather it is used in GPS4PPC app but I don't know how...

Mike.
 

penserv

Member
Licensed User
When I try to load the sbp file I get two error messages and when I try to compile to a device, I get two more. I captured the error messages with Snagit for your perusal. I was wondering if you had an updated verion of this program. I'm only interested in drawing lines from GPS coordinates. I'm trying to recreate a program that my programmer is using as a means of extorting exhorbitant sums of money from me. I do electromagnetic surveys and when I am doing a survey, the Recon data collector keeps track of the GPS coordinates while I am collecting data and draws a line showing where I have gone. Also, if I lose lock on the satellites or the EM sensor, it will display a message box and pause the program so that I can correct the situation and resume the survey. With the lines on the display, It is an easy matter to navigate back to the point where the interruptiopn occurred and resume from that point. I've got the GPS portion OK. I'm working on appending the binary EM string onto the GPS and now I'm starting to work on the GPS line of travel and scaling of the map being created. Whenever I get a more or less finished program, I'll post it under Shared Creations, because I'm not too interested in maintaining code for various platforms and devices.
 

Attachments

  • ScaledMapErrors.zip
    25.7 KB · Views: 239

klaus

Expert
Licensed User
Longtime User
You find the last version 3.0 in the first post, with some GPS support not really tested, but it the map part works with B4PPC 6.9.
I am no more developping this program further, but you can use it pick up code if you want.

Best regards.
 

mjcoon

Well-Known Member
Licensed User
When I try to load the sbp file I get two error messages and when I try to compile to a device, I get two more.

The messages look like you haven't provided the necessary additional DLL(s) that are needed, which will be at least ControlsExDesktop.dll and ControlsExDesktop.dll. There must be a tutorial about downloading and using additional (not in free version of Basic4PPC) libraries. The list of libraries shows up under Tools/Components in the IDE.

Not sure, as an ex-programmer myself, that I approve of your using our expertise to enable you to cut out your tame programmer; seems a bit blatant!

HTH, Mike.
 

penserv

Member
Licensed User
I guess that's what is most frustrating. All of the required libraries appear to be there, but still the error messages. Maybe B4P doesn't load the libraries as fast as it should, but I still cannot compile this program to see how it works. I kind of like doing that before I get into the code. Just a personal thing.
 
Top