[OpenLayers-Dev] snapping

Tim Schaub tschaub at opengeo.org
Fri Jan 9 13:32:58 EST 2009


Hey-

Ivan Grcic wrote:
> Excellent work guys! It really works very nice!
> 
> But it always can get better :) my first questions were:
> 1) hmmm can it snap to coordinate grid? (for en example 1mx1m if its in meters)

This is a pretty simple case.  Since it is not really feature based 
snapping, it doesn't make sense to do in the snapping control.  With the 
new events added to the vector layer, you could do something like:

layer.events.on({
     vertexmodified: function(event) {
         var point = event.vertex;
         point.x = Math.round(point.x);  // "snap" to integer values
         point.y = Math.round(point.y);
     }
});

Same could be done for a sketch with the "sketchmodified" event.


> 2) hmmm can it snap to features intersections?

The data in that example is just hand drawn.  I scribbled those lines 
and didn't include vertices at intersections.  Typical data would have 
vertices at intersections - in which case you would get snapping.

If you want to split your geometries based on intersections, that is a 
different task - and a job for a Split control.  More on that next week.

Tim

> 
> But I guess you also have these and many others improvments in ur head
> for future versions ;)
> Tnx again!
> 
> On Fri, Jan 9, 2009 at 7:07 AM, Roald de Wit <roald.dewit at lisasoft.com> wrote:
>> Hi Tim, Jachym and fredj,
>>
>> This is great work!
>>
>> I think I mentioned it somewhere before: for me OpenLayers has by far
>> the most intuitive interface for editing features (compared to the OS
>> desktop alternatives that I tried). Snapping only makes it better!
>>
>> Cheers, Roald
>>
>> On Fri, 2009-01-09 at 10:00 +1030, Tim Schaub wrote:
>>> Hey-
>>>
>>> I done some work to create a snapping agent for vector editing [1].
>>> This extends (in spirit) the work started by jachym and continued by
>>> fredj [2].  The snapping agent is implemented as a single control that
>>> listens for vector layer events.
>>>
>>> This included a number of enhancements to the geometry classes and
>>> sketch handlers.  One particularly nice addition (in my opinion) is
>>> geometry.distanceTo for all geometry types.  I'll tease out this change
>>> and others to create specific tickets.
>>>
>>> If others are interested in snapping, see the wiki page for more details
>>> [3].  Add any comments if there are additional bits of functionality
>>> that should be considered.
>>>
>>> Tim
>>>
>>> [1] http://dev.openlayers.org/sandbox/topp/editing/examples/snapping.html
>>> [2] http://trac.openlayers.org/ticket/954
>>> [3] http://trac.openlayers.org/wiki/Proposal/Snapping
>>>
>> --
>> Roald de Wit
>> Software Engineer
>> roald.dewit at lisasoft.com
>>
>> Commercial Support for Open Source GIS Software
>> http://lisasoft.com/LISAsoft/SupportedProducts/
>>
>>
>> The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.
>> _______________________________________________
>> Dev mailing list
>> Dev at openlayers.org
>> http://openlayers.org/mailman/listinfo/dev
>>
> 
> 
> 


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Dev mailing list