KennethEvans / VS-GpxViewer

C# application to view and work with GPX files.
2 stars 0 forks source link

Can we have a executable ready release? #1

Open caspertone2003 opened 3 years ago

caspertone2003 commented 3 years ago

Would like to try the viewer... but I need an executable... Can we have a executable ready release? Thanks!

KennethEvans commented 3 years ago

Ok. Just did that. It's working for me, and I have no immediate plans for adding to it.

caspertone2003 commented 3 years ago

Thank you very much! I tried it; discovered that I am converting my files to gpx 1.0 and not to 1.1 (gpsbabel default is 1.0) I have been unable to see the points in GEarth, I get an error: Failed to send to Google Earth: Failed to send to Google Earth: D:\GPXViewer_1.1.1\gpxviewer.kml (changed to that folder, but also tried with the default one) Otherwise works smoothly. I was mainly interested in the find near feature, but I had misunderstood what GPXViewer does in this respect. My use case is a bit different, I am interested in finding which waypoints of one file are close to waypoints in another. I am interested in creating a route from A to B, defined by waypoints (a kind of track), and find out which points of interest are closer to 5kms to the route (get the POIs from OSM). So, before traveling, I can prepare which places are close to the route that I could detour so to see them.

I could split the POIs file into files (one file per POI) and so try to use your sw, but seems cumbersome.

Thanks again, CT

KennethEvans commented 3 years ago

I am not supporting GPX 1.0. That would be a fair amount of work and extra files, and it is no longer used much. Any GPX 1.0 files would have to be converted elsewhere first.

You didn't give me enough information to know why send to Google Earth fails. You do have to have Google Earth installed, and there is some configuration, which should be covered in the Help.

You are right. It doesn't do what you want with waypoints. It just finds waypoints within a specified radius of some lat/lon point. And it doesn't "find" waypoints, just which files have a waypoint inside that radius. It was intended to find tracks or waypoints close to some location so only those could be sent to Google Earth.

I take it you're not a programmer. The routine that does the search could be modified to loop over all the trackpoints in one file instead of just using a specified point and it could output a list of waypoints found. I don't have the time or interest to do that myself and then incorporate it into the UI, though. Sorry.

BTW a route from A to B, defined by waypoints is just a Route, not a Track.

KennethEvans commented 3 years ago

I am leaving the issue open. I did not intend to close it. It decided to do that on its own.

KennethEvans commented 3 years ago

On thinking about your use case more. You need to get Google Earth working. You can use Find Near for selected route points in your route, and it will find all files with whatever radius you use. GE will show the waypoints as isolated points. You can then copy and paste the ones you want where you want them using the UI.

As to Google Earth, what the program really does is create a KML file. You can use that KML file in any of the Google programs, including Maps. The fact that you can start GE with a toolbar button is just a convenience. The information is in the KML file, and you could manually drop it on GE if you like.

caspertone2003 commented 3 years ago

