Hi, Below a function I use to snap the points of my features (point, line, polygon) programatically to a rounded value, so that the points lie all on a grid with a raster i.e 1000x1000 (SnapRadius=1000).
Arnd function ctrlDragFeature_SnapPoint(feature) { if(SnapRadius>0) { var objF = feature; geomType = objF.geometry.CLASS_NAME.replace(/OpenLayers.Geometry./,""); if(geomType=="Point") { objF.geometry.x = Math.round(objF.geometry.x/SnapRadius)*SnapRadius; objF.geometry.y = Math.round(objF.geometry.y/SnapRadius)*SnapRadius; } else if(geomType=="LineString") { for(var j=0;j<objF.geometry.components.length;j++) { objF.geometry.components[j].x = Math.round(objF.geometry.components[j].x/SnapRadius)*SnapRadius; objF.geometry.components[j].y = Math.round(objF.geometry.components[j].y/SnapRadius)*SnapRadius; } } else if(geomType=="Polygon") { var objFpt = objF.geometry.components[0].components; for(var i=0;i<objFpt.length;i++) { objFpt[i].x = Math.round(objFpt[i].x/SnapRadius)*SnapRadius; objFpt[i].y = Math.round(objFpt[i].y/SnapRadius)*SnapRadius; } objFpt[i-1].x = objFpt[0].x; } objF.layer.drawFeature(feature); } } -----Ursprüngliche Nachricht----- Von: users-boun...@openlayers.org [mailto:users-boun...@openlayers.org] Im Auftrag von ulao Gesendet: Montag, 16. August 2010 14:11 An: users@openlayers.org Betreff: Re: [OpenLayers-Users] edit points in Geometry of a vector? I'd like to do this programatically . -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/edit-points-in-Geometry-of-a-vector-t p5417230p5427609.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users