Closed lklepner closed 2 years ago
:+1: many thanks!
given a clipped mask like this:
instead of showing this in the preview
it should show this:
So we need to get the bounds of the clip. The clip mask is in image pixel space and not lat / lon - so we need to use the control points and warp this mask and then get the bounds from that.
ogr2ogr -f 'geojson' -s_srs 'epsg:4326' -t_srs 'epsg:3857' -gcp 1014.7415730337, 387.3707865169, -4.8339843748, 27.3717672995 -gcp 2748.8539325843, 301.6179775281, 27.5097656239, 24.3671135617 -gcp 2086.6516853933, 1573.61797752809, 11.8652343745, 1.7575368112 /dev/stdout 40.gml
`var vector = new OpenLayers.Layer.Vector("GeoJSON", { projection: "EPSG:4326" }); warpedmap.addLayer(vector);
var gformat = new OpenLayers.Format.GeoJSON();
var geojson = { "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } }, "features": [ { "type": "Feature", "properties": { "gml_id": "OpenLayers.Feature.Vector_1062" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1473251.146541122812778, 1750757.330724694067612 ], [ -565473.037400622386485, 1677228.57177498540841 ], [ 147463.154717215918936, 121651.659036649682093 ], [ 1644856.532875066390261, 1304113.145248382119462 ], [ 2281665.7328170100227, 1386434.738192284712568 ], [ 3311048.52826199959964, 1472702.619407647522166 ], [ 3015320.313555198255926, -674648.850655971094966 ], [ -2732571.129231195896864, 106772.551659110293258 ], [ -2484078.486649194266647, 1429663.375425678445026 ], [ -1473251.146541122812778, 1750757.330724694067612 ] ] ] } } ] }; var features = gformat.read(geojson) vector.addFeatures(features); `
I've noticed that the bounds of the Preview window, which are determined by the clipmap_bounds_merc value, seem to be the bounds of the raw map, not the clipped map, causing zoomToMaxExtent to be offcenter and too wide (framing for the uncropped map).
Originally reported here - https://github.com/nypl-spacetime/nypl-warper/issues/45