2013-06-05 14 views
12

Kiedy patrzę w górę specyfikacje GeoJSON widzę, że okręgi są obsługiwane:kręgach geojsona, obsługiwane czy nie?

http://geopriv.dreamhosters.com/geojson/geojson-spec.html#circleExample

Kiedy wypróbować kod w geojsonlint (http://geojsonlint.com/) Jednakże, to daje mi błąd.

Wejście:

{ 
"type": "Circle", 
"coordinates": [4.884, 52.353], 
"radius": 200 
} 

Daje:

"Circle" is not a valid GeoJSON type. 

chcę pokazać różne miejsca zainteresowań z zakresu oddziaływania na mapie za pomocą D3. Do wprowadzenia potrzebny jest GeoJson, ale czy to prawda, że ​​kręgi nie są obsługiwane przez GeoJson?

+0

caould zastąpić 'L.Circle.toGeoJSON()', aby dodać dodatkowe właściwości, aby wskazać, że punkt powinien być reprezentowany jako okrąg: https://github.com/Leaflet/Leaflet/issues/2888 Pomimo, iż to nie jest standard, daje ci metadane, aby wiedzieć, że reprezentują cię jako okrąg. –

+0

Ach tak, ale to zostanie rozwiązane przy użyciu apletu Ulotka. To działałoby, ale nie używałbyś geojsona per se, używałbyś funkcji dostarczanej przez ulotkę. D3 oferowałoby podobne rozwiązanie, niezależne od używanej biblioteki mapującej. – cantdutchthis

Odpowiedz

19

Kiedy patrzę w górę specyfikacje GeoJSON widzę, że okręgi są obsługiwane

nie są. Wygląda na to, że udało Ci się znaleźć fałszywe lub nieprawidłowe specyfikacje. Przejdź do geojson.org, aby znaleźć specs, nie ma nic na temat kręgów.

+1

Myślę, że znalazł coś w wersji roboczej lub propozycji, jak tutaj https://github.com/geojson/geojson-spec/issues/1 lub https://github.com/geojson/geojson-spec/wiki/Proposal--- Kręgi-i-elipsy-Geomy –

2

Brak wsparcia koło z GeoJSON, ale można użyć LineString symulować koło

użyć LineString geiometry sprzeciw

"geometry": { 
     "type": "LineString", 
     "coordinates": [ 
        [center_X, center_y], 
        [center_X, center_y] 
       ] 
     } 
then set the dynamic style use radius as the strokeweight 
function featureStyle(feature){ 
    return { 
     strokeWeight: radius, 
    }; 
    } 

wygląda jak okrąg na mapie.

+0

Można również zrobić z 'Point', jestem prawie pewien ... –

-1
A circle... some code I use for making a circle for an OpenStreetMap 

-- x is decimal latitude 
-- y is decimal longitude 
-- r is radius -- .00010 is about 40m in OSM (3 about 50km) 

-- Adjust for map latitude distortion further north or south 

x = math.log(math.tan((90 + x) * math.pi/360))/(math.pi/180) 

-- For loop to gather all the points of circle here 1 to 360 
-- can also use the for loop to make some other interesting shapes 

for i = 1, 360 do 
    angle = i * math.pi/180 
    ptx = x + r * math.cos(angle) 
    pty = y + r * math.sin(angle) 

-- readjust latitude for map distortion 

    ptx = 180/math.pi * (2 * math.atan(math.exp(ptx * math.pi/180)) - math.pi/2) 

-- Build an array of positions for GeoJSON - formatted lat and long 

    data[i] = '[' .. string.format("%.6f",pty) .. "," 
    data[i] = data[i] .. string.format("%.6f",ptx) .. ']' 

-- End of for loop 
end 

-- Cycle through the data array with another for loop to build the 
    coordinates (put in brackets and commas etc. for the actual 
    GeoJSON coordinates string. Add data[1] to the end to close 
    the polygon (circle). A circle. 

-- If you want a solid circle then use fill and a hex color 
-- If you want a LineString just make fill invisible or #ffffff 
     Include the stroke-width and stroke-color parameters as well. 
-- If latitude is greater than 89.5 or less than -89.5 you may wish 
    to cut off the circle by drawing a line at polar regions by using 
    those latitudes. 
-- I use this simply for several circles and not for hundreds of them. 

Cheers! 
-- 
+2

Witaj w SO! Pamiętaj, że to pytanie pochodzi z 2013 roku (4 lata temu!). Oczywiście nadal możesz odpowiadać na stare posty, ale w takim przypadku upewnij się, że odpowiedź jest lepsza niż poprzednia. Może to być spowodowane nową technologią, biblioteką itp. W tym konkretnym przypadku nie jestem jednak pewien, czy Twój post zawiera odpowiedź na pytanie: nie chodzi o to, jak narysować okrąg, ale jeśli metadane koła są ważne w GeoJSON format. – ghybs

Powiązane problemy