# Lucene Geo spatial3d - Failure creating a 3 dot polygon

**URL:** <https://discuss.elastic.co/t/lucene-geo-spatial3d-failure-creating-a-3-dot-polygon/101601>\
**Category:** Elasticsearch\
**Created:** [September 24, 2017, 1:18pm UTC](https://discuss.elastic.co/t/lucene-geo-spatial3d-failure-creating-a-3-dot-polygon/101601 "2017-09-24T13:18:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lior-k](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lior-k/32/18100_2.png) [@lior-k](https://discuss.elastic.co/u/lior-k)\
**Post date:** [September 24, 2017, 1:18pm UTC](https://discuss.elastic.co/t/lucene-geo-spatial3d-failure-creating-a-3-dot-polygon/101601/1 "2017-09-24T13:18:04Z")

</div>

Hi,

I'm trying to create a polygon from 3 GeoPoints, but I get this exception:

> java.lang.IllegalArgumentException: Convex polygon has a side that is more than 180 degrees  
> at org.apache.lucene.spatial3d.geom.GeoConvexPolygon.done(GeoConvexPolygon.java:237)  
> at org.apache.lucene.spatial3d.geom.GeoConvexPolygon.(GeoConvexPolygon.java:114)  
> at org.apache.lucene.spatial3d.geom.GeoPolygonFactory.findConvexPolygon(GeoPolygonFactory.java:1294)  
> at org.apache.lucene.spatial3d.geom.GeoPolygonFactory.buildPolygonShape(GeoPolygonFactory.java:817)  
> at org.apache.lucene.spatial3d.geom.GeoPolygonFactory.generateGeoPolygon(GeoPolygonFactory.java:278)  
> at org.apache.lucene.spatial3d.geom.GeoPolygonFactory.makeGeoPolygon(GeoPolygonFactory.java:116)  
> at org.apache.lucene.spatial3d.geom.GeoPolygonFactory.makeGeoPolygon(GeoPolygonFactory.java:67)

Same points on an older Lucene version (5.5.2) did create a convex polygon without any problem.

This is the code to recreate:

```
        ArrayList<GeoPoint> geoPoints = new ArrayList<>();
        GeoPoint A = new GeoPoint(0.018666906832587843, -0.734685195457333, 0.6775208545943724);
        GeoPoint B = new GeoPoint(0.02114286423885716, -0.7361764416720697, 0.6758386402661503);
        GeoPoint C = new GeoPoint(0.021142824333297772, -0.7361763954440932, 0.6758386915242299);
        geoPoints.add(A);
        geoPoints.add(B);
        geoPoints.add(C);
        GeoPolygon polygon = GeoPolygonFactory.makeGeoPolygon(PlanetModel.WGS84, geoPoints, null);

```

The last line is where the exception happens.

My goal is to measure distance between a GeoPoint and the convex polygon. for example, if I continue the code snippet from above:

```
        Pair<Double,Double> location = new Pair<>(1.0, 1.0);
        GeoPoint locationGeoPoint = new GeoPoint(PlanetModel.WGS84, location.fst * Math.PI / 180, location.snd * Math.PI / 180);
        double distance = polygon.computeOutsideDistance(DistanceStyle.NORMAL, locationGeoPoint) * Math.pow(180/Math.PI, 2);
        System.out.println("distance from polygon: " + distance);

```

Thanks in advance,  
Lior

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 26, 2017, 4:59am UTC](https://discuss.elastic.co/t/lucene-geo-spatial3d-failure-creating-a-3-dot-polygon/101601/2 "2017-09-26T04:59:29Z")

</div>

Forgive my obliviousness, but are you asking how to do this in Elasticsearch?

---

<div class="post-metadata">

**Author:** ![lior-k](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lior-k/32/18100_2.png) [@lior-k](https://discuss.elastic.co/u/lior-k)\
**Post date:** [September 26, 2017, 3:25pm UTC](https://discuss.elastic.co/t/lucene-geo-spatial3d-failure-creating-a-3-dot-polygon/101601/3 "2017-09-26T15:25:44Z")

</div>

Hi Mark.

No, I'm doing some post processing on my app after fetching from ES.  
I'm creating multiple Polygons (clustering several close points) & measure the distance between a given point and all other polygons.

Can you help?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 26, 2017, 10:57pm UTC](https://discuss.elastic.co/t/lucene-geo-spatial3d-failure-creating-a-3-dot-polygon/101601/4 "2017-09-26T22:57:24Z")

</div>

I can't sorry, I was just trying to understand a bit better what it's about to see if I could!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 24, 2017, 10:57pm UTC](https://discuss.elastic.co/t/lucene-geo-spatial3d-failure-creating-a-3-dot-polygon/101601/5 "2017-10-24T22:57:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
