Coder Social home page Coder Social logo

basonjui / hexagon-grid-system Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 3.9 MB

A simple API that can generate various types of hexagon grids - returns GeoJSON data or load into PostGIS with performant JDBC.

License: MIT License

Java 100.00%
geojson geometry java aws-lambda geospatial postgis grid-system hexagons tessellations postgresql

hexagon-grid-system's People

Contributors

basonjui avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hexagon-grid-system's Issues

calculation issue in hexagon API

Hello,
thanks for your work.
I have this sample which result a non-symmetric hexagon

{
    "latitude": 52.513337,
    "longitude": 13.326161,
    "radius": 10000
}

Optimize Tessellation algorithm: reduce required rings to produce grid map

Purpose

Reduce the overall required hexagons to produce a complete Grid Map, without sacrificing accuracy in coverage.

Criteria

  1. Grid map has less hexagons compare to previous algorithm
  2. Grid map must ensure coverage for given boundary, regardless of where Centroid is placed.

Benchmark

Previous algorithm output

------------Tessellation stats------------
Boundary: GisBoundary(minLat=21.0, minLng=105.0, maxLat=23.383333, maxLng=109.466667)
Great-circle distance: 531312.330953638
Minimum required rings: 616
Total hexagons: 1136521

GeoJSON constraint - Polygon positions follow Right-hand Rule

Descriptions

This issue cause hexagons to be flipped vertically when projected on maps (tested on www.geojson.io).

Sample data:

No major issue yet due to GeoJSON support backward compatibility.
But this cause our Hexagon's direction system to not work correctly. It will effect the following features:

  • To be fully control in generating hexagons in expected directions (visual).
  • Grouping of hexagons in expected directions (visual).

GeoJSON constraint

Right-hand rule

Tessellation miss 30 wards from `vietnam_ward_border`

Tessellation configurations

final Coordinates origin = new Coordinates(106, 15);

final Hexagon hexagon_750 = new Hexagon(origin, 750);

final Boundary oct_17_boundary = new Boundary(
                new Coordinates(102.050278, 23.583612),
                new Coordinates(109.666945, 8)
);

Missing wards data

ccid_q ccid_r ccid_s circumradius centroid geometry ward_id ward_name district_id district_name province_id province_name administrative_geometry
null null null null null null 3154.0 Sín Thầu 96 Mường Nhé 11 Điện Biên POINT (102.22693404451861 22.37376839966541)
null null null null null null 3155.0 Sen Thượng 96 Mường Nhé 11 Điện Biên POINT (102.32597044746589 22.44792037314389)
null null null null null null 3158.0 Leng Su Sìn 96 Mường Nhé 11 Điện Biên POINT (102.32155389898442 22.320728528880508)
null null null null null null 3436.0 Thu Lũm 107 Mường Tè 12 Lai Châu POINT (102.47324801688195 22.715096758175346)
null null null null null null 3439.0 Ka Lăng 107 Mường Tè 12 Lai Châu POINT (102.45663563379959 22.617095593839046)
null null null null null null 3440.0 Tá Bạ 107 Mường Tè 12 Lai Châu POINT (102.55995555988436 22.671490806607313)
null null null null null null 3442.0 Pa Ủ 107 Mường Tè 12 Lai Châu POINT (102.68397206470014 22.6087599213968)
null null null null null null 3445.0 Mường Tè 107 Mường Tè 12 Lai Châu POINT (102.59974568081792 22.52807723622943)
null null null null null null 3451.0 Mù Cả 107 Mường Tè 12 Lai Châu POINT (102.45925563226353 22.48466714633623)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (112.59551682806364 8.826195164890027)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (112.2241757177768 8.862732021740054)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (112.34957364357632 8.931247167582027)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (114.65611418149093 8.858338761852979)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (114.25707199321283 9.770336616886793)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (113.30626215426895 8.17209505311578)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (114.1827784398648 8.716716624024492)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (113.9843103415622 8.808466898212313)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (113.67028385782623 8.956693624282392)
null null null null null null 22737.0 Song Tử Tây 576 Trường Sa 56 Khánh Hòa POINT (114.33120353673795 11.430372852460769)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (112.92099934393683 7.893248290119303)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (111.92029892929641 8.645672344266185)
null null null null null null 22736.0 Trường Sa 576 Trường Sa 56 Khánh Hòa POINT (111.67431166558843 8.668642270379609)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (114.58389510275136 10.406012647190245)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (114.3737192835275 9.779630983937032)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (114.32984108529662 9.885713528221466)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (114.56411805958788 9.902507370954256)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (113.85441221897096 10.057525385647883)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (114.36616441592359 10.179277030671942)
null null null null null null 22739.0 Sinh Tồn 576 Trường Sa 56 Khánh Hòa POINT (114.48081871210499 10.376716528885602)
null null null null null null 22737.0 Song Tử Tây 576 Trường Sa 56 Khánh Hòa POINT (114.30158173759206 11.384901164645331)

Visualization of the problem

image

Top corner coordinates

latitude: 24.3628, longitude: 106.000

Left corner coordinates

latitude: 19.6814, longitude: 97.8916

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.