Using get_XY returns no Coordinates

Hello,

using the shape.get_XY function which is to prefer over the shape.Point property as described in the documentation does not change the values of x and y with no error (result=True)?
See the following Code:

Dim sh As Shape
Dim handle as Integer = mymap.AddLayerFromDatabase(OGRCONNSTRING,
                                                    $"SELECT hek_koordinate{postfix}, km_num FROM hektometer WHERE hek_vo_nummer IN ({voString})",
                                                    False)
Dim sf As Shapefile = mymap.get_Shapefile(handle)

      sf.FastMode = True
	  For i = 0 To sf.NumShapes - 1
	  
            If sf.Shape(i).numPoints > 0 Then

                sh = sf.Shape(i)

                ' Works not !!! -> x and y always keep their initlal value, result is always true
                result = sh.XY(0, x, y)

                ' Works ->
                x = sf.Shape(i).Point(0).x
                y = sf.Shape(i).Point(0).y
                
				sf.Labels.AddLabel(Format(sf.Table.CellValue(0, i), "###0.0"), x, y)
                
            End If
		
        Next

Has anyone an idea?

Regards,
Frank

try this one it works for me declare currentPoint
mousemove events
currentPosition = PointToCartesian(Location);
label1.Text = string.Format(“0,0:F3 , 1,0:F3”, IGeoProjection(currentPosition));

Hello ,

there is an error in MapWinGIS.idl:

interface IShape:
the entry for the get_XY function should be:

[id(38), helpstring("method get_XY")] HRESULT get_XY([in] LONG PointIndex, [in, out]double* x, [in, out]double* y, [out, retval] VARIANT_BOOL* retval);

WRONG:

[propget, id(38), helpstring("property XY")] HRESULT XY([in]long PointIndex, [in, out]double* x, [in, out]double* y, [out, retval] VARIANT_BOOL* retval);

A function should not described as a property!
After that change the get_XY function works as described in the documentation!

Regards,
Frank

1 Like