pro mg_ogmap_example, projection, renderer=renderer, _extra=e
compile_opt strictarr
_projection = n_elements(projection) eq 0L ? 'cylindrical' : projection
map = map_proj_init(_projection)
statesFilename = filepath('states.shp', subdir=['examples', 'data'])
states = obj_new('IDLffShape', statesFilename)
view = obj_new('IDLgrView')
model = obj_new('IDLgrModel')
view->add, model
states->getProperty, n_entities=nEntities
for s = 0L, nEntities - 1L do begin
state = states->getEntity(s)
conn = [0]
for p = 0, state.n_parts - 1L do begin
startInd = (*state.parts)[p]
endInd = p eq state.n_parts - 1 $
? state.n_vertices $
: (*state.parts)[p + 1]
conn = [conn, endInd - startInd, lindgen(endInd - startInd) + startInd]
endfor
xy = map_proj_forward(*state.vertices, map_structure=map)
xyMax = max(xy, dimension=2, min=xyMin)
if (n_elements(viewMax) gt 0) then begin
viewMax >= xyMax
viewMin <
endif else begin
viewMax = xyMax
viewMin = xyMin
endelse
statePoly = obj_new('IDLgrPolyline', xy, polylines=conn[1:*], $
_extra=e)
model->add, statePoly
states->destroyEntity, state
endfor
obj_destroy, states
sz = viewMax - viewMin
view->setProperty, viewplane_rect=[viewMin, sz]
window = obj_new('IDLgrWindow', graphics_tree=view, title=_projection, $
dimensions=500 * [1, sz[1] / sz[0]], renderer=renderer)
window->draw
end
mg_ogmap_example, 'Stereographic'
mg_ogmap_example, 'Mercator'
mg_ogmap_example, 'Cylindrical'
end