Skip to content

Commit

Permalink
Rebuild: Enable rendering of coastlines as areas.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.openstreetmap.org/applications/rendering/gosmore@25386 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
  • Loading branch information
nic committed Feb 21, 2011
1 parent c9233e8 commit ccfce5c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
21 changes: 11 additions & 10 deletions libgosm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,25 +1508,25 @@ deque<string> Osm2Gosmore (int /*id*/, k2vType &k2v, wayType &w,
ndType *LFollow (ndType *nd, ndType *ndItr, wayType *w, int forward)
{ // Helper function when a way is copied into lowzoom table.
if (forward) {
nd += nd->other[1];
if (nd->other[1]) return nd;
nd += nd->other[0];
if (nd->other[0]) return nd;
}
if (nd->lat == nd[1].lat && nd->lon == nd[1].lon) {
if ((nd->lat != nd[2].lat || nd->lon != nd[2].lon) &&
(nd->lat != nd[-1].lat || nd->lon != nd[-1].lon ||
// If there is a 3rd object there,
(nd[-1].other[0] == 0 && nd[-1].other[0] == 0)) &&
(nd[-1].other[1] == 0 && nd[-1].other[1] == 0)) &&
// then it must be a node
nd + 1 != ndItr && nd[1].other[!forward ? 1 : 0] == 0
nd + 1 != ndItr && nd[1].other[forward ? 1 : 0] == 0
// Must not loop back to start and must not be T juntion
&& StyleNr (w) == StyleNr ((wayType*)(data + nd[1].wayPtr))) nd++;
}
else if (nd->lat == nd[-1].lat && nd->lon == nd[-1].lon &&
(nd->lat != nd[-2].lat || nd->lon != nd[-2].lon ||
// If there is a 3rd object there,
(nd[-2].other[0] == 0 && nd[-2].other[0] == 0)) &&
(nd[-2].other[1] == 0 && nd[-2].other[1] == 0)) &&
// then it must be a node
nd - 1 != ndItr && nd[-1].other[!forward ? 1 : 0] == 0
nd - 1 != ndItr && nd[-1].other[forward ? 1 : 0] == 0
// Must not loop back to start and must not be T juntion
&& StyleNr (w) == StyleNr ((wayType*)(data + nd[-1].wayPtr))) nd--;
// If nd ends at a point where exactly two ways meet and they have the same
Expand Down Expand Up @@ -2159,17 +2159,18 @@ int RebuildPak(const char* pakfile, const char* elemstylefile,
// and the lats & lons have been dereferenced previously. So the pairing is
// simplified a lot.
ndType *prev = LFollow (ndItr, ndItr, way, 0);
if (!ndItr->other[0] && prev->wayPtr >= ndItr->wayPtr) {
if (!ndItr->other[1] && prev->wayPtr >= ndItr->wayPtr) {
int length = 0;
ndType *end;
for (end = ndItr; end->other[1]; end = LFollow (end, ndItr, way, 1)) {
length += lrint (sqrt (Sqr ((double)(end->lat - end[end->other[1]].lat)) +
Sqr ((double)(end->lon - end[end->other[1]].lon))));
for (end = ndItr; end->other[0]; end = LFollow (end, ndItr, way, 1)) {
length += lrint (sqrt (Sqr ((double)(end->lat - end[end->other[0]].lat)) +
Sqr ((double)(end->lon - end[end->other[0]].lon))));
if (prev != ndItr && end->wayPtr < ndItr->wayPtr) break;
// If it is circular and we didn't start at the way with the lowest
// wayPtr, then we abort
}
if ((prev == ndItr || prev == end) && (length > 500000 ||
StyleNr(way) == natural_coastline ||
(end == ndItr && srec[StyleNr (way)].scaleMax > 100000))) {
//printf (prev == ndItr ? "%3d Non circular %s\n" : "%3d Circular %s\n",
// ndItr - ndBase, (char*)(way+1)+1);
Expand Down
8 changes: 5 additions & 3 deletions libgosm.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ typedef int intptr_t;
#endif

#ifndef _WIN32
#ifndef ANDROID_NDK
#include <libxml/xmlreader.h>
#endif
#include <inttypes.h>
#define stricmp strcasecmp
typedef long long __int64;
Expand All @@ -26,7 +28,7 @@ typedef long long __int64;
#define M_PI 3.14159265358979323846 // Not in math ??
#endif

#if __FreeBSD__ || __APPLE__ // Thanks to Ted Mielczarek & Dmitry
#if __FreeBSD__ || __APPLE__ || ANDROID_NDK
#define fopen64(x,y) fopen(x,y)
#endif

Expand All @@ -46,7 +48,7 @@ typedef long long __int64;
#endif

#define Sqr(x) ((x)*(x))
inline int isqrt (int x) { return lrint (sqrt (x)); } // Optimize this ?
inline int isqrt (int x) { return lrint (sqrt ((double)x)); } // Optimize this ?

#define TILEBITS (18)
#define TILESIZE (1<<TILEBITS)
Expand Down Expand Up @@ -270,7 +272,7 @@ enum {
s (landuse, retail, "retail area" , "") \
s (landuse, commercial, "commercial area" , "") \
s (landuse, construction, "construction area" , "") \
s (landuse, reservoir, "reservoir" , "") \
s (natural, coastline, "coastline" , "") \
s (natural, water, "lake / dam" , "") \
s (landuse, basin, "basin" , "") \
s (landuse, landfill, "landfill" , "") \
Expand Down

0 comments on commit ccfce5c

Please sign in to comment.