Skip to content
This repository
Browse code

Add some asserts() to check multipolygon code

  • Loading branch information...
commit 3fc270d3a025123b5e483368d474a2004a2d595c 1 parent dc7dfdf
Jochen Topf authored

Showing 1 changed file with 19 additions and 13 deletions. Show diff stats Hide diff stats

  1. +19 13 include/osmium/osm/area.hpp
32 include/osmium/osm/area.hpp
@@ -22,6 +22,7 @@ You should have received a copy of the Licenses along with Osmium. If not, see
22 22
23 23 */
24 24
  25 +#include <assert.h>
25 26 #include <sys/types.h>
26 27 #include <string.h>
27 28 #include <stdio.h>
@@ -536,13 +537,13 @@ namespace Osmium {
536 537 vv->insert(vv->end(), coords->begin(), coords->begin() + cutoutend);
537 538 vv->insert(vv->end(), coords->begin() + cutoutstart, coords->end());
538 539 }
539   - geos::geom::CoordinateSequence *cs = geos::geom::CoordinateArraySequenceFactory::instance()->create(vv);
540   - geos::geom::LinearRing *a = Osmium::Geometry::geos_geometry_factory()->createLinearRing(cs);
  540 + geos::geom::CoordinateSequence* cs = geos::geom::CoordinateArraySequenceFactory::instance()->create(vv);
  541 + geos::geom::LinearRing* a = Osmium::Geometry::geos_geometry_factory()->createLinearRing(cs);
541 542
542 543 // if this results in a valid ring, return it; else return NULL.
543 544
544 545 if (!a->isValid()) return NULL;
545   - geos::geom::LinearRing *b = dynamic_cast<geos::geom::LinearRing *>(a->clone());
  546 + geos::geom::LinearRing* b = dynamic_cast<geos::geom::LinearRing *>(a->clone());
546 547 //delete a;
547 548 return b;
548 549 }
@@ -569,7 +570,9 @@ namespace Osmium {
569 570 }
570 571 }
571 572 for (int i=0; i<sequence; i++) {
572   - cs->add(dynamic_cast<geos::geom::LineString *>(sorted_ways[i]->way_geom)->getCoordinatesRO(), false, !sorted_ways[i]->invert);
  573 + geos::geom::LineString* linestring = dynamic_cast<geos::geom::LineString *>(sorted_ways[i]->way_geom);
  574 + assert(linestring);
  575 + cs->add(linestring->getCoordinatesRO(), false, !sorted_ways[i]->invert);
573 576 }
574 577 delete[] sorted_ways;
575 578 lr = Osmium::Geometry::geos_geometry_factory()->createLinearRing(cs);
@@ -923,8 +926,9 @@ namespace Osmium {
923 926 if (ringlist[i]->direction == CLOCKWISE) {
924 927 g->push_back(ringlist[i]->polygon->clone());
925 928 } else {
926   - geos::geom::LineString *tmp = dynamic_cast<geos::geom::LineString *>(ringlist[i]->polygon->getExteriorRing()->reverse());
927   - geos::geom::LinearRing *reversed_ring =
  929 + geos::geom::LineString* tmp = dynamic_cast<geos::geom::LineString *>(ringlist[i]->polygon->getExteriorRing()->reverse());
  930 + assert(tmp);
  931 + geos::geom::LinearRing* reversed_ring =
928 932 Osmium::Geometry::geos_geometry_factory()->createLinearRing(tmp->getCoordinates());
929 933 delete tmp;
930 934 g->push_back(Osmium::Geometry::geos_geometry_factory()->createPolygon(reversed_ring, NULL));
@@ -1009,12 +1013,13 @@ namespace Osmium {
1009 1013
1010 1014 for (unsigned int j=0; j<ringlist[i]->inner_rings.size(); j++) {
1011 1015 if (!ringlist[i]->inner_rings[j]->polygon) continue;
1012   - geos::geom::LinearRing *ring = (geos::geom::LinearRing *) ringlist[i]->inner_rings[j]->polygon->getExteriorRing();
  1016 + geos::geom::LinearRing *ring = (geos::geom::LinearRing *) ringlist[i]->inner_rings[j]->polygon->getExteriorRing(); // XXX cast is not const-correct!
1013 1017
1014 1018 if (ringlist[i]->inner_rings[j]->direction == CLOCKWISE) {
1015 1019 // reverse ring
1016   - geos::geom::LineString *tmp = dynamic_cast<geos::geom::LineString *>(ring->reverse());
1017   - geos::geom::LinearRing *reversed_ring =
  1020 + geos::geom::LineString* tmp = dynamic_cast<geos::geom::LineString*>(ring->reverse());
  1021 + assert(tmp);
  1022 + geos::geom::LinearRing* reversed_ring =
1018 1023 Osmium::Geometry::geos_geometry_factory()->createLinearRing(tmp->getCoordinates());
1019 1024 delete tmp;
1020 1025 holes->push_back(reversed_ring);
@@ -1023,14 +1028,15 @@ namespace Osmium {
1023 1028 }
1024 1029 }
1025 1030
1026   - geos::geom::LinearRing *ring = (geos::geom::LinearRing *) ringlist[i]->polygon->getExteriorRing();
  1031 + geos::geom::LinearRing* ring = (geos::geom::LinearRing*)ringlist[i]->polygon->getExteriorRing(); // XXX cast is not const-correct!
1027 1032 if (ringlist[i]->direction == COUNTERCLOCKWISE) {
1028   - geos::geom::LineString *tmp = dynamic_cast<geos::geom::LineString *>(ring->reverse());
1029   - geos::geom::LinearRing *reversed_ring = Osmium::Geometry::geos_geometry_factory()->createLinearRing(tmp->getCoordinates());
  1033 + geos::geom::LineString* tmp = dynamic_cast<geos::geom::LineString*>(ring->reverse());
  1034 + assert(tmp);
  1035 + geos::geom::LinearRing* reversed_ring = Osmium::Geometry::geos_geometry_factory()->createLinearRing(tmp->getCoordinates());
1030 1036 ring = reversed_ring;
1031 1037 delete tmp;
1032 1038 } else {
1033   - ring = dynamic_cast<geos::geom::LinearRing *>(ring->clone());
  1039 + ring = dynamic_cast<geos::geom::LinearRing*>(ring->clone());
1034 1040 }
1035 1041 delete ringlist[i]->polygon;
1036 1042 ringlist[i]->polygon = NULL;

0 comments on commit 3fc270d

Please sign in to comment.
Something went wrong with that request. Please try again.