Граф коммитов

88 Коммитов

Автор SHA1 Сообщение Дата
Jason Davies 3d84b49ae4 Better handling of ambiguous centroids.
Rather than doing something like picking the last seen point, return
an undefined centroid if it is ambiguous.

Users can decide what to do, e.g. when picking an origin for a rotating
globe, using the last coordinate in a MultiPoint or LineString seems
reasonable in an ambiguous situation.
2012-12-13 12:48:52 +00:00
Jason Davies b87bcbc22a Implement d3.geo.centroid via d3.geo.stream. 2012-12-13 12:22:41 +00:00
Jason Davies b8ab3ad3ef Benchmark U.S. counties.
This is useful to see how fast we can process polygons that don't
intersect with the clip edge.
2012-12-13 10:57:38 +00:00
Mike Bostock 1c529da03e Silence bogus test failures. 2012-12-12 21:22:54 -08:00
Jason Davies 37f64b74f2 Fix streaming polygon clipping. 2012-12-13 02:01:04 +00:00
Mike Bostock 08b4357087 Don't emit closing points in rings.
This breaks d3.geo.path area & centroid, and d3.geo.area. Fix incoming.
2012-12-12 16:54:58 -08:00
Mike Bostock 32e13768bd Merge branch 'geo-refactor' of https://github.com/jasondavies/d3 into 3.0 2012-12-12 14:13:03 -08:00
Mike Bostock 2e88ce7f03 Add tests for d3.geo.stream. 2012-12-12 13:56:41 -08:00
Jason Davies 33e24962be Refactor clipping to use streams.
Work in progress: everything is treated as lines at the moment.
2012-12-12 21:33:59 +00:00
Jason Davies 876a6542d8 Minor optimisation. 2012-12-12 13:51:10 +00:00
Jason Davies b1d078db1a More robust handling of polygons with empty ring(s).
This is a valid situation but won't usually happen at the moment since
we don't return empty rings when clipping.
2012-12-12 12:01:36 +00:00
Jason Davies 913173ea7f Graticule: s/GeometryCollection/MultiLineString. 2012-12-12 11:57:25 +00:00
Jason Davies 31d59cfc93 Fix d3.geo.circle.origin. 2012-12-12 08:51:31 +00:00
Jason Davies eb7a56e943 Simplify.
This includes a minor tweak to d3_geo_type to avoid errors if the object
is null e.g. due to being removed by clipping.
2012-12-12 00:11:08 +00:00
Jason Davies bc06b2ec57 Refactor d3.geo.projection to be more data-driven. 2012-12-11 21:43:14 +00:00
Jason Davies 34180a7485 More accurate winding order check. 2012-12-10 23:09:14 +00:00
Jason Davies 7dfdcda0b2 d3.geo.area: fix holes. 2012-12-10 12:01:36 +00:00
Jason Davies a9e47f3b8a d3.geo.area: improve handling of tiny polygons. 2012-12-09 20:46:14 +00:00
Jason Davies e0c91c1e27 d3.geo.area: return positive areas. 2012-12-09 20:32:01 +00:00
Jason Davies 7860b0d31e Add d3.geo.area.
See #941.
2012-12-09 19:42:05 +00:00
Jason Davies 2467834ec2 Add d3.geo.centroid.
Polygons are temporarily treated as lines while I work on adding area
weighting.

See #941.
2012-12-09 11:29:29 -08:00
Jason Davies 86e159872f s/º/°/g 2012-12-08 14:48:54 +00:00
Jason Davies 531b443c09 Take into account clipping when computing centroids. 2012-12-05 21:30:13 +00:00
Jason Davies bf180cb8a0 Take into account clipping when computing areas.
This can be optimised later.
2012-12-05 20:35:50 +00:00
Jason Davies 25098ab0ff Add Sphere centroid and area. 2012-12-05 20:04:18 +00:00
Jason Davies 050b1c319e Define a new "Sphere" GeoJSON type.
This allows us to generate the clip outline for whole-earth projections
with arbitrary rotations.

Internally, this is interpreted as a polygon with null coordinates.
2012-12-05 18:39:57 +00:00
Jason Davies 36702f197f Revert "Restore support for empty & ccw polygons."
This reverts commit 7712dcd59e.

