MapWindow 4 - Plugins : MapWindow Discussion Forum
Hi, I am trying to build adjacency matrices for the features in a vector layer by testing the interconnections between the respective features. I have experienced some problems in using "MapWinGIS.SelectMode.INTERSECTION". Basically I am using the following c
error in MapWinGIS.SelectMode.INTERSECTION
Posted by: naransula ()
Date: April 10, 2012 03:18AM

Hi,

I am trying to build adjacency matrices for the features in a vector layer by testing the interconnections between the respective features. I have experienced some problems in using "MapWinGIS.SelectMode.INTERSECTION".

Basically I am using the following code;

Public Module MyExample
Public Sub ScriptMain(ByRef m_MapWin As IMapWin)

Dim sh as new MapWinGIS.shapefile
Dim handle As Long
dim s1 as new MapWinGIS.shape
Dim ArrayShpCount As Integer = 0
Dim ArrayShp(ArrayShpCount) As Integer

sh = CType(m_MapWin.Layers(handle).GetObject, MapWinGIS.Shapefile)
s1 = sh.shape(0)
sh.SelectShapes(s1.Extents, 0.0, MapWinGIS.SelectMode.INTERSECTION, ArrayShp)

End Sub
End Module

The resulting Arrayshp does not include some IDs of the feature that actually intersect with the selected feature (s1). I attached a sample file to this message. If you try to select the features that intersect with s1 (ID=0) by using MapWinGIS.SelectMode.INTERSECTION, it could find any intersection between ID=0 and ID=4 features even through the respective features actually intersect each other.

I think some modifications are needed in the respective part of MapWindow GIS package to solve the problem associated with MapWinGIS.SelectMode.INTERSECTION.

Kind regards,


Burak

Attachments: select1.rar (1.3 KB)  
Options: ReplyQuote
Re: error in MapWinGIS.SelectMode.INTERSECTION
Posted by: pmeems ()
Date: April 10, 2012 04:14AM

You can increase the tolerance to search in a more wider area around your shape.
Do remember the shapes have an internal ID which don't need to be the same as your ID.
sf.SelectShapes() returns True is it finds one or more shapes.
Here's some documentation: [www.mapwindow.org]

--
Paul

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: error in MapWinGIS.SelectMode.INTERSECTION
Posted by: naransula ()
Date: April 10, 2012 08:42AM

When I increase the tolerance to search in a more wider area, features previously not selected can be selected. Nevertheless, those features which do not actually intersect with sı (ID=0) are also included in the resulting ArrayShp (I did not sent the original file that involves a large network of lines).

By the way I am checking the intersection through internal ID of the features by employing the following code for each feature ID included in ArrayShp;

for j = 0 to ArrayShp.Length - 1
mapwinutility.logger.msg("Testing Intersection: " & ArrayShp(j))
next j

for the first 4 features (0, 1, 2, 3) the result corresponds to the internal ID. But beginning from the 4th feature the correspondence between IDs is disturbed, signalling the failure in detection of the intersection between feature ID = 0 and feature ID = 4.

Best regards,


Burak

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: