spatial-go / geoos

A library provides spatial data and geometric algorithms
http://www.spatial-go.com
GNU Lesser General Public License v2.1
617 stars 130 forks source link

Is there a bug on BufferInMeter? #87

Closed jarcoug closed 2 years ago

jarcoug commented 2 years ago
  1. When I used the method on polygon, the result is not what I want.
  2. Remove the following code maybe more suitable or accurate? (reference postgis st_buffer and turf.js)
    centroid := geom.Centroid()
    width = measure.MercatorDistance(width, centroid.Lat())
xiaogu-space commented 2 years ago

Because in mercator scale factor is changed along the meridians . Can you provide sample data ?

jarcoug commented 2 years ago

Because in mercator scale factor is changed along the meridians . Can you provide sample data ?

Scale factor I understand, accuracy based on 3d map,if on 2d map, it maybe not need the scale factor, like turf.js buffer.

Polygon BufferInMeter comparison: Original geometry: polygon((114.041146 22.553089,114.041232 22.552118,114.042761 22.552152,114.043013 22.55295,114.042042 22.553327,114.041146 22.553089))

  1. BufferInMeter polygon buffer 100 meter result: POLYGON ((114.04089769218193 22.5538862907146, 114.0403366748081 22.552050366539866, 114.04278262334702 22.551322616035844, 114.04387538874555 22.552717726258393, 114.0423901459922 22.554091775665167, 114.04089769218193 22.5538862907146))

  2. turf.js(or postgis) polygon buffer 100 meter result: POLYGON ((114.04089769218197 22.553886290714484, 114.04179369218198 22.554124289339047, 114.04199347077368 22.55415540082962, 114.0421957177938 22.554144376016684, 114.04239014599214 22.554091775665054, 114.04336114599218 22.55371477775494, 114.04352471152406 22.553631858927076, 114.04366620027919 22.553519522652962, 114.04377950800645 22.55338261539289, 114.0438597462691 22.55322704367508, 114.04390345334679 22.553059519281078, 114.0439087435845 22.552887269687986, 114.04387538874543 22.552717726258443, 114.04362338874542 22.551919724914978, 114.04355180399293 22.55175844157698, 114.0434453103021 22.55161453118163, 114.04330860868826 22.55149434651581, 114.04314773365333 22.551403193031717, 114.04296978680112 22.55134509463328, 114.04278262334704 22.551322616035943, 114.04125362334703 22.551288615831556, 114.04108437548857 22.551299654550743, 114.0409203939583 22.551339886846975, 114.04076752860149 22.551407877456516, 114.04063123270724 22.551501200856777, 114.04051636846884 22.55161652779941, 114.04042703353083 22.551749744084066, 114.04036641481046 22.55189609733439, 114.04033667480823 22.552050366539856, 114.04025067480822 22.553021367015855, 114.04025356028689 22.553183730847028, 114.04029063741544 22.553342465111346, 114.04036048567424 22.55349148831553, 114.04046042899766 22.55362509103935, 114.04058663830112 22.553738154672022, 114.04073427818315 22.55382634751145, 114.04089769218197 22.553886290714484))

xiaogu-space commented 2 years ago

OK,We will fix this bug as soon as possible.

xiaogu-space commented 2 years ago

@jarcoug have fix this bug.