2

The polygon may or may not be convex and cannot be rotated. The label is a rectangle that also cannot be rotated. I need the center of the biggest zone for placing the center of the label.

(Ideally would be to get a polygon of possible placements for the center of the label. That would allow disjointedly placing labels on overlapping polygons, but it would be too much...)

I'm using a Geometry Service (ESRI) which can test if a geometry (rectangle, polygon, etc) is inside another polygon (The irregular polygon.)

Not a very good solution

dbc
  • 104,963
  • 20
  • 228
  • 340
horiatu
  • 356
  • 2
  • 10
  • 2
    Maybe center it on the [maximum circle inside a non-convex polygon](http://stackoverflow.com/questions/4279478/maximum-circle-inside-a-non-convex-polygon). – dbc Aug 25 '14 at 23:21
  • That is an interesting point, and I'm going to investigate. Yet, from the very start it has a flaw: the label may be very wide and not so high, and may fit better in an area where the biggest circle does not fit! – horiatu Aug 26 '14 at 17:13
  • Can you help me to solve [This](https://stackoverflow.com/q/51627888/5081243) question Thanks in advance – Shreejay Pendse Aug 02 '18 at 13:46

1 Answers1

2

Actually, the solution was simple:

  1. Create four polygons by translating the original one with w, -w, h, -h where w and h are the semi-width and semi-height of the label.
  2. Intersect those four polygons.
  3. if the intersection is null - the label won't fit in the polygon. Exit.
  4. All points inside the intersection satisfy the requirement: place the center of the label in one of those points. enter image description here
horiatu
  • 356
  • 2
  • 10