forked from miurahr/lua-nginx-osm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
169 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,60 @@ | ||
local region = { | ||
{ | ||
{lon=112.1661,lat=9.000349}, | ||
{lon=112.1663,lat=7.666295}, | ||
{lon=116.9998,lat=7.666033}, | ||
{lon=117.9661,lat=6.86657}, | ||
{lon=117.9666,lat=6.28266}, | ||
{lon=118.3333,lat=5.999379}, | ||
{lon=118.8327,lat=5.999363}, | ||
{lon=119.5823,lat=5.266686}, | ||
{lon=118.9995,lat=4.700475}, | ||
{lon=118.9999,lat=4.442441}, | ||
{lon=120.0003,lat=4.382696}, | ||
{lon=120.0008,lat=4.749364}, | ||
{lon=127.073,lat=4.829195}, | ||
{lon=127.0742,lat=21.52734}, | ||
{lon=118.0067,lat=21.53021}, | ||
{lon=118.0067,lat=21.53021}, | ||
{lon=112.1661,lat=9.000349}, | ||
{lon=120.243353,lat=18.7611196}, | ||
{lon=120.155462,lat=18.6986925}, | ||
{lon=118.990911,lat=16.1201207}, | ||
{lon=119.869818,lat=14.4882875}, | ||
{lon=120.243353,lat=18.7611196}, | ||
}, | ||
{ | ||
{lon=117.496771,lat=9.65533149}, | ||
{lon=116.573919,lat=7.5480816}, | ||
{lon=117.518743,lat=7.70053038}, | ||
{lon=117.496771,lat=9.65533149}, | ||
}, | ||
{ | ||
{lon=123.451361,lat=6.78505247}, | ||
{lon=125.51679,lat=4.75205228}, | ||
{lon=127.450384,lat=6.95957071}, | ||
{lon=126.439642,lat=10.5638446}, | ||
{lon=125.868353,lat=12.5013593}, | ||
{lon=124.901556,lat=13.0798968}, | ||
{lon=123.451361,lat=6.78505247}, | ||
}, | ||
{ | ||
{lon=119.650091,lat=5.53987336}, | ||
{lon=119.166693,lat=4.77394906}, | ||
{lon=119.496283,lat=4.40161139}, | ||
{lon=123.451361,lat=6.78505247}, | ||
{lon=124.901556,lat=13.0798968}, | ||
{lon=119.650091,lat=5.53987336}, | ||
}, | ||
{ | ||
{lon=118.968939,lat=10.8660978}, | ||
{lon=117.496771,lat=9.65533149}, | ||
{lon=117.518743,lat=7.70053038}, | ||
{lon=118.375677,lat=6.30480588}, | ||
{lon=119.650091,lat=5.53987336}, | ||
{lon=124.901556,lat=13.0798968}, | ||
{lon=124.835638,lat=14.1902541}, | ||
{lon=118.968939,lat=10.8660978}, | ||
}, | ||
{ | ||
{lon=119.847845,lat=12.8871987}, | ||
{lon=118.968939,lat=10.8660978}, | ||
{lon=124.835638,lat=14.1902541}, | ||
{lon=122.6164,lat=15.4858593}, | ||
{lon=119.847845,lat=12.8871987}, | ||
}, | ||
{ | ||
{lon=120.243353,lat=18.7611196}, | ||
{lon=119.869818,lat=14.4882875}, | ||
{lon=119.847845,lat=12.8871987}, | ||
{lon=122.6164,lat=15.4858593}, | ||
{lon=122.94599,lat=18.4695965}, | ||
{lon=121.869329,lat=21.2590618}, | ||
{lon=121.869329,lat=21.2590618}, | ||
{lon=120.243353,lat=18.7611196}, | ||
}, | ||
} | ||
return region |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env lua5.1 | ||
|
||
package.path = '../?.lua' | ||
|
||
function table_print(t1) | ||
indent_string = string.rep(" ", 4) | ||
if t1 then | ||
for _, b in pairs(t1) do | ||
print('polygon:') | ||
for _, v in pairs(b) do | ||
print(indent_string,'lon=',v.lon,',lat=', v.lat) | ||
end | ||
end | ||
end | ||
end | ||
|
||
local osm_tile = require "osm.tile" | ||
local osm_data = require "osm.data" | ||
|
||
local regname = "philippines" | ||
|
||
print('Region: ', regname) | ||
print('tile.data test:') | ||
local region = assert(osm_data.get_region(regname)) | ||
print(' ok') | ||
table_print(region,0) | ||
|
||
print('ph (inside?):') | ||
local z = 17 | ||
local x = 110649 | ||
local y = 61763 | ||
assert(osm_tile.is_inside_region(region, x, y, z), 'expected true') | ||
print(' ok') | ||
|
||
print('ph davao (inside?):') | ||
local z = 17 | ||
local x = 111268 | ||
local y = 62952 | ||
assert(osm_tile.is_inside_region(region, x, y, z), 'expected true') | ||
print(' ok') | ||
|
||
print('ph manila (inside?):') | ||
local z = 12 | ||
local x = 3424 | ||
local y = 1880 | ||
assert(osm_tile.is_inside_region(region, x, y, z), 'expected true') | ||
print(' ok') | ||
|
||
print('ph mapun (inside?):') | ||
local z = 16 | ||
local x = 54341 | ||
local y = 31486 | ||
assert(osm_tile.is_inside_region(region, x, y, z), 'expected false') | ||
print(' ok') | ||
|
||
print('ph (outside?):') | ||
local z = 14 | ||
local x = 12783 | ||
local y = 8178 | ||
assert(not osm_tile.is_inside_region(region, x, y, z), 'expected false') | ||
print(' ok') | ||
|
||
|
||
-- japan | ||
print('japan (outside?):') | ||
local z = 18 | ||
local x = 233816 | ||
local y = 100256 | ||
assert(not osm_tile.is_inside_region(region, x, y, z), 'expected false') | ||
print(' ok') | ||
|
||
-- kurgan | ||
print('kurgan (outside):') | ||
local z = 17 | ||
local x = 89319 | ||
local y = 41167 | ||
assert(not osm_tile.is_inside_region(region, x, y, z), 'expected false') | ||
print(' ok') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kml xmlns="http://www.opengis.net/kml/2.2"> | ||
<Document> | ||
<name>Shapes</name><Style id="thickLine"><LineStyle><width>2.5</width></LineStyle></Style> | ||
<Style id="transparent50Poly"><PolyStyle><color>7fffffff</color></PolyStyle></Style> | ||
<Placemark> | ||
<name>Shape</name> | ||
<description>Shape</description> | ||
<Polygon><outerBoundaryIs><LinearRing><coordinates> | ||
120.24335283448795,18.761119645987616,0 | ||
121.86932939698795,21.25906181105591,0 | ||
122.94598955323795,18.469596489834544,0 | ||
122.61639970948795,15.485859298480339,0 | ||
124.83563799073795,14.190254122516004,0 | ||
124.90155595948795,13.079896847649955,0 | ||
125.86835283448795,12.501359285359891,0 | ||
126.43964189698795,10.563844565988205,0 | ||
127.45038408448795,6.959570707307809,0 | ||
125.51679033448795,4.752052283411461,0 | ||
123.45136064698795,6.785052465334246,0 | ||
119.49628252198795,4.401611389926859,0 | ||
119.16669267823795,4.773949061073163,0 | ||
119.65009111573795,5.539873360535281,0 | ||
118.37567705323795,6.304805884393846,0 | ||
117.51874345948795,7.700530375373683,0 | ||
116.57391924073795,7.548081596867926,0 | ||
117.49677080323795,9.655331486233719,0 | ||
118.96893877198795,10.86609784120241,0 | ||
119.84784502198795,12.887198695969015,0 | ||
119.86981767823795,14.48828748868609,0 | ||
118.99091142823795,16.120120730129614,0 | ||
120.15546220948795,18.69869251197727,0 | ||
120.24335283448795,18.761119645987616,0 | ||
</coordinates></LinearRing></outerBoundaryIs></Polygon><styleUrl>#transparent50Poly</styleUrl></Placemark> | ||
</Document> | ||
</kml> |