MapWindow Developer Team : MapWindow Discussion Forum
Hello, I decided to shift some of the geoprocessing functions from my vb6 application to ocx. They'll work faster there and may be usefull for community, especially for people with non-net languages. Here is approximate list of what I plan to do: - coordinates
Pages: Previous12
Current Page: 2 of 2
Re: Re:Add ValidationError to last erro
Posted by: pmeems ()
Date: September 09, 2009 04:36AM

Sergei,

I like strict checks ;)
You shouldn't loosen them.
I can create a valid polygon now.
The points needed to be in counter-clockwise order and a part needs to be inserted at the end.

Now I can continue with building the test script.

--
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: New geoprocessing functions to ocx
Posted by: pmeems ()
Date: September 11, 2009 07:44AM

Sergei (and others),

I've added a new script to test most of these functions: TestingScripts/GeosMethods.cs

I do have some questions about some functions:
What is the difference of Intersects() and GetIntersection()?
The first one is checking if two shapes intersect and the second one is returning the shape that intersect. In both cases you end up knowing which shape intersect. Why two different calls?
This also applies to GetUnion, GetDifference, etc.

Thanks,

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
Shape.Clip - Union of disjoint shapes (Re: New geoprocessing functions to ocx)
Posted by: Mark Gray ()
Date: September 11, 2009 09:01AM

I have been using the new Shape.Clip with Union to merge two shapes. Usually it works fine and sometimes it works better than the NTS version, but it cannot merge shapes that are not adjacent to each other. I have started using the following code to merge shapes by adding the parts of one shape to the other if the Clip-Union fails:

With aCatchmentShapeFile
    Dim lTargetShape As MapWinGIS.Shape = aCatchmentShapeFile.Shape(lRecordKeptIndex).Clip(aCatchmentShapeFile.Shape(lRecordAddingIndex), MapWinGIS.tkClipOperation.clUnion)
    If lTargetShape IsNot Nothing Then
        .EditDeleteShape(lRecordKeptIndex)
        .EditInsertShape(lTargetShape, lRecordKeptIndex)
    Else
        Logger.Dbg("Shape Union Failed, merging by adding parts")
        Dim lToPointIndex As Integer = aCatchmentShapeFile.Shape(lRecordKeptIndex).numPoints
        For lFromPartIndex As Integer = 0 To aCatchmentShapeFile.Shape(lRecordAddingIndex).NumParts - 1
            Dim lLastFromPointIndex As Integer = aCatchmentShapeFile.Shape(lRecordAddingIndex).numPoints - 1
            If lFromPartIndex + 1 < aCatchmentShapeFile.Shape(lRecordAddingIndex).NumParts Then
                lLastFromPointIndex = aCatchmentShapeFile.Shape(lRecordAddingIndex).Part(lFromPartIndex + 1) - 1
            End If
            If lLastFromPointIndex >= lFromPartIndex Then
                aCatchmentShapeFile.Shape(lRecordKeptIndex).InsertPart(lToPointIndex, aCatchmentShapeFile.Shape(lRecordKeptIndex).NumParts)
                For lFromPointIndex As Integer = aCatchmentShapeFile.Shape(lRecordAddingIndex).Part(lFromPartIndex) To lLastFromPointIndex
                    aCatchmentShapeFile.Shape(lRecordKeptIndex).InsertPoint(aCatchmentShapeFile.Shape(lRecordAddingIndex).Point(lFromPointIndex), lToPointIndex)
                    lToPointIndex += 1
                Next
            End If
        Next
    End If
    For lFieldIndex As Integer = 0 To .NumFields - 1
        .EditCellValue(lFieldIndex, lRecordKeptIndex, lNewFieldValues(lFieldIndex))
    Next
    .EditDeleteShape(lRecordAddingIndex)
End With

Options: ReplyQuote
Re: New geoprocessing functions to ocx
Posted by: Sergei ()
Date: September 11, 2009 03:58PM

Hi,

