Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

ST_ApproximateMedialAxis ERROR: straight skeleton of Polygon with touching interior rings is not implemented #138

Closed
ppenn opened this issue May 5, 2017 · 3 comments

Comments

@ppenn
Copy link

ppenn commented May 5, 2017

A polygon with 1 interior ring is causing this error but I'm not sure why -- the error seems to state there are multiple rings.

NOTICE: During approximate_medial_axis(A) :
ERROR: straight skeleton of Polygon with touching interior rings is not implemented

select st_approximatemedialaxis(st_geomfromtext('POLYGON((1925547.06715944 13587647.6,1925546.0802568 13587644.2080911,1925566.85674009 13587638.7784466,1925568.32749709 13587638.2352911,1925569.66407359 13587637.4157133,1925570.8151335 13587636.3511922,1925570.85 13587636.3031847,1925570.85 13587622.4070144,1925570.0505545 13587619.3425667,1925569.507843 13587617.8711903,1925568.68850829 13587616.5339638,1925567.624037 13587615.382276,1925566.355336 13587614.4603856,1925564.9311608 13587613.8037204,1925563.4062417 13587613.4375156,1925561.8391806 13587613.3758442,1925560.29019859 13587613.6210764,1925560.2934407 13587613.6202291,1925561.76458009 13587613.0768756,1925563.10144889 13587612.2569574,1925564.2526721 13587611.1919835,1925565.11802176 13587610,1925514 13587610,1925514 13587612.698902,1925524.15476353 13587647.6,1925547.06715944 13587647.6),(1925560.29019859 13587613.6210764,1925558.8188222 13587614.1637878,1925557.4815957 13587614.9831226,1925556.32990789 13587616.0475939,1925555.40801749 13587617.3162949,1925554.7513522 13587618.7404701,1925554.3851474 13587620.2653891,1925554.3234761 13587621.8324503,1925554.5687082 13587623.3814323,1925555.0744951 13587625.3202231,1925535.80126999 13587630.3570121,1925533.0064687 13587620.7515068,1925560.29019859 13587613.6210764))'));

@danielcu888
Copy link
Contributor

Confirmed and reproduced on Mac OS X with the following unit test:

BOOST_AUTO_TEST_CASE( testIssue138 )
{
  std::unique_ptr< Geometry > poly = io::readWkt( "POLYGON((1925547.06715944 13587647.6,1925546.0802568 13587644.2080911,1925566.8567\
4009 13587638.7784466,1925568.32749709 13587638.2352911,1925569.66407359 13587637.4157133,1925570.8151335 13587636.3511922,1925570.85\
 13587636.3031847,1925570.85 13587622.4070144,1925570.0505545 13587619.3425667,1925569.507843 13587617.8711903,1925568.68850829 13587\
616.5339638,1925567.624037 13587615.382276,1925566.355336 13587614.4603856,1925564.9311608 13587613.8037204,1925563.4062417 13587613.\
4375156,1925561.8391806 13587613.3758442,1925560.29019859 13587613.6210764,1925560.2934407 13587613.6202291,1925561.76458009 13587613\
.0768756,1925563.10144889 13587612.2569574,1925564.2526721 13587611.1919835,1925565.11802176 13587610,1925514 13587610,1925514 135876\
12.698902,1925524.15476353 13587647.6,1925547.06715944 13587647.6),(1925560.29019859 13587613.6210764,1925558.8188222 13587614.163787\
8,1925557.4815957 13587614.9831226,1925556.32990789 13587616.0475939,1925555.40801749 13587617.3162949,1925554.7513522 13587618.74047\
01,1925554.3851474 13587620.2653891,1925554.3234761 13587621.8324503,1925554.5687082 13587623.3814323,1925555.0744951 13587625.320223\
1,1925535.80126999 13587630.3570121,1925533.0064687 13587620.7515068,1925560.29019859 13587613.6210764))" );

  std::cout << algorithm::isValid( *poly ) << std::endl;
  std::cout << poly->as<Polygon>().numInteriorRings() << std::endl;
  std::unique_ptr< MultiLineString > result =  algorithm::approximateMedialAxis( *poly ) ;

  std::cout << result->asText() << std::endl;
}

with the following output:

fatal error: in "void SFCGAL::algorithm::(anonymous namespace)::checkNoTouchingHoles(const SFCGAL::Polygon &)": 3D/SFCGAL/src/algorithm/straightSkeleton.cpp(218): Throw in function void SFCGAL::algorithm::(anonymous namespace)::checkNoTouchingHoles(const SFCGAL::Polygon &)
Dynamic exception type: boost::wrapexcept<SFCGAL::NotImplementedException>
std::exception::what: straight skeleton of Polygon with touching interior rings is not implemented

Looking at the referenced code this appears to be a mistake in the error message, which should remove the word "interior" as it simply tests for point intersections between rings (this is equivalent to a point touch since point crossing intersections are excluded by isValid), as indicated by the comment immediately above it:

// Throw an exception if any two polygon rings touch,                                                                                 
// since CGAL segfaults in that case.      

Also confirmed that the above Polygon is valid, has a single interior ring that touches the exterior one.

danielcu888 added a commit to danielcu888/SFCGAL that referenced this issue Apr 22, 2020
… for straightskeleton regarding throwing notimplemented exception for polygon with touching rings.
@danielcu888
Copy link
Contributor

Raised PR #222 to update the error message and the documentation for the affected API functions.

mhugo pushed a commit that referenced this issue Apr 24, 2020
…aightskeleton regarding throwing notimplemented exception for polygon with touching rings.
@danielcu888
Copy link
Contributor

danielcu888 commented Apr 27, 2020

@lbartoletti @mhugo Since this is a feature rather than a bug, this ticket should be closed and an enhancement issue to implement this feature created, if so desired.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants