@@ -389,7 +389,7 @@ public static string SaveSnapshot2(AxMap axMap1, string baseName, bool shouldFai
389389 Application . DoEvents ( ) ;
390390 var filename = Path . Combine ( Path . GetTempPath ( ) , baseName ) ;
391391 DeleteFile ( filename ) ;
392-
392+
393393 var img = axMap1 . SnapShot2 ( 0 , axMap1 . CurrentZoom + 10 , 1000 ) ;
394394 if ( img == null ) throw new NullReferenceException ( "Snapshot is null" ) ;
395395
@@ -484,11 +484,42 @@ public static void AddPointToPointSf(Shapefile sfPoints, Point point)
484484 {
485485 // Save first point to result shapefile:
486486 var shp = new Shape ( ) ;
487- shp . Create ( ShpfileType . SHP_POINT ) ;
487+ if ( ! shp . Create ( ShpfileType . SHP_POINT ) )
488+ throw new Exception ( "Error in creating shape. Error: " + shp . ErrorMsg [ shp . LastErrorCode ] ) ;
488489 var index = 0 ;
489490 if ( ! shp . InsertPoint ( point , ref index ) )
490491 throw new Exception ( "Error in inserting point. Error: " + shp . ErrorMsg [ shp . LastErrorCode ] ) ;
491- sfPoints . EditAddShape ( shp ) ;
492+ if ( sfPoints . EditAddShape ( shp ) < 0 )
493+ throw new Exception ( "Error in adding shape. Error: " + sfPoints . ErrorMsg [ sfPoints . LastErrorCode ] ) ;
494+ }
495+
496+ public static Coordinate PointToCoordinate ( Point point )
497+ {
498+ return new Coordinate ( point . x , point . y ) ;
499+ }
500+
501+ public struct Coordinate
502+ {
503+ public double X { get ; set ; }
504+ public double Y { get ; set ; }
505+
506+ public Coordinate ( double x , double y )
507+ {
508+ X = x ;
509+ Y = y ;
510+ }
511+
512+ public override string ToString ( )
513+ {
514+ return $ "X: { X } , Y: { Y } ";
515+ }
516+ }
517+
518+ public static Point CoordinateToPoint ( Coordinate coordinate )
519+ {
520+ var pnt = new Point ( ) ;
521+ pnt . Set ( coordinate . X , coordinate . Y ) ;
522+ return pnt ;
492523 }
493524 }
494525}
0 commit comments