Dear Kenneth, Thanks for your ideas of my use case. Up to now what I do is use mymaps from google. I find the route I am interested in and also upload a GPX file with all potential POIs in my country, then, I zoom in the route and visually find out which POIs are close to the route. Problem is ... that it takes a lot of time and is not fail safe... I am not sure I understand your proposal and how that could improve over my current way. I found an interesting app for android that it quite similar to what I look for, but I cannot upload my POIs (it is roadtripper. it computes the route, and computes a wide corridor both sides of the route - width can be specified, I call it the hot area; then it pops the POIs within the hot area) besides, I cannot "download" to a csv the points within the hot area... If I could upload my POIs it would speed a lot the task... Perhaps furkot is the way to go, still to be tested how works with my POIs (https://help.furkot.com/getting-started/attractions.html)

In relation to GE, I identified which is probably the problem... I always confuse google maps (web) with GE... I have not installed GE... and, as I have been testing alternatives, I had the (obviously wrong) idea that within a tab the map will pop up (such as gpxeditor does - https://sourceforge.net/projects/gpxeditor/ ). Also, as you say, once kml is generated, opening GE is just a convenience.

I feel now I understand better the most unique use case of your sw - please indulge me if I am wrong. It seems that it is targeted to find how to "hop" from one track to another track at the closest points, so to say, if you have some cycling loops in an area and one would like to "combine" those, that would be using the "Find Files Near" feature. Most other uses can be done using other tools or combinations of them. In any case I understand gpxviewer is the tool that fulfill your needs and so it is.

I am also looking for a sw that allows me to change a point from one point in the map to another, such as Basecamp does: select a waypoint, right click, select move, and the move it in the map - coordinates are changed to next point. But this is not either a feature of your sw.

Coming back to your first answer, in relation to GPX 1.0, I was neither complaining nor asking you to retrofit the sw, just informing you that thanks to your sw I just discovered that by default gpsbabel creates GPX 1.0 files, so I have my GPXs files in 1.0 format... I was not aware of that!

In relation to the GE issue... you know, my fault. No GE installed! Perhaps a note in the documentation reminding that GE has to be installed... in hindsight it is obvious, but you know...

I used to program long time ago, but I am far rusty and obsolete. I am pre-bazar and I would be unable to use git, toolchains, and so on, unless devoting long time to get up again. So, even if would be able to propose sw changes, I would not be able to as for things such as "pull requests" etc.

Certainly your sw could be "easily" enhanced to do what I need (I am unsure the algorithms are easy or easy euristics can be used; I am totally unaware of the status quo of cartography mathematics - but most car navigators are able to show "close" waypoints such as speedcams ;-) so should not be rocket science either). In any case I understand quite well that you dont have the time and interest to do it.

I am really surprised that I am unable to find a sw doing it. Perhaps this is the first time in many years that I do not find a ready available and even free solution for a need! (I consider myself as "proficient" making searches).

Thanks for the clarification route/track; I was aware of that but for my purposes it is not relevant. I mean, I certainly start with a route (start/intermediate points/end) in a GPX file. But a track GPX file can be generated from it (such as using QGIS or graphhopper and the reduced to a "reasonable" amount of points such as with routeconverter ) if I would need it.

So, perhaps the way to go for me is to do it using a spreadsheet. Create a track GPX of my route, then export to CSV, then compute the distance from each point in the track to my collection of POIs. Should need to apply some rules to prune points to reduce calculations (no need to calculate distance for "far away points", instead compare delta long and delta lat) and to use a simple distance computation (flat-earth short distance), avoiding as much trigonometry as possible. It is less accurate to calculate distance to all track points than using cross-track distance, but it is really not that important. A coarse, fast and automatic raw answer is good enough!

Thank you very much for your kindness and for the conversation; it helped me also to focus ideas for a solution (excel based). I am happy you close the issue as per your convenience.

CT

KennethEvans commented 3 years ago

I think you're right that what I suggested is about the same as what you're doing; that is, find the waypoints by looking at a map and then move them manually some way.

GPXV is essentially just a way to examine and edit GPX files using a GUI rather than messing with the XML It is also a way to view tracks. My use case is for biking, running, hiking, canoeing and the like. I do a lot of that in the woods where it's difficult to know exactly where you are or in what direction you're going. So it's interesting to see where I've been on a map and, over time, see all the places I've covered in a given area. I don't use it for road trips. Over the years I've written other programs that do read GPX 1.0 and allow you to drag the points around. The problem is that the UIs like Windows keep changing, and I don't have the resources to make as sophisticated an interface as GE in any event. Using GE as the GUI is a good compromise.

My running program, while good in many ways, screws up the generated GPX files badly. Consequently there are menu items to fix them. Like your task these are sort of single purpose. The code there could probably be reasonably easily modified to do what you want in the same way. However, your suggestion of doing it in a spreadsheet is likely better for you. The most useful software is the one you know how to use.

I also use Base Camp and used Mappoint before that.

Best wishes for finding a solution.

KennethEvans commented 3 years ago

One other thought: I use GPS Essentials on Android. It seems to be a pretty good program and is free. I don't use it a lot and am not intimately familiar with it. I don't recall if it has what you need or not. However, it might be worth your looking into. The price is right.

KennethEvans commented 3 years ago

Thinking about it yet more, I think I can probably do what you want. To define the problem as I understand it, you want to specify a file with one or more routes and one or more other files with POI waypoints (not in a route). I am not sure what you want out, another file with the matching waypoints? If you send me some test files, I will see what I can do.

caspertone2003 commented 3 years ago

Hi, sorry, life has kept me busy in other topics ...

As I see that you can consider doing it I can help preparing

Will try to send soon

Thanks again

CT

caspertone2003 commented 3 years ago

Let us start with the problem statement

Input:

Objective: find out with POIs are in near range of the route, in order to review those POIs and check if it is worth deviating from the route to visit them.

Examples of POIs: castles; hotels; petrol stations

Route: it can be represented in whatever format is it more easy for you. One option is to use a GPX track file, with the list of succesive latitude/longitude points (we can think of points every 500m just to make a first attemp to the problem)

d: could be anything, but let us think it is in the range of 5000 meters to the first attemp to the problem.

There are libraries to do the computation; it could be done using APIs to google maps... For the first attempt, I would use the following scheme

A) Remove "far away" POIs (lat and long, decimal) Euristics: find in route-track table the min latitud, min longitude, max latitude, max latitude (that defines a rectangle) This can be done reading the route table and retaining the min and max of lat and long Retain as potential POI only those with lat and log equal to min latitud - a, min longitude -a, max latitude +a and max long +a This can be done reading the POI table and deleting those outside the bounds We get a reduced set of POIs. should be fast, only comparisons... a = x / 155000 (simplification of how much in decimal degrees could be x) ; 5000 m around 0.033 degress at equator

