Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in map is 30 years old #152

Open
df7cb opened this issue Jul 28, 2019 · 34 comments
Open

Built-in map is 30 years old #152

df7cb opened this issue Jul 28, 2019 · 34 comments

Comments

@df7cb
Copy link

df7cb commented Jul 28, 2019

The built-in map that is shown the first time xastir is lanched is at least 30 years old. It still shows the German Democratic Republic, the Soviet Union, and Yugoslavia.
gdr
Please update it to something less embarrassing. Thanks.

@tvrusso
Copy link
Member

tvrusso commented Jul 28, 2019

Yes, that is pretty appalling. I guess nobody actually looks at that map anymore.

The ancient APRSDOS worldhi.map file that comes with Xastir is simply the only map we had available that can run with the minimal build of Xastir. It is better than the map that used to come with Xastir before that was found (nothing).

We would be happy to accept any other map that is less embarrassing. Unfortunately, whatever we take has to work with a minimal build (no shapefile, no imagemagick, no geotiff, no xpm... that is, a vector map of the most primitive type, like, say, an ancient APRSDOS), or we have to change what constitutes "minimal."

@we7u , correct me if I'm wrong, but I thought the whole reason why we originally created a shapelib fork in the Xastir source tree was so that we could assume shapefile support, precisely so we could distribute a simple and maintainable shapefile map instead of the horrid worldhi.map thing. But I can find no shapefile map in the Xastir source tree.

If we make shapelib a required package instead of an optional, then it would be much more straightforward to keep a reasonable and not miserably outdated shapefile as our default map.

@tvrusso
Copy link
Member

tvrusso commented Jul 28, 2019

Correcting myself: the internal shapelib (since removed) was added to Xastir not so we could have a good default shapefile map, but so that NWS weather alerts would always work (they depend on shapefiles).

I found this in my old archives:

On Tue, 14 Nov 2006, Jeremy Utley wrote:

The main reason for including shapelib by default is so we can have a
shapelib-based map come up right from the very start.

Well, at this point the main reason is to have weather alerts from
the start, but it still requires the user to run the get-NWSdata
script (to download and install the NOAA data files) in order to
make that functional.

We have a default map in the distribution now but it's a WinAPRS
map, created by Keith Sproul. I would have liked a Shapefile map in
there but didn't find one I liked that was small enough to add to
the distribution. If we come across one later we can add it easily
enough though.

--
Curt, WE7U.

I would suggest that since we removed the internal shapelib (because all distros have it in package management nowadays), we should make it mandatory instead of optional and refuse to build without it, just like we refuse to build without Motif and X11. Then we could find a decent world shapefile and just include it instead of the awful APRSDOS map.

@tvrusso
Copy link
Member

tvrusso commented Jul 28, 2019

A possible sources of world shapefiles we might be able to use:

https://www.naturalearthdata.com/downloads/50m-cultural-vectors/50m-admin-0-countries-2/
which has a version on github:
https://github.com/nvkelso/natural-earth-vector

We wouldn't need the whole thing, just national outlines with names (and a dbfawk file to go with it so it could be rendered, after we resolve #128, making dbfawk and pcre required instead of optional).

But it, too, may become outdated quickly. It's already a couple of years old, it seems.

@df7cb
Copy link
Author

df7cb commented Jul 29, 2019

I heard a lot of good things about naturalearth, so I'd think that would be a good choice.

@we7u
Copy link
Member

we7u commented Jul 29, 2019 via email

@tvrusso
Copy link
Member

tvrusso commented Jul 29, 2019 via email

@we7u
Copy link
Member

we7u commented Jul 29, 2019 via email

@we7u
Copy link
Member

we7u commented Jul 29, 2019 via email

@we7u
Copy link
Member

we7u commented Jul 29, 2019 via email

@tvrusso
Copy link
Member

tvrusso commented Jul 29, 2019

