@@ -279,7 +279,7 @@ public void Reproject2281Test()
279279 }
280280 Assert . IsTrue ( sf . NumShapes == 1 , "Unexpected number of shapes in " + filename ) ;
281281 Debug . WriteLine ( sf . GeoProjection . ProjectionName ) ;
282-
282+
283283 var proj = new GeoProjection ( ) ;
284284 proj . ImportFromEPSG ( 32612 ) ; // WGS 84 / UTM zone 12N
285285 var numShps = 0 ;
@@ -346,7 +346,7 @@ public void CreateFishnet()
346346 var startY = shp . Extents . yMin - blockSizeY ;
347347 var numPoints = 0 ;
348348 // Use diagonal for total size of fishnet:
349- var width = ( int ) Math . Ceiling (
349+ var width = ( int ) Math . Ceiling (
350350 Math . Sqrt ( Math . Pow ( shp . Extents . xMax - shp . Extents . xMin , 2 ) +
351351 Math . Pow ( shp . Extents . yMax - shp . Extents . yMin , 2 ) ) ) ;
352352 width += blockSizeX ;
@@ -359,16 +359,16 @@ public void CreateFishnet()
359359 Assert . Fail ( "Create a new shape failed: " + shp . ErrorMsg [ shp . LastErrorCode ] ) ;
360360
361361 // First point:
362- if ( ! shpBlock . InsertPoint ( new Point { x = startX , y = startY } , ref numPoints ) )
362+ if ( ! shpBlock . InsertPoint ( new Point { x = startX , y = startY } , ref numPoints ) )
363363 Assert . Fail ( "Inserting a point failed: " + shp . ErrorMsg [ shp . LastErrorCode ] ) ;
364364 // Second point:
365- if ( ! shpBlock . InsertPoint ( new Point { x = startX + blockSizeX , y = startY } , ref numPoints ) )
365+ if ( ! shpBlock . InsertPoint ( new Point { x = startX + blockSizeX , y = startY } , ref numPoints ) )
366366 Assert . Fail ( "Inserting a point failed: " + shp . ErrorMsg [ shp . LastErrorCode ] ) ;
367367 // Third point:
368- if ( ! shpBlock . InsertPoint ( new Point { x = startX + blockSizeX , y = startY + blockSizeY } , ref numPoints ) )
368+ if ( ! shpBlock . InsertPoint ( new Point { x = startX + blockSizeX , y = startY + blockSizeY } , ref numPoints ) )
369369 Assert . Fail ( "Inserting a point failed: " + shp . ErrorMsg [ shp . LastErrorCode ] ) ;
370370 // Fourth point:
371- if ( ! shpBlock . InsertPoint ( new Point { x = startX , y = startY + blockSizeY } , ref numPoints ) )
371+ if ( ! shpBlock . InsertPoint ( new Point { x = startX , y = startY + blockSizeY } , ref numPoints ) )
372372 Assert . Fail ( "Inserting a point failed: " + shp . ErrorMsg [ shp . LastErrorCode ] ) ;
373373 // Closing:
374374 if ( ! shpBlock . InsertPoint ( new Point { x = startX , y = startY } , ref numPoints ) )
@@ -414,5 +414,107 @@ public void SaveAs()
414414 if ( ! sf . SaveAs ( tmpFilename ) )
415415 Assert . Fail ( "Failed to save shapefile: " + sf . ErrorMsg [ sf . LastErrorCode ] ) ;
416416 }
417+
418+ /// <summary>
419+ /// Merges the sf.
420+ /// </summary>
421+ /// <remarks>MWGIS-69</remarks>
422+ [ TestMethod ]
423+ public void MergeSf ( )
424+ {
425+ const string sf3Location = @"D:\dev\GIS-Data\Issues\0031 Merge M\shp3_point\SHP3_POINT.shp" ;
426+ const string sf4Location = @"D:\dev\GIS-Data\Issues\0031 Merge M\shp4_point\SHP4_POINT.shp" ;
427+
428+ var sf3 = new Shapefile ( ) ;
429+ if ( ! sf3 . Open ( sf3Location ) ) Assert . Fail ( "Can't open " + sf3Location + " Error: " + sf3 . ErrorMsg [ sf3 . LastErrorCode ] ) ;
430+
431+ var sf4 = new Shapefile ( ) ;
432+ if ( ! sf4 . Open ( sf4Location ) ) Assert . Fail ( "Can't open " + sf4Location + " Error: " + sf4 . ErrorMsg [ sf4 . LastErrorCode ] ) ;
433+
434+ var sfMerged = sf3 . Merge ( false , sf4 , false ) ;
435+ Assert . IsNotNull ( sfMerged , "Merge failed" ) ;
436+ Assert . AreEqual ( 2 , sfMerged . NumShapes , "Incorrect number of shapes" ) ;
437+ }
438+
439+ /// <summary>
440+ /// Merges the M shapefiles
441+ /// </summary>
442+ /// <remarks>MWGIS-69</remarks>
443+ [ TestMethod ]
444+ public void MergeM ( )
445+ {
446+ const string sf1Location = @"D:\dev\GIS-Data\Issues\MWGIS-69 Merge M\shp1_point_m\SHP1_POINT_M.shp" ;
447+ const string sf2Location = @"D:\dev\GIS-Data\Issues\MWGIS-69 Merge M\shp2_point_m\SHP2_POINT_M.shp" ;
448+
449+ var sf1 = new Shapefile ( ) ;
450+ if ( ! sf1 . Open ( sf1Location ) ) Assert . Fail ( "Can't open " + sf1Location + " Error: " + sf1 . ErrorMsg [ sf1 . LastErrorCode ] ) ;
451+
452+ var sf2 = new Shapefile ( ) ;
453+ if ( ! sf2 . Open ( sf2Location ) ) Assert . Fail ( "Can't open " + sf2Location + " Error: " + sf2 . ErrorMsg [ sf2 . LastErrorCode ] ) ;
454+
455+ Debug . WriteLine ( "Before merge" ) ;
456+ var sfMerged = sf1 . Merge ( false , sf2 , false ) ;
457+ Assert . IsNotNull ( sfMerged , "Merge failed" ) ;
458+ Assert . AreEqual ( 2 , sfMerged . NumShapes , "Incorrect number of shapes" ) ;
459+ }
460+
461+ [ TestMethod ]
462+ public void LoadAmericanData ( )
463+ {
464+ const string sfLocation = @"D:\dev\GIS-Data\MapWindow-Projects\UnitedStates\Shapefiles\states.shp" ;
465+
466+ var sf = new Shapefile ( ) ;
467+ if ( ! sf . Open ( sfLocation ) ) Assert . Fail ( "Can't open " + sfLocation + " Error: " + sf . ErrorMsg [ sf . LastErrorCode ] ) ;
468+
469+ var value = sf . CellValue [ 1 , 0 ] as string ;
470+ sf . Close ( ) ;
471+ Debug . WriteLine ( value ) ;
472+ // Value should be Washington
473+ Assert . AreEqual ( 'h' , value [ 3 ] ) ;
474+ }
475+
476+ [ TestMethod ]
477+ public void ReadRussionDataFromTable ( )
478+ {
479+ const string sfLocation = @"D:\dev\GIS-Data\Issues\CORE-199 Russian\point.shp" ;
480+ const int fieldIndex = 2 ;
481+
482+ var sf = new Shapefile ( ) ;
483+ if ( ! sf . Open ( sfLocation ) )
484+ Assert . Fail ( "Can't open " + sfLocation + " Error: " + sf . ErrorMsg [ sf . LastErrorCode ] ) ;
485+
486+ var value = sf . CellValue [ fieldIndex , 0 ] as string ;
487+ Assert . IsNotNull ( value , "No value returned" ) ;
488+ sf . Close ( ) ;
489+ Debug . WriteLine ( value ) ;
490+ // Value should be Воздух
491+ Assert . AreEqual ( 'д' , value [ 3 ] ) ;
492+ }
493+
494+ [ TestMethod ]
495+ public void CreateRussionCategories ( )
496+ {
497+ const string sfLocation = @"D:\dev\GIS-Data\Issues\CORE-199 Russian\point.shp" ;
498+ const int fieldIndex = 2 ;
499+
500+ var sf = new Shapefile ( ) ;
501+ if ( ! sf . Open ( sfLocation ) )
502+ Assert . Fail ( "Can't open " + sfLocation + " Error: " + sf . ErrorMsg [ sf . LastErrorCode ] ) ;
503+
504+ // create visualization categories
505+ sf . DefaultDrawingOptions . FillType = tkFillType . ftStandard ;
506+ sf . Categories . Generate ( fieldIndex , tkClassificationType . ctUniqueValues , 0 ) ;
507+ sf . Categories . ApplyExpressions ( ) ;
508+
509+ // apply color scheme
510+ var scheme = new ColorScheme ( ) ;
511+ scheme . SetColors2 ( tkMapColor . LightBlue , tkMapColor . LightYellow ) ;
512+ sf . Categories . ApplyColorScheme ( tkColorSchemeType . ctSchemeGraduated , scheme ) ;
513+ Assert . IsTrue ( sf . Categories . Count > 0 , "No categories were made" ) ;
514+
515+ var cat = sf . Categories . Item [ 0 ] ;
516+ Console . WriteLine ( cat . Name ) ;
517+ Assert . AreNotEqual ( cat . Name [ 0 ] , '?' , "The category name is invalid" ) ;
518+ }
417519 }
418520}
0 commit comments