Git Product home page Git Product logo

Comments (23)

 avatar commented on June 19, 2024

This imports geojson to mongodb:

jq --compact-output ".features" 1051.geojson > extracted1051.geojson
mongoimport --db ctp -c ForestCompartmentBoundary --file "extracted1051.geojson" --jsonArray

from camera-trap-api.

 avatar commented on June 19, 2024

前端會使用的狀況請見 WF 2.8

/forest-compartment-boundary/overall
這個 endpoint 沒有要列出所有的樣區喔,這樣 API 的內容會很長

請只做 POST /forest-compartment-boundary 就好,如果沒有送出 query 座標就報錯

這裡預期前端是就地圖的中心位置來抓取林班地 polygon 來套疊

from camera-trap-api.

rwu823 avatar rwu823 commented on June 19, 2024

@cjk-halodule
wf 不是有一個全台灣的 overall 嗎 ?

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

POST /forest-compartment-boundary
這個可否協助加上API文件, thanks

@cjk-halodule
這裡預期前端是就地圖的中心位置來抓取林班地 polygon 來套疊

  1. 所以前端只送中心點不考慮zoom size嗎?
  2. 只有移動地圖時才需要重call API對嗎?

from camera-trap-api.

 avatar commented on June 19, 2024
  1. leaflet 的 map.setZoom(9) // 9 以上才顯示
  2. yes

from camera-trap-api.

rwu823 avatar rwu823 commented on June 19, 2024

@oahehc

目前 API 用法就是送經緯度即可。

POST /forest-compartment-boundary

{
  "decimalLatitude": "24.564853",
  "decimalLongitude": "120.991452"
}

有 match 到就會回 MultiPolygon 的坐標,沒有就是空的

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

@rwu823
能否協助提供一組不會回空的座標供測試, thanks~

from camera-trap-api.

 avatar commented on June 19, 2024
{
  "decimalLatitude": "24.277863",
  "decimalLongitude": "121.151822"
}

不過目前應該會超大超慢。請確認有 geoJSON 丟出來就好。我還得轉 TopoJSON 才能供 Leaflet 套疊。

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

對於 response 的結構有點不太懂,
coordinates 的部分是三層的 array, 請問是有什麼原因嗎?

[
        {
            "_id": "5bfe9e866efcfc940977f5da",
			...
            "geometry": {
                "type": "MultiPolygon",
                "coordinates": [
                    [
                        [
                            [
                                121.1690969809685,
                                24.29407719915862
                            ],
                            [
                                121.1690788508802,
                                24.29407442028118
                            ],
							...
                        ]
                    ]
                ]
            }
        }
]

from camera-trap-api.

 avatar commented on June 19, 2024

表示多邊形的關係。請先別處理呈現,我還在試 topojson.

Sent with GitHawk

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

有考慮 center 變動範圍在某個幅度下就不要重送 api 嗎?
目前 map zoom-in/out 有時也會導致 center 小幅變動, 怕會對 server 負擔太大

from camera-trap-api.

 avatar commented on June 19, 2024

同意,請你設定一個合理的範圍,例如在目前的 zoom level 原中心移到 x 軸或 y軸的 1/3 以上?

from camera-trap-api.

 avatar commented on June 19, 2024

這兩天的研究下來,瞭解到將個別的 feature 轉成 topojson 對於體積並沒有多大幫助;純粹就體積來說,features 整個一起轉才能看到顯著差別。經過幾個程序得到目前已匯入 db 的 geojson:

# Reduce precision of the decimal value, limited to 5 places
# https://www.npmjs.com/package/geojson-precision
geojson-precision -p 5 1051.geojson rp-1051.geojson  // 176M to 83M

# https://mapshaper.org/ to reduce points to 23.5%
mapshaper rp-1051.geojson\
  -simplify percentage=23.5% visvalingam weighted keep-shapes stats\
  -o format=geojson ms-rp-1051.geojson // 83M to 20M