Yeah, the naturalearthdata was the one I mentioned several comments above. They also have a github repo (it's about 7 comments up).

@we7u
Copy link
Member

we7u commented Jul 29, 2019 via email

@tvrusso
Copy link
Member

tvrusso commented Jul 29, 2019

It could potentially be added as a git submodule. But that would cause the entire git repo to be cloned, which is probably too much. Better just to have a single shapefile to distribute, and we can just periodically update it when naturalearth does.

License is "public domain" and they don't even require that they be credited or cited (but provide text and logos to do so if desired).

https://github.com/nvkelso/natural-earth-vector/blob/master/LICENSE.md

@tvrusso
Copy link
Member

tvrusso commented Jul 29, 2019

Then again, naturalearth has 104 open issues (mostly complaints about bad data at the local level) and hasn't been updated in a year. Eventually, this too will become obsolete. But at least it'll be a shapefile, and we can use ArcGIS or some other shapefile editor to hack on it if we needed to merge or rename a country that ceases to exist in the next few years.

@halmueller
Copy link
Contributor

QGIS (https://qgis.org) is the FOSS4G tool of choice for viewing spatial data, and for manipulating it with a GUI. If you need something scriptable, look at GDAL.

@kg4wsv
Copy link

kg4wsv commented Aug 2, 2019

Late to the party here.

I've been playing with the 50 and 110 series files (I sort of started under the assumption the goal was to replace worldhi with something comparable in detail and file size, just up-to-date). I've started on some dbfawks.

I've hit several glitches in some of the data files (random straight lines, e.g. between points on rivers in NM connecting to the southern part of South America). Xastir is my only GIS software so I don't really have any way to check to see if it's a data issue or an xastir issue. Suggestions?

I'll have to double-check, but I think there are duplicate dbfawk signatures on some of the files so the dbfawks would need to be name-based.

Beyond the "up to date data" requirement, are there any other requirements for file sizes, etc that anyone has in mind?

-Jason

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019 via email

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

Zowiewow. I had (not seriously) suggested that we could make naturalearth a git submodule of Xastir, so that git users would just get it all.

Glad I wasn't serious. A git clone of that repo is freakin' huge. It's downloaded 1.23GB of data so far, and that's only 14% of the clone.

@kg4wsv
Copy link

kg4wsv commented Aug 2, 2019 via email

@kg4wsv
Copy link

kg4wsv commented Aug 2, 2019

I also thought about labels, but what size display should I design for for general use? I've got a 800x480 7" pi all the way up to my 24" linux desktop at work.

Something else I noticed, this data has language support - names are in a dozen or two languages. Is there some sort of environment variable or flag passed in to dbfawk for runtime internationalization?

-j

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

Unfortunately, there is no such existing flag or environment variable for DBFAWK internationalization. One could, of course, add such a thing. DBFAWK has pretty much been unmodified ever since Alan Crosswell added it back in 2003 (a few bug fixes, but no really serious new features).

@halmueller
Copy link
Contributor

halmueller commented Aug 2, 2019 via email

@kg4wsv
Copy link

kg4wsv commented Aug 2, 2019

Here are two samples. Files are from 50m_physical set. ne_50m_rivers_lake_centerlines is shown in black, ne_50m_coastlines is shown in blue. I've been saying "glitch" but I believe it's a data error. Note there's at least one error on the coastline data and lots on the river data.

NE-50m-glitches-1

NE-50m-glitches-2

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

I just pulled 50m_physical/ne_50m_rivers_lake_centerlines, 50m_physical/ne_50m_coastline, and 50m_cultural/ne_50m_admin_0_countries into ArcGIS and see absolutely none of these lines.

In fact, they look clean. (attaching 3 map renderings of various pieces, with graticule overlaid)
world.pdf
NorthAmerica.pdf
EuropeLabeled.pdf

But in fact, it appears that the "river in NM" you're looking at is actually the Colorado river in Arizona, and it is in present as a single shape combined with the Colorado river in Argentina. When they generated the shapefile, they must have merged features with identical names.

ColoradoRiverUS.pdf
ColoradoRiverArgentina.pdf

Xastir is doing exactly what it's told, connecting all points of a line together.

I think the only way to fix that issue is to change Xastir's shapefile rendering to skip drawing lines between points a certain distance apart (expressed in degrees, probably), possibly controlled by a dbfawk option. That would be some coding.

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

Notably, it's shape number 155 that has both a US Colorado river and an Argentina Colorado river combined into one shape. There's a second shape, shape number 5, that is also Colorado River, but only has extent in North America.

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

Note, this sort of data error is somewhat deadly to Xastir's shapefile rendering optimizations (such as rtree), which are supposed to restrict its reads of shapefiles to shapes whose bounding boxes intersect the current display extents. An enormous, discontinuous polyline like this means an enormous bounding box that pretty much guarantees the shape will be read no matter where in the western hemisphere you might be.

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

FWIW, the 10m river/lake shapefile does NOT have the same data error of combining the North American Colorado River with the one in South America. It may have other issues, such as being about 13MB between the .shp and .dbf file. And of course it could have some other ridiculous data error, too.

The 10m coastline is pretty, but it, too, is quite large (over 7MB for the shp and dbf files).

We could potentially work to clean these up and feed back the cleanup to the natural-earth git repo as issue reports. There are a lot of such errors showing up in your second image, such as ridiculous straight lines connecting bits and pieces of the Rio Grande where there shouldn't be any lines.

It could also be that we're handling polylines in Xastir incorrectly. ogrinfo is showing the Colorado River shapes as type "MULTILINESTRING" which tells us that there are multiple, unconnected lines in them. We appear to be treating all SHPT_ARC shapefiles (as indicated from the Shapelib function "SHPGetInfo") as if they're plain "LINESTRING".

Scanning over map_shp.c, we do not appear to be respecting the "nParts" element of a shape object returned by SHPReadObject, which would tell us the difference between these two types. We go through great lengths to take care of POLYGON shapefiles that are in multiple parts, but do no checking of a multipart line --- we treat the list of vertices as if it was a single shape to draw.

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

Confirmed, the code starting around line 2972 of map_shp.c is very clearly constructing a single polyline out of all of the vertices present in the shape object, paying no regard whatsoever to the fact that the shape might be in multiple parts. It should only be doing that if nParts is 0, and if nParts is nonzero, it should loop over parts and make separate polylines out of the vertices, using the start points in the panPartStart array to determine which part starts at what vertex offset in the full list.

But the code here is clearly structured as assuming a single part, and some careful refactor should be done.

It would help if bug #128 were resolved before doing that work --- the presence of dbfawk/non-dbfawk code in this file makes it extraordinarily difficult to read (and the non-dbfawk code is much more of the file than the dbfawk code).

I'm going to open a new issue for the improper rendering of muiltipart polylines. I will certainly not be able to work on either bug #128 or that bug anytime soon, but if we get it into the tracker maybe someone will leap at it and do the work.

@halmueller
Copy link
Contributor

halmueller commented Aug 2, 2019

There's nothing wrong with the data, nothing to "clean up". Multipart strings are common.

In the interest of getting a better default map out sooner rather than later, I suggest converting the MULTILINESTRING elements to single LINESTRING elements.

I note:
% ogrinfo -al ne_50m_coastline.shp|grep MULTI|wc -l
1
% ogrinfo -al ne_50m_rivers_lake_centerlines.shp|grep MULTI|wc -l
182

I don't have a working/built Xastir repo at the moment to test this fix. @kg4wsv or @tvrusso, could you try these commands (assuming you have GDAL/OGR installed):
% ogr2ogr -f "ESRI Shapefile" -nlt LINESTRING -explodecollections -lco ENCODING=UTF-8 exploded_rivers.shp ne_50m_rivers_lake_centerlines.shp
% ogr2ogr -f "ESRI Shapefile" -nlt LINESTRING -explodecollections -lco ENCODING=UTF-8 exploded_coastlines.shp ne_50m_coastline.shp

and then try those files in Xastir? Alternatively, I can commit them in a branch.

@kg4wsv
Copy link

kg4wsv commented Aug 2, 2019 via email

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

Yes, there's nothing wrong with the data (I had already concluded that and said so after initially postulating that there was a data error). Xastir is rendering it incorrectly. Multipart shapefile lines are not processed correctly. I have already opened bug #154 for that.

The ogr2ogr explosion command you give does indeed break up all the MULTILINESTRING shapes into individual LINESTRINGs, and should no longer render with incorrect connecting lines in Xastir.

Doing this has another advantage besides getting Xastir to render nicely, it lets the rtree optimization (which is based on individual shape bounding boxes, and doesn't know anything about multi-part shapes, either) select more appropriate subsets of the shapefile for rendering.

BTW, your two ogr2ogr commands are identical. I presume you meant to apply one to the river/lake centerlines and the other to the coastlines?

@halmueller
Copy link
Contributor

Yes, fixed it, thanks.

@kg4wsv
Copy link

kg4wsv commented Aug 2, 2019

confirmed, ogr2ogr fixed issues with both files.

@tvrusso
Copy link
Member

tvrusso commented Aug 2, 2019

FWIW, while the existence of MULTILINESTRING features in this file is not a data error, and the failure to render these multilines as separate polylines is a bug in Xastir, it is certainly wrong for two rivers with the same name on different continents to be lumped into the same shape.

So while the Rio Grande rendering errors (with straight line segments between the parts) in Xastir are not the sign of a data error, one can definitely argue that the natural-earth shapefile should be "cleaned up" to separate the two completely unrelated "Colorado" rivers into separate shapes (each of which might very appropriately be a multilinestring) --- that might be a reasonable issue report for the natural-earth github repo at https://github.com/nvkelso/natural-earth-vector

@kg4wsv
Copy link

kg4wsv commented Aug 6, 2019

On the question of map file sizes, what would be an acceptable size to include in the distribution?

On my first pass I've whittled it down to a set of about half a dozen of the 50m files that includes countries, states, rivers, and populated places. The files are ~16.5M uncompressed, 3.1M in a gzipped tarball. It's slightly more detailed than worldhi.map; it includes more in the way of rivers and lakes, has labels, and lists larger cities. It does not include any roads. I was shooting for "roughly the same but maybe a little better than worldhi".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

5 participants