B) for each pont in route-track, see if point in reduced POI table is within range as a first approximation, I would propose to use the following hipothesis: 1 - distances are so close that we can think earth is a plane. do not use even spherical aproximation; consider that we can think meridian distances as constant for the range of the route (=distance of meridians for the route point with minimun latitude) 2 - coarse identification: we need to find close enough points but not exactly within "x" distance; no precise calculations, same approach as the A) heuristics.

Algoritm: For each point in the route file, find which retained points are close, that is, lat of poi = lat of poing +/- a and long of poi = long of poi +/- a

Output those POIs retained.

That is my idea of what I was planning to do in my excel...

Of course, if the proof of concept works, we can see if the increase of complexity in calculations and the more time involved does merit to be done.

For my use case it is good enough, just get a coarse list of POIs "close" to my route.

I will prepare a route gpx file and a set of POIs in gpx format also.

Cheers CT

KennethEvans commented 3 years ago

I can use a track or route. The problem with routes is the points may be far apart so all points within a distance from a route point may not be all the points along the route. I know how to do the math and already have ways to specify any distance in a choice of units. I would want the input in a GPX file as waypoints plus the track or route file. It would be easier to require a track and not a route. The output would be a file of waypoints or maybe adding the waypoints to one of the two input files. So I need 2 files for a test case and a suggested distance. We can play it by ear from there. I had the time available before. It may take a little longer now.

caspertone2003 commented 3 years ago

thanks again. no hurry. I will prepare the inputs, of course a) I did not tried but to help with the algorithm/maths and b) you can do it the best it suits you. CT

caspertone2003 commented 3 years ago

a csv with petrol stations (POIs). are over full Spain (about 2000, just one company) two gpx with same track, one with near 600 and the other around 100 points; route is Malaga to Madrid. Both gpx come from a real trip with about 5000 points, I compresed to those tracks.

Find out with petrol stations are near 10kms (give or take) from the route

LocalizacionPOIsCercanos.zip

As said, I am not in a hurry, so take the time you need. It is your time, and it was not your use case. I believe this can become quite popular ... The test data are not brilliant for a showcase, but good enough for a trial, I believe. I will try to prepare scenic points for the show...

KennethEvans commented 3 years ago

I don't want to use a CSV for the POIs. There is no standard CSV format for POIs. It took me a while to even figure out which was latitude and which was longitude. I'm not used to European lat/lon, and it didn't help that some were in the Canary Islands. The POIs need to be waypoints in a GPX file. I converted yours manually to get going, but CSV will not be supported. You don't have to do anything now. I have what I need to get started. I intend to follow the KISS principle. It may not have a lot of bells and whistles, but it should do what you want.

