anchor.diff:      v1 := KMPointF(fNodes[i1].Loc.X, fNodes[i1].Loc.Y);
       v2 := KMPointF(fNodes[i2].Loc.X, fNodes[i2].Loc.Y);
       v3 := KMPointF(fNodes[i3].Loc.X, fNodes[i3].Loc.Y);
  -    //CenterPoint := KMPoint( Round((v1.X+v2.X+v3.X)/3), Round((v1.Y+v2.Y+v3.Y)/3) );
  -    fPolygons[I].CenterPoint := KMPoint( Round((v1.X+v2.X+v3.X)/3), Round((v1.Y+v2.Y+v3.Y)/3) );
  +    // Center point must be inside of map coords
  +    fPolygons[I].CenterPoint := KMPoint(
  +                                         Min(  gTerrain.MapX-1, Max( 1, Round((v1.X+v2.X+v3.X)/3) )  ),
  +                                         Min(  gTerrain.MapY-1, Max( 1, Round((v1.Y+v2.Y+v3.Y)/3) )  )
  +                                       );
   
       MinPoint.X := Min(  Min( fNodes[i1].Loc.X, fNodes[i2].Loc.X ), fNodes[i3].Loc.X  );
       MinPoint.Y := Min(  Min( fNodes[i1].Loc.Y, fNodes[i2].Loc.Y ), fNodes[i3].Loc.Y  );
  
positive.code:   var
      SecondPoint: Boolean;
      I,K,L, ToIdx: Integer;
      Indices: array[0..1] of Word;
    begin
      for I := 0 to fPolygons[aIdx].NearbyCount - 1 do
  
negative.code:           SecondPoint := True;
            break;
          end;
         P := KMPointAverage(fNodes[ Indices[0] ].Loc, fNodes[ Indices[1] ].Loc);
         fPolygons[aIdx].NearbyPoints[I] := KMPoint(
                                                     Min( gTerrain.MapX-1, Max(1,P.X) ),
                                                     Min( gTerrain.MapY-1, Max(1,P.Y) )
                                                    );
      end;
    end;
  var
  