I'm very new to R/Shiny/Leaflet.
I have a barebones working example where I can display points on map based on their lat/long in a table I pull from Oracle:
siteData <- conn %>% tbl(in_schema("SCHEMANAME", "TABLENAME")) %>% as.data.frame();
function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
setView(lng = -93.85, lat = 37.45, zoom = 4)
})
...
observe({
colorBy <- input$color
sizeBy <- input$size
leafletProxy("map", data = siteData) %>%
clearMarkers() %>%
addCircleMarkers(~LONGITUDE, ~LATITUDE,
popup=
~paste("ID: ", as.character(ID), "<br>",
"Latitude: ", as.character(LATITUDE) , "<br/>" ,
"Longitude: ", as.character(LONGITUDE) , "<BR/>"
),
clusterOptions=markerClusterOptions())
})
I have an additional table with polygons that I only want to show at certain zoom levels. Basically, once close-enough in, I want to take the IDs of the points currently in view, go to the db and pull the polygons whose IDs match.
I see the flow like this:
What is the current zoom level?
If the zoome level is appropriate, what are the visible points?
What are the IDs of the visible points?
SELECT * FROM details WHERE ID in (<set of ID's of visible points>)
and then render the returned polygons.
Many of the examples I see seem to assume that you have all the data you need in a single pull, and I don't want to draw that many polygons at once. I'd rather pay the toll for latency than browser memory.
====EDITED TO ADD====
The column that holds the polygon in the detail table is coded as:
SDO_GEOMETRY(
2003, -- two-dimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1), -- EXTERIOR POLYGON
SDO_ORDINATE_ARRAY(
LONGITUDE , LATITUDE ,
LONGITUDE + C.ROW_NUMBER*0.0001*COS(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2)), LATITUDE + C.ROW_NUMBER*0.0001*SIN(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2)) ,
LONGITUDE + C.ROW_NUMBER*0.0001*COS(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + B.BEAMWIDTH/4 )),LATITUDE + C.ROW_NUMBER*0.0001*SIN(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + B.BEAMWIDTH/4)) ,
LONGITUDE + C.ROW_NUMBER*0.0001*COS(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + 2*B.BEAMWIDTH/4)),LATITUDE + C.ROW_NUMBER*0.0001*SIN(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + 2*B.BEAMWIDTH/4)) ,
LONGITUDE + C.ROW_NUMBER*0.0001*COS(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + 3*B.BEAMWIDTH/4)),LATITUDE + C.ROW_NUMBER*0.0001*SIN(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + 3*B.BEAMWIDTH/4)) ,
LONGITUDE + C.ROW_NUMBER*0.0001*COS(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + 4*B.BEAMWIDTH/4)),LATITUDE + C.ROW_NUMBER*0.0001*SIN(0.017456329*(A.AZIMUTH - B.BEAMWIDTH/2 + 4*B.BEAMWIDTH/4)) ,
LONGITUDE , LATITUDE
)
) AS SECTORPOLYGON
SDO_GEOMETRY
type. Is this correct ? If so you need a spatial query that returns those polygons that interact with those points ?