Opened 13 years ago

Closed 13 years ago

Last modified 3 years ago

#435 closed defect (fixed)

2d/3d overlay fails elevating all vertices

Reported by: strk Owned by: strk
Priority: major Milestone: 3.3.0
Component: Default Version: main
Severity: Content Keywords:
Cc:

Description

Intersection between these two lines

LINESTRING(0 0,0 10,10 10,10 0)
LINESTRING(10 10 4,10 0 5,0 0 5)

Results in a collection of a 3d point and a 2d line.

ElevationMatrix should instead be engaged to elevate everything.

Change History (8)

comment:1 by strk, 13 years ago

Owner: changed from geos-devel@… to strk
Status: newassigned

comment:2 by strk, 13 years ago

ElevationMatrix is doing the right thing. I suspect the problem depends on a geometry's getCoordinateDimension

comment:3 by strk, 13 years ago

Ok, problem is CoordinateSequence::getDimension which is using a cached 'dimension' member and not updating it after filtering.

Should be fixable by either avoiding the cache or properly maintaining it.

The caching code was introduced here:

commit ecffbba56f92f454dcdd8d5542c890439718a676
Author: warmerdam <warmerdam@5242fede-7e19-0410-aef8-94bd7d2200fb>
Date:   Mon May 31 16:25:57 2010 +0000

    Attempt to make geometry dimension perform more smoothly.
    Modified CoordinateArraySequence to default to unknown dimension (0), which
    is determined at the point getDimension() is called by examination of the
    first coordinate Z (ISNAN test).  The WKTWriter has also been altered to
    write 0.0 instead of nan, and to avoid writing "Z" for EMPTY geometries.(#348)
    
    
    git-svn-id: http://svn.osgeo.org/geos/trunk@2998 5242fede-7e19-0410-aef8-94bd7d2200fb

@FrankW : willing to take a look yourself ?

comment:4 by strk, 13 years ago

Clearing the cache in CoordinateArraySequence::apply_rw seems to fix it effectively.

comment:5 by strk, 13 years ago

Resolution: fixed
Status: assignedclosed

r3278 fixes by clearning the "dimension" cache in ::apply_rw

comment:6 by strk, 13 years ago

I dubt the cache makes sense, btw, as the way dimension is computed is by looking at a single Coordinate anyway, which doesn't take all that time...

comment:7 by warmerdam, 13 years ago

The dimension variable is used primarily so that at creation time the dimension can be set explicitly. For instance, it should be legal to have a geometry with all zero "Z" values but still having dimension 3 *or* 2.

I think it would be more appropriate for apply_rw() to reset a dimension of 2 to 3 if any of the filtered vertices have a non-NAN, non-zero Z coordinate after processing.

comment:8 by Sandro Santilli <strk@…>, 3 years ago

In 2ad9efe/git:

Port ElevationModel class from JTS

Closes #1070

Differences from JTS:

  • Cells are all initialized upfront, no heap allocations
  • CoordinateSequence::hasZ implemented as non-virtual
  • ElevationModel::populateZ uses CoordinateFilter instead of CoordinateSequenceFilter (see note 1)

Note1:

Using CoordinateFilter instead of CoordinateSequenceFilter
allows CoordinateSequence to clear the dimension cache which
would otherwise not properly set the sequence as having Z
(see #435)

Note: See TracTickets for help on using tickets.