Unfortunately, this caused empty polygons to be interpreted as "the
whole sphere", which is undesirable.  Also, it is more useful to have a
definite graticule outline, at least for a graticule that doesn't cover
the whole sphere.
2012-12-05 18:16:35 +00:00
Mike Bostock 7712dcd59e Restore support for empty & ccw polygons. 2012-12-05 09:48:24 -08:00
Jason Davies 4d268a7966 Add some test cases for small U.S. counties.
These were originally anticlockwise in examples/data/us-counties.  I
have corrected the ordering for these tests.
2012-12-05 09:14:07 -08:00
Jason Davies e6ab7219b8 Detect polygon direction using area calculation.
This fixes various problems that were occurring due to winding numbers
being tricky on a finite sphere.

This also includes some cleanup and fixes for degenerate points.
2012-12-05 09:14:07 -08:00
Jason Davies acbce53ec5 Fix antemeridian clip point ordering. 2012-12-05 09:13:51 -08:00
Jason Davies 210085d3ea Fix antemeridian degeneracy handling. 2012-12-05 09:13:13 -08:00
Jason Davies f58b5db715 Fix path.centroid for polygons with holes.
The centroid was not being subtracted for interior polygon rings
(holes), hence it was appearing too far to the right.  The winding order
is ignored.
2012-12-04 20:56:14 +00:00
Jason Davies ba8c8ce170 Add benchmarks and performance improvement.
Dense graticule: 140→110ms/op.
Circle polygons: 69→61ms/op.
Spiral polygons: 3.3→2.6ms/op.
2012-11-21 15:35:44 +00:00
Jason Davies cba8a77bad Improve Polygon clipping.
1. We no longer perform an equality check on GeoJSON polygon endpoints,
since we know that the first and last points should be equal.
2. However, there are special cases where a polygon just touches the
clip edge, generating two coincident intersection points.  Here we avoid
generating a coincident point, and continue as normal.
3. Another special case is where we have coincident intersection points
e.g. due to a self-intersecting polygon.  Here we continue calculating
the winding number as if this is a closed polygon (so we know whether to
insert a polygon around the whole clip edge).
2012-11-20 22:20:54 +00:00
Jason Davies 28fb58b635 Fix polygon clipping. 2012-11-19 13:05:43 +00:00
Mike Bostock 2fc940787f Delete d3.geo.circle clip test. 2012-11-18 10:16:01 -08:00
Mike Bostock 3297cf23e0 Collection centroids are undefined.
It's not always meaningful to define the centroid of a collection because
collections are heterogenous: they can contain points, lines, polygons, or all
these types together. The previous code ignored objects that had dimensionality
lower than the collection's maximum dimensionality; for example, ignoring lines
and points if the collection contains polygons. While this may be what you want,
this feels magical and it's simpler to just define the centroid as undefined.
I'd prefer to force the user to state what they want explicitly, say by creating
a MultiPolygon that merges together a collection's polygons.
2012-11-18 08:40:57 -08:00
Jason Davies ad30a774f0 Add another resampling test for points near poles.
This tests the fix in 091f389499.
2012-11-16 09:35:37 +00:00
Jason Davies f9f4e265f4 Add tests for longitude wrapping. 2012-11-16 09:08:46 +00:00
Jason Davies fbbbfbf239 Add failing test case for Albers artefacts. 2012-11-14 14:51:11 +00:00
Jason Davies dbd0745a8b Another fix for d3.geo.circle Polygon exteriors. 2012-11-14 14:07:33 +00:00
Jason Davies 0bb3d29539 Fix d3.geo.circle Polygon exterior insertion. 2012-11-14 13:24:16 +00:00
Jason Davies 18de5cd5c1 Fix d3.geo.circle clipping of [Multi]Point. 2012-11-14 12:44:29 +00:00
Jason Davies 8ac44493ce Fix resampling along antemeridian. 2012-11-14 11:50:37 +00:00
Jason Davies 112ed8489a Update Phillipines test for d3.geo.albers. 2012-11-13 13:29:03 +00:00
Jason Davies 38c304b68d Add test for d3.geo.circle.
Fixes an error when no angle is explicitly set.
2012-11-10 21:57:56 +00:00
Mike Bostock 5cacd70702 Configurable graticule precision. 2012-10-29 19:49:35 -07:00
Jason Davies b04954bc9f Fix drawing of [Multi]Point geometries. 2012-10-25 18:31:12 +01:00
Jason Davies 3cf08d3df1 Add tests and fixes for d3.geo.path().centroid.
These are from #765.
2012-10-06 10:11:47 +01:00