Paul,
- Shape.Intersects is test for intersection of 2 shapes like you mention. Same call is used in Shape.Relates. Internally Shape.Intersects, Shape.Touches etc use Shape.Relates with different parameters (it’s easier to write one function with additional parameter than 8 similar functions). Correspondingly Shape.Relates (Intersection) will be faster than Shape.Intersects.
– I added GetIntersection method to shapefile class and it returns a shapefile which is intersection of 2 shapefiles. Initially I wanted to call it just "Intersecton" but this word was already used in SelectMode enumeration, and new method appeared in API like "INTERSECTION", so I prefered GetIntersection to avoid possible name conflicts.
– I hasn't found GetUnion, GetDifference methods in ocx API (???). I didn't make separate methods for polygon operations like union, difference, clip etc in shape class. Just Shape.Clip for all of them.
– Utils.ShapesIntersection is used to return all resulting shapes produced by intersection operation (with NextResultShape method). This method’s name is not very intuitive so possibly I’ll change it.
Sorry, but after all I don't understand what are you asking about. Am I too tired to think today? ;)

Mark,
I can’t answer right now why current implementation of union doesn’t merge non-adjacent shapes. But it’d be logical thing to teach it to do so. Thanks for information and code.

Regards,
Sergei

Options: ReplyQuote
Re: New geoprocessing functions to ocx
Posted by: Sergei ()
Date: September 13, 2009 02:24PM

Hello,

I've added Shapefile.Dissolve method to ocx. Have fun.

Mark, I looked at the problem with Shape.Clip. It's very easy to deal with. Just change:
if (RelateShapeExtents(this, Shape) == erNone)
to:
if (RelateShapeExtents(this, Shape) == erNone && Operation == clIntersection)
My CShape version is different from repository now and I’m not ready to commit these changes.

Regards,
Sergei

Options: ReplyQuote
Re: Shape.Clip - Union of disjoint shapes (Re: New geoprocessing functions to ocx)
Posted by: pmeems ()
Date: September 14, 2009 01:29AM

Sergei,

I'll add the new Dissolve method to the test shortly.

Thanks,

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: New geoprocessing functions to ocx
Posted by: pmeems ()
Date: October 09, 2009 03:15AM

Here's a nice presentation about the JTS Library. The GEOS library is a C++ wrapper of JTS.

New functions are not yet mentioned but it gives a nice impression.

jts_secrets_foss4g2007.pdf

--
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: New geoprocessing functions to ocx
Posted by: geofran80 ()
Date: October 09, 2009 04:02AM

Oh yeah Paul, is very good this link, and very clear.

Many thaks.

Francisco J.

Options: ReplyQuote
Re: Shape.Clip - Union of disjoint shapes (Re: New geoprocessing functions to ocx)
Posted by: nmb100 ()
Date: April 26, 2010 04:12AM

Hi Mark

I am trying to use your code, as above and keep running into a problem after i have assigned a shapefile to aCatchmentShapeFile using the aCatchmentShapeFile.Open() function. I think that i am indexing lRecordKeptIndex and lRecordAddingIndex incorrectly from the shapefile. As i couldn't find any documention, i have gone with the following for these (both being declared as integers):

lRecordKeptIndex = 0
lRecordAddingIndex = aCatchmentShapeFile.NumShapes

however when i run the union:

Dim lTargetShape As MapWinGIS.Shape = aCatchmentShapeFile.Shape(lRecordKeptIndex).Clip(aCatchmentShapeFile.Shape(lRecordAddingIndex), MapWinGIS.tkClipOperation.clUnion)

it kicks out a general exception.

Any assistance would be greatly appreciated. I have asked for assistance in a forum i have set up on MW called, 'Union/Merge shapefiles and check topology', which explains fully what i am aiming to do.

Thanks.

Options: ReplyQuote
Re: Shape.Clip - Union of disjoint shapes (Re: New geoprocessing functions to ocx)
Posted by: Mark Gray ()
Date: April 29, 2010 09:43AM

nmb100: the indexes I am using refer to the two shapes to be merged. These need to be found by other code before my sample code can be used.
lRecordKeptIndex is the index of the shape to keep
lRecordAddingIndex is the index of the shape to merge into the kept shape and then remove from the shapefile.

Your example of using lRecordAddingIndex = aCatchmentShapeFile.NumShapes causes an exception because that is one more than the maximum shape index.

Options: ReplyQuote
Pages: Previous12
Current Page: 2 of 2


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: