Comments (3)
Hi, I've added a testcase for the signed area 100197f
The signed area function assumes the polygon is closed (first point is the same as last point), maybe I should add a check on that.
In your simple triangle case it results in area == -1 (when polygon closed), its negative because polygon is defined clockwise. So I think the area calculation is correct?
I'll take an extra check on the CW/CCW issue you mention later this week.
from mapbox-vector-tile-cs.
Hi. In the definition seen in the 4.3.4.4 above, it is a positive area that is clockwise, not a negative area. This is because the Y axis is inverted. Your code claims a negative area is clockwise, but it is the opposite that is true.
public bool IsCW()
{
return SignedArea() < 0;
}
Here is your calculation for the signed area:
for (var i = 0; i < points.Count-1; i++)
{
sum = sum + (points[i].X * points[i + 1].Y - (points[i].Y * points[i + 1].X));
}
It is missing out the term for point[Count-1].X. This X value has to loop back to the point[0].Y. That is why it's called the shoelace formula, the X and Y values cross over, and the last X and Y values go back to the beginning.
Your code misses out the XnY1 and -X1Yn terms, where n is point.Count - 1. This corrects the sign of the area and also the area itself.
from mapbox-vector-tile-cs.
can you create a pr for the code changes involved?
from mapbox-vector-tile-cs.
Related Issues (20)
- Bugs in Attribute Parser ... HOT 4
- Issues with thread safety ... HOT 9
- Test TestMapzenTileFromUrl fails HOT 1
- Decryption of Encrypted Vector Tiles HOT 1
- Zero integer values lost on serialization HOT 16
- To Protobuf-net 3.0 HOT 1
- Question: Net Core 3.1 compaibility HOT 1
- Add support for vector tile spec version 2 HOT 1
- C#: How to encode vector tiles to be used in a mapbox endpoint HOT 2
- Is Grpc.AspNetCore implementation in the roadmap? HOT 2
- could not support new tile format. HOT 1
- Mapbox-vector-tile does not support MemoryStream HOT 3
- Nested geometry data arrays are not identified. HOT 4
- add support for polygon inner- and outerrings HOT 4
- Not supported in a UWP application HOT 3
- Using The package on UWP application with .pbf extention files. HOT 1
- Support older versions with polygons having outer/inner ring NOT coded by winding order HOT 4
- .Net Standard support HOT 3
- [Question] Mapbox vector tile server solution HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-vector-tile-cs.