KennethEvans commented 3 years ago

I believe I have it implemented. I made a new release, and you can try it. The directions are in the help. I have tested it but not extensively and only with your files.

caspertone2003 commented 3 years ago

Thanks! Will try and report back CT

caspertone2003 commented 3 years ago

Works a treat!!!!! And very fast.... Thank you very much. By the way, I installed GE. I imagine you find out that the petrol station coordinates were swapped lat/log... I send you a) the gpx of POIs for petrol station (correct lat/log order) - sorry for having sent a CSV, was too fast. b) output gpx c) a couple of captures of one example of POI close to the track

Will stress test it a bit another day, using many more points in the track and in the POIs.

User interface surprised me... I had not though about it and was thinging that the track would be taken from the open track so only ask for poi file (but after using it I thought that there can be many), and would love if a distance/units could be remembered (I imagine this spoils portability).

I am ok with the current state; should you with to fine-tune the UI, perhaps it could be: load gpx of route, as usual load gpx of POIs, as usual right click on route, select "find near POIs" offer to use a gpx from the loaded ones outcome to be loaded directly (besides or instead of saving them in a file)

By the way, I would be more than happy should you be interested in providing the spanish translation of the menus, just in case you would be interested in localization ...

Thanks for doing this for me this! Now trip planning and trips will be much more pleasurable.

By the way, I will write a small note about your program in one of the spanish gps forums that I visit. CT

I edited to add the files that yesterday night I forgot... Once again, very sorry for having sent a CSV... far from my wish to complex your work

Test-1.zip

caspertone2003 commented 3 years ago

Some more feedback.

I tested it with a track with 3257 points and the POI file with 1301 points. It takes like 3 to 5 seconds. Very good, I was expecting long delays. Not soon but will try with 3000 points in the track and 10000 POIs... but I think times will be ok.

I have one minor point. You know, users always discover something unexpected after coder deliver what users asked for...

If some track point has the nearest track point far away than the distance specified for the POIs, POIS in the line going through that track points can escape... Yes, this corresponds to my specification request... Of course. But I was not fully understanding that implication... I tried with petrol stations and puting 200m and most disappeared while they are close to the road. As the program is doing point-to-point distance (I just tested with track file and poi file ) (not sure if you would have programmed route to POI ie, line to POI), thats it.

Perhaps a warning should be said somewhere (for other users). That would involve making a check: compute if there are points in the track whose neigbours are far away doble thant the user specified distance, and then in that case show a warning ("your specified distance is bigger that distance amongst some points in the track - should there be POIs in the line between those track points far away from the points than the specified distance will not be kept; it is recommended a resampling of points in the track") The other approach could be to add "internal" points along the track to avoid such situation (I am afraid not so many users will have a tool to resample the track), or to increase the distance to the maximum half distance between track points. Or, suggest to use a route instead of a track, if line to poi is implemented....

For my use case it is not important, as tipically the POIs that are interesting to me are at a distance much highther that distance amongst points in the track. Not for the case of petrol stations, but I know how to manage... I only need to have a view in the map of "close" petrol stations and that can be done with distance = 10kms while along track there is not more that 5000m

Thinking aloud, perhaps the best solution and perhaps not too complex to program is to generate two files, one as current, and another for those POIs between specified distance and maximum half distance between track points.

Well, now, it is fully up to you. As it is, I am fully happy!! ;-)

CT

KennethEvans commented 3 years ago

The good thing is that it seems the important things are working correctly.

Perhaps a warning should be said somewhere (for other users).

I am aware of that, and there is a warning in the Overview. You can get around it by having more track points. Maybe I'll fix it by adding track points automatically by interpolation before doing the calculation -- Insure there is one every half the specified distance or so. Note that interpolated tracks will be straight lines and not follow a road. Calculation time does not seem to be a problem so more calculation is feasible.

As to your previous message. "If it ain't broke, it doesn't have enough features yet." —Scott Adams

I try to strike a balance between reliability, maintainability, and features. Reliability and maintainability favor Simplicity. I very much like for my programs to not be broke, and I will almost always fix bugs. For features I use my judgement and weigh the cost (to me) vs the benefit (to you).