# Produce newline-delimited JSON with each feature as a line.
cat ms-rp-1051.geojson | jq -c '.features | .[]' > ms-rp-1051.jsonld

# Import to MongoDB
mongoimport --db ctp -c ForestCompartmentBoundary --file "ms-rp-1051.jsonld"

如此將原本 176M 的 geojson 縮到 20M, 3699 個 features 平均每個約 5.4K.

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

請你設定一個合理的範圍,例如在目前的 zoom level 原中心移到 x 軸或 y軸的 1/3 以上?
我覺得要看BE的計算邏輯, 目前FE只送中心座標並沒有送zoom size,
表示會撈多遠的範圍應該是BE決定的, 可能要看在目前撈取範圍下, 經緯度移動多少沒有必要重送API

from camera-trap-api.

 avatar commented on June 19, 2024

我是這樣想,後端只做 point-in-polygon 的計算,丟出目前中心點所在林班地的 geojson 多邊形供套疊。
後端其實沒有決定會撈多遠,如果送出的點剛好是一個超小的林班地,目前就只送那一個,所以不用考慮撈取範圍。zoom level 及前端地圖被使用者拖移了多少,我沒記錯的話 leaflet 應該知道,所以可以就如我說在目前的 zoom level 下中心移超過 1/3 再重送。

這個功能沒給使用者測試過,有回應了再看看是否細部調整。如何?

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

後端只做 point-in-polygon 的計算,丟出目前中心點所在林班地的 geojson 多邊形供套疊
所以只有目前中心點剛好落在林班地內才有資料對嗎?
如果是這樣當zoom level超過一定大小是否就沒必要再call API
(因為剛好落在林班地內的機會很低, 即便剛好打中顯示在地圖也是一個小點而已)

目前的 zoom level 下中心移超過 1/3 再重送
這部分要配合zoom level & 地圖大小來計算經緯度, 我先找一下合適的做法再update出來

from camera-trap-api.

 avatar commented on June 19, 2024

所以只有目前中心點剛好落在林班地內才有資料對嗎?
Yes
如果是這樣當zoom level超過一定大小是否就沒必要再call API
如前所說,超過9才call
這部分要配合zoom level & 地圖大小來計算經緯度, 我先找一下合適的做法再update出來
看來有點複雜,或是移動 0.05 度再送即可?

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

已補上 zoom level & 經緯度移動範圍判斷
TaiBIF/camera-trap-webapp#101

from camera-trap-api.

oahehc avatar oahehc commented on June 19, 2024

有遇到另一個問題, 這筆資料的 coordinates 內有多組 element,
想確認前端要怎麼顯示才是正確的 (我原本以為只會有一組資料)

_id: "5c03a64c6efcfc9409780666"
image

from camera-trap-api.

 avatar commented on June 19, 2024

@kelp404 我把林班地資料直接複製到目前的資料庫中?

from camera-trap-api.

 avatar commented on June 19, 2024

目前這個 endpoint 由 @moogoo78 接手,做法是:

  • 將 DB ctp 中 forestCompartmentBoundary 的資料複製到 cameraTrap
  • 將 Rocky 在 master-2018 branch 中的實作,按 v1 版實作在本版
  • 其餘 spec 同此一討論串

from camera-trap-api.

 avatar commented on June 19, 2024

@moogoo78

curl -v --cookie "" \
  --header "Content-Type: application/json" \
  --request GET \
  --data '{"decimalLatitude":24.564853,"decimalLongitude":120.991452}' \
  https://api-dev.camera-trap.tw/api/v1/forest-compartment-boundary | jq`

得到

{
  "message": "decimalLongitude: This field is required.\ndecimalLatitude: This field is required."
}

另外也缺文件喔。

from camera-trap-api.

 avatar commented on June 19, 2024

Verified. Document to clarify usage: http://bit.ly/2VKfuhb.

from camera-trap-api.

Related Issues (20)

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.