Commit 7fc8d857 authored by Bas Couwenberg's avatar Bas Couwenberg

Imported Upstream version 2.0.1

parent d172b4c9
......@@ -6,6 +6,10 @@
#
#-----------------------------------------------------------------------------
from os.path import realpath, dirname
basedir = dirname(realpath(__file__))
# some default flags
# for more information install clang-3.2-doc package and
# check UsersManual.html
......@@ -26,7 +30,7 @@ flags = [
'c++',
# libosmium include dirs
'-I../libosmium/include',
'-I%s/../libosmium/include' % basedir,
'-I/usr/include/gdal',
]
......
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## [unreleased] -
## [2.0.1] - 2015-03-31
### Changed
- Added man pages
[unreleased]: https://github.com/osmcode/osmium-tool/compare/v2.0.1...HEAD
[2.0.1]: https://github.com/osmcode/osmium-tool/compare/v2.0.0...v2.0.1
......@@ -20,11 +20,13 @@ project(osmcoastline)
set(OSMCOASTLINE_VERSION_MAJOR 2)
set(OSMCOASTLINE_VERSION_MINOR 0)
set(OSMCOASTLINE_VERSION_PATCH 0)
set(OSMCOASTLINE_VERSION_PATCH 1)
set(OSMCOASTLINE_VERSION
${OSMCOASTLINE_VERSION_MAJOR}.${OSMCOASTLINE_VERSION_MINOR}.${OSMCOASTLINE_VERSION_PATCH})
set(AUTHOR "Jochen Topf <jochen@topf.org>")
#-----------------------------------------------------------------------------
#
......@@ -156,19 +158,69 @@ endif(CPPCHECK)
#-----------------------------------------------------------------------------
#
# Optional "man" target to generate man pages
#
#-----------------------------------------------------------------------------
message(STATUS "Looking for pandoc")
find_program(PANDOC pandoc)
function(add_man_page _section _name)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/man/man${_section})
set(_output_file ${CMAKE_BINARY_DIR}/man/man${_section}/${_name}.${_section})
set(_source_file ${CMAKE_SOURCE_DIR}/man/${_name}.md)
set(_install_dir "share/man/man{$_section}")
string(TOUPPER ${_name} _name_upcase)
add_custom_command(OUTPUT ${_output_file}
COMMAND ${PANDOC}
${PANDOC_MAN_OPTIONS}
--variable "title=${_name_upcase}"
--variable "section=${_section}"
-o ${_output_file}
${_source_file}
DEPENDS ${_source_file}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Building manpage ${_name}.${_section}"
VERBATIM)
set(ALL_MAN_PAGES "${ALL_MAN_PAGES};${_output_file}" PARENT_SCOPE)
endfunction()
if(PANDOC)
message(STATUS "Looking for pandoc - found")
message(STATUS " Manual pages will be built")
execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE PUBDATE OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PANDOC_MAN_OPTIONS
-s
-t man
--template ${CMAKE_CURRENT_SOURCE_DIR}/man/manpage.template
--variable "description=osmcoastline/${OSMCOASTLINE_VERSION}"
--variable "date=${PUBDATE}"
--variable "author=${AUTHOR}"
)
set(PANDOC_HTML_OPTIONS -s -t html)
find_library(GEOS_C_LIBRARIES NAMES geos_c)
add_man_page(1 osmcoastline)
add_man_page(1 osmcoastline_filter)
add_man_page(1 osmcoastline_readmeta)
add_man_page(1 osmcoastline_ways)
add_definitions(${OSMIUM_WARNING_OPTIONS})
install(DIRECTORY ${CMAKE_BINARY_DIR}/man DESTINATION share)
add_executable(osmcoastline osmcoastline.cpp coastline_ring.cpp coastline_ring_collection.cpp coastline_polygons.cpp output_database.cpp output_layers.cpp srs.cpp options.cpp)
target_link_libraries(osmcoastline ${OSMIUM_IO_LIBRARIES} ${GDAL_LIBRARIES} ${GEOS_C_LIBRARIES})
add_custom_target(man ALL DEPENDS ${ALL_MAN_PAGES})
else()
message(STATUS "Looking for pandoc - not found")
message(STATUS " Manual pages will not be built")
endif(PANDOC)
add_executable(osmcoastline_filter osmcoastline_filter.cpp)
target_link_libraries(osmcoastline_filter ${OSMIUM_IO_LIBRARIES})
add_executable(osmcoastline_ways osmcoastline_ways.cpp osmcoastline.hpp)
target_link_libraries(osmcoastline_ways ${OSMIUM_IO_LIBRARIES} ${GDAL_LIBRARIES})
#-----------------------------------------------------------------------------
find_library(GEOS_C_LIBRARIES NAMES geos_c)
add_definitions(${OSMIUM_WARNING_OPTIONS})
add_subdirectory(src)
configure_file(
${PROJECT_SOURCE_DIR}/runtest.sh.in
......@@ -185,6 +237,13 @@ configure_file(
${PROJECT_BINARY_DIR}/coastline_sources.qgs
)
configure_file(
${PROJECT_SOURCE_DIR}/osmcoastline_readmeta
${PROJECT_BINARY_DIR}/osmcoastline_readmeta
COPYONLY
)
install(PROGRAMS osmcoastline_readmeta DESTINATION bin)
#-----------------------------------------------------------------------------
#
......
# OSMCoastline
OSMCoastline extracts the coastline from an OSM planet file and assembles all
the pieces into polygons for use in map renderers etc.
OSMCoastline extracts the coastline data from an OSM planet file and assembles
all the pieces into polygons for use in map renderers etc.
http://wiki.openstreetmap.org/wiki/OSMCoastline
......@@ -40,10 +40,16 @@ https://github.com/osmcode/osmcoastline
http://www.gaia-gis.it/gaia-sins/
Debian/Ubuntu: sqlite3
### Pandoc (optional, to build documentation)
http://johnmacfarlane.net/pandoc/
Debian/Ubuntu: pandoc
(If pandoc is found by CMake, the manpages will automatically be built.)
## Building
You'll need all the prerequisites including `libosmium` installed.
You'll need the prerequisites including `libosmium` installed.
OSMCoastline uses CMake for building:
......@@ -138,7 +144,7 @@ directory for some more ways of doing this.
The database tables `options` and `meta` contain the command line options
used to create the database and some metadata. You can use the script
`osmcoastline_readmeta.sh` to look at them.
`osmcoastline_readmeta` to look at them.
## Steps
......
#!/bin/sh
#
# fix-formatting
#
exec astyle --style=java --indent-namespaces --indent-switches --pad-header --lineend=linux --suffix=none src/*pp
$if(has-tables)$
.\"t
$endif$
.TH "$title$" "$section$" "$date$" "$footer$" "$header$"
$for(header-includes)$
$header-includes$
$endfor$
$for(include-before)$
$include-before$
$endfor$
$body$
$for(include-after)$
$include-after$
$endfor$
$if(author)$
.SH COPYRIGHT
.PP
Copyright (C) 2012\-2015 Jochen Topf <jochen@topf.org>.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
.SH CONTACT
.PP
http://osmcode.org/contact.html
.SH AUTHORS
$for(author)$$author$$sep$; $endfor$.
$endif$
# NAME
osmcoastline - extract coastline from OSM data
# SYNOPSIS
**osmcoastline** \[*OPTIONS*\] --output=*OUTPUT-DB* *INPUT-FILE*
# DESCRIPTION
**osmcoastline** extracts the coastline data from the *INPUT-FILE*, ususally
a planet file (or the output of the **osmcoastline_filter** program, see below)
and assembles all the pieces into polygons for use in map renderers etc.
The output is written to the Spatialite database *OUTPUT-DB*. Depending on the
options it will contains the coastlines in different formats. See the
description of the options below and the README.md for details.
# OPTIONS
-h, --help
: Display usage information.
-b, --bbox-overlap=OVERLAP
: Polygons that are too large are split into two halves (recursively if need
be). Where the polygons touch the OVERLAP is added, because two polygons
just touching often lead to rendering problems. The value is given in the
units used for the projection (for WGS84 (4326) this is in degrees, for
Mercator (3857) this is in meters). If this is set too small you might get
rendering artefacts where polygons touch. The larger you set this the
larger the output polygons will be. The best values depend on the map scale
or zoom level you are preparing the data for. Disable the overlap by
setting it to 0. Default is 0.0001 for WGS84 and 10 for Mercator.
-c, --close-distance=DISTANCE
: **osmcoastline** assembles ways tagged `natural=coastline` into rings.
Sometimes there is a gap in the coastline in the OSM data. OSMCoastline
will close this gap if it is smaller than DISTANCE. Use 0 to disable this
feature.
-d, --debug
: Enable debugging output.
-f, --overwrite
: Overwrite output file if it already exists.
-i, --no-index
: Do not create spatial indexes in output db. The default is to create those
indexes which makes the database larger, but the data is faster to use.
-l, --output-lines
: Output coastlines as lines to database file.
-m, --max-points=NUM
: Set this to 0 to prevent splitting of large polygons and linestrings. If
set to any other positive integer **osmcoastline** will try to split
polygons/linestrings to not have more than this many points. Depending on
the overlap defined with **-b** and the shape of the polygons it is
sometimes not possible to get the polygons small enough. **osmcoastline**
will warn you on STDERR if this is the case. Default is 1000.
-o, --output=FILE
: Spatialite database file for output. This option must be set.
-p, --output-polygons=land|water|both|none
: Which polygons to write out (default: land).
-r, --output-rings
: Output rings to database file. This is used for debugging purposes.
-s, --srs=EPSGCODE
: Set spatial reference system/projection. Use 4326 for WGS84 or 3857 for
"Google Mercator". If you want to use the data for the usual tiled web
maps, 3857 is probably right. For other uses, especially if you want to
re-project to some other projection, 4326 is probably right. Other
projections are curently not supported. Default is 4326.
-v, --verbose
: Gives you detailed information on what **osmcoastline** is doing,
including timing.
# NOTES
To speed up processing you might want to run the **osmcoastline_filter**
program first. See its man page for details.
# EXAMPLES
Run **osmcoastline** on a planet file using default options:
osmcoastline -o coastline.db planet.osm.pbf
Running **osmcoastline_filter** first:
osmcoastline_filter -o coastline.osm.pbf planet.osm.pbf
osmcoastline -o coastline.db coastline.osm.pbf
# SEE ALSO
* `README.md`
* **osmcoastline_filter**(1), **osmcoastline_readmeta**(1), **osmcoastline_ways**(1)
* [OSMCoastline in OSM wiki](http://wiki.openstreetmap.org/wiki/OSMCoastline)
# NAME
osmcoastline_filter - filter coastline data from OSM file
# SYNOPSIS
**osmcoastline_filter** --output=*OUTPUT_FILE* *INPUT-FILE*
**osmcoastline_filter** --help
# DESCRIPTION
**osmcoastline_filter** is used to filter all nodes and ways needed for
building the coastlines from an OSM planet. The data is written to the
output file in PBF format.
This output file will be a lot smaller (less than 1%) than the original planet
file, but it contains everything needed to assemble the coastline polygons.
If you are playing around or want to run **osmcoastline** several times with
different parameters, run **osmcoastline_filter** once first and use its output
as the input for **osmcoastline**.
**osmcoastline_filter** can read PBF and XML files, but write only PBF files.
PBF files are much smaller and faster to read and write than XML files. The
output file will first contain all ways tagged "natural=coastline", then all
nodes used for those ways (and all nodes tagged "natural=coastline"). Having
the ways first and the nodes later in the file is unusual for OSM files, but
the **osmcoastline** and **osmcoastline_ways** programs work fine with it.
# OPTIONS
-h, --help
: Display usage information
-o, --output=OSMFILE
: Where to write output (default: none)
# EXAMPLES
Run it as follows:
osmcoastline_filter -o coastline-data.osm.pbf planet.osm.pbf
# SEE ALSO
* **osmcoastline**(1), **osmcoastline_ways**(1)
* [OSMCoastline in OSM wiki](http://wiki.openstreetmap.org/wiki/OSMCoastline)
# NAME
osmcoastline_readmeta - display metadata from database create by osmcoastline
# SYNOPSIS
**osmcoastline_readmeta** \[*COASTLINE-DB*\]
# DESCRIPTION
This program displays various meta data from a database created by the
**osmcoastline** program.
If no database name is specified on the command line "testdata.db" is used.
Displayed are the command line options used to create the database, some
statistics about the coastline, the number of warnings and errors detected
and more.
# SEE ALSO
* **osmcoastline**(1)
* [OSMCoastline in OSM wiki](http://wiki.openstreetmap.org/wiki/OSMCoastline)
# NAME
osmcoastline_ways - extract coastline ways from OSM data
# SYNOPSIS
**osmcoastline_ways** *INPUT-FILE* \[*OUTPUT-DB*\]
# DESCRIPTION
**osmcoastline_ways** extracts coastline ways from OSM data and writes them
into a Spatialite database. The output data is meant for debugging and
statistics. Use the **osmcoastline** program to assemble coastlines for
"real" use.
You have to run **osmcoastline_ways** on the output of the
**osmcoastline_filter** program, otherwise it will not work correctly!
The data is written to the Spatialite database *OUTPUT-DB*. If *OUTPUT-DB* is
not set, the default "coastline-ways.db" is used. A single table "ways" is
written. It contains the IDs of all ways, their geometries, and the contents
of their "name" and "source" tags.
**osmcoastline_ways** outputs the sum of all way lengths.
# SEE ALSO
* **osmcoastline**(1), **osmcoastline_filter**(1)
* [OSMCoastline in OSM wiki](http://wiki.openstreetmap.org/wiki/OSMCoastline)
#!/bin/sh
#
# osmcoastline_readmeta.sh [COASTLINEDB]
# osmcoastline_readmeta [COASTLINEDB]
#
SQLEXEC="sqlite3"
if [ "x$1" = "x" ]; then
DBFILE=testdata.db
else
......@@ -17,69 +19,69 @@ fi
echo "Options used to create this data:\n"
echo -n " Overlap (--bbox-overlap/-b): "
sqlite3 $DBFILE "SELECT overlap FROM options;"
$SQLEXEC $DBFILE "SELECT overlap FROM options;"
echo -n " Close gaps in coastline smaller than (--close-distance/-c): "
sqlite3 $DBFILE "SELECT close_distance FROM options;"
$SQLEXEC $DBFILE "SELECT close_distance FROM options;"
echo -n " Max points in polygons (--max-points/-m): "
sqlite3 $DBFILE "SELECT max_points_in_polygons FROM options;"
$SQLEXEC $DBFILE "SELECT max_points_in_polygons FROM options;"
echo -n " Split large polygons: "
sqlite3 $DBFILE "SELECT CASE split_large_polygons WHEN 0 THEN 'no' ELSE 'yes' END FROM options;"
$SQLEXEC $DBFILE "SELECT CASE split_large_polygons WHEN 0 THEN 'no' ELSE 'yes' END FROM options;"
echo -n " Spatial reference system (--srid/-s): "
sqlite3 $DBFILE "SELECT CASE srid WHEN 4326 THEN '4326 (WGS84)' WHEN 3857 THEN '3857 (Mercator)' ELSE srid END FROM geometry_columns WHERE f_table_name='land_polygons';"
$SQLEXEC $DBFILE "SELECT CASE srid WHEN 4326 THEN '4326 (WGS84)' WHEN 3857 THEN '3857 (Mercator)' ELSE srid END FROM geometry_columns WHERE f_table_name='land_polygons';"
echo "\nMetadata:\n"
echo -n " Database created at: "
sqlite3 $DBFILE "SELECT timestamp FROM meta;"
$SQLEXEC $DBFILE "SELECT timestamp FROM meta;"
echo -n " Runtime (minutes): "
sqlite3 $DBFILE "SELECT CAST(round(CAST(runtime AS REAL)/60) AS INT) FROM meta;"
$SQLEXEC $DBFILE "SELECT CAST(round(CAST(runtime AS REAL)/60) AS INT) FROM meta;"
echo -n " Memory usage (MB): "
sqlite3 $DBFILE "SELECT memory_usage FROM meta;"
$SQLEXEC $DBFILE "SELECT memory_usage FROM meta;"
echo -n " Ways tagged natural=coastline: "
sqlite3 $DBFILE "SELECT num_ways FROM meta;"
$SQLEXEC $DBFILE "SELECT num_ways FROM meta;"
echo -n " Number of nodes where coastline is not closed (before fixing): "
sqlite3 $DBFILE "SELECT num_unconnected_nodes FROM meta;"
$SQLEXEC $DBFILE "SELECT num_unconnected_nodes FROM meta;"
echo -n " Coastline rings: "
sqlite3 $DBFILE "SELECT num_rings FROM meta;"
$SQLEXEC $DBFILE "SELECT num_rings FROM meta;"
echo -n " Coastline rings created from a single way: "
sqlite3 $DBFILE "SELECT num_rings_from_single_way FROM meta;"
$SQLEXEC $DBFILE "SELECT num_rings_from_single_way FROM meta;"
echo -n " Coastline rings created from more then one way: "
sqlite3 $DBFILE "SELECT num_rings - num_rings_from_single_way FROM meta;"
$SQLEXEC $DBFILE "SELECT num_rings - num_rings_from_single_way FROM meta;"
echo -n " Number of rings fixed (closed): "
sqlite3 $DBFILE "SELECT num_rings_fixed FROM meta;"
$SQLEXEC $DBFILE "SELECT num_rings_fixed FROM meta;"
echo -n " Number of rings turned around: "
sqlite3 $DBFILE "SELECT num_rings_turned_around FROM meta;"
$SQLEXEC $DBFILE "SELECT num_rings_turned_around FROM meta;"
echo -n " Number of land polygons before split: "
sqlite3 $DBFILE "SELECT num_land_polygons_before_split FROM meta;"
$SQLEXEC $DBFILE "SELECT num_land_polygons_before_split FROM meta;"
echo -n " Number of land polygons after split: "
sqlite3 $DBFILE "SELECT CASE num_land_polygons_after_split WHEN 0 THEN 'NOT SPLIT' ELSE num_land_polygons_after_split END FROM meta;"
$SQLEXEC $DBFILE "SELECT CASE num_land_polygons_after_split WHEN 0 THEN 'NOT SPLIT' ELSE num_land_polygons_after_split END FROM meta;"
echo "\nErrors/warnings (Points):\n"
echo ".width 3 20\nSELECT count(*), error FROM error_points GROUP BY error;" | sqlite3 -column $DBFILE | sed -e 's/^/ /'
echo ".width 3 20\nSELECT count(*), error FROM error_points GROUP BY error;" | $SQLEXEC -column $DBFILE | sed -e 's/^/ /'
echo "\nErrors/warnings (LineStrings):\n"
echo ".width 3 20\nSELECT count(*), error FROM error_lines GROUP BY error;" | sqlite3 -column $DBFILE | sed -e 's/^/ /'
echo ".width 3 20\nSELECT count(*), error FROM error_lines GROUP BY error;" | $SQLEXEC -column $DBFILE | sed -e 's/^/ /'
echo "\nOutput:\n"
echo "SELECT count(*), 'land_polygons' FROM land_polygons;" | sqlite3 -column $DBFILE | sed -e 's/^/ /'
echo "SELECT count(*), 'water_polygons' FROM water_polygons;" | sqlite3 -column $DBFILE | sed -e 's/^/ /'
echo "SELECT count(*), 'lines' FROM lines;" | sqlite3 -column $DBFILE | sed -e 's/^/ /'
echo "SELECT count(*), 'rings' FROM rings;" | sqlite3 -column $DBFILE | sed -e 's/^/ /'
echo "SELECT count(*), 'land_polygons' FROM land_polygons;" | $SQLEXEC -column $DBFILE | sed -e 's/^/ /'
echo "SELECT count(*), 'water_polygons' FROM water_polygons;" | $SQLEXEC -column $DBFILE | sed -e 's/^/ /'
echo "SELECT count(*), 'lines' FROM lines;" | $SQLEXEC -column $DBFILE | sed -e 's/^/ /'
echo "SELECT count(*), 'rings' FROM rings;" | $SQLEXEC -column $DBFILE | sed -e 's/^/ /'
echo
......@@ -4,5 +4,5 @@ if [ "x$1" = "x-v" ]; then
osmcoastline_valgrind="valgrind --leak-check=full --show-reachable=yes"
fi
exec $osmcoastline_valgrind ./osmcoastline --debug --verbose --overwrite --output-lines --output-polygons=both --output-rings -o testdata.db @PROJECT_SOURCE_DIR@/testdata.osm
exec $osmcoastline_valgrind src/osmcoastline --debug --verbose --overwrite --output-lines --output-polygons=both --output-rings -o testdata.db @PROJECT_SOURCE_DIR@/testdata.osm
#-----------------------------------------------------------------------------
#
# CMake Config
#
# OSMCoastline
#
#-----------------------------------------------------------------------------
add_executable(osmcoastline osmcoastline.cpp coastline_ring.cpp coastline_ring_collection.cpp coastline_polygons.cpp output_database.cpp output_layers.cpp srs.cpp options.cpp)
target_link_libraries(osmcoastline ${OSMIUM_IO_LIBRARIES} ${GDAL_LIBRARIES} ${GEOS_C_LIBRARIES})
install(TARGETS osmcoastline DESTINATION bin)
add_executable(osmcoastline_filter osmcoastline_filter.cpp)
target_link_libraries(osmcoastline_filter ${OSMIUM_IO_LIBRARIES})
install(TARGETS osmcoastline_filter DESTINATION bin)
add_executable(osmcoastline_ways osmcoastline_ways.cpp osmcoastline.hpp)
target_link_libraries(osmcoastline_ways ${OSMIUM_IO_LIBRARIES} ${GDAL_LIBRARIES})
install(TARGETS osmcoastline_ways DESTINATION bin)
......@@ -22,6 +22,9 @@
*/
#include <iostream>
#include <utility>
#include <osmium/handler.hpp>
#include <osmium/geom/ogr.hpp>
......@@ -40,8 +43,7 @@ class CoastlineHandlerPass1 : public osmium::handler::Handler {
public:
CoastlineHandlerPass1(CoastlineRingCollection& coastline_rings) :
m_coastline_rings(coastline_rings)
{
m_coastline_rings(coastline_rings) {
}
void way(const osmium::Way& way) {
......@@ -82,8 +84,7 @@ public:
CoastlineHandlerPass2(CoastlineRingCollection& coastline_rings, OutputDatabase& output) :
m_coastline_rings(coastline_rings),
m_posmap(),
m_output(output)
{
m_output(output) {
m_coastline_rings.setup_positions(m_posmap);
}
......
......@@ -315,7 +315,7 @@ void CoastlinePolygons::split_bbox(OGREnvelope e, polygon_vector_type&& v) {
break;
}
}
} catch(...) {
} catch (...) {
std::cerr << "ignoring exception\n";
}
} else {
......
......@@ -92,7 +92,9 @@ public:
}
/// Number of polygons
int num_polygons() const { return m_polygons.size(); }
int num_polygons() const {
return m_polygons.size();
}
polygon_vector_type::const_iterator begin() const {
return m_polygons.begin();
......
......@@ -24,6 +24,8 @@
#include <map>
#include <memory>
#include <ostream>
#include <vector>
#include <osmium/geom/ogr.hpp>
#include <osmium/osm/undirected_segment.hpp>
......@@ -91,8 +93,7 @@ public:
m_ring_id(way.id()),
m_nways(1),
m_fixed(false),
m_outer(false)
{
m_outer(false) {
m_way_node_list.reserve(way.is_closed() ? way.nodes().size() : 1000);
m_way_node_list.insert(m_way_node_list.begin(), way.nodes().begin(), way.nodes().end());
}
......@@ -106,19 +107,29 @@ public:
}
/// ID of first node in the ring.
osmium::object_id_type first_node_id() const { return m_way_node_list.front().ref(); }
osmium::object_id_type first_node_id() const {
return m_way_node_list.front().ref();
}
/// ID of last node in the ring.
osmium::object_id_type last_node_id() const { return m_way_node_list.back().ref(); }
osmium::object_id_type last_node_id() const {
return m_way_node_list.back().ref();
}
/// Position of the first node in the ring.
osmium::Location first_position() const { return m_way_node_list.front().location(); }
osmium::Location first_position() const {
return m_way_node_list.front().location();
}
/// Position of the last node in the ring.
osmium::Location last_position() const { return m_way_node_list.back().location(); }
osmium::Location last_position() const {
return m_way_node_list.back().location();
}
/// Return ID of this ring (defined as smallest ID of the ways making up the ring).
osmium::object_id_type ring_id() const { return m_ring_id; }
osmium::object_id_type ring_id() const {
return m_ring_id;
}
/**
* Set ring ID. The ring will only get the new ID if it is smaller than the
......@@ -131,16 +142,24 @@ public:
}
/// Returns the number of ways making up this ring.
unsigned int nways() const { return m_nways; }
unsigned int nways() const {
return m_nways;
}
/// Returns the number of points in this ring.
unsigned int npoints() const { return m_way_node_list.size(); }
unsigned int npoints() const {
return m_way_node_list.size();
}
/// Returns true if the ring is closed.
bool is_closed() const { return first_node_id() == last_node_id(); }
bool is_closed() const {
return first_node_id() == last_node_id();
}
/// Was this ring fixed because of missing/wrong OSM data?
bool is_fixed() const { return m_fixed; }
bool is_fixed() const {
return m_fixed;
}
/**
* When there are two different nodes with the same position
......
......@@ -23,6 +23,8 @@
*/
#include <list>
#include <map>
#include <memory>
#include <vector>
#include <osmium/geom/ogr.hpp>
......@@ -65,7 +67,9 @@ public:
CoastlineRingCollection();
/// Return the number of CoastlineRings in the collection.
size_t size() const { return m_list.size(); }
size_t size() const {
return m_list.size();
}
/**
* Add way to collection. A new CoastlineRing will be created for the way
......@@ -81,13 +85,21 @@ public:
}
}
unsigned int num_ways() const { return m_ways; }
unsigned int num_ways() const {
return m_ways;
}