For that reason I do not do localization and lots of other bells and whistles. (KISS.)

It was implemented as it was, because the main interface is for viewing and editing GPX files. More sophisticated calculations are in the TCX/GPX menu. This is implemented as a class library (DLL) so it can be (and is) used in several programs. Class libraries don't have settings. Those are in the main program. Thus there is no default distance or retaining the last value entered. This leaves you with a fixed default for the distance as 10 mi, surely not your preferred unit.

I don't know if it is important to you but I will probably change the calculation so the resulting POIs are in the order they are encountered in the track. I should have done that to start with.

So let me know of any other issues you find or suggestions, too. It's better to get it working while it's fresh in my mind.

caspertone2003 commented 3 years ago

Yes, functionality is there working nicely!!

I fully understand your stand point regarding KISS and effort. So, go ahead as you consider. I am already very lucky and happy.

Creating intermediate points sounds a sensible approach. I was not expecting them to lay on the road neither to have spline interpolation amongts nearby points... Point is... this works should the distance between points not be too far bigger than user specified distance.

Default 10 miles... well, when I travel to your country I have to deal with gallons and miles, so, that is a fact of life ;-)

Wishes... I feel this function "close" to "find files near" so feel are best in the same tab. Either tools tab or both in gpx/tcx ... I would include in the gpx of the retained POIs the distance of each of the retained POI to the track point, perhaps in the comment field or alike. A pure command line version would be useful just to make repetitive operations consistently using bat files

But, as said, fully happy, do as you consider; I only can praise your work and tool.

CT

caspertone2003 commented 3 years ago

A minor poing, I believe the output gpx has a small issue: as far as I understand it, "version" attribute is missing in the tag

that gpx has ""

some other <gpx version="1.1" creator="GPSBabel - https://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1">"

some pricky sw do reject your output...

KennethEvans commented 3 years ago

That's a bug. version is a required parameter. I am using a 3rd-party package developed by Microsoft to do the parsing. It should be putting that in there when I create a new one.

The 3rd-party class already has the version defined as 1.1, and you cannot set it to anything except 1.1. However, it doesn't get put in the header unless you explicitly set it (to what it already was set to). This is probably a bug in their implementation, and I will let them know. In the meantime I modified their code to do the kludge. So it should be fixed in the next release of GPX Viewer independently of what they do.

Thanks.

caspertone2003 commented 3 years ago

ok, one glitch less..

caspertone2003 commented 3 years ago

Hello again I have been running test cases. The outcome is very positive as the functionality works as desired.

Performance is ... another topic.

Runs with 3000 track points and 2500 POIs 10kms distance take about 35 seconds in my I5 machine. That could be 3 minutes for 25K POIs and 30 for 250k POIs. Workable although long...

One of the runs was with the wrong order lat/log, so after 35 seconds I got 0 points. I believe it would be nice to include in the program the logic to crop off POIs outside the boundaries of the box containing the track points, I feel this would reduce a lot the computation time. Of course second law of entrophy is there and it would imply you devoting time to reduce the waste computation versus lean calculation.

As always, your trade off.

Thanks for the tool also as always!!!

KennethEvans commented 3 years ago

I made a new release 1.3.1. The GPX version is fixed. It interpolates between track / route points if the distance is greater than 1/3 the specified distance. And it lists the found POIs in the order found. It seems to be working, but has not been tested extensively. You are in a better position to test it than I.

I am attaching a GPS route file with just 3 route points along your track (and my GPX file with your CSV POIs). You can check the before and after with the route. It didn't seem to find more points with the two GPX track files you sent though.

The saved POIs are exactly what were input. I did not add a description or otherwise modify them. I think this is the wisest approach.

TestPOI.zip

caspertone2003 commented 3 years ago

Thanks, I take care of testing and report back CT

caspertone2003 commented 3 years ago

Tested. Works a treat!!! Sweet!!!

I made a run with distance 100m and waypoints far away. Worked well (took its time, 4 minutes).

I also made a run with a lot of points in a different country of the route and was almost instant, no pois (correctly) not found.

Thanks for all again.

No more to ask ;-) Now to enjoy the tool ;-)

Please close the thread as you feel.

CT