mirror of
https://github.com/osm2pgsql-dev/osm2pgsql.git
synced 2025-08-16 15:04:27 +00:00

This adds a copyright notice to all C++ files and the README clarifying the license. (There is no change of the license.) This also removes a few names explicitly mentioned as copyright holders, instead refering to the git log which has a full list of all osm2pgsql developers. (There is also still the AUTHORS file which names the most important developers.) The only exception is the sprompt.cpp file which was taken from PostgreSQL and keeps its original license information (and, of course, the files in contrib).
140 lines
4.9 KiB
C++
140 lines
4.9 KiB
C++
/**
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*
|
|
* This file is part of osm2pgsql (https://osm2pgsql.org/).
|
|
*
|
|
* Copyright (C) 2006-2020 by the osm2pgsql developer community.
|
|
* For a full list of authors see the git log.
|
|
*/
|
|
|
|
#include <catch.hpp>
|
|
|
|
#include "common-import.hpp"
|
|
#include "common-options.hpp"
|
|
|
|
static testing::db::import_t db;
|
|
|
|
static void require_tables(testing::pg::conn_t const &conn)
|
|
{
|
|
conn.require_has_table("osm2pgsql_test_point");
|
|
conn.require_has_table("osm2pgsql_test_line");
|
|
conn.require_has_table("osm2pgsql_test_polygon");
|
|
conn.require_has_table("osm2pgsql_test_roads");
|
|
}
|
|
|
|
TEST_CASE("liechtenstein slim regression simple")
|
|
{
|
|
REQUIRE_NOTHROW(db.run_file(testing::opt_t().slim(),
|
|
"liechtenstein-2013-08-03.osm.pbf"));
|
|
|
|
auto conn = db.db().connect();
|
|
require_tables(conn);
|
|
|
|
REQUIRE(1342 == conn.get_count("osm2pgsql_test_point"));
|
|
REQUIRE(3231 == conn.get_count("osm2pgsql_test_line"));
|
|
REQUIRE(375 == conn.get_count("osm2pgsql_test_roads"));
|
|
REQUIRE(4130 == conn.get_count("osm2pgsql_test_polygon"));
|
|
|
|
// Check size of lines
|
|
conn.assert_double(
|
|
1696.04,
|
|
"SELECT ST_Length(way) FROM osm2pgsql_test_line WHERE osm_id = 1101");
|
|
conn.assert_double(1151.26,
|
|
"SELECT ST_Length(ST_Transform(way,4326)::geography) "
|
|
"FROM osm2pgsql_test_line WHERE osm_id = 1101");
|
|
|
|
conn.assert_double(
|
|
311.289,
|
|
"SELECT way_area FROM osm2pgsql_test_polygon WHERE osm_id = 3265");
|
|
conn.assert_double(
|
|
311.289,
|
|
"SELECT ST_Area(way) FROM osm2pgsql_test_polygon WHERE osm_id = 3265");
|
|
conn.assert_double(143.845,
|
|
"SELECT ST_Area(ST_Transform(way,4326)::geography) FROM "
|
|
"osm2pgsql_test_polygon WHERE osm_id = 3265");
|
|
|
|
// Check a point's location
|
|
REQUIRE(1 == conn.get_count("osm2pgsql_test_point",
|
|
"ST_DWithin(way, 'SRID=3857;POINT(1062645.12 "
|
|
"5972593.4)'::geometry, 0.1)"));
|
|
}
|
|
|
|
TEST_CASE("liechtenstein slim latlon")
|
|
{
|
|
REQUIRE_NOTHROW(db.run_file(testing::opt_t().slim().srs(PROJ_LATLONG),
|
|
"liechtenstein-2013-08-03.osm.pbf"));
|
|
|
|
auto conn = db.db().connect();
|
|
require_tables(conn);
|
|
|
|
REQUIRE(1342 == conn.get_count("osm2pgsql_test_point"));
|
|
REQUIRE(3229 == conn.get_count("osm2pgsql_test_line"));
|
|
REQUIRE(374 == conn.get_count("osm2pgsql_test_roads"));
|
|
REQUIRE(4130 == conn.get_count("osm2pgsql_test_polygon"));
|
|
|
|
// Check size of lines
|
|
conn.assert_double(
|
|
0.0105343,
|
|
"SELECT ST_Length(way) FROM osm2pgsql_test_line WHERE osm_id = 1101");
|
|
conn.assert_double(1151.26,
|
|
"SELECT ST_Length(ST_Transform(way,4326)::geography) "
|
|
"FROM osm2pgsql_test_line WHERE osm_id = 1101");
|
|
|
|
conn.assert_double(
|
|
1.70718e-08,
|
|
"SELECT way_area FROM osm2pgsql_test_polygon WHERE osm_id = 3265");
|
|
conn.assert_double(
|
|
1.70718e-08,
|
|
"SELECT ST_Area(way) FROM osm2pgsql_test_polygon WHERE osm_id = 3265");
|
|
conn.assert_double(143.845,
|
|
"SELECT ST_Area(ST_Transform(way,4326)::geography) FROM "
|
|
"osm2pgsql_test_polygon WHERE osm_id = 3265");
|
|
|
|
// Check a point's location
|
|
REQUIRE(1 == conn.get_count("osm2pgsql_test_point",
|
|
"ST_DWithin(way, 'SRID=4326;POINT(9.5459035 "
|
|
"47.1866494)'::geometry, 0.00001)"));
|
|
}
|
|
|
|
TEST_CASE("way area slim flatnode")
|
|
{
|
|
REQUIRE_NOTHROW(db.run_file(testing::opt_t().slim().flatnodes(),
|
|
"test_output_pgsql_way_area.osm"));
|
|
|
|
auto conn = db.db().connect();
|
|
require_tables(conn);
|
|
|
|
REQUIRE(0 == conn.get_count("osm2pgsql_test_point"));
|
|
REQUIRE(0 == conn.get_count("osm2pgsql_test_line"));
|
|
REQUIRE(0 == conn.get_count("osm2pgsql_test_roads"));
|
|
REQUIRE(1 == conn.get_count("osm2pgsql_test_polygon"));
|
|
}
|
|
|
|
TEST_CASE("route relation slim flatnode")
|
|
{
|
|
REQUIRE_NOTHROW(db.run_file(testing::opt_t().slim().flatnodes(),
|
|
"test_output_pgsql_route_rel.osm"));
|
|
|
|
auto conn = db.db().connect();
|
|
require_tables(conn);
|
|
|
|
REQUIRE(0 == conn.get_count("osm2pgsql_test_point"));
|
|
REQUIRE(2 == conn.get_count("osm2pgsql_test_line"));
|
|
REQUIRE(1 == conn.get_count("osm2pgsql_test_roads"));
|
|
REQUIRE(0 == conn.get_count("osm2pgsql_test_polygon"));
|
|
}
|
|
|
|
TEST_CASE("liechtenstein slim bz2 parsing regression")
|
|
{
|
|
REQUIRE_NOTHROW(db.run_file(testing::opt_t().slim(),
|
|
"liechtenstein-2013-08-03.osm.bz2"));
|
|
|
|
auto conn = db.db().connect();
|
|
require_tables(conn);
|
|
|
|
REQUIRE(1342 == conn.get_count("osm2pgsql_test_point"));
|
|
REQUIRE(3231 == conn.get_count("osm2pgsql_test_line"));
|
|
REQUIRE(375 == conn.get_count("osm2pgsql_test_roads"));
|
|
REQUIRE(4130 == conn.get_count("osm2pgsql_test_polygon"));
|
|
}
|