Skip to content

JtsAdapter calculate polygon area wrong #37

@zxp209

Description

@zxp209

This's one of my data -----POLYGON ((116.378477 39.960438, 116.378312 39.960438, 116.378312 39.960344, 116.378371 39.960344, 116.378365 39.960303, 116.378347 39.960261, 116.378276 39.960261, 116.378276 39.96032, 116.377202 39.960297, 116.377205 39.960191, 116.378477 39.960197, 116.378477 39.960438))

I'd try to build my polygon with JtsAdapter.java

JtsLayer layer = new JtsLayer(layerName, geoms); JtsMvt mvt = new JtsMvt(singletonList(layer)); return MvtEncoder.encode(mvt);

But when I debug my code ,I found that
final List<VectorTile.Tile.Feature> features JtsAdapter.toFeatures(layerGeoms, layerProps, userDataConverter); features's size is zero.
So,I follow the JtsAdapter.java and I found

 // Area must be non-zero
                final double exteriorArea = CGAlgorithms.signedArea(exteriorRing.getCoordinates());
                if(((int) Math.round(exteriorArea)) == 0) {
                    continue;
                }

the result of area is negative,and decimal,like -0.0008944.So Math.round(-0.0008944) ==0 is true.
Is a problem with that?

jts version is 1.13,
<dependency>
			<groupId>com.wdtinc</groupId>
			<artifactId>mapbox-vector-tile</artifactId>
			<version>2.0.0</version>
		</dependency>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions