From 43c37d0572a1e7ffdcc34d133a73af436956a990 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 19:47:57 +0000 Subject: [PATCH 01/14] Initial plan for issue From 4d4163f212a7e48dbd720b030ed10c82d1a6cc7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 19:53:20 +0000 Subject: [PATCH 02/14] Add .editorconfig file to repository root Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- .editorconfig | 268 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..60c637a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,268 @@ +root = true + +[*.csproj] +indent_style = space +indent_size = 2 + +[*] +# add guidelines +guidelines = 160 +insert_final_newline = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_readonly_field = true:suggestion +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion +dotnet_style_allow_multiple_blank_lines_experimental = true:silent +dotnet_style_allow_statement_immediately_after_block_experimental = true:silent +dotnet_code_quality_unused_parameters = all:suggestion + +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +[*.sh] +indent_style = space +indent_size = 2 + +[*.props] +indent_style = space +indent_size = 2 + +[*.cs] +indent_size = 4 +indent_style = space +tab_width = 4 + +# Sort System namespaces alphabetically +dotnet_sort_system_directives_first = false + +# Treat missing xmldoc comments as suggestion instead of warning +dotnet_diagnostic.CS1591.severity = suggestion + +# Code style +csharp_new_line_before_members_in_object_initializers = false +csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion +csharp_space_after_cast = false +csharp_style_namespace_declarations = file_scoped:silent +csharp_style_prefer_primary_constructors = false:suggestion +dotnet_style_qualification_for_event = false:suggestion +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_switch_labels = true + +# Naming rules +dotnet_naming_rule.private_constants_rule.severity = warning +dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style +dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols +dotnet_naming_rule.private_instance_fields_rule.severity = warning +dotnet_naming_rule.private_instance_fields_rule.style = underscore_lower_camel_case_style +dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols +dotnet_naming_rule.private_static_fields_rule.severity = warning +dotnet_naming_rule.private_static_fields_rule.style = underscore_lower_camel_case_style +dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols +dotnet_naming_rule.private_static_readonly_rule.severity = warning +dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style +dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols + +# Naming styles +dotnet_naming_style.underscore_lower_camel_case_style.capitalization = camel_case +dotnet_naming_style.underscore_lower_camel_case_style.required_prefix = _ +dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case + +# Symbol specifications +dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field +dotnet_naming_symbols.private_constants_symbols.required_modifiers = const +dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static +dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly + +# Style aliases promoted to warnings: As styles don't have severity setting, they do not fail dotnet format checks. +# To make the checks fail, configure corresponding analyzer issue severity to warning. +# Only a subset of issues is listed here to avoid overly strict rules. +dotnet_diagnostic.IDE0003.severity = warning # Remove this or Me qualification - dotnet_style_qualification_for_* +dotnet_diagnostic.IDE0011.severity = suggestion # Add braces - csharp_prefer_braces +dotnet_diagnostic.IDE0016.severity = warning # Use throw expression - csharp_style_throw_expression +dotnet_diagnostic.IDE0019.severity = warning # Use pattern matching to avoid as followed by a null check - csharp_style_pattern_matching_over_as_with_null_check +dotnet_diagnostic.IDE0020.severity = warning # Use pattern matching to avoid is check followed by a cast (with variable) - csharp_style_pattern_matching_over_is_with_cast_check +dotnet_diagnostic.IDE0033.severity = warning # Use explicitly provided tuple name - dotnet_style_explicit_tuple_names +dotnet_diagnostic.IDE0034.severity = warning # Simplify default expression - csharp_prefer_simple_default_expression +dotnet_diagnostic.IDE0036.severity = warning # Order modifiers - csharp_preferred_modifier_order +dotnet_diagnostic.IDE0038.severity = warning # Use pattern matching to avoid is check followed by a cast (without variable) - csharp_style_pattern_matching_over_is_with_cast_check +dotnet_diagnostic.IDE0040.severity = warning # Add accessibility modifiers - dotnet_style_require_accessibility_modifiers +dotnet_diagnostic.IDE0044.severity = warning # Add readonly modifier - dotnet_style_readonly_field +dotnet_diagnostic.IDE0048.severity = suggestion # Add parentheses for clarity - dotnet_style_parentheses_in_* +dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references - dotnet_style_predefined_type_for_* +dotnet_diagnostic.IDE0055.severity = warning # Fix formatting +dotnet_diagnostic.IDE0059.severity = warning # Remove unnecessary value assignment - csharp_style_unused_value_assignment_preference +dotnet_diagnostic.IDE0060.severity = warning # Remove unused parameter - dotnet_code_quality_unused_parameters +dotnet_diagnostic.IDE0065.severity = warning # using directive placement - csharp_using_directive_placement +dotnet_diagnostic.IDE0130.severity = warning # Namespace does not match folder structure - dotnet_style_namespace_match_folder +dotnet_diagnostic.IDE0150.severity = warning # Prefer 'null' check over type check - csharp_style_prefer_null_check_over_type_check +dotnet_diagnostic.IDE0161.severity = warning # Use file-scoped namespace - csharp_style_namespace_declarations +dotnet_diagnostic.IDE0170.severity = warning # Simplify property pattern - csharp_style_prefer_extended_property_pattern +dotnet_diagnostic.IDE0200.severity = warning # Remove unnecessary lambda expression - csharp_style_prefer_method_group_conversion +dotnet_diagnostic.IDE0220.severity = warning # Add explicit cast in foreach loop - dotnet_style_prefer_foreach_explicit_cast_in_source +dotnet_diagnostic.IDE0250.severity = warning # Struct can be made 'readonly' - csharp_style_prefer_readonly_struct +dotnet_diagnostic.IDE0251.severity = warning # Member can be made 'readonly' - csharp_style_prefer_readonly_struct_member +dotnet_diagnostic.IDE0260.severity = warning # Use pattern matching - csharp_style_pattern_matching_over_as_with_null_check +dotnet_diagnostic.IDE1005.severity = warning # Use conditional delegate call - csharp_style_conditional_delegate_call + +# These are undocumented as they are for experimental analyzers but can be found in Roslyn sources: +# https://github.com/dotnet/roslyn/blob/b3dc95ebc77bcdf064617c3c4a85d1da0ea911ac/src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs#L211-L219 +dotnet_diagnostic.IDE2000.severity = warning # dotnet_style_allow_multiple_blank_lines_experimental +dotnet_diagnostic.IDE2002.severity = warning # csharp_style_allow_blank_lines_between_consecutive_braces_experimental +dotnet_diagnostic.IDE2003.severity = warning # dotnet_style_allow_statement_immediately_after_block_experimental +dotnet_diagnostic.IDE2004.severity = warning # csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental +dotnet_diagnostic.IDE2005.severity = warning # csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental + +# Others +dotnet_diagnostic.IDE0002.severity = warning # Simplify member access +dotnet_diagnostic.IDE0004.severity = warning # Remove unnecessary cast +dotnet_diagnostic.IDE0005.severity = warning # Remove unnecessary import +dotnet_diagnostic.IDE0070.severity = warning # Use 'System.HashCode.Combine' +dotnet_diagnostic.IDE0082.severity = warning # Convert typeof to nameof +dotnet_diagnostic.IDE0110.severity = warning # Remove unnecessary discard +dotnet_diagnostic.IDE0120.severity = warning # Simplify LINQ expression - Where followed by Any, First, Last, Count etc. without a predicate +dotnet_diagnostic.IDE0240.severity = warning # Nullable directive is redundant +dotnet_diagnostic.IDE0241.severity = warning # Nullable directive is unnecessary + +######################################################### +# Code quality - Design +######################################################### +# Do not declare visible fields +dotnet_diagnostic.CA1051.severity = warning +dotnet_diagnostic.CA1051.api_surface = all + +dotnet_diagnostic.CA1067.severity = warning # Override Equals when implementing IEquatable +dotnet_diagnostic.CA1068.severity = warning # CancellationToken parameters must come last + +# Do not declare event fields as virtual +dotnet_diagnostic.CA1070.severity = warning +dotnet_diagnostic.CA1070.api_surface = all + +######################################################### +# Code quality - Globalization +######################################################### +dotnet_diagnostic.CA1304.severity = warning # Specify CultureInfo +dotnet_diagnostic.CA1305.severity = warning # Specify IFormatProvider +dotnet_diagnostic.CA1310.severity = warning # Specify StringComparison for correctness + +######################################################### +# Code quality - Mantainability +######################################################### +dotnet_diagnostic.CA1507.severity = warning # Use nameof in place of string + +######################################################### +# Code quality - Performance +######################################################### +dotnet_diagnostic.CA1854.severity = warning # Prefer the IDictionary.TryGetValue(TKey, out TValue) method + +######################################################### +# Code quality - Reliability +######################################################### +dotnet_diagnostic.CA2016.severity = warning # Forward the CancellationToken parameter to methods that take one +dotnet_diagnostic.CA2012.severity = warning # Use ValueTasks correctly + +######################################################### +# Code quality - Usage +######################################################### +dotnet_diagnostic.CA2208.severity = warning # Instantiate argument exceptions correctly +dotnet_diagnostic.CA2211.severity = warning # Non-constant fields should not be visible +dotnet_diagnostic.CA2215.severity = warning # Dispose methods should call base class dispose +dotnet_diagnostic.CA2241.severity = warning # Provide correct arguments to formatting methods +dotnet_diagnostic.CA2242.severity = warning # Test for NaN correctly +dotnet_diagnostic.CA2244.severity = warning # Do not duplicate indexed element initializations +dotnet_diagnostic.CA2246.severity = warning # Do not assign a symbol and its member in the same statement +dotnet_diagnostic.CA2248.severity = warning # Provide correct enum argument to Enum.HasFlag +dotnet_diagnostic.CA2251.severity = warning # Use String.Equals over String.Compare +dotnet_diagnostic.CA2253.severity = warning # Named placeholders should not be numeric values (logging) +dotnet_diagnostic.CA2254.severity = warning # Template should be a static expression (logging) + +######################################################### +# Microsoft.VisualStudio.Threading.Analyzers +######################################################### +dotnet_diagnostic.VSTHRD003.severity = none # Avoid awaiting foreign Tasks (https://github.com/microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD003.md) +dotnet_diagnostic.VSTHRD012.severity = none # Provide JoinableTaskFactory where allowed (https://github.com/microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD012.md) +dotnet_diagnostic.VSTHRD100.severity = error # Avoid async void methods (https://github.com/microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD100.md) +dotnet_diagnostic.VSTHRD103.severity = none # Call async methods when in an async method - produces false positives with EF Core (https://github.com/microsoft/vs-threading/blob/main/doc/analyzers/VSTHRD103.md) +csharp_indent_labels = one_less_than_current +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_braces = true:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_prefer_system_threading_lock = true:suggestion +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_throw_expression = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_implicitly_typed_lambda_expression = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_unbound_generic_type_in_nameof = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent +csharp_prefer_static_anonymous_function = true:suggestion +csharp_prefer_static_local_function = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:silent +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +csharp_style_conditional_delegate_call = true:suggestion + +[*Builder{s,}.cs] # Apply to SomethingBuilder.cs as well as SomethingBuilders.cs +dotnet_diagnostic.IDE0003.severity = none # Allow this. qualification in builder types + +[*Tests{.*,}.cs] # Apply to SomethingTests.cs as well as SomethingTests.Part.cs +# Do not check for Async suffix in tests +dotnet_diagnostic.VSTHRD200.severity = none # Use Async suffix for async methods \ No newline at end of file From 35fb6cf28a1b62b0fafe873870d1416da0706c9a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 19:55:00 +0000 Subject: [PATCH 03/14] Add dotnet-format check to CI workflow Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6dd9634..e7fe90d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,13 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' + + - name: Install dotnet-format + run: dotnet tool install -g dotnet-format + + - name: Check code format + run: dotnet format --no-restore --verify-no-changes + continue-on-error: true - name: Restore dependencies run: dotnet restore From 4f2cb9328676b2615ef2dc1f404aa9019cbb1dcc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 20:37:31 +0000 Subject: [PATCH 04/14] Format all source files according to .editorconfig rules Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- .github/workflows/ci.yml | 1 - src/Benchmark.SpatialLite.Osm/Program.cs | 457 ++--- .../Properties/AssemblyInfo.cs | 38 +- src/SpatialLite.Core/API/Coordinate.cs | 289 ++-- src/SpatialLite.Core/API/Envelope.cs | 152 +- src/SpatialLite.Core/API/ICoordinateList.cs | 82 +- src/SpatialLite.Core/API/IGeometry.cs | 38 +- .../API/IGeometryCollection.cs | 16 +- src/SpatialLite.Core/API/ILineString.cs | 46 +- src/SpatialLite.Core/API/IMultiLineString.cs | 8 +- src/SpatialLite.Core/API/IMultiPoint.cs | 8 +- src/SpatialLite.Core/API/IMultiPolygon.cs | 8 +- src/SpatialLite.Core/API/IPoint.cs | 16 +- src/SpatialLite.Core/API/IPolygon.cs | 24 +- .../Algorithms/Euclidean2DCalculator.cs | 158 +- .../Algorithms/Euclidean2DLocator.cs | 383 ++-- .../Algorithms/IDimensionsCalculator.cs | 52 +- .../Algorithms/IGeometryLocator.cs | 90 +- src/SpatialLite.Core/Algorithms/LineMode.cs | 24 +- .../Algorithms/Sphere2DCalculator.cs | 278 +-- .../Geometries/CoordinateList.cs | 192 +- src/SpatialLite.Core/Geometries/Geometry.cs | 38 +- .../Geometries/GeometryCollection.cs | 145 +- src/SpatialLite.Core/Geometries/LineString.cs | 202 ++- .../Geometries/MultiLineString.cs | 49 +- src/SpatialLite.Core/Geometries/MultiPoint.cs | 51 +- .../Geometries/MultiPolygon.cs | 49 +- src/SpatialLite.Core/Geometries/Point.cs | 162 +- src/SpatialLite.Core/Geometries/Polygon.cs | 134 +- .../Geometries/ReadOnlyCoordinateList.cs | 48 +- src/SpatialLite.Core/IO/BinaryEncoding.cs | 24 +- src/SpatialLite.Core/IO/TokenType.cs | 64 +- src/SpatialLite.Core/IO/WkbFormatException.cs | 23 +- src/SpatialLite.Core/IO/WkbGeometryType.cs | 88 +- src/SpatialLite.Core/IO/WkbReader.cs | 746 ++++---- src/SpatialLite.Core/IO/WkbWriter.cs | 666 +++---- src/SpatialLite.Core/IO/WkbWriterSettings.cs | 85 +- src/SpatialLite.Core/IO/WktParseException.cs | 23 +- src/SpatialLite.Core/IO/WktReader.cs | 1466 ++++++++-------- src/SpatialLite.Core/IO/WktToken.cs | 32 +- src/SpatialLite.Core/IO/WktTokenizer.cs | 144 +- src/SpatialLite.Core/IO/WktTokensBuffer.cs | 254 +-- src/SpatialLite.Core/IO/WktWriter.cs | 1010 ++++++----- src/SpatialLite.Core/IO/WktWriterSettings.cs | 29 +- src/SpatialLite.Core/Measurements.cs | 373 ++-- .../Properties/AssemblyInfo.cs | 2 +- src/SpatialLite.Core/Topology.cs | 269 +-- src/SpatialLite.Gps/Geometries/GpsFix.cs | 64 +- src/SpatialLite.Gps/Geometries/GpsPoint.cs | 110 +- .../Geometries/GpsTrackBase.cs | 90 +- .../Geometries/GpxFixHelper.cs | 86 +- src/SpatialLite.Gps/Geometries/GpxLink.cs | 67 +- src/SpatialLite.Gps/Geometries/GpxMetadata.cs | 83 +- src/SpatialLite.Gps/Geometries/GpxPoint.cs | 121 +- .../Geometries/GpxPointMetadata.cs | 114 +- src/SpatialLite.Gps/Geometries/GpxRoute.cs | 75 +- src/SpatialLite.Gps/Geometries/GpxTrack.cs | 79 +- .../Geometries/GpxTrackMetadata.cs | 24 +- .../Geometries/GpxTrackSegment.cs | 56 +- src/SpatialLite.Gps/GpxDocument.cs | 266 +-- src/SpatialLite.Gps/GpxGeometryType.cs | 44 +- src/SpatialLite.Gps/IGpsPoint.cs | 30 +- src/SpatialLite.Gps/IGpxGeometry.cs | 28 +- src/SpatialLite.Gps/IO/GpxReader.cs | 848 ++++----- src/SpatialLite.Gps/IO/GpxReaderSettings.cs | 85 +- src/SpatialLite.Gps/IO/GpxWriter.cs | 572 +++--- src/SpatialLite.Gps/IO/GpxWriterSettings.cs | 121 +- src/SpatialLite.Gps/IO/IGpxReader.cs | 24 +- src/SpatialLite.Gps/IO/IGpxWriter.cs | 54 +- .../Properties/AssemblyInfo.cs | 2 +- src/SpatialLite.Osm/EntityCollection.cs | 331 ++-- src/SpatialLite.Osm/EntityMetadata.cs | 80 +- src/SpatialLite.Osm/EntityType.cs | 48 +- .../Geometries/IOsmGeometry.cs | 20 +- src/SpatialLite.Osm/Geometries/Node.cs | 157 +- .../Geometries/OsmGeometryDatabase.cs | 203 ++- src/SpatialLite.Osm/Geometries/Relation.cs | 141 +- .../Geometries/RelationMember.cs | 279 +-- src/SpatialLite.Osm/Geometries/Way.cs | 215 +-- .../Geometries/WayCoordinateList.cs | 232 +-- src/SpatialLite.Osm/IEntityCollection.cs | 6 +- src/SpatialLite.Osm/IEntityInfo.cs | 16 +- src/SpatialLite.Osm/IO/CompressionMode.cs | 34 +- src/SpatialLite.Osm/IO/IOsmReader.cs | 30 +- src/SpatialLite.Osm/IO/IOsmWriter.cs | 54 +- src/SpatialLite.Osm/IO/OsmReaderSettings.cs | 85 +- src/SpatialLite.Osm/IO/OsmWriterSettings.cs | 123 +- src/SpatialLite.Osm/IO/OsmXmlReader.cs | 929 +++++----- .../IO/OsmXmlReaderSettings.cs | 76 +- src/SpatialLite.Osm/IO/OsmXmlWriter.cs | 570 +++--- src/SpatialLite.Osm/IO/Pbf/Blob.cs | 60 +- src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs | 66 +- .../IO/Pbf/EntityInfoBuffer.cs | 326 ++-- src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs | 72 +- .../IO/Pbf/IStringTableBuilder.cs | 40 +- src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs | 104 +- src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs | 36 +- .../IO/Pbf/PbfDenseMetadata.cs | 210 +-- src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs | 186 +- src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs | 84 +- src/SpatialLite.Osm/IO/Pbf/PbfNode.cs | 100 +- src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs | 179 +- .../IO/Pbf/PbfRelationMemberType.cs | 40 +- src/SpatialLite.Osm/IO/Pbf/PbfWay.cs | 129 +- src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs | 118 +- src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs | 88 +- src/SpatialLite.Osm/IO/Pbf/StringTable.cs | 137 +- src/SpatialLite.Osm/IO/PbfReader.cs | 250 ++- src/SpatialLite.Osm/IO/PbfWriter.cs | 1208 +++++++------ src/SpatialLite.Osm/IO/PbfWriterSettings.cs | 117 +- src/SpatialLite.Osm/IOsmEntity.cs | 40 +- src/SpatialLite.Osm/ITypedEntityCollection.cs | 44 +- src/SpatialLite.Osm/NodeInfo.cs | 127 +- src/SpatialLite.Osm/OsmDatabase.cs | 451 ++--- src/SpatialLite.Osm/OsmEntityInfoDatabase.cs | 121 +- .../Properties/AssemblyInfo.cs | 2 +- src/SpatialLite.Osm/RelationInfo.cs | 120 +- src/SpatialLite.Osm/RelationMemberInfo.cs | 51 +- src/SpatialLite.Osm/Tag.cs | 201 ++- src/SpatialLite.Osm/TagsCollection.cs | 488 +++--- src/SpatialLite.Osm/WayInfo.cs | 112 +- .../API/CoordinateTests.cs | 416 ++--- .../API/EnvelopeTests.cs | 499 +++--- .../Algorithms/Euclidean2DCalculatorTests.cs | 492 +++--- .../Algorithms/Euclidean2DLocatorTests.cs | 571 +++--- .../Algorithms/Sphere2DCalculatorTests.cs | 322 ++-- .../Data/TestDataReader.cs | 52 +- .../Geometries/CoordinateListTests.cs | 317 ++-- .../Geometries/GeometryCollectionTests.cs | 239 +-- .../Geometries/LineStringTests.cs | 349 ++-- .../Geometries/MultiLineStringTests.cs | 22 +- .../Geometries/MultiPointTests.cs | 22 +- .../Geometries/MultiPolygonTests.cs | 22 +- .../Geometries/PointTests.cs | 265 +-- .../Geometries/PolygonTests.cs | 267 +-- .../Geometries/ReadOnlyCoordinateListTests.cs | 180 +- .../IO/WkbReaderTests.cs | 1310 +++++++------- .../IO/WkbWriterSettingsTests.cs | 60 +- .../IO/WkbWriterTests.cs | 1421 ++++++++------- .../IO/WktReaderTests.cs | 1538 +++++++++-------- .../IO/WktTokenizerTests.cs | 278 +-- .../IO/WktTokensBufferTests.cs | 390 +++-- .../IO/WktWriterSettingsTests.cs | 45 +- .../IO/WktWriterTests.cs | 648 +++---- .../MeasurementsTests.cs | 570 +++--- src/Tests.SpatialLite.Core/PathHelper.cs | 51 +- .../Properties/AssemblyInfo.cs | 38 +- src/Tests.SpatialLite.Core/TopologyTests.cs | 47 +- .../Data/TestDataReader.cs | 44 +- .../Geometries/GpsPointTests.cs | 117 +- .../Geometries/GpsTrackBaseTests.cs | 128 +- .../Geometries/GpxFixHelperTests.cs | 89 +- .../Geometries/GpxLinkTests.cs | 37 +- .../Geometries/GpxMetadataTests.cs | 40 +- .../Geometries/GpxPointTests.cs | 132 +- .../Geometries/GpxRouteTests.cs | 82 +- .../Geometries/GpxTrackSegmentTests.cs | 65 +- .../Geometries/GpxTrackTests.cs | 72 +- src/Tests.SpatialLite.Gps/GpxDocumentTests.cs | 323 ++-- .../IO/GpxReaderSettingsTests.cs | 50 +- .../IO/GpxReaderTests.cs | 854 ++++----- .../IO/GpxWriterSettingsTests.cs | 67 +- .../IO/GpxWriterTests.cs | 709 ++++---- src/Tests.SpatialLite.Gps/PathHelper.cs | 51 +- .../Properties/AssemblyInfo.cs | 38 +- .../XDocumentExtensions.cs | 98 +- .../Data/TestDataReader.cs | 47 +- .../EntityCollectionTests.cs | 428 ++--- .../Geometries/NodeTests.cs | 201 ++- .../Geometries/OsmGeometryDatabaseTests.cs | 341 ++-- .../Geometries/RelationMemberTests.cs | 340 ++-- .../Geometries/RelationTests.cs | 223 +-- .../Geometries/WayCoordinateListTests.cs | 178 +- .../Geometries/WayTests.cs | 79 +- .../IO/OsmReaderSettingsTests.cs | 52 +- .../IO/OsmWriterSettingsTests.cs | 69 +- .../IO/OsmXmlReaderTests.cs | 746 ++++---- .../IO/OsmXmlWriterTests.cs | 230 ++- .../IO/PbfReaderTests.cs | 162 +- .../IO/PbfWriterSettingsTests.cs | 73 +- .../IO/PbfWriterTests.cs | 984 ++++++----- .../Pbf/OsmosisIntegrationTests.cs | 386 +++-- .../Pbf/PbfReaderPbfWriterComplianceTests.cs | 263 +-- .../Integration/Xml/OsmDatabaseTests.cs | 68 +- .../Xml/OsmosisIntegrationTests.cs | 189 +- src/Tests.SpatialLite.Osm/NodeInfoTests.cs | 134 +- src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs | 890 +++++----- .../OsmEntityInfoDatabaseTests.cs | 265 +-- src/Tests.SpatialLite.Osm/PathHelper.cs | 65 +- .../Properties/AssemblyInfo.cs | 38 +- .../RelationInfoTests.cs | 150 +- .../RelationMemberInfoTests.cs | 43 +- src/Tests.SpatialLite.Osm/TagTests.cs | 200 ++- .../TagsCollectionTests.cs | 648 +++---- src/Tests.SpatialLite.Osm/WayInfoTests.cs | 132 +- 195 files changed, 22235 insertions(+), 19331 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7fe90d..71fd6c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,6 @@ jobs: - name: Check code format run: dotnet format --no-restore --verify-no-changes - continue-on-error: true - name: Restore dependencies run: dotnet restore diff --git a/src/Benchmark.SpatialLite.Osm/Program.cs b/src/Benchmark.SpatialLite.Osm/Program.cs index 0852d5d..8dd1165 100644 --- a/src/Benchmark.SpatialLite.Osm/Program.cs +++ b/src/Benchmark.SpatialLite.Osm/Program.cs @@ -1,203 +1,254 @@ -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm.IO; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; - -namespace Benchmark.SpatialLite.Osm { - public class Program { - static List _entities; - - static void Main(string[] args) { - List> benchmarks = new List>(); - benchmarks.Add(new Tuple("XmlReader with metadata", TestXmlReaderSpeed)); - benchmarks.Add(new Tuple("XmlReader without metadata", TestXmlReaderSpeedWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfReader (no compression) with metadata", TestPbfReaderSpeedNoDenseNoCompression)); - //benchmarks.Add(new Tuple("PbfReader (no compression) without metadata", TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfReader (dense, deflate) with metadata", TestPbfReaderSpeedDenseDeflate)); - //benchmarks.Add(new Tuple("PbfReader (dense, deflate) without metadata", TestPbfReaderSpeedDenseDeflateWithoutMetadata)); - - //LoadSourceData(); - //benchmarks.Add(new Tuple("XmlWriter with metadata", TestXmlWriterSpeed)); - //benchmarks.Add(new Tuple("XmlWriter without metadata", TestXmlWriterSpeedWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfWriter (no compression) with metadata", TestPbfWriterSpeed)); - //benchmarks.Add(new Tuple("PbfWriter (no compression) without metadata", TestPbfWriterSpeedWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfWritre (dense, deflate) with metadata", TestPbfWriterSpeedDenseDeflate)); - //benchmarks.Add(new Tuple("PbfWriter (dense, deflate) without metadata", TestPbfWriterSpeedDenseDeflateWithoutMetadata)); - - //benchmarks.Add(new Tuple("OsmGeometryDatabase.Load(PbfReader)", TestOsmGeometryDatabaseLoadFromPbfReader)); - //benchmarks.Add(new Tuple("OsmEntityInfoDatabase.Load(PbfReader)", TestOsmEntityInfoDatabaseLoadFromPbfReader)); - - Console.WriteLine("Benchmark.SpatialLite.Osm.IO requires 'test-file.osm', 'test-file.pbf' and 'test-file-dc.pbf' in 'TestFiles'folder"); - - using (var stream = new FileStream("Benchmark.SpatialLite.Osm.IO.log", FileMode.Create, FileAccess.Write)) { - using (TextWriter tw = new StreamWriter(stream)) { - foreach (var benchmark in benchmarks) { - long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); - tw.WriteLine(string.Format("{0} ms \t\t{1}", avgTime, benchmark.Item1)); - } - } - } - } - - static long DoTest(Action testAction, string testName) { - Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); - - long totalTime = 0; - for (int i = 0; i < 10; i++) { - Console.Write(string.Format("Run ({0}/{1}) ...", i + 1, 10)); - Stopwatch watch = new Stopwatch(); - watch.Start(); - - testAction(); - - watch.Stop(); - totalTime += watch.ElapsedMilliseconds; - Console.WriteLine(string.Format("\t\t({0} ms)", watch.ElapsedMilliseconds)); - } - - Console.WriteLine(); - Console.WriteLine("Average runnig time: {0} ms\n", totalTime / 10); - return totalTime / 10; - } - - static void LoadSourceData() { - _entities = new List(); - - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - while ((info = reader.Read()) != null) { - _entities.Add(info); - } - } - } - - static void TestXmlReaderSpeed() { - int entitiesRead = 0; - - IEntityInfo info = null; - using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) { - while ((info = reader.Read()) != null) { - entitiesRead++; - } - } - } - - static void TestXmlReaderSpeedWithoutMetadata() { - int entitiesRead = 0; - - IEntityInfo info = null; - using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) { - while ((info = reader.Read()) != null) { - entitiesRead++; - } - } - } - - static void TestXmlWriterSpeed() { - using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) { - foreach (var entity in _entities) { - writer.Write(entity); - } - } - } - - static void TestXmlWriterSpeedWithoutMetadata() { - using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) { - foreach (var entity in _entities) { - writer.Write(entity); - } - } - } - - static void TestPbfReaderSpeedNoDenseNoCompression() { - int entitiesRead = 0; - - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - while ((info = reader.Read()) != null) { - entitiesRead++; - } - } - } - - static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() { - int entitiesRead = 0; - - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) { - while ((info = reader.Read()) != null) { - entitiesRead++; - } - } - } - - static void TestPbfReaderSpeedDenseDeflate() { - int entitiesRead = 0; - - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - while ((info = reader.Read()) != null) { - entitiesRead++; - } - } - } - - static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() { - int entitiesRead = 0; - - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) { - while ((info = reader.Read()) != null) { - entitiesRead++; - } - } - } - - static void TestPbfWriterSpeed() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) { - foreach (var entity in _entities) { - writer.Write(entity); - } - } - } - - static void TestPbfWriterSpeedWithoutMetadata() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) { - foreach (var entity in _entities) { - writer.Write(entity); - } - } - } - - static void TestPbfWriterSpeedDenseDeflate() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { - foreach (var entity in _entities) { - writer.Write(entity); - } - } - } - - static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { - foreach (var entity in _entities) { - writer.Write(entity); - } - } - } - - static void TestOsmGeometryDatabaseLoadFromPbfReader() { - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - OsmGeometryDatabase db = OsmGeometryDatabase.Load(reader, true); - } - } - - static void TestOsmEntityInfoDatabaseLoadFromPbfReader() { - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - OsmEntityInfoDatabase db = OsmEntityInfoDatabase.Load(reader); - } - } - } -} +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.IO; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +namespace Benchmark.SpatialLite.Osm +{ + public class Program + { + static List _entities; + + static void Main(string[] args) + { + List> benchmarks = new List>(); + benchmarks.Add(new Tuple("XmlReader with metadata", TestXmlReaderSpeed)); + benchmarks.Add(new Tuple("XmlReader without metadata", TestXmlReaderSpeedWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfReader (no compression) with metadata", TestPbfReaderSpeedNoDenseNoCompression)); + //benchmarks.Add(new Tuple("PbfReader (no compression) without metadata", TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfReader (dense, deflate) with metadata", TestPbfReaderSpeedDenseDeflate)); + //benchmarks.Add(new Tuple("PbfReader (dense, deflate) without metadata", TestPbfReaderSpeedDenseDeflateWithoutMetadata)); + + //LoadSourceData(); + //benchmarks.Add(new Tuple("XmlWriter with metadata", TestXmlWriterSpeed)); + //benchmarks.Add(new Tuple("XmlWriter without metadata", TestXmlWriterSpeedWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfWriter (no compression) with metadata", TestPbfWriterSpeed)); + //benchmarks.Add(new Tuple("PbfWriter (no compression) without metadata", TestPbfWriterSpeedWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfWritre (dense, deflate) with metadata", TestPbfWriterSpeedDenseDeflate)); + //benchmarks.Add(new Tuple("PbfWriter (dense, deflate) without metadata", TestPbfWriterSpeedDenseDeflateWithoutMetadata)); + + //benchmarks.Add(new Tuple("OsmGeometryDatabase.Load(PbfReader)", TestOsmGeometryDatabaseLoadFromPbfReader)); + //benchmarks.Add(new Tuple("OsmEntityInfoDatabase.Load(PbfReader)", TestOsmEntityInfoDatabaseLoadFromPbfReader)); + + Console.WriteLine("Benchmark.SpatialLite.Osm.IO requires 'test-file.osm', 'test-file.pbf' and 'test-file-dc.pbf' in 'TestFiles'folder"); + + using (var stream = new FileStream("Benchmark.SpatialLite.Osm.IO.log", FileMode.Create, FileAccess.Write)) + { + using (TextWriter tw = new StreamWriter(stream)) + { + foreach (var benchmark in benchmarks) + { + long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); + tw.WriteLine(string.Format("{0} ms \t\t{1}", avgTime, benchmark.Item1)); + } + } + } + } + + static long DoTest(Action testAction, string testName) + { + Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); + + long totalTime = 0; + for (int i = 0; i < 10; i++) + { + Console.Write(string.Format("Run ({0}/{1}) ...", i + 1, 10)); + Stopwatch watch = new Stopwatch(); + watch.Start(); + + testAction(); + + watch.Stop(); + totalTime += watch.ElapsedMilliseconds; + Console.WriteLine(string.Format("\t\t({0} ms)", watch.ElapsedMilliseconds)); + } + + Console.WriteLine(); + Console.WriteLine("Average runnig time: {0} ms\n", totalTime / 10); + return totalTime / 10; + } + + static void LoadSourceData() + { + _entities = new List(); + + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + { + while ((info = reader.Read()) != null) + { + _entities.Add(info); + } + } + } + + static void TestXmlReaderSpeed() + { + int entitiesRead = 0; + + IEntityInfo info = null; + using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) + { + while ((info = reader.Read()) != null) + { + entitiesRead++; + } + } + } + + static void TestXmlReaderSpeedWithoutMetadata() + { + int entitiesRead = 0; + + IEntityInfo info = null; + using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) + { + while ((info = reader.Read()) != null) + { + entitiesRead++; + } + } + } + + static void TestXmlWriterSpeed() + { + using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) + { + foreach (var entity in _entities) + { + writer.Write(entity); + } + } + } + + static void TestXmlWriterSpeedWithoutMetadata() + { + using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) + { + foreach (var entity in _entities) + { + writer.Write(entity); + } + } + } + + static void TestPbfReaderSpeedNoDenseNoCompression() + { + int entitiesRead = 0; + + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) + { + while ((info = reader.Read()) != null) + { + entitiesRead++; + } + } + } + + static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() + { + int entitiesRead = 0; + + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) + { + while ((info = reader.Read()) != null) + { + entitiesRead++; + } + } + } + + static void TestPbfReaderSpeedDenseDeflate() + { + int entitiesRead = 0; + + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + { + while ((info = reader.Read()) != null) + { + entitiesRead++; + } + } + } + + static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() + { + int entitiesRead = 0; + + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) + { + while ((info = reader.Read()) != null) + { + entitiesRead++; + } + } + } + + static void TestPbfWriterSpeed() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) + { + foreach (var entity in _entities) + { + writer.Write(entity); + } + } + } + + static void TestPbfWriterSpeedWithoutMetadata() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) + { + foreach (var entity in _entities) + { + writer.Write(entity); + } + } + } + + static void TestPbfWriterSpeedDenseDeflate() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + { + foreach (var entity in _entities) + { + writer.Write(entity); + } + } + } + + static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + { + foreach (var entity in _entities) + { + writer.Write(entity); + } + } + } + + static void TestOsmGeometryDatabaseLoadFromPbfReader() + { + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + { + OsmGeometryDatabase db = OsmGeometryDatabase.Load(reader, true); + } + } + + static void TestOsmEntityInfoDatabaseLoadFromPbfReader() + { + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + { + OsmEntityInfoDatabase db = OsmEntityInfoDatabase.Load(reader); + } + } + } +} diff --git a/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs b/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs index 87088b7..0236e4b 100644 --- a/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs +++ b/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs @@ -1,19 +1,19 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Benchmark.SpatialLite.Osm")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ebe5e8af-6eda-4967-ab80-df979d3dd720")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Benchmark.SpatialLite.Osm")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ebe5e8af-6eda-4967-ab80-df979d3dd720")] diff --git a/src/SpatialLite.Core/API/Coordinate.cs b/src/SpatialLite.Core/API/Coordinate.cs index 73780ab..e03d437 100644 --- a/src/SpatialLite.Core/API/Coordinate.cs +++ b/src/SpatialLite.Core/API/Coordinate.cs @@ -1,60 +1,65 @@ using System; -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Represents a location in the coordinate space. /// /// /// A Coordinate may include a M value. The M value allows an application to associate some measure with the Coordinate. /// - public struct Coordinate : IEquatable { - - /// - /// Represents an empty coordinate. - /// - /// - /// The empty coordinate has all coordinates equal to NaN. - /// - public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - /// - /// Initializes a new instance of the Coordinate struct with X, Y ordinates. - /// - /// X-coordinate value. - /// Y-coordinate value. - public Coordinate(double x, double y) { - X = x; - Y = y; - Z = double.NaN; - M = double.NaN; - } - - /// - /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates. - /// - /// X-coordinate value. - /// Y-coordinate value. - /// Z-coordinate value. - public Coordinate(double x, double y, double z) { - X = x; - Y = y; - Z = z; - M = double.NaN; - } - - /// - /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates and M value. - /// - /// X-coordinate value. - /// Y-coordinate value. - /// Z-coordinate value. - /// Measured value associated with the Coordinate. - public Coordinate(double x, double y, double z, double m) { - X = x; - Y = y; - Z = z; - M = m; - } + public struct Coordinate : IEquatable + { + + /// + /// Represents an empty coordinate. + /// + /// + /// The empty coordinate has all coordinates equal to NaN. + /// + public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + /// + /// Initializes a new instance of the Coordinate struct with X, Y ordinates. + /// + /// X-coordinate value. + /// Y-coordinate value. + public Coordinate(double x, double y) + { + X = x; + Y = y; + Z = double.NaN; + M = double.NaN; + } + + /// + /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates. + /// + /// X-coordinate value. + /// Y-coordinate value. + /// Z-coordinate value. + public Coordinate(double x, double y, double z) + { + X = x; + Y = y; + Z = z; + M = double.NaN; + } + + /// + /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates and M value. + /// + /// X-coordinate value. + /// Y-coordinate value. + /// Z-coordinate value. + /// Measured value associated with the Coordinate. + public Coordinate(double x, double y, double z, double m) + { + X = x; + Y = y; + Z = z; + M = m; + } /// /// Gets the X-coordinate @@ -79,91 +84,103 @@ public Coordinate(double x, double y, double z, double m) { /// /// Gets a value indicating whether this coordinate has assigned coordinate. /// - public bool Is3D { - get { - return !double.IsNaN(this.Z); - } - } - - /// - /// Gets a value indicating whether this coordinate has assigned value. - /// - public bool IsMeasured { - get { - return !double.IsNaN(this.M); - } - } - - /// - /// Determiens whether specific Coordinates values are equal - /// - /// Coordinate to compare - /// Coordinate to compare - /// true if the specified Coordinate values are equal; otherwise, false. - public static bool operator ==(Coordinate lhs, Coordinate rhs) { - return lhs.Equals(rhs); - } - - /// - /// Determiens whether specific Coordinate values are not equal - /// - /// Coordinate to compare - /// Coordinate to compare - /// true if the specified Coordinate values are not equal; otherwise, false. - public static bool operator !=(Coordinate lhs, Coordinate rhs) { - return !(lhs == rhs); - } - - /// - /// Returns a string that represents the current Coordinate. - /// - /// A string that represents the current Coordinate - public override string ToString() { - return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", this.X, this.Y, this.Z, this.M); - } - - /// - /// Determines whether specific object instance is equal to the current Coordinate. - /// - /// The object to compare with the current Coordinate - /// true if the specified object is equal to the current Coordinate; otherwise, false. - public override bool Equals(object obj) { - Coordinate? other = obj as Coordinate?; - if (other == null) { - return false; - } - - return this.Equals(other.Value); - } - - /// - /// Determines whether two Coordinate values are equal. - /// - /// The Coordinate to compare with the current Coordinate - /// true if the specified Coordinate is equal to the current Coordinate; otherwise, false. - public bool Equals(Coordinate other) { - return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && - ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))) && - ((this.Z == other.Z) || (double.IsNaN(this.Z) && double.IsNaN(other.Z))) && - ((this.M == other.M) || (double.IsNaN(this.M) && double.IsNaN(other.M))); - } - - /// - /// Serves as a hash function for the Coordinate structure. - /// - /// Hash code for current Coordinate value. - public override int GetHashCode() { - return X.GetHashCode() + 7 * Y.GetHashCode() + 13 * Z.GetHashCode() + 17 * M.GetHashCode(); - } - - /// - /// Determines whether two Coordinate are equal in 2D space. - /// - /// The Coordinate to compare with the current Coordinate - /// true if the specified Coordinate is equal to the current Coordinate in 2D space otherwise, false. - public bool Equals2D(Coordinate other) { - return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && - ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))); - } - } + public bool Is3D + { + get + { + return !double.IsNaN(this.Z); + } + } + + /// + /// Gets a value indicating whether this coordinate has assigned value. + /// + public bool IsMeasured + { + get + { + return !double.IsNaN(this.M); + } + } + + /// + /// Determiens whether specific Coordinates values are equal + /// + /// Coordinate to compare + /// Coordinate to compare + /// true if the specified Coordinate values are equal; otherwise, false. + public static bool operator ==(Coordinate lhs, Coordinate rhs) + { + return lhs.Equals(rhs); + } + + /// + /// Determiens whether specific Coordinate values are not equal + /// + /// Coordinate to compare + /// Coordinate to compare + /// true if the specified Coordinate values are not equal; otherwise, false. + public static bool operator !=(Coordinate lhs, Coordinate rhs) + { + return !(lhs == rhs); + } + + /// + /// Returns a string that represents the current Coordinate. + /// + /// A string that represents the current Coordinate + public override string ToString() + { + return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", this.X, this.Y, this.Z, this.M); + } + + /// + /// Determines whether specific object instance is equal to the current Coordinate. + /// + /// The object to compare with the current Coordinate + /// true if the specified object is equal to the current Coordinate; otherwise, false. + public override bool Equals(object obj) + { + Coordinate? other = obj as Coordinate?; + if (other == null) + { + return false; + } + + return this.Equals(other.Value); + } + + /// + /// Determines whether two Coordinate values are equal. + /// + /// The Coordinate to compare with the current Coordinate + /// true if the specified Coordinate is equal to the current Coordinate; otherwise, false. + public bool Equals(Coordinate other) + { + return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && + ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))) && + ((this.Z == other.Z) || (double.IsNaN(this.Z) && double.IsNaN(other.Z))) && + ((this.M == other.M) || (double.IsNaN(this.M) && double.IsNaN(other.M))); + } + + /// + /// Serves as a hash function for the Coordinate structure. + /// + /// Hash code for current Coordinate value. + public override int GetHashCode() + { + return X.GetHashCode() + 7 * Y.GetHashCode() + 13 * Z.GetHashCode() + 17 * M.GetHashCode(); + } + + /// + /// Determines whether two Coordinate are equal in 2D space. + /// + /// The Coordinate to compare with the current Coordinate + /// true if the specified Coordinate is equal to the current Coordinate in 2D space otherwise, false. + public bool Equals2D(Coordinate other) + { + return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && + ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))); + } + } } diff --git a/src/SpatialLite.Core/API/Envelope.cs b/src/SpatialLite.Core/API/Envelope.cs index dfa5815..1ad55f9 100644 --- a/src/SpatialLite.Core/API/Envelope.cs +++ b/src/SpatialLite.Core/API/Envelope.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Represents minimal bounding box of a object. /// - public class Envelope { + public class Envelope + { /// /// Empty Envelope, that has all it's bounds set to double.NaN @@ -25,14 +27,16 @@ public class Envelope { /// /// Initializes a new instance of the Envelope class that is empty and has all it's values initialized to double.NaN. /// - public Envelope() { + public Envelope() + { } /// /// Initializes a new instance of the Envelope class with the single coordinate. /// /// The coordinate used initialize Envelope - public Envelope(Coordinate coord) { + public Envelope(Coordinate coord) + { this.Initialize(coord.X, coord.X, coord.Y, coord.Y, coord.Z, coord.Z, coord.M, coord.M); } @@ -40,7 +44,8 @@ public Envelope(Coordinate coord) { /// Initializes a new instance of the Envelope class that covers specified coordinates. /// /// The coordinates to be covered. - public Envelope(IEnumerable coords) { + public Envelope(IEnumerable coords) + { this.Extend(coords); } @@ -48,63 +53,72 @@ public Envelope(IEnumerable coords) { /// Initializes a new instance of the Envelope class as copy of specified Envelope. /// /// The Envelope object whose values are to be copied. - public Envelope(Envelope source) { + public Envelope(Envelope source) + { this.Initialize(source.MinX, source.MaxX, source.MinY, source.MaxY, source.MinZ, source.MaxZ, source.MinM, source.MaxM); } /// /// Gets Envelope's minimal x-coordinate. /// - public double MinX { + public double MinX + { get { return _bounds[XIndex][0]; } } /// /// Gets Envelope's maximal x-coordinate. /// - public double MaxX { + public double MaxX + { get { return _bounds[XIndex][1]; } } /// /// Gets Envelope's minimal y-coordinate. /// - public double MinY { + public double MinY + { get { return _bounds[YIndex][0]; } } /// /// Gets Envelope's maximal y-coordinate. /// - public double MaxY { + public double MaxY + { get { return _bounds[YIndex][1]; } } /// /// Gets Envelope's minimal z-coordinate. /// - public double MinZ { + public double MinZ + { get { return _bounds[ZIndex][0]; } } /// /// Gets Envelope's maximal z-coordinate. /// - public double MaxZ { + public double MaxZ + { get { return _bounds[ZIndex][1]; } } /// /// Gets Envelope's minimal m-coordinate. /// - public double MinM { + public double MinM + { get { return _bounds[MIndex][0]; } } /// /// Gets Envelope's maximal m-coordinate. /// - public double MaxM { + public double MaxM + { get { return _bounds[MIndex][1]; } } @@ -112,9 +126,12 @@ public double MaxM { /// Returns the difference between the maximum and minimum x values. /// /// max x - min x, or 0 if this is a null Envelope. - public double Width { - get { - if (this.IsEmpty) { + public double Width + { + get + { + if (this.IsEmpty) + { return 0; } @@ -126,9 +143,12 @@ public double Width { /// Returns the difference between the maximum and minimum y values. /// /// max y - min y, or 0 if this is a null Envelope. - public double Height { - get { - if (this.IsEmpty) { + public double Height + { + get + { + if (this.IsEmpty) + { return 0; } @@ -139,8 +159,10 @@ public double Height { /// /// Checks if this Envelope equals the empty Envelope. /// - public bool IsEmpty { - get { + public bool IsEmpty + { + get + { return this.Equals(Envelope.Empty); } } @@ -149,13 +171,17 @@ public bool IsEmpty { /// Extends this Envelope to cover specified Coordinate. /// /// The Coordinate to be covered by extended Envelope. - public void Extend(Coordinate coord) { - if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) { + public void Extend(Coordinate coord) + { + if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) + { _bounds[XIndex][0] = _bounds[XIndex][1] = coord.X; _bounds[YIndex][0] = _bounds[YIndex][1] = coord.Y; _bounds[ZIndex][0] = _bounds[ZIndex][1] = coord.Z; _bounds[MIndex][0] = _bounds[MIndex][1] = coord.M; - } else { + } + else + { if (coord.X < _bounds[XIndex][0]) { _bounds[XIndex][0] = coord.X; } if (coord.X > _bounds[XIndex][1]) { _bounds[XIndex][1] = coord.X; } @@ -174,8 +200,10 @@ public void Extend(Coordinate coord) { /// Extends this Envelope to cover specified Coordinates. /// /// The collection of Coordinates to be covered by extended Envelope. - public void Extend(IEnumerable coords) { - foreach (var coord in coords) { + public void Extend(IEnumerable coords) + { + foreach (var coord in coords) + { this.Extend(coord); } } @@ -184,8 +212,10 @@ public void Extend(IEnumerable coords) { /// Extends this Envelope to cover specified Envelope. /// /// The Envelope to be covered by extended Envelope. - public void Extend(Envelope envelope) { - if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) { + public void Extend(Envelope envelope) + { + if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) + { _bounds[XIndex][0] = envelope.MinX; _bounds[XIndex][1] = envelope.MaxX; @@ -197,7 +227,9 @@ public void Extend(Envelope envelope) { _bounds[MIndex][0] = envelope.MinM; _bounds[MIndex][1] = envelope.MaxM; - } else { + } + else + { if (envelope.MinX < _bounds[XIndex][0]) { _bounds[XIndex][0] = envelope.MinX; } if (envelope.MaxX > _bounds[XIndex][1]) { _bounds[XIndex][1] = envelope.MaxX; } @@ -217,9 +249,11 @@ public void Extend(Envelope envelope) { /// /// The object to compare with the current Envelope /// true if the specified object is equal to the current Envelope; otherwise, false. - public override bool Equals(object obj) { + public override bool Equals(object obj) + { Envelope other = obj as Envelope; - if (other == null) { + if (other == null) + { return false; } @@ -231,7 +265,8 @@ public override bool Equals(object obj) { /// /// The Envelope to compare with the current Envelope /// true if the specified Envelope is equal to the current Envelope; otherwise, false. - public bool Equals(Envelope other) { + public bool Equals(Envelope other) + { return ((this.MinX == other.MinX) || (double.IsNaN(this.MinX) && double.IsNaN(other.MinX))) && ((this.MinY == other.MinY) || (double.IsNaN(this.MinY) && double.IsNaN(other.MinY))) && ((this.MinZ == other.MinZ) || (double.IsNaN(this.MinZ) && double.IsNaN(other.MinZ))) && @@ -252,8 +287,10 @@ public bool Equals(Envelope other) { /// /// true if the Envelopes overlap. /// - public bool Intersects(Envelope other) { - if (this.IsEmpty || other.IsEmpty) { + public bool Intersects(Envelope other) + { + if (this.IsEmpty || other.IsEmpty) + { return false; } @@ -266,8 +303,10 @@ public bool Intersects(Envelope other) { /// the x-coordinate of the point which this Envelope is being checked for containing /// the y-coordinate of the point which this Envelope is being checked for containing /// true if (x, y) lies in the interior or on the boundary of this Envelope. - public bool Covers(double x, double y) { - if (this.IsEmpty) { + public bool Covers(double x, double y) + { + if (this.IsEmpty) + { return false; } @@ -282,7 +321,8 @@ public bool Covers(double x, double y) { /// /// the point which this Envelope is being checked for containing /// true if the point lies in the interior or on the boundary of this Envelope. - public bool Covers(Coordinate p) { + public bool Covers(Coordinate p) + { return Covers(p.X, p.Y); } @@ -291,8 +331,10 @@ public bool Covers(Coordinate p) { /// /// the Envelope to check /// true if this Envelope covers the other - public bool Covers(Envelope other) { - if (this.IsEmpty || other.IsEmpty) { + public bool Covers(Envelope other) + { + if (this.IsEmpty || other.IsEmpty) + { return false; } @@ -306,7 +348,8 @@ public bool Covers(Envelope other) { /// Serves as a hash function for the Envelope class. /// /// Hash code for current Envelope object. - public override int GetHashCode() { + public override int GetHashCode() + { return _bounds.GetHashCode(); } @@ -317,7 +360,8 @@ public override int GetHashCode() { /// Second x-coordinate. /// First y-coordinate. /// Second y-coordinate. - public void Initialize(double x1, double x2, double y1, double y2) { + public void Initialize(double x1, double x2, double y1, double y2) + { var sortedX = this.SortCoordinates(x1, x2); _bounds[XIndex][0] = sortedX[0]; _bounds[XIndex][1] = sortedX[1]; @@ -336,7 +380,8 @@ public void Initialize(double x1, double x2, double y1, double y2) { /// Second y-coordinate. /// First z-coordinate. /// Second z-coordinate. - public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2) { + public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2) + { var sortedX = this.SortCoordinates(x1, x2); _bounds[XIndex][0] = sortedX[0]; _bounds[XIndex][1] = sortedX[1]; @@ -361,7 +406,8 @@ public void Initialize(double x1, double x2, double y1, double y2, double z1, do /// Second z-coordinate. /// First measure value. /// Second measure value. - public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2, double m1, double m2) { + public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2, double m1, double m2) + { var sortedX = this.SortCoordinates(x1, x2); _bounds[XIndex][0] = sortedX[0]; _bounds[XIndex][1] = sortedX[1]; @@ -386,20 +432,26 @@ public void Initialize(double x1, double x2, double y1, double y2, double z1, do /// Second coordinate. /// Array with sorted coordinates - [min, max] /// If any value is double.NaN the other is used for min and max. - private double[] SortCoordinates(double c1, double c2) { - if (double.IsNaN(c1)) { + private double[] SortCoordinates(double c1, double c2) + { + if (double.IsNaN(c1)) + { c1 = c2; } - if (double.IsNaN(c2)) { + if (double.IsNaN(c2)) + { c2 = c1; } - if (c1 > c2) { + if (c1 > c2) + { return new double[] { c2, c1 }; - } else { + } + else + { return new double[] { c1, c2 }; } } } -} \ No newline at end of file +} diff --git a/src/SpatialLite.Core/API/ICoordinateList.cs b/src/SpatialLite.Core/API/ICoordinateList.cs index f414bca..bdae7fb 100644 --- a/src/SpatialLite.Core/API/ICoordinateList.cs +++ b/src/SpatialLite.Core/API/ICoordinateList.cs @@ -1,51 +1,53 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines properties and methods for collection of coordinates. /// - public interface ICoordinateList : IEnumerable { - /// - /// Gets number of Coordinates in the list - /// - int Count { get; } + public interface ICoordinateList : IEnumerable + { + /// + /// Gets number of Coordinates in the list + /// + int Count { get; } - /// - /// Gets or sets Coordinate at the given index. - /// - /// The zero-based index of the Coordinate to get or set. - /// The element at the specified index. - Coordinate this[int index] { get; set; } + /// + /// Gets or sets Coordinate at the given index. + /// + /// The zero-based index of the Coordinate to get or set. + /// The element at the specified index. + Coordinate this[int index] { get; set; } - /// - /// Adds Coordinate to the end of the list. - /// - /// The Coordinate to add to the list - void Add(Coordinate coord); + /// + /// Adds Coordinate to the end of the list. + /// + /// The Coordinate to add to the list + void Add(Coordinate coord); - /// - /// Adds collection of coordinates to the end of the list. - /// - /// The collection of coordinates to add to the list - void Add(IEnumerable coords); + /// + /// Adds collection of coordinates to the end of the list. + /// + /// The collection of coordinates to add to the list + void Add(IEnumerable coords); - /// - /// Inserts Coordinate to the list at the specified index. - /// - /// The zero-based index at which coord should be inserted. - /// The Coordinate to insert into list. - /// If index equals the number of items in the list, then item is appended to the list. - void Insert(int index, Coordinate coord); - - /// - /// Removes Coordinate at the specified index from the list. - /// - /// The zero-based index of the Coordinate to remove. - void RemoveAt(int index); + /// + /// Inserts Coordinate to the list at the specified index. + /// + /// The zero-based index at which coord should be inserted. + /// The Coordinate to insert into list. + /// If index equals the number of items in the list, then item is appended to the list. + void Insert(int index, Coordinate coord); - /// - /// Removes all Coordinates from the collection. - /// - void Clear(); - } + /// + /// Removes Coordinate at the specified index from the list. + /// + /// The zero-based index of the Coordinate to remove. + void RemoveAt(int index); + + /// + /// Removes all Coordinates from the collection. + /// + void Clear(); + } } diff --git a/src/SpatialLite.Core/API/IGeometry.cs b/src/SpatialLite.Core/API/IGeometry.cs index 460e8d8..8983ee6 100644 --- a/src/SpatialLite.Core/API/IGeometry.cs +++ b/src/SpatialLite.Core/API/IGeometry.cs @@ -1,32 +1,34 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines common properties and methods for all geometry objects. /// - public interface IGeometry { - /// - /// Gets a value indicating whether the IGeometry object has Z coordinates. - /// - bool Is3D { get; } + public interface IGeometry + { + /// + /// Gets a value indicating whether the IGeometry object has Z coordinates. + /// + bool Is3D { get; } - /// - /// Gets a value indicating whether the IGeometry object has M values. - /// - bool IsMeasured { get; } + /// + /// Gets a value indicating whether the IGeometry object has M values. + /// + bool IsMeasured { get; } - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the IGeometry object. - /// - Envelope GetEnvelope(); + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the IGeometry object. + /// + Envelope GetEnvelope(); /// /// Gets collection of all of this IGeometry object /// /// the collection of all of this object IEnumerable GetCoordinates(); - } + } } diff --git a/src/SpatialLite.Core/API/IGeometryCollection.cs b/src/SpatialLite.Core/API/IGeometryCollection.cs index d74f777..6b1a624 100644 --- a/src/SpatialLite.Core/API/IGeometryCollection.cs +++ b/src/SpatialLite.Core/API/IGeometryCollection.cs @@ -1,14 +1,16 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines properties and methods for Geometry collection. /// /// The type of the objects included in the collection. - public interface IGeometryCollection : IGeometry where T : IGeometry { - /// - /// Gets the collection of geometry objects from the IGeometryCollection. - /// - IEnumerable Geometries { get; } - } + public interface IGeometryCollection : IGeometry where T : IGeometry + { + /// + /// Gets the collection of geometry objects from the IGeometryCollection. + /// + IEnumerable Geometries { get; } + } } diff --git a/src/SpatialLite.Core/API/ILineString.cs b/src/SpatialLite.Core/API/ILineString.cs index b0e16cd..5792240 100644 --- a/src/SpatialLite.Core/API/ILineString.cs +++ b/src/SpatialLite.Core/API/ILineString.cs @@ -1,29 +1,31 @@ -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defiens properties and methods for line strings. A line string is a curve with linear connection between concesutive points. /// - public interface ILineString : IGeometry { - /// - /// Gets a value indicating whether the ILineString is closed. - /// - /// - /// The ILineString is closed if and are identical. - /// - bool IsClosed { get; } + public interface ILineString : IGeometry + { + /// + /// Gets a value indicating whether the ILineString is closed. + /// + /// + /// The ILineString is closed if and are identical. + /// + bool IsClosed { get; } - /// - /// Gets the first coordinate of the ILineString object. - /// - Coordinate Start { get; } + /// + /// Gets the first coordinate of the ILineString object. + /// + Coordinate Start { get; } - /// - /// Gets the last coordinate of the ILineString object. - /// - Coordinate End { get; } + /// + /// Gets the last coordinate of the ILineString object. + /// + Coordinate End { get; } - /// - /// Gets the list of çoordinates that define this LisneString - /// - ICoordinateList Coordinates { get; } - } + /// + /// Gets the list of çoordinates that define this LisneString + /// + ICoordinateList Coordinates { get; } + } } diff --git a/src/SpatialLite.Core/API/IMultiLineString.cs b/src/SpatialLite.Core/API/IMultiLineString.cs index eb8fc1c..511b681 100644 --- a/src/SpatialLite.Core/API/IMultiLineString.cs +++ b/src/SpatialLite.Core/API/IMultiLineString.cs @@ -1,7 +1,9 @@ -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines properties and methodss for Collection of LineStrings. /// - public interface IMultiLineString : IGeometryCollection { - } + public interface IMultiLineString : IGeometryCollection + { + } } diff --git a/src/SpatialLite.Core/API/IMultiPoint.cs b/src/SpatialLite.Core/API/IMultiPoint.cs index 0526afa..994d9a5 100644 --- a/src/SpatialLite.Core/API/IMultiPoint.cs +++ b/src/SpatialLite.Core/API/IMultiPoint.cs @@ -1,7 +1,9 @@ -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines properties and methods collections of points. /// - public interface IMultiPoint : IGeometryCollection { - } + public interface IMultiPoint : IGeometryCollection + { + } } diff --git a/src/SpatialLite.Core/API/IMultiPolygon.cs b/src/SpatialLite.Core/API/IMultiPolygon.cs index 8ef19fe..4b0f4d9 100644 --- a/src/SpatialLite.Core/API/IMultiPolygon.cs +++ b/src/SpatialLite.Core/API/IMultiPolygon.cs @@ -1,7 +1,9 @@ -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines properties and methods for collections of polygons. /// - public interface IMultiPolygon : IGeometryCollection { - } + public interface IMultiPolygon : IGeometryCollection + { + } } diff --git a/src/SpatialLite.Core/API/IPoint.cs b/src/SpatialLite.Core/API/IPoint.cs index 40f9e3d..a973d3f 100644 --- a/src/SpatialLite.Core/API/IPoint.cs +++ b/src/SpatialLite.Core/API/IPoint.cs @@ -1,11 +1,13 @@ -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines properties and methods for points. /// - public interface IPoint : IGeometry { - /// - /// Gets position of the point. - /// - Coordinate Position { get; } - } + public interface IPoint : IGeometry + { + /// + /// Gets position of the point. + /// + Coordinate Position { get; } + } } diff --git a/src/SpatialLite.Core/API/IPolygon.cs b/src/SpatialLite.Core/API/IPolygon.cs index d9138b1..0b59146 100644 --- a/src/SpatialLite.Core/API/IPolygon.cs +++ b/src/SpatialLite.Core/API/IPolygon.cs @@ -1,18 +1,20 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API { +namespace SpatialLite.Core.API +{ /// /// Defines properties and methods for polygons. /// - public interface IPolygon : IGeometry { - /// - /// Gets the exterior boundary of the polygon - /// - ICoordinateList ExteriorRing { get; } + public interface IPolygon : IGeometry + { + /// + /// Gets the exterior boundary of the polygon + /// + ICoordinateList ExteriorRing { get; } - /// - /// Gets a collection of interior boundaries that define holes in the polygon - /// - IEnumerable InteriorRings { get; } - } + /// + /// Gets a collection of interior boundaries that define holes in the polygon + /// + IEnumerable InteriorRings { get; } + } } diff --git a/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs b/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs index f725292..fd3aa61 100644 --- a/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs @@ -1,43 +1,49 @@ using System; using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms { +namespace SpatialLite.Core.Algorithms +{ /// /// Provides methods for calculating distance and area in 2D euclidean space /// - public class Euclidean2DCalculator : IDimensionsCalculator { - - /// - /// Calculates distance between two points - /// - /// The first point - /// The second point - /// distance between two point in coordinate's units. - public double CalculateDistance(Coordinate c1, Coordinate c2) { - double deltaX = c1.X - c2.X; - double deltaY = c1.Y - c2.Y; - - return Math.Sqrt(deltaX * deltaX + deltaY * deltaY); - } - - /// - /// Calculates distance between a point and a line AB - /// - /// The coordinate to compute the distance for. - /// One point of the line. - /// Another point of the line. - /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. - /// The distance from C to line AB in coordinate's units. - public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - if (a.Equals2D(b)) { - return this.CalculateDistance(c, a); - } - - double deltaX = b.X - a.X; - double deltaY = b.Y - a.Y; - - if (mode == LineMode.LineSegment) { - /* + public class Euclidean2DCalculator : IDimensionsCalculator + { + + /// + /// Calculates distance between two points + /// + /// The first point + /// The second point + /// distance between two point in coordinate's units. + public double CalculateDistance(Coordinate c1, Coordinate c2) + { + double deltaX = c1.X - c2.X; + double deltaY = c1.Y - c2.Y; + + return Math.Sqrt(deltaX * deltaX + deltaY * deltaY); + } + + /// + /// Calculates distance between a point and a line AB + /// + /// The coordinate to compute the distance for. + /// One point of the line. + /// Another point of the line. + /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. + /// The distance from C to line AB in coordinate's units. + public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + if (a.Equals2D(b)) + { + return this.CalculateDistance(c, a); + } + + double deltaX = b.X - a.X; + double deltaY = b.Y - a.Y; + + if (mode == LineMode.LineSegment) + { + /* Let P be the point of perpendicular projection of C on AB. The parameter r, which indicates P's position along AB, is computed by the dot product of AC and AB divided by the square of the length of AB: @@ -55,18 +61,20 @@ AC dot AB 0= 1.0) { - return this.CalculateDistance(c, b); - } - } + if (r >= 1.0) + { + return this.CalculateDistance(c, b); + } + } - /* + /* Use another parameter s to indicate the location along PC, with the following meaning: s<0 C is left of AB s>0 C is right of AB @@ -81,38 +89,42 @@ AC dot AB L^2 */ - double s = ((a.Y - c.Y) * deltaX - (a.X - c.X) * deltaY) / (deltaX * deltaX + deltaY * deltaY); + double s = ((a.Y - c.Y) * deltaX - (a.X - c.X) * deltaY) / (deltaX * deltaX + deltaY * deltaY); - /* + /* Then the distance from C to P = |s|*L. */ - return Math.Abs(s) * Math.Sqrt(deltaX * deltaX + deltaY * deltaY); - } - - /// - /// Calculates area of the polygon specified by given vertices - /// - /// The vertices of the polygon - /// The area of the polygon in squareed coordinate's units - /// Polygon is expected to be simple. ComputeArea method handles correctly CoordinateList from Polygon class, where first and last vertices are the same. - public double CalculateArea(ICoordinateList vertices) { - if (vertices.Count < 3) { - throw new ArgumentException("List must contain at least 3 vertices.", "vertices"); - } - - double area = 0; - int maxIndex = vertices.Count - 1; - if (vertices[0] != vertices[maxIndex]) { - maxIndex++; - } - - for (int i = 0; i < maxIndex; i++) { - area += (vertices[(i + 1) % vertices.Count].X + vertices[i % vertices.Count].X) * (vertices[(i + 1) % vertices.Count].Y - vertices[i % vertices.Count].Y); - } - - return area / 2.0; - } - - } + return Math.Abs(s) * Math.Sqrt(deltaX * deltaX + deltaY * deltaY); + } + + /// + /// Calculates area of the polygon specified by given vertices + /// + /// The vertices of the polygon + /// The area of the polygon in squareed coordinate's units + /// Polygon is expected to be simple. ComputeArea method handles correctly CoordinateList from Polygon class, where first and last vertices are the same. + public double CalculateArea(ICoordinateList vertices) + { + if (vertices.Count < 3) + { + throw new ArgumentException("List must contain at least 3 vertices.", nameof(vertices)); + } + + double area = 0; + int maxIndex = vertices.Count - 1; + if (vertices[0] != vertices[maxIndex]) + { + maxIndex++; + } + + for (int i = 0; i < maxIndex; i++) + { + area += (vertices[(i + 1) % vertices.Count].X + vertices[i % vertices.Count].X) * (vertices[(i + 1) % vertices.Count].Y - vertices[i % vertices.Count].Y); + } + + return area / 2.0; + } + + } } diff --git a/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs b/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs index d228fab..539204b 100644 --- a/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs +++ b/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs @@ -2,193 +2,224 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms { +namespace SpatialLite.Core.Algorithms +{ /// /// Provides methods for determining relative position of geometries in Euclidean 2D space. /// - public class Euclidean2DLocator : IGeometryLocator { - - /// - /// Determines whether specific coordinate is on the line defined by two points. - /// - /// The coordinate to be tested - /// The first point of the line. - /// The second point of the line. - /// LineMode value that specifies whether AB should be treated as infinite line or as line segment - /// true if coordinate C is on line AB, otherwise false - public bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - /* + public class Euclidean2DLocator : IGeometryLocator + { + + /// + /// Determines whether specific coordinate is on the line defined by two points. + /// + /// The coordinate to be tested + /// The first point of the line. + /// The second point of the line. + /// LineMode value that specifies whether AB should be treated as infinite line or as line segment + /// true if coordinate C is on line AB, otherwise false + public bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + /* Express line in analytic form paramA * x + paramB * y + paramC = 0 */ - double paramA = b.Y - a.Y; - double paramB = a.X - b.X; - double paramC = b.X * a.Y - a.X * b.Y; + double paramA = b.Y - a.Y; + double paramB = a.X - b.X; + double paramC = b.X * a.Y - a.X * b.Y; - /* + /* induct coordinate C into equation of the line - if equation paramA * c.X + paramB * c.Y + paramC = 0 is valid, point lies on the line */ - double cLineResult = paramA * c.X + paramB * c.Y + paramC; - - if (cLineResult != 0.0) { - return false; - } - - if (mode == LineMode.Line) { - return true; - } - - // compute distance of the C along vector AB - double r; - double dx = Math.Abs(b.X - a.X); - double dy = Math.Abs(b.Y - a.Y); - - if (dx > dy) { - r = (c.X - a.X) / (b.X - a.X); - } - else { - r = (c.Y - a.Y) / (b.Y - a.Y); - } - - if (r < 0.0 || r > 1.0) { - return false; - } - else { - return true; - } - } - - /// - /// Determines whether specific coordinate is on the given polyline - /// - /// The coordinate to be tested - /// The polyline - /// true if coordinate C is on the line, otherwise false - public bool IsOnLine(Coordinate c, ICoordinateList line) { - for (int i = 1; i < line.Count; i++) { - if (this.IsOnLine(c, line[i - 1], line[i], LineMode.LineSegment)) { - return true; - } - } - - return false; - } - - /// - /// Determines if specific point is in ring - /// - /// The coordinate to be tested - /// The ring to locate point in - /// True if point lies inside ring, otherwise false - public bool IsInRing(Coordinate c, ICoordinateList ring) { - if (ring.Count < 3) { - throw new ArgumentException("Ring must contain at least 3 points", "ring"); - } - - if (ring[0].Equals2D(ring[ring.Count - 1]) == false) { - throw new ArgumentException("Ring does not have the same endpoints", "ring"); - } - - // determine if point is in ring using ray-tracing algorithm - // ray is casted from c in the direction of positive x-axis - int crossings = 0; - - for (int i = 0; i < ring.Count; i++) { - Coordinate p1 = ring[i]; - Coordinate p2 = ring[(i + 1) % ring.Count]; - - double y1 = p1.Y - c.Y; - double y2 = p2.Y - c.Y; - - // check there can be crossing - c lies between P1 and P2 on y-axis - if (((y1 > 0) && (y2 <= 0)) || ((y2 > 0) && (y1 <= 0))) { - double x1 = p1.X - c.X; - double x2 = p2.X - c.X; - - // compute intersection - double intersection = (x1 * y2 - x2 * y1) / (y2 - y1); - - if (intersection > 0) { - crossings++; - } - } - } - - // p is inside if an odd number of crossings - if ((crossings % 2) == 1) { - return true; - } - else { - return false; - } - } - - /// - /// Determines whether two lines or line segments intersects - /// - /// The first point of the first line - /// The second point of the first line - /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment - /// The first point of the second line - /// The second point of the second line - /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment - /// true if A1B1 intersects A2B2, otherwise returns false - public bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode) { - double paramA1 = b1.Y - a1.Y; - double paramB1 = a1.X - b1.X; - double paramC1 = paramA1 * a1.X + paramB1 * a1.Y; - - double paramA2 = b2.Y - a2.Y; - double paramB2 = a2.X - b2.X; - double paramC2 = paramA2 * a2.X + paramB2 * a2.Y; - - double det = paramA1 * paramB2 - paramA2 * paramB1; - if (det == 0) { - return false; - } - else { - double x = (paramB2 * paramC1 - paramB1 * paramC2) / det; - double y = (paramA1 * paramC2 - paramA2 * paramC1) / det; - - if (line1Mode == LineMode.LineSegment) { - if (x < Math.Min(a1.X, b1.X) || x > Math.Max(a1.X, b1.X) || y < Math.Min(a1.Y, b1.Y) || y > Math.Max(a1.Y, b1.Y)) { - return false; - } - } - - if (line2Mode == LineMode.LineSegment) { - if (x < Math.Min(a2.X, b2.X) || x > Math.Max(a2.X, b2.X) || y < Math.Min(a2.Y, b2.Y) || y > Math.Max(a2.Y, b2.Y)) { - return false; - } - } - - return true; - } - } - - /// - /// Determines whether two polylines defined by series of coordinates intersects - /// - /// The first polyline to test - /// The second polyline to test - /// true if polylines intersets, otherwise false - public bool Intersects(ICoordinateList line1, ICoordinateList line2) { - //TODO implement more efficient algorithm - - for (int i = 1; i < line1.Count; i++) { - for (int ii = 1; ii < line2.Count; ii++) { - if (this.Intersects(line1[i - 1], line1[i], LineMode.LineSegment, line2[ii - 1], line2[ii], LineMode.LineSegment)) { - return true; - } - } - } - - return false; - } - - } + double cLineResult = paramA * c.X + paramB * c.Y + paramC; + + if (cLineResult != 0.0) + { + return false; + } + + if (mode == LineMode.Line) + { + return true; + } + + // compute distance of the C along vector AB + double r; + double dx = Math.Abs(b.X - a.X); + double dy = Math.Abs(b.Y - a.Y); + + if (dx > dy) + { + r = (c.X - a.X) / (b.X - a.X); + } + else + { + r = (c.Y - a.Y) / (b.Y - a.Y); + } + + if (r < 0.0 || r > 1.0) + { + return false; + } + else + { + return true; + } + } + + /// + /// Determines whether specific coordinate is on the given polyline + /// + /// The coordinate to be tested + /// The polyline + /// true if coordinate C is on the line, otherwise false + public bool IsOnLine(Coordinate c, ICoordinateList line) + { + for (int i = 1; i < line.Count; i++) + { + if (this.IsOnLine(c, line[i - 1], line[i], LineMode.LineSegment)) + { + return true; + } + } + + return false; + } + + /// + /// Determines if specific point is in ring + /// + /// The coordinate to be tested + /// The ring to locate point in + /// True if point lies inside ring, otherwise false + public bool IsInRing(Coordinate c, ICoordinateList ring) + { + if (ring.Count < 3) + { + throw new ArgumentException("Ring must contain at least 3 points", nameof(ring)); + } + + if (ring[0].Equals2D(ring[ring.Count - 1]) == false) + { + throw new ArgumentException("Ring does not have the same endpoints", nameof(ring)); + } + + // determine if point is in ring using ray-tracing algorithm + // ray is casted from c in the direction of positive x-axis + int crossings = 0; + + for (int i = 0; i < ring.Count; i++) + { + Coordinate p1 = ring[i]; + Coordinate p2 = ring[(i + 1) % ring.Count]; + + double y1 = p1.Y - c.Y; + double y2 = p2.Y - c.Y; + + // check there can be crossing - c lies between P1 and P2 on y-axis + if (((y1 > 0) && (y2 <= 0)) || ((y2 > 0) && (y1 <= 0))) + { + double x1 = p1.X - c.X; + double x2 = p2.X - c.X; + + // compute intersection + double intersection = (x1 * y2 - x2 * y1) / (y2 - y1); + + if (intersection > 0) + { + crossings++; + } + } + } + + // p is inside if an odd number of crossings + if ((crossings % 2) == 1) + { + return true; + } + else + { + return false; + } + } + + /// + /// Determines whether two lines or line segments intersects + /// + /// The first point of the first line + /// The second point of the first line + /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment + /// The first point of the second line + /// The second point of the second line + /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment + /// true if A1B1 intersects A2B2, otherwise returns false + public bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode) + { + double paramA1 = b1.Y - a1.Y; + double paramB1 = a1.X - b1.X; + double paramC1 = paramA1 * a1.X + paramB1 * a1.Y; + + double paramA2 = b2.Y - a2.Y; + double paramB2 = a2.X - b2.X; + double paramC2 = paramA2 * a2.X + paramB2 * a2.Y; + + double det = paramA1 * paramB2 - paramA2 * paramB1; + if (det == 0) + { + return false; + } + else + { + double x = (paramB2 * paramC1 - paramB1 * paramC2) / det; + double y = (paramA1 * paramC2 - paramA2 * paramC1) / det; + + if (line1Mode == LineMode.LineSegment) + { + if (x < Math.Min(a1.X, b1.X) || x > Math.Max(a1.X, b1.X) || y < Math.Min(a1.Y, b1.Y) || y > Math.Max(a1.Y, b1.Y)) + { + return false; + } + } + + if (line2Mode == LineMode.LineSegment) + { + if (x < Math.Min(a2.X, b2.X) || x > Math.Max(a2.X, b2.X) || y < Math.Min(a2.Y, b2.Y) || y > Math.Max(a2.Y, b2.Y)) + { + return false; + } + } + + return true; + } + } + + /// + /// Determines whether two polylines defined by series of coordinates intersects + /// + /// The first polyline to test + /// The second polyline to test + /// true if polylines intersets, otherwise false + public bool Intersects(ICoordinateList line1, ICoordinateList line2) + { + //TODO implement more efficient algorithm + + for (int i = 1; i < line1.Count; i++) + { + for (int ii = 1; ii < line2.Count; ii++) + { + if (this.Intersects(line1[i - 1], line1[i], LineMode.LineSegment, line2[ii - 1], line2[ii], LineMode.LineSegment)) + { + return true; + } + } + } + + return false; + } + + } } diff --git a/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs b/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs index 79f9be1..a9e3709 100644 --- a/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs @@ -1,33 +1,35 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms { +namespace SpatialLite.Core.Algorithms +{ /// /// Defines methods that a class providing distance and area calculations capabilities must implement /// - public interface IDimensionsCalculator { - /// - /// Calculates distance between two points - /// - /// The first point - /// The second point - /// distance between two point - double CalculateDistance(Coordinate c1, Coordinate c2); + public interface IDimensionsCalculator + { + /// + /// Calculates distance between two points + /// + /// The first point + /// The second point + /// distance between two point + double CalculateDistance(Coordinate c1, Coordinate c2); - /// - /// Calculates distance between a point and a line AB - /// - /// The coordinate to compute the distance for. - /// One point of the line. - /// Another point of the line. - /// LineDistanceMode value that specifies whether AB should be treated as infinite line or as line segment - /// The distance from c to line AB. - double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode); + /// + /// Calculates distance between a point and a line AB + /// + /// The coordinate to compute the distance for. + /// One point of the line. + /// Another point of the line. + /// LineDistanceMode value that specifies whether AB should be treated as infinite line or as line segment + /// The distance from c to line AB. + double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode); - /// - /// Calculates area of the polygon specified by given vertices - /// - /// The vertices of the polygon - /// The area of the polygon - double CalculateArea(ICoordinateList vertices); - } + /// + /// Calculates area of the polygon specified by given vertices + /// + /// The vertices of the polygon + /// The area of the polygon + double CalculateArea(ICoordinateList vertices); + } } diff --git a/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs b/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs index 2e4dbe0..b0b68af 100644 --- a/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs +++ b/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs @@ -1,54 +1,56 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms { +namespace SpatialLite.Core.Algorithms +{ /// /// Defines methods that a class providing relative geometry position computation capabilities must implement. /// - public interface IGeometryLocator { - /// - /// Determines whether specific coordinate is on line defined by two points. - /// - /// The coordinate to be tested. - /// The first point of the line. - /// The second point of the line. - /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. - /// true if coordinate C is on line AB, otherwise false. - bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode); + public interface IGeometryLocator + { + /// + /// Determines whether specific coordinate is on line defined by two points. + /// + /// The coordinate to be tested. + /// The first point of the line. + /// The second point of the line. + /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. + /// true if coordinate C is on line AB, otherwise false. + bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode); - /// - /// Determines whether specific coordinate is on the given polyline. - /// - /// The coordinate to be tested. - /// The polyline. - /// true if coordinate C is on the line, otherwise false. - bool IsOnLine(Coordinate c, ICoordinateList line); + /// + /// Determines whether specific coordinate is on the given polyline. + /// + /// The coordinate to be tested. + /// The polyline. + /// true if coordinate C is on the line, otherwise false. + bool IsOnLine(Coordinate c, ICoordinateList line); - /// - /// Determines whether specific point is in ring. - /// - /// The coordinate to be tested. - /// The ring to locate point in. - /// True if point lies inside ring, otherwise false. - bool IsInRing(Coordinate c, ICoordinateList ring); + /// + /// Determines whether specific point is in ring. + /// + /// The coordinate to be tested. + /// The ring to locate point in. + /// True if point lies inside ring, otherwise false. + bool IsInRing(Coordinate c, ICoordinateList ring); - /// - /// Determines whether two lines or line segments defined by two points each intersects. - /// - /// The first point of the first line. - /// The second point of the first line. - /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment. - /// The first point of the second line. - /// The second point of the second line. - /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment. - /// true if A1B1 intersects A2B2, otherwise returns false. - bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode); + /// + /// Determines whether two lines or line segments defined by two points each intersects. + /// + /// The first point of the first line. + /// The second point of the first line. + /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment. + /// The first point of the second line. + /// The second point of the second line. + /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment. + /// true if A1B1 intersects A2B2, otherwise returns false. + bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode); - /// - /// Determines whether two polylines defined by series of coordinates intersects. - /// - /// The first polyline to test. - /// The second polyline to test. - /// true if polylines intersets, otherwise false. - bool Intersects(ICoordinateList line1, ICoordinateList line2); - } + /// + /// Determines whether two polylines defined by series of coordinates intersects. + /// + /// The first polyline to test. + /// The second polyline to test. + /// true if polylines intersets, otherwise false. + bool Intersects(ICoordinateList line1, ICoordinateList line2); + } } diff --git a/src/SpatialLite.Core/Algorithms/LineMode.cs b/src/SpatialLite.Core/Algorithms/LineMode.cs index a8b3fb8..926fa17 100644 --- a/src/SpatialLite.Core/Algorithms/LineMode.cs +++ b/src/SpatialLite.Core/Algorithms/LineMode.cs @@ -1,16 +1,18 @@ -namespace SpatialLite.Core.Algorithms { +namespace SpatialLite.Core.Algorithms +{ /// /// Specifies how algorithms treats line defined by two points. /// - public enum LineMode { - /// - /// Line is treated as line segment. - /// - LineSegment, + public enum LineMode + { + /// + /// Line is treated as line segment. + /// + LineSegment, - /// - /// Line is treated as infinite line. - /// - Line - } + /// + /// Line is treated as infinite line. + /// + Line + } } diff --git a/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs b/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs index cd1baa3..7286297 100644 --- a/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs @@ -2,7 +2,8 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms { +namespace SpatialLite.Core.Algorithms +{ /// /// Provides methods for calculating distance and area on the surface of a sphere. /// @@ -12,134 +13,149 @@ namespace SpatialLite.Core.Algorithms { /// /// All coordinate are expected to be a long/lat pairs in degrees. /// - public class Sphere2DCalculator : IDimensionsCalculator { - - /// - /// The radius of spheric approximation of the Earth. - /// - public const double EarthRadius = 6371010; - - - - /// - /// Initializes a new instance of the Sphere2DCalculator that uses sphere approximation of the Earth. - /// - public Sphere2DCalculator() { - this.Radius = Sphere2DCalculator.EarthRadius; - } - - /// - /// Gets radius of the sphere that Sphere2DCalculator uses for calculations. - /// - public double Radius { get; private set; } - - /// - /// Calculates distance between 2 objects using great circle path. - /// - /// The first coordinate. - /// The second coordinate. - /// The distance of the points in units of the property. - public double CalculateDistance(Coordinate c1, Coordinate c2) { - double dLon = (c2.X - c1.X) * Math.PI / 180; - double dLat = (c2.Y - c1.Y) * Math.PI / 180; - - double sinLat = Math.Sin(dLat / 2); - double sinLon = Math.Sin(dLon / 2); - - double a = sinLat * sinLat + Math.Cos(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * sinLon * sinLon; - - //length or arc in radians - double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); - - return c * this.Radius; - } - - /// - /// Calculates distance between a point and a great circle path connecting points A and B. - /// - /// The coordinate to compute the distance for. - /// The first point of the great circle. - /// The second point of the great circle. - /// LineMode value that specifies whether great circle should be treated as whole circle or as arc segment between points A and B. - /// The distance from c to great circle connecting points AB in units of the property. - public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - double bearingAB = this.CalculateBearing(a, b); - double bearingAC = this.CalculateBearing(a, c); - - double distAC = this.CalculateDistance(a, c); - - //Sign can be used to determine if point is left/right of the great circle - double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / Sphere2DCalculator.EarthRadius) * Math.Sin(bearingAC - bearingAB)) * Sphere2DCalculator.EarthRadius); - - if (mode == LineMode.Line) { - return distCircleC; - } - else { - double bearingBA = this.CalculateBearing(b, a); - double bearingBC = this.CalculateBearing(b, c); - - if (Math.Abs(bearingAC - bearingAB) > Math.PI / 2) { - return distAC; - } - else if (Math.Abs(bearingBC - bearingBA) > Math.PI / 2) { - return this.CalculateDistance(b, c); - } - else { - return distCircleC; - } - } - } - - /// - /// Calculates area of the polygon on the surface of a sphere specified by given vertices. - /// - /// The vertices of the polygon. - /// The area of the polygon in squared units of the property. - /// Polygon is expected to be simple. - public double CalculateArea(ICoordinateList vertices) { - if (vertices.Count < 3) { - throw new ArgumentException("List must contain at least 3 vertices.", "vertices"); - } - - double area = 0; - int maxIndex = vertices.Count - 1; - if (vertices[0] != vertices[maxIndex]) { - maxIndex++; - } - - for (int i = 0; i <= maxIndex; i++) { - area += (this.ToRadians(vertices[(i + 1) % maxIndex].X) - this.ToRadians(vertices[(i - 1) % maxIndex].X)) * Math.Sin(this.ToRadians(vertices[i % maxIndex].Y)); - } - - return Math.Abs(area * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius); - } - - /// - /// Calculates initial course when moving from point C1 to point C2 on great circle path. - /// - /// The first point. - /// The second point - /// The bearing in radians. - /// The bearing changes as traveling along great circle. - private double CalculateBearing(Coordinate c1, Coordinate c2) { - double dLon = (c2.X - c1.X) * Math.PI / 180; - - double y = Math.Sin(dLon) * Math.Cos(c2.Y * Math.PI / 180); - double x = Math.Cos(c1.Y * Math.PI / 180) * Math.Sin(c2.Y * Math.PI / 180) - - Math.Sin(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * Math.Cos(c2.X * Math.PI / 180); - - double bearing = Math.Atan2(y, x); - - return bearing; - } - - /// - /// Converts angle in degrees to radians - /// - /// Angle in degrees - /// angle in radians - private double ToRadians(double degrees) { - return degrees * Math.PI / 180; - } - } + public class Sphere2DCalculator : IDimensionsCalculator + { + + /// + /// The radius of spheric approximation of the Earth. + /// + public const double EarthRadius = 6371010; + + + + /// + /// Initializes a new instance of the Sphere2DCalculator that uses sphere approximation of the Earth. + /// + public Sphere2DCalculator() + { + this.Radius = Sphere2DCalculator.EarthRadius; + } + + /// + /// Gets radius of the sphere that Sphere2DCalculator uses for calculations. + /// + public double Radius { get; private set; } + + /// + /// Calculates distance between 2 objects using great circle path. + /// + /// The first coordinate. + /// The second coordinate. + /// The distance of the points in units of the property. + public double CalculateDistance(Coordinate c1, Coordinate c2) + { + double dLon = (c2.X - c1.X) * Math.PI / 180; + double dLat = (c2.Y - c1.Y) * Math.PI / 180; + + double sinLat = Math.Sin(dLat / 2); + double sinLon = Math.Sin(dLon / 2); + + double a = sinLat * sinLat + Math.Cos(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * sinLon * sinLon; + + //length or arc in radians + double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); + + return c * this.Radius; + } + + /// + /// Calculates distance between a point and a great circle path connecting points A and B. + /// + /// The coordinate to compute the distance for. + /// The first point of the great circle. + /// The second point of the great circle. + /// LineMode value that specifies whether great circle should be treated as whole circle or as arc segment between points A and B. + /// The distance from c to great circle connecting points AB in units of the property. + public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + double bearingAB = this.CalculateBearing(a, b); + double bearingAC = this.CalculateBearing(a, c); + + double distAC = this.CalculateDistance(a, c); + + //Sign can be used to determine if point is left/right of the great circle + double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / Sphere2DCalculator.EarthRadius) * Math.Sin(bearingAC - bearingAB)) * Sphere2DCalculator.EarthRadius); + + if (mode == LineMode.Line) + { + return distCircleC; + } + else + { + double bearingBA = this.CalculateBearing(b, a); + double bearingBC = this.CalculateBearing(b, c); + + if (Math.Abs(bearingAC - bearingAB) > Math.PI / 2) + { + return distAC; + } + else if (Math.Abs(bearingBC - bearingBA) > Math.PI / 2) + { + return this.CalculateDistance(b, c); + } + else + { + return distCircleC; + } + } + } + + /// + /// Calculates area of the polygon on the surface of a sphere specified by given vertices. + /// + /// The vertices of the polygon. + /// The area of the polygon in squared units of the property. + /// Polygon is expected to be simple. + public double CalculateArea(ICoordinateList vertices) + { + if (vertices.Count < 3) + { + throw new ArgumentException("List must contain at least 3 vertices.", nameof(vertices)); + } + + double area = 0; + int maxIndex = vertices.Count - 1; + if (vertices[0] != vertices[maxIndex]) + { + maxIndex++; + } + + for (int i = 0; i <= maxIndex; i++) + { + area += (this.ToRadians(vertices[(i + 1) % maxIndex].X) - this.ToRadians(vertices[(i - 1) % maxIndex].X)) * Math.Sin(this.ToRadians(vertices[i % maxIndex].Y)); + } + + return Math.Abs(area * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius); + } + + /// + /// Calculates initial course when moving from point C1 to point C2 on great circle path. + /// + /// The first point. + /// The second point + /// The bearing in radians. + /// The bearing changes as traveling along great circle. + private double CalculateBearing(Coordinate c1, Coordinate c2) + { + double dLon = (c2.X - c1.X) * Math.PI / 180; + + double y = Math.Sin(dLon) * Math.Cos(c2.Y * Math.PI / 180); + double x = Math.Cos(c1.Y * Math.PI / 180) * Math.Sin(c2.Y * Math.PI / 180) - + Math.Sin(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * Math.Cos(c2.X * Math.PI / 180); + + double bearing = Math.Atan2(y, x); + + return bearing; + } + + /// + /// Converts angle in degrees to radians + /// + /// Angle in degrees + /// angle in radians + private double ToRadians(double degrees) + { + return degrees * Math.PI / 180; + } + } } diff --git a/src/SpatialLite.Core/Geometries/CoordinateList.cs b/src/SpatialLite.Core/Geometries/CoordinateList.cs index d377f30..05ec6b2 100644 --- a/src/SpatialLite.Core/Geometries/CoordinateList.cs +++ b/src/SpatialLite.Core/Geometries/CoordinateList.cs @@ -3,107 +3,123 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents read-write list of Coordinates. /// - public class CoordinateList : ICoordinateList { + public class CoordinateList : ICoordinateList + { - private List _storage; + private List _storage; - /// - /// Initializes a new instance of the CoordinateList class, that is empty. - /// - public CoordinateList() { - _storage = new List(); - } + /// + /// Initializes a new instance of the CoordinateList class, that is empty. + /// + public CoordinateList() + { + _storage = new List(); + } - /// - /// Initializes a new instance of the CoordinateList class that contains coordinates from the given collection. - /// - /// The collection whose elements are used to fill CoordinateList. - public CoordinateList(IEnumerable coords) { - _storage = new List(coords); - } + /// + /// Initializes a new instance of the CoordinateList class that contains coordinates from the given collection. + /// + /// The collection whose elements are used to fill CoordinateList. + public CoordinateList(IEnumerable coords) + { + _storage = new List(coords); + } - /// - /// Gets number of Coordinates in the list. - /// - public int Count { - get { - return _storage.Count; - } - } + /// + /// Gets number of Coordinates in the list. + /// + public int Count + { + get + { + return _storage.Count; + } + } - /// - /// Gets or sets Coordinate at the given index. - /// - /// The zero-based index of the Coordinate to get or set. - /// The element at the specified index. - public Coordinate this[int index] { - get { - return _storage[index]; - } - set { - _storage[index] = value; - } - } + /// + /// Gets or sets Coordinate at the given index. + /// + /// The zero-based index of the Coordinate to get or set. + /// The element at the specified index. + public Coordinate this[int index] + { + get + { + return _storage[index]; + } + set + { + _storage[index] = value; + } + } - /// - /// Adds Coordinate to the end of the list. - /// - /// The Coordinate to add to the list. - public void Add(Coordinate coord) { - _storage.Add(coord); - } + /// + /// Adds Coordinate to the end of the list. + /// + /// The Coordinate to add to the list. + public void Add(Coordinate coord) + { + _storage.Add(coord); + } - /// - /// Adds collection of coordinates to the end of the list. - /// - /// The collection of coordinates to add to the list. - public void Add(IEnumerable coords) { - _storage.AddRange(coords); - } + /// + /// Adds collection of coordinates to the end of the list. + /// + /// The collection of coordinates to add to the list. + public void Add(IEnumerable coords) + { + _storage.AddRange(coords); + } - /// - /// Insertes Coordinate to the list at the specified index. - /// - /// The zero-based index at which coord should be inserted. - /// The Coordinate to insert into list. - /// If index equals the number of items in the list, then item is appended to the list. - public void Insert(int index, Coordinate coord) { - _storage.Insert(index, coord); - } + /// + /// Insertes Coordinate to the list at the specified index. + /// + /// The zero-based index at which coord should be inserted. + /// The Coordinate to insert into list. + /// If index equals the number of items in the list, then item is appended to the list. + public void Insert(int index, Coordinate coord) + { + _storage.Insert(index, coord); + } - /// - /// Removes Coordinate at the specified index from the list. - /// - /// The zero-based index of the Coordinate to remove. - public void RemoveAt(int index) { - _storage.RemoveAt(index); - } + /// + /// Removes Coordinate at the specified index from the list. + /// + /// The zero-based index of the Coordinate to remove. + public void RemoveAt(int index) + { + _storage.RemoveAt(index); + } - /// - /// Removes all Coordinates from the collection. - /// - public void Clear() { - _storage.Clear(); - } + /// + /// Removes all Coordinates from the collection. + /// + public void Clear() + { + _storage.Clear(); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - public IEnumerator GetEnumerator() { - return _storage.GetEnumerator(); - } + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + public IEnumerator GetEnumerator() + { + return _storage.GetEnumerator(); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - IEnumerator IEnumerable.GetEnumerator() { - return ((IEnumerable)_storage).GetEnumerator(); - } - } + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)_storage).GetEnumerator(); + } + } } diff --git a/src/SpatialLite.Core/Geometries/Geometry.cs b/src/SpatialLite.Core/Geometries/Geometry.cs index 4a4cee2..c443558 100644 --- a/src/SpatialLite.Core/Geometries/Geometry.cs +++ b/src/SpatialLite.Core/Geometries/Geometry.cs @@ -2,34 +2,36 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represetns the base class for all geometry object. /// - public abstract class Geometry : IGeometry { + public abstract class Geometry : IGeometry + { - /// - /// Gets a value indicating whether this has Z-coordinates. - /// - public abstract bool Is3D { get; } + /// + /// Gets a value indicating whether this has Z-coordinates. + /// + public abstract bool Is3D { get; } - /// - /// Gets a value indicating whether this has M values. - /// - public abstract bool IsMeasured { get; } + /// + /// Gets a value indicating whether this has M values. + /// + public abstract bool IsMeasured { get; } - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the Geometry object. - /// - public abstract Envelope GetEnvelope(); + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the Geometry object. + /// + public abstract Envelope GetEnvelope(); /// /// Gets collection of all of this IGeometry object /// /// the collection of all of this object public abstract IEnumerable GetCoordinates(); - } + } } diff --git a/src/SpatialLite.Core/Geometries/GeometryCollection.cs b/src/SpatialLite.Core/Geometries/GeometryCollection.cs index d2457de..f27bb06 100644 --- a/src/SpatialLite.Core/Geometries/GeometryCollection.cs +++ b/src/SpatialLite.Core/Geometries/GeometryCollection.cs @@ -3,90 +3,103 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents generic collection of geometry objects. /// /// All objects should be in the same spatial reference system, but it isn't enforced by this class. /// The type of objects in the collection - public class GeometryCollection : Geometry, IGeometryCollection where T : IGeometry { - private readonly List _geometries; + public class GeometryCollection : Geometry, IGeometryCollection where T : IGeometry + { + private readonly List _geometries; - /// - /// Initializes a new instance of the GeometryCollection class that is empty and has assigned WSG84 coordinate reference system. - /// - public GeometryCollection() - : base() { - _geometries = new List(); - } + /// + /// Initializes a new instance of the GeometryCollection class that is empty and has assigned WSG84 coordinate reference system. + /// + public GeometryCollection() + : base() + { + _geometries = new List(); + } - /// - /// Initializes a new instance of the GeometryCollection class in WSG84 coordinate reference system and fills it with specified geometries. - /// - /// Geometry objects to be added to the collection - public GeometryCollection(IEnumerable geometries) - : base() { - _geometries = new List(geometries); - } + /// + /// Initializes a new instance of the GeometryCollection class in WSG84 coordinate reference system and fills it with specified geometries. + /// + /// Geometry objects to be added to the collection + public GeometryCollection(IEnumerable geometries) + : base() + { + _geometries = new List(geometries); + } - /// - /// Gets a value indicating whether the this "/> has Z ordinates set. - /// - /// - /// Is3D returns true if any of the geometries contained in this GeometryCollection has Z ordinate set. - /// - public override bool Is3D { - get { - return _geometries.Any(geometry => geometry.Is3D); - } - } + /// + /// Gets a value indicating whether the this "/> has Z ordinates set. + /// + /// + /// Is3D returns true if any of the geometries contained in this GeometryCollection has Z ordinate set. + /// + public override bool Is3D + { + get + { + return _geometries.Any(geometry => geometry.Is3D); + } + } - /// - /// Gets a value indicating whether this has M values. - /// - /// - /// IsMeasured returns true if any of the geometries in this GeometryCollection has M value set. - /// - public override bool IsMeasured { - get { return _geometries.Any(c => c.IsMeasured); } - } + /// + /// Gets a value indicating whether this has M values. + /// + /// + /// IsMeasured returns true if any of the geometries in this GeometryCollection has M value set. + /// + public override bool IsMeasured + { + get { return _geometries.Any(c => c.IsMeasured); } + } - /// - /// Gets the list of IGeometry objects in this collection - /// - public List Geometries { - get { - return _geometries; - } - } + /// + /// Gets the list of IGeometry objects in this collection + /// + public List Geometries + { + get + { + return _geometries; + } + } - /// - /// Gets collection of geometry obejcts from this GeometryCollection as the collection of IGeometry objects. - /// - IEnumerable IGeometryCollection.Geometries { - get { return _geometries; } - } + /// + /// Gets collection of geometry obejcts from this GeometryCollection as the collection of IGeometry objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return _geometries; } + } - /// - /// Computes envelope of the GeometryCollection object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the GeometryCollection object. - /// - public override Envelope GetEnvelope() { - Envelope result = new Envelope(); - foreach (var item in _geometries) { - result.Extend(item.GetEnvelope()); - } + /// + /// Computes envelope of the GeometryCollection object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the GeometryCollection object. + /// + public override Envelope GetEnvelope() + { + Envelope result = new Envelope(); + foreach (var item in _geometries) + { + result.Extend(item.GetEnvelope()); + } - return result; - } + return result; + } /// /// Gets collection of all of this IGeometry object /// /// the collection of all of this object - public override IEnumerable GetCoordinates() { + public override IEnumerable GetCoordinates() + { return this.Geometries.SelectMany(o => o.GetCoordinates()); } } diff --git a/src/SpatialLite.Core/Geometries/LineString.cs b/src/SpatialLite.Core/Geometries/LineString.cs index 7a9f164..cb9aafd 100644 --- a/src/SpatialLite.Core/Geometries/LineString.cs +++ b/src/SpatialLite.Core/Geometries/LineString.cs @@ -2,90 +2,104 @@ using System.Linq; using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents a curve with linear interpolation between consecutive vertices. /// - public class LineString : Geometry, ILineString { + public class LineString : Geometry, ILineString + { - private CoordinateList _coordinates; + private CoordinateList _coordinates; - /// - /// Initializes a new instance of the LineString class that is empty and has assigned WSG84 coordinate reference system. - /// - public LineString() - : base() { - _coordinates = new CoordinateList(); - } + /// + /// Initializes a new instance of the LineString class that is empty and has assigned WSG84 coordinate reference system. + /// + public LineString() + : base() + { + _coordinates = new CoordinateList(); + } - /// - /// Initializes a new instance of the LineString class with specified coordinates and WSG84 coordinate reference system. - /// - /// The collection of coordinates to be copied to the new LineString. - public LineString(IEnumerable coords) - : base() { - _coordinates = new CoordinateList(coords); - } + /// + /// Initializes a new instance of the LineString class with specified coordinates and WSG84 coordinate reference system. + /// + /// The collection of coordinates to be copied to the new LineString. + public LineString(IEnumerable coords) + : base() + { + _coordinates = new CoordinateList(coords); + } - /// - /// Gets a value indicating whether the this has Z-coordinates set. - /// - /// - /// Is3D returns true if any of the coordinates in this LineString has Z-coordinate set. - /// - public override bool Is3D { - get { return _coordinates.Any(c => c.Is3D); } - } + /// + /// Gets a value indicating whether the this has Z-coordinates set. + /// + /// + /// Is3D returns true if any of the coordinates in this LineString has Z-coordinate set. + /// + public override bool Is3D + { + get { return _coordinates.Any(c => c.Is3D); } + } - /// - /// Gets a value indicating whether this has M values. - /// - /// - /// IsMeasured returns true if any of the coordinates in this LineString has M value set. - /// - public override bool IsMeasured { - get { return _coordinates.Any(c => c.IsMeasured); } - } + /// + /// Gets a value indicating whether this has M values. + /// + /// + /// IsMeasured returns true if any of the coordinates in this LineString has M value set. + /// + public override bool IsMeasured + { + get { return _coordinates.Any(c => c.IsMeasured); } + } - /// - /// Gets the list of çoordinates that define this LisneString - /// - public virtual ICoordinateList Coordinates { - get { return _coordinates; } - } + /// + /// Gets the list of çoordinates that define this LisneString + /// + public virtual ICoordinateList Coordinates + { + get { return _coordinates; } + } - /// - /// Gets the list of çoordinates that define this LisneString - /// - ICoordinateList ILineString.Coordinates { - get { return this.Coordinates; } - } + /// + /// Gets the list of çoordinates that define this LisneString + /// + ICoordinateList ILineString.Coordinates + { + get { return this.Coordinates; } + } - /// - /// Gets the first coordinate of the ILineString object. - /// - public Coordinate Start { - get { - if (_coordinates.Count == 0) { - return Coordinate.Empty; - } + /// + /// Gets the first coordinate of the ILineString object. + /// + public Coordinate Start + { + get + { + if (_coordinates.Count == 0) + { + return Coordinate.Empty; + } - return _coordinates[0]; - } - } + return _coordinates[0]; + } + } - /// - /// Gets the last coordinate of the ILineString object. - /// - public Coordinate End { - get { - if (_coordinates.Count == 0) { - return Coordinate.Empty; - } + /// + /// Gets the last coordinate of the ILineString object. + /// + public Coordinate End + { + get + { + if (_coordinates.Count == 0) + { + return Coordinate.Empty; + } - return _coordinates[_coordinates.Count - 1]; - } - } + return _coordinates[_coordinates.Count - 1]; + } + } /// /// Gets a value indicating whether this LineString is closed. @@ -93,33 +107,39 @@ public Coordinate End { /// /// The LineStringBase is closed if and are identical. /// - public virtual bool IsClosed { - get { - if (_coordinates.Count == 0) { - return false; - } - else { - return this.Start.Equals(this.End); - } - } - } + public virtual bool IsClosed + { + get + { + if (_coordinates.Count == 0) + { + return false; + } + else + { + return this.Start.Equals(this.End); + } + } + } - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the IGeometry object. - /// - public override Envelope GetEnvelope() { - return new Envelope(_coordinates); - } + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the IGeometry object. + /// + public override Envelope GetEnvelope() + { + return new Envelope(_coordinates); + } /// /// Gets collection of all of this IGeometry object /// /// the collection of all of this object - public override IEnumerable GetCoordinates() { + public override IEnumerable GetCoordinates() + { return this.Coordinates; } - } + } } diff --git a/src/SpatialLite.Core/Geometries/MultiLineString.cs b/src/SpatialLite.Core/Geometries/MultiLineString.cs index dcf4f49..32893ed 100644 --- a/src/SpatialLite.Core/Geometries/MultiLineString.cs +++ b/src/SpatialLite.Core/Geometries/MultiLineString.cs @@ -2,32 +2,37 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents a collection of LineStrings /// - public class MultiLineString : GeometryCollection, IMultiLineString { + public class MultiLineString : GeometryCollection, IMultiLineString + { - /// - /// Initializes a new instance of the MultiLineString class that is empty and has assigned WSG84 coordinate reference system. - /// - public MultiLineString() - : base() { - } + /// + /// Initializes a new instance of the MultiLineString class that is empty and has assigned WSG84 coordinate reference system. + /// + public MultiLineString() + : base() + { + } - /// - /// Initializes a new instance of the MultiLineString class with specified LineStrings - /// - /// The collection of LineString to be copied to the new MultiLineString. - public MultiLineString(IEnumerable linestrings) - : base(linestrings) { - } + /// + /// Initializes a new instance of the MultiLineString class with specified LineStrings + /// + /// The collection of LineString to be copied to the new MultiLineString. + public MultiLineString(IEnumerable linestrings) + : base(linestrings) + { + } - /// - /// Gets collection of geometry obejcts from this MultiLineString as the collection of IMultiLineString objects. - /// - IEnumerable IGeometryCollection.Geometries { - get { return base.Geometries; } - } - } + /// + /// Gets collection of geometry obejcts from this MultiLineString as the collection of IMultiLineString objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return base.Geometries; } + } + } } diff --git a/src/SpatialLite.Core/Geometries/MultiPoint.cs b/src/SpatialLite.Core/Geometries/MultiPoint.cs index 32776e6..c674ca2 100644 --- a/src/SpatialLite.Core/Geometries/MultiPoint.cs +++ b/src/SpatialLite.Core/Geometries/MultiPoint.cs @@ -2,32 +2,37 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents a collection of Points /// - public class MultiPoint : GeometryCollection, IMultiPoint { + public class MultiPoint : GeometryCollection, IMultiPoint + { - /// - /// Initializes a new instance of the MultiPoint class that is empty and has assigned WSG84 coordinate reference system. - /// - public MultiPoint() - : base() { - } + /// + /// Initializes a new instance of the MultiPoint class that is empty and has assigned WSG84 coordinate reference system. + /// + public MultiPoint() + : base() + { + } - /// - /// Initializes a new instance of the MultiPoint class with specified points. - /// - /// The collection of points to be copied to the new MultiPoint. - public MultiPoint(IEnumerable points) - : base(points) { - } + /// + /// Initializes a new instance of the MultiPoint class with specified points. + /// + /// The collection of points to be copied to the new MultiPoint. + public MultiPoint(IEnumerable points) + : base(points) + { + } - /// - /// Gets collection of points from this Multipoint as the collection of IPoint objects. - /// - IEnumerable IGeometryCollection.Geometries { - get { return base.Geometries; } - } - } -} \ No newline at end of file + /// + /// Gets collection of points from this Multipoint as the collection of IPoint objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return base.Geometries; } + } + } +} diff --git a/src/SpatialLite.Core/Geometries/MultiPolygon.cs b/src/SpatialLite.Core/Geometries/MultiPolygon.cs index b72ca76..99a5f55 100644 --- a/src/SpatialLite.Core/Geometries/MultiPolygon.cs +++ b/src/SpatialLite.Core/Geometries/MultiPolygon.cs @@ -2,32 +2,37 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents a collection of Polygons /// - public class MultiPolygon : GeometryCollection, IMultiPolygon { + public class MultiPolygon : GeometryCollection, IMultiPolygon + { - /// - /// Initializes a new instance of the MultiPolygon class that is empty and has assigned WSG84 coordinate reference system. - /// - public MultiPolygon() - : base() { - } + /// + /// Initializes a new instance of the MultiPolygon class that is empty and has assigned WSG84 coordinate reference system. + /// + public MultiPolygon() + : base() + { + } - /// - /// Initializes a new instance of the MultiPolygon class with specified Polygons - /// - /// The collection of Polygons to be copied to the new MultiPolygon. - public MultiPolygon(IEnumerable polygons) - : base(polygons) { - } + /// + /// Initializes a new instance of the MultiPolygon class with specified Polygons + /// + /// The collection of Polygons to be copied to the new MultiPolygon. + public MultiPolygon(IEnumerable polygons) + : base(polygons) + { + } - /// - /// Gets collection of polygons from this MultiPolygon as the collection of IPolygon objects. - /// - IEnumerable IGeometryCollection.Geometries { - get { return base.Geometries; } - } - } + /// + /// Gets collection of polygons from this MultiPolygon as the collection of IPolygon objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return base.Geometries; } + } + } } diff --git a/src/SpatialLite.Core/Geometries/Point.cs b/src/SpatialLite.Core/Geometries/Point.cs index 6656f88..e2bf7b1 100644 --- a/src/SpatialLite.Core/Geometries/Point.cs +++ b/src/SpatialLite.Core/Geometries/Point.cs @@ -2,103 +2,117 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents a location in the coordinate space. /// - public class Point : Geometry, IPoint { + public class Point : Geometry, IPoint + { - private Coordinate _position = Coordinate.Empty; + private Coordinate _position = Coordinate.Empty; - /// - /// Initializes a new instance of the Point class that is empty and has assigned the WSG84 coordinate reference system. - /// - public Point() - : base() { - } + /// + /// Initializes a new instance of the Point class that is empty and has assigned the WSG84 coordinate reference system. + /// + public Point() + : base() + { + } - /// - /// Initializes a new instance of the Point class with specified X and Y coordinates in WSG84 coordinate reference system. - /// - /// The X-coordinate of the Point - /// The Y-coordinate of the Point - public Point(double x, double y) - : base() { - _position = new Coordinate(x, y); - } + /// + /// Initializes a new instance of the Point class with specified X and Y coordinates in WSG84 coordinate reference system. + /// + /// The X-coordinate of the Point + /// The Y-coordinate of the Point + public Point(double x, double y) + : base() + { + _position = new Coordinate(x, y); + } - /// - /// Initializes a new instance of the Point class with specified X, Y and Z coordinates in WSG84 coordinate reference system. - /// - /// The X-coordinate of the Point - /// The Y-coordinate of the Point - /// The Z-coordinate of the Point - public Point(double x, double y, double z) - : base() { - _position = new Coordinate(x, y, z); - } + /// + /// Initializes a new instance of the Point class with specified X, Y and Z coordinates in WSG84 coordinate reference system. + /// + /// The X-coordinate of the Point + /// The Y-coordinate of the Point + /// The Z-coordinate of the Point + public Point(double x, double y, double z) + : base() + { + _position = new Coordinate(x, y, z); + } - /// - /// Initializes a new instance of the Point class with specified X, Y, Z coordinates and M value in WSG84 coordinate reference system. - /// - /// The X-coordinate of the Point - /// The Y-coordinate of the Point - /// The Z-coordinate of the Point - /// The measured value of the Point - public Point(double x, double y, double z, double m) - : base() { - _position = new Coordinate(x, y, z, m); - } + /// + /// Initializes a new instance of the Point class with specified X, Y, Z coordinates and M value in WSG84 coordinate reference system. + /// + /// The X-coordinate of the Point + /// The Y-coordinate of the Point + /// The Z-coordinate of the Point + /// The measured value of the Point + public Point(double x, double y, double z, double m) + : base() + { + _position = new Coordinate(x, y, z, m); + } - /// - /// Initializes a new instance of the Point class with specific Position in WSG84 coordinate reference system. - /// - /// The position of this Point - public Point(Coordinate position) - : base() { - _position = position; - } + /// + /// Initializes a new instance of the Point class with specific Position in WSG84 coordinate reference system. + /// + /// The position of this Point + public Point(Coordinate position) + : base() + { + _position = position; + } - /// - /// Gets or sets position of this Point - /// - public Coordinate Position { - get { - return _position; - } + /// + /// Gets or sets position of this Point + /// + public Coordinate Position + { + get + { + return _position; + } - set { - _position = value; - } - } + set + { + _position = value; + } + } - /// - /// Gets a value indicating whether the this Point has Z-coordinate set. - /// - public override bool Is3D { - get { return _position.Is3D; } - } + /// + /// Gets a value indicating whether the this Point has Z-coordinate set. + /// + public override bool Is3D + { + get { return _position.Is3D; } + } - /// - /// Gets a value indicating whether the this Point has M value set. - /// - public override bool IsMeasured { - get { return _position.IsMeasured; } - } + /// + /// Gets a value indicating whether the this Point has M value set. + /// + public override bool IsMeasured + { + get { return _position.IsMeasured; } + } /// /// Returns Envelope, that covers this Point. /// /// Envelope, that covers this Point. - public override Envelope GetEnvelope() { - return new Envelope(this.Position); - } + public override Envelope GetEnvelope() + { + return new Envelope(this.Position); + } /// /// Gets collection of all of this IGeometry object /// /// the collection of all of this object - public override IEnumerable GetCoordinates() { + public override IEnumerable GetCoordinates() + { yield return this.Position; } } diff --git a/src/SpatialLite.Core/Geometries/Polygon.cs b/src/SpatialLite.Core/Geometries/Polygon.cs index 507bf50..5849fc6 100644 --- a/src/SpatialLite.Core/Geometries/Polygon.cs +++ b/src/SpatialLite.Core/Geometries/Polygon.cs @@ -3,84 +3,94 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Represents a polygon, which may include holes. /// - public class Polygon : Geometry, IPolygon { - /// - /// Initializes a new instance of the Polygon class in WSG84 coordinate reference system that without ExteriorRing and no InteriorRings. - /// - public Polygon() - : base() { - this.ExteriorRing = new CoordinateList(); - this.InteriorRings = new List(0); - } + public class Polygon : Geometry, IPolygon + { + /// + /// Initializes a new instance of the Polygon class in WSG84 coordinate reference system that without ExteriorRing and no InteriorRings. + /// + public Polygon() + : base() + { + this.ExteriorRing = new CoordinateList(); + this.InteriorRings = new List(0); + } - /// - /// Initializes a new instance of the Polygon class with the given exterior boundary in WSG84 coordinate reference system. - /// - /// The exterior boundary of the polygon. - public Polygon(ICoordinateList exteriorRing) { - this.ExteriorRing = exteriorRing; - this.InteriorRings = new List(0); - } + /// + /// Initializes a new instance of the Polygon class with the given exterior boundary in WSG84 coordinate reference system. + /// + /// The exterior boundary of the polygon. + public Polygon(ICoordinateList exteriorRing) + { + this.ExteriorRing = exteriorRing; + this.InteriorRings = new List(0); + } - /// - /// Gets or sets the exterior boundary of the polygon. - /// - public ICoordinateList ExteriorRing { get; set; } + /// + /// Gets or sets the exterior boundary of the polygon. + /// + public ICoordinateList ExteriorRing { get; set; } - /// - /// Gets the exterior boundary of the polygon. - /// - ICoordinateList IPolygon.ExteriorRing { - get { return this.ExteriorRing; } - } + /// + /// Gets the exterior boundary of the polygon. + /// + ICoordinateList IPolygon.ExteriorRing + { + get { return this.ExteriorRing; } + } - /// - /// Gets the list of holes in the polygon. - /// - public List InteriorRings { get; private set; } + /// + /// Gets the list of holes in the polygon. + /// + public List InteriorRings { get; private set; } - /// - /// Gets the list of holes in the polygon. - /// - IEnumerable IPolygon.InteriorRings { - get { return this.InteriorRings; } - } + /// + /// Gets the list of holes in the polygon. + /// + IEnumerable IPolygon.InteriorRings + { + get { return this.InteriorRings; } + } - /// - /// Gets a value indicating whether the this has Z-coordinate set. - /// - public override bool Is3D { - //TODO consider using InteriorRings as well - get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.Is3D); } - } + /// + /// Gets a value indicating whether the this has Z-coordinate set. + /// + public override bool Is3D + { + //TODO consider using InteriorRings as well + get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.Is3D); } + } - /// - /// Gets a value indicating whether this has M values. - /// - public override bool IsMeasured { - //TODO consider using InteriorRings as well - get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.IsMeasured); } - } + /// + /// Gets a value indicating whether this has M values. + /// + public override bool IsMeasured + { + //TODO consider using InteriorRings as well + get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.IsMeasured); } + } - /// - /// Computes envelope of the Polygon object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the Polygon object. - /// - public override Envelope GetEnvelope() { - return this.ExteriorRing.Count == 0 ? new Envelope() : new Envelope(this.ExteriorRing); - } + /// + /// Computes envelope of the Polygon object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the Polygon object. + /// + public override Envelope GetEnvelope() + { + return this.ExteriorRing.Count == 0 ? new Envelope() : new Envelope(this.ExteriorRing); + } /// /// Gets collection of all of this IGeometry object /// /// the collection of all of this object - public override IEnumerable GetCoordinates() { + public override IEnumerable GetCoordinates() + { return this.ExteriorRing.Concat(this.InteriorRings.SelectMany(o => o)); } } diff --git a/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs b/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs index ec4ee5e..61dd35b 100644 --- a/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs +++ b/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs @@ -3,24 +3,29 @@ using System.Collections.Generic; using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries { +namespace SpatialLite.Core.Geometries +{ /// /// Provides read-only ICoordinateList wrapper around collection of points /// - public class ReadOnlyCoordinateList : ICoordinateList where T : IPoint { + public class ReadOnlyCoordinateList : ICoordinateList where T : IPoint + { /// /// Initializes a new instance of the ReadOnlyCoordinateList class with specified source list fo nodes /// /// The list of Points to be used as source for this ReadOnlyCoordinateList - public ReadOnlyCoordinateList(IReadOnlyList source) { + public ReadOnlyCoordinateList(IReadOnlyList source) + { this.Source = source; } /// /// Gets number of Coordinates in the list. /// - public int Count { - get { + public int Count + { + get + { return this.Source.Count; } } @@ -35,11 +40,14 @@ public int Count { /// /// The zero-based index of the Coordinate to get or set. /// The element at the specified index. - public Coordinate this[int index] { - get { + public Coordinate this[int index] + { + get + { return this.Source[index].Position; } - set { + set + { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } } @@ -48,7 +56,8 @@ public Coordinate this[int index] { /// Adds Coordinate to the end of the list. /// /// The Coordinate to add to the list. - public void Add(Coordinate coord) { + public void Add(Coordinate coord) + { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } @@ -56,7 +65,8 @@ public void Add(Coordinate coord) { /// Adds collection of coordinates to the end of the list. /// /// The collection of coordinates to add to the list. - public void Add(IEnumerable coords) { + public void Add(IEnumerable coords) + { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } @@ -66,7 +76,8 @@ public void Add(IEnumerable coords) { /// The zero-based index at which coord should be inserted. /// The Coordinate to insert into list. /// If index equals the number of items in the list, then item is appended to the list. - public void Insert(int index, Coordinate coord) { + public void Insert(int index, Coordinate coord) + { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } @@ -74,14 +85,16 @@ public void Insert(int index, Coordinate coord) { /// Removes Coordinate at the specified index from the list. /// /// The zero-based index of the Coordinate to remove. - public void RemoveAt(int index) { + public void RemoveAt(int index) + { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } /// /// Removes all Coordinates from the collection. /// - public void Clear() { + public void Clear() + { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } @@ -89,8 +102,10 @@ public void Clear() { /// Returns an enumerator that iterates through the CoordinateList /// /// The Enumerator for the CoordinateList - public IEnumerator GetEnumerator() { - foreach (var node in this.Source) { + public IEnumerator GetEnumerator() + { + foreach (var node in this.Source) + { yield return node.Position; } } @@ -99,7 +114,8 @@ public IEnumerator GetEnumerator() { /// Returns an enumerator that iterates through the CoordinateList /// /// The Enumerator for the CoordinateList - IEnumerator IEnumerable.GetEnumerator() { + IEnumerator IEnumerable.GetEnumerator() + { return this.GetEnumerator(); } } diff --git a/src/SpatialLite.Core/IO/BinaryEncoding.cs b/src/SpatialLite.Core/IO/BinaryEncoding.cs index 03ece00..ddcbc1c 100644 --- a/src/SpatialLite.Core/IO/BinaryEncoding.cs +++ b/src/SpatialLite.Core/IO/BinaryEncoding.cs @@ -1,15 +1,17 @@ -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Specifies byte ordering in multibyte values. /// - public enum BinaryEncoding : byte { - /// - /// Most significant byte first. - /// - BigEndian = 0, - /// - /// Least significant byte first. - /// - LittleEndian = 1 - } + public enum BinaryEncoding : byte + { + /// + /// Most significant byte first. + /// + BigEndian = 0, + /// + /// Least significant byte first. + /// + LittleEndian = 1 + } } diff --git a/src/SpatialLite.Core/IO/TokenType.cs b/src/SpatialLite.Core/IO/TokenType.cs index 1910def..655b2d5 100644 --- a/src/SpatialLite.Core/IO/TokenType.cs +++ b/src/SpatialLite.Core/IO/TokenType.cs @@ -1,41 +1,43 @@ -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Represents type of the WKT token. /// - internal enum TokenType { - /// - /// String token - it consists of a-zA-Z characters - /// - STRING, + internal enum TokenType + { + /// + /// String token - it consists of a-zA-Z characters + /// + STRING, - /// - /// WHITESPACE token (' ', '\t', '\r', '\n'). - /// - WHITESPACE, + /// + /// WHITESPACE token (' ', '\t', '\r', '\n'). + /// + WHITESPACE, - /// - /// '(' token - /// - LEFT_PARENTHESIS, + /// + /// '(' token + /// + LEFT_PARENTHESIS, - /// - /// ')' token - /// - RIGHT_PARENTHESIS, + /// + /// ')' token + /// + RIGHT_PARENTHESIS, - /// - /// ',' token - /// - COMMA, + /// + /// ',' token + /// + COMMA, - /// - /// Number token - it consists of '-','0'-'9' and '.' characters - /// - NUMBER, + /// + /// Number token - it consists of '-','0'-'9' and '.' characters + /// + NUMBER, - /// - /// Token that represents end of available data - /// - END_OF_DATA - } + /// + /// Token that represents end of available data + /// + END_OF_DATA + } } diff --git a/src/SpatialLite.Core/IO/WkbFormatException.cs b/src/SpatialLite.Core/IO/WkbFormatException.cs index f7d6f23..e460505 100644 --- a/src/SpatialLite.Core/IO/WkbFormatException.cs +++ b/src/SpatialLite.Core/IO/WkbFormatException.cs @@ -1,16 +1,19 @@ using System; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Represents exception that occurs if WkbReader encouters invalid data. /// - public class WkbFormatException : Exception { - /// - /// Initializes a new instance of the WktParseException class. - /// - /// The message that describes the error. - public WkbFormatException(string message) - : base(message) { - } - } + public class WkbFormatException : Exception + { + /// + /// Initializes a new instance of the WktParseException class. + /// + /// The message that describes the error. + public WkbFormatException(string message) + : base(message) + { + } + } } diff --git a/src/SpatialLite.Core/IO/WkbGeometryType.cs b/src/SpatialLite.Core/IO/WkbGeometryType.cs index 4ab5689..14dd964 100644 --- a/src/SpatialLite.Core/IO/WkbGeometryType.cs +++ b/src/SpatialLite.Core/IO/WkbGeometryType.cs @@ -1,50 +1,52 @@ -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Defines WkbGeometryType. /// - internal enum WkbGeometryType : uint { - Point = 1, - LineString = 2, - Polygon = 3, - Triangle = 17, - MultiPoint = 4, - MultiLineString = 5, - MultiPolygon = 6, - GeometryCollection = 7, - PolyhedralSurface = 15, - TIN = 16, + internal enum WkbGeometryType : uint + { + Point = 1, + LineString = 2, + Polygon = 3, + Triangle = 17, + MultiPoint = 4, + MultiLineString = 5, + MultiPolygon = 6, + GeometryCollection = 7, + PolyhedralSurface = 15, + TIN = 16, - PointZ = 1001, - LineStringZ = 1002, - PolygonZ = 1003, - Trianglez = 1017, - MultiPointZ = 1004, - MultiLineStringZ = 1005, - MultiPolygonZ = 1006, - GeometryCollectionZ = 1007, - PolyhedralSurfaceZ = 1015, - TINZ = 1016, + PointZ = 1001, + LineStringZ = 1002, + PolygonZ = 1003, + Trianglez = 1017, + MultiPointZ = 1004, + MultiLineStringZ = 1005, + MultiPolygonZ = 1006, + GeometryCollectionZ = 1007, + PolyhedralSurfaceZ = 1015, + TINZ = 1016, - PointM = 2001, - LineStringM = 2002, - PolygonM = 2003, - TriangleM = 2017, - MultiPointM = 2004, - MultiLineStringM = 2005, - MultiPolygonM = 2006, - GeometryCollectionM = 2007, - PolyhedralSurfaceM = 2015, - TINM = 2016, + PointM = 2001, + LineStringM = 2002, + PolygonM = 2003, + TriangleM = 2017, + MultiPointM = 2004, + MultiLineStringM = 2005, + MultiPolygonM = 2006, + GeometryCollectionM = 2007, + PolyhedralSurfaceM = 2015, + TINM = 2016, - PointZM = 3001, - LineStringZM = 3002, - PolygonZM = 3003, - TriangleZM = 3017, - MultiPointZM = 3004, - MultiLineStringZM = 3005, - MultiPolygonZM = 3006, - GeometryCollectionZM = 3007, - PolyhedralSurfaceZM = 3015, - TinZM = 3016 - } + PointZM = 3001, + LineStringZM = 3002, + PolygonZM = 3003, + TriangleZM = 3017, + MultiPointZM = 3004, + MultiLineStringZM = 3005, + MultiPolygonZM = 3006, + GeometryCollectionZM = 3007, + PolyhedralSurfaceZM = 3015, + TinZM = 3016 + } } diff --git a/src/SpatialLite.Core/IO/WkbReader.cs b/src/SpatialLite.Core/IO/WkbReader.cs index 0179683..0b6ce51 100644 --- a/src/SpatialLite.Core/IO/WkbReader.cs +++ b/src/SpatialLite.Core/IO/WkbReader.cs @@ -5,355 +5,405 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Provides functions for reading and parsing geometries from WKB format. /// - public class WkbReader : IDisposable { - - private BinaryReader _inputReader; - private FileStream _inputFileStream; - private bool _disposed = false; - - /// - /// Initializes a new instance of the WkbReader class that reads data from specific stream. - /// - /// The stream to read data from. - public WkbReader(Stream input) { - if (input == null) { - throw new ArgumentNullException("input", "Input stream cannot be null"); - } - - _inputReader = new BinaryReader(input); - } - - /// - /// Initializes a new instance of the WkbReader class that reads data from specific file. - /// - /// Path to the file to read data from. - public WkbReader(string path) { - _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); - _inputReader = new BinaryReader(_inputFileStream); - } - - /// - /// Parses data from the binnary array. - /// - /// The binary array with WKB serialized geometry. - /// Parsed geometry. - /// Throws exception if wkb array does not contrains valid WKB geometry. - public static Geometry Parse(byte[] wkb) { - if (wkb == null) { - throw new ArgumentNullException("wkb"); - } - - using (MemoryStream ms = new MemoryStream(wkb)) { - using (BinaryReader reader = new BinaryReader(ms)) { - if (reader.PeekChar() == -1) { - return null; - } - - try { - BinaryEncoding encoding = (BinaryEncoding)reader.ReadByte(); - if (encoding == BinaryEncoding.BigEndian) { - throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); - } - - Geometry parsed = WkbReader.ReadGeometry(reader); - - return parsed; - } - catch (EndOfStreamException) { - throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); - } - } - } - } - - /// - /// Parses data from the binary array as given geometry type. - /// - /// The Geometry type to be parsed. - /// The binary array with WKB serialized geometry. - /// Parsed geometry. - /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. - public static T Parse(byte[] wkb) where T : Geometry { - Geometry parsed = WkbReader.Parse(wkb); - - if (parsed != null) { - T result = parsed as T; - if (result == null) { - throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); - } - - return result; - } - else { - return null; - } - } - - /// - /// Releases all resources used by the ComponentLibrary. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Read geometry in WKB format from the input. - /// - /// Parsed geometry or null if no other geometry is available. - public Geometry Read() { - if (_inputReader.PeekChar() == -1) { - return null; - } - - try { - BinaryEncoding encoding = (BinaryEncoding)_inputReader.ReadByte(); - if (encoding == BinaryEncoding.BigEndian) { - throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); - } - - return WkbReader.ReadGeometry(_inputReader); - } - catch (EndOfStreamException) { - throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); - } - } - - /// - /// Read geometry in WKB format from the input. - /// - /// The Geometry type to be parsed. - /// Geometry obejct of specific type read from the input, or null if no other geometry is available. - /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. - public T Read() where T : Geometry { - Geometry parsed = this.Read(); - - if (parsed != null) { - T result = parsed as T; - if (result == null) { - throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); - } - - return result; - } - else { - return null; - } - } - - /// - /// Reads Coordinate from the BinaryReader. - /// - /// The reader to read from. - /// Bool value indicating whether Coordinate has Z value. - /// Bool value indicating whether Coordinate has M value. - /// Parsed Coordinate. - private static Coordinate ReadCoordinate(BinaryReader reader, bool is3D, bool isMeasured) { - double x = reader.ReadDouble(); - double y = reader.ReadDouble(); - double z = is3D ? reader.ReadDouble() : double.NaN; - double m = isMeasured ? reader.ReadDouble() : double.NaN; - - return new Coordinate(x, y, z, m); - } - - /// - /// Reads a list of coordinates from the BinaryReader. - /// - /// The reader to read from. - /// Bool value indicating whether coordinates has Z value. - /// Bool value indicating whether coordinates has M value. - /// Parsed Coordinate. - private static IEnumerable ReadCoordinates(BinaryReader reader, bool is3D, bool isMeasured) { - int pointCount = (int)reader.ReadUInt32(); - - List result = new List(pointCount); - for (int i = 0; i < pointCount; i++) { - result.Add(WkbReader.ReadCoordinate(reader, is3D, isMeasured)); - } - - return result; - } - - /// - /// Reads Geometry from the reader. - /// - /// The reader used to read data from input stream. - /// Geometry read from the input. - private static Geometry ReadGeometry(BinaryReader reader) { - WkbGeometryType geometryType = (WkbGeometryType)reader.ReadUInt32(); - - bool is3D, isMeasured; - WkbGeometryType basicType; - WkbReader.GetGeometryTypeDetails(geometryType, out basicType, out is3D, out isMeasured); - - switch (basicType) { - case WkbGeometryType.Point: return WkbReader.ReadPoint(reader, is3D, isMeasured); - case WkbGeometryType.LineString: return WkbReader.ReadLineString(reader, is3D, isMeasured); - case WkbGeometryType.Polygon: return WkbReader.ReadPolygon(reader, is3D, isMeasured); - case WkbGeometryType.MultiPoint: return WkbReader.ReadMultiPoint(reader, is3D, isMeasured); - case WkbGeometryType.MultiLineString: return WkbReader.ReadMultiLineString(reader, is3D, isMeasured); - case WkbGeometryType.MultiPolygon: return WkbReader.ReadMultiPolygon(reader, is3D, isMeasured); - case WkbGeometryType.GeometryCollection: return WkbReader.ReadGeometryCollection(reader, is3D, isMeasured); - default: throw new WkbFormatException("Unknown geometry type."); - } - } - - /// - /// Reads Point from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether point beeing read has Z-dimension. - /// bool value indicating whether point beeing read has M-value. - /// Point read from the input - private static Point ReadPoint(BinaryReader reader, bool is3D, bool isMeasured) { - Coordinate position = WkbReader.ReadCoordinate(reader, is3D, isMeasured); - return new Point(position); - } - - /// - /// Reads LineString from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether linestring beeing read has Z-dimension. - /// bool value indicating whether linestring beeing read has M-value. - /// Linestring read from the input. - private static LineString ReadLineString(BinaryReader reader, bool is3D, bool isMeasured) { - IEnumerable coordinates = WkbReader.ReadCoordinates(reader, is3D, isMeasured); - return new LineString(coordinates); - } - - /// - /// Reads Polygon from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether polygon beeing read has Z-dimension. - /// bool value indicating whether polygon beeing read has M-value. - /// Polygon read from the input. - private static Polygon ReadPolygon(BinaryReader reader, bool is3D, bool isMeasured) { - int ringsCount = (int)reader.ReadUInt32(); - - if (ringsCount == 0) { - return new Polygon(); - } - - IEnumerable exterior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); - Polygon result = new Polygon(new CoordinateList(exterior)); - - for (int i = 1; i < ringsCount; i++) { - IEnumerable interior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); - result.InteriorRings.Add(new CoordinateList(interior)); - } - - return result; - } - - /// - /// Reads MultiLineString from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether multilinestring beeing read has Z-dimension. - /// bool value indicating whether multilinestring beeing read has M-value. - /// MultiLineString read from the input. - private static MultiPoint ReadMultiPoint(BinaryReader reader, bool is3D, bool isMeasured) { - int pointsCount = (int)reader.ReadUInt32(); - - MultiPoint result = new MultiPoint(); - for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadPoint(reader, is3D, isMeasured)); - } - - return result; - } - - /// - /// Reads MultiLineString from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether multilinestring beeing read has Z-dimension. - /// bool value indicating whether multilinestring beeing read has M-value. - /// MultiLineString read from the input - private static MultiLineString ReadMultiLineString(BinaryReader reader, bool is3D, bool isMeasured) { - int pointsCount = (int)reader.ReadUInt32(); - - MultiLineString result = new MultiLineString(); - for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadLineString(reader, is3D, isMeasured)); - } - - return result; - } - - /// - /// Reads MultiPolygon from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether MultiPolygon beeing read has Z-dimension. - /// bool value indicating whether MultiPolygon beeing read has M-value. - /// MultiPolygon read from the input. - private static MultiPolygon ReadMultiPolygon(BinaryReader reader, bool is3D, bool isMeasured) { - int pointsCount = (int)reader.ReadUInt32(); - - MultiPolygon result = new MultiPolygon(); - for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadPolygon(reader, is3D, isMeasured)); - } - - return result; - } - - /// - /// Reads GeometryCollection from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether GeometryCollection beeing read has Z-dimension. - /// bool value indicating whether GeometryCollection beeing read has M-value. - /// GeometryCollection read from the input. - private static GeometryCollection ReadGeometryCollection(BinaryReader reader, bool is3D, bool isMeasured) { - int pointsCount = (int)reader.ReadUInt32(); - - GeometryCollection result = new GeometryCollection(); - for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadGeometry(reader)); - } - - return result; - } - - /// - /// Gets details form the WkbGeometryType value. - /// - /// The value to be examined. - /// Outputs type striped of dimension information. - /// Outputs bool value indicating whether type represents 3D geometry. - /// Outputs bool value indicating whether type represents measured geometry. - private static void GetGeometryTypeDetails(WkbGeometryType type, out WkbGeometryType basicType, out bool is3D, out bool isMeasured) { - is3D = ((int)type > 1000 && (int)type < 2000) || (int)type > 3000; - isMeasured = (int)type > 2000; - basicType = (WkbGeometryType)((int)type % 1000); - } - - /// - /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!this._disposed) { - if (disposing) { - _inputReader.Dispose(); - - if (_inputFileStream != null) { - _inputFileStream.Dispose(); - } - } - - _disposed = true; - } - } - - } + public class WkbReader : IDisposable + { + + private BinaryReader _inputReader; + private FileStream _inputFileStream; + private bool _disposed = false; + + /// + /// Initializes a new instance of the WkbReader class that reads data from specific stream. + /// + /// The stream to read data from. + public WkbReader(Stream input) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input), "Input stream cannot be null"); + } + + _inputReader = new BinaryReader(input); + } + + /// + /// Initializes a new instance of the WkbReader class that reads data from specific file. + /// + /// Path to the file to read data from. + public WkbReader(string path) + { + _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _inputReader = new BinaryReader(_inputFileStream); + } + + /// + /// Parses data from the binnary array. + /// + /// The binary array with WKB serialized geometry. + /// Parsed geometry. + /// Throws exception if wkb array does not contrains valid WKB geometry. + public static Geometry Parse(byte[] wkb) + { + if (wkb == null) + { + throw new ArgumentNullException(nameof(wkb)); + } + + using (MemoryStream ms = new MemoryStream(wkb)) + { + using (BinaryReader reader = new BinaryReader(ms)) + { + if (reader.PeekChar() == -1) + { + return null; + } + + try + { + BinaryEncoding encoding = (BinaryEncoding)reader.ReadByte(); + if (encoding == BinaryEncoding.BigEndian) + { + throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); + } + + Geometry parsed = WkbReader.ReadGeometry(reader); + + return parsed; + } + catch (EndOfStreamException) + { + throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); + } + } + } + } + + /// + /// Parses data from the binary array as given geometry type. + /// + /// The Geometry type to be parsed. + /// The binary array with WKB serialized geometry. + /// Parsed geometry. + /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. + public static T Parse(byte[] wkb) where T : Geometry + { + Geometry parsed = WkbReader.Parse(wkb); + + if (parsed != null) + { + T result = parsed as T; + if (result == null) + { + throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); + } + + return result; + } + else + { + return null; + } + } + + /// + /// Releases all resources used by the ComponentLibrary. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Read geometry in WKB format from the input. + /// + /// Parsed geometry or null if no other geometry is available. + public Geometry Read() + { + if (_inputReader.PeekChar() == -1) + { + return null; + } + + try + { + BinaryEncoding encoding = (BinaryEncoding)_inputReader.ReadByte(); + if (encoding == BinaryEncoding.BigEndian) + { + throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); + } + + return WkbReader.ReadGeometry(_inputReader); + } + catch (EndOfStreamException) + { + throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); + } + } + + /// + /// Read geometry in WKB format from the input. + /// + /// The Geometry type to be parsed. + /// Geometry obejct of specific type read from the input, or null if no other geometry is available. + /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. + public T Read() where T : Geometry + { + Geometry parsed = this.Read(); + + if (parsed != null) + { + T result = parsed as T; + if (result == null) + { + throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); + } + + return result; + } + else + { + return null; + } + } + + /// + /// Reads Coordinate from the BinaryReader. + /// + /// The reader to read from. + /// Bool value indicating whether Coordinate has Z value. + /// Bool value indicating whether Coordinate has M value. + /// Parsed Coordinate. + private static Coordinate ReadCoordinate(BinaryReader reader, bool is3D, bool isMeasured) + { + double x = reader.ReadDouble(); + double y = reader.ReadDouble(); + double z = is3D ? reader.ReadDouble() : double.NaN; + double m = isMeasured ? reader.ReadDouble() : double.NaN; + + return new Coordinate(x, y, z, m); + } + + /// + /// Reads a list of coordinates from the BinaryReader. + /// + /// The reader to read from. + /// Bool value indicating whether coordinates has Z value. + /// Bool value indicating whether coordinates has M value. + /// Parsed Coordinate. + private static IEnumerable ReadCoordinates(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointCount = (int)reader.ReadUInt32(); + + List result = new List(pointCount); + for (int i = 0; i < pointCount; i++) + { + result.Add(WkbReader.ReadCoordinate(reader, is3D, isMeasured)); + } + + return result; + } + + /// + /// Reads Geometry from the reader. + /// + /// The reader used to read data from input stream. + /// Geometry read from the input. + private static Geometry ReadGeometry(BinaryReader reader) + { + WkbGeometryType geometryType = (WkbGeometryType)reader.ReadUInt32(); + + bool is3D, isMeasured; + WkbGeometryType basicType; + WkbReader.GetGeometryTypeDetails(geometryType, out basicType, out is3D, out isMeasured); + + switch (basicType) + { + case WkbGeometryType.Point: return WkbReader.ReadPoint(reader, is3D, isMeasured); + case WkbGeometryType.LineString: return WkbReader.ReadLineString(reader, is3D, isMeasured); + case WkbGeometryType.Polygon: return WkbReader.ReadPolygon(reader, is3D, isMeasured); + case WkbGeometryType.MultiPoint: return WkbReader.ReadMultiPoint(reader, is3D, isMeasured); + case WkbGeometryType.MultiLineString: return WkbReader.ReadMultiLineString(reader, is3D, isMeasured); + case WkbGeometryType.MultiPolygon: return WkbReader.ReadMultiPolygon(reader, is3D, isMeasured); + case WkbGeometryType.GeometryCollection: return WkbReader.ReadGeometryCollection(reader, is3D, isMeasured); + default: throw new WkbFormatException("Unknown geometry type."); + } + } + + /// + /// Reads Point from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether point beeing read has Z-dimension. + /// bool value indicating whether point beeing read has M-value. + /// Point read from the input + private static Point ReadPoint(BinaryReader reader, bool is3D, bool isMeasured) + { + Coordinate position = WkbReader.ReadCoordinate(reader, is3D, isMeasured); + return new Point(position); + } + + /// + /// Reads LineString from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether linestring beeing read has Z-dimension. + /// bool value indicating whether linestring beeing read has M-value. + /// Linestring read from the input. + private static LineString ReadLineString(BinaryReader reader, bool is3D, bool isMeasured) + { + IEnumerable coordinates = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + return new LineString(coordinates); + } + + /// + /// Reads Polygon from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether polygon beeing read has Z-dimension. + /// bool value indicating whether polygon beeing read has M-value. + /// Polygon read from the input. + private static Polygon ReadPolygon(BinaryReader reader, bool is3D, bool isMeasured) + { + int ringsCount = (int)reader.ReadUInt32(); + + if (ringsCount == 0) + { + return new Polygon(); + } + + IEnumerable exterior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + Polygon result = new Polygon(new CoordinateList(exterior)); + + for (int i = 1; i < ringsCount; i++) + { + IEnumerable interior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + result.InteriorRings.Add(new CoordinateList(interior)); + } + + return result; + } + + /// + /// Reads MultiLineString from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether multilinestring beeing read has Z-dimension. + /// bool value indicating whether multilinestring beeing read has M-value. + /// MultiLineString read from the input. + private static MultiPoint ReadMultiPoint(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); + + MultiPoint result = new MultiPoint(); + for (int i = 0; i < pointsCount; i++) + { + result.Geometries.Add(WkbReader.ReadPoint(reader, is3D, isMeasured)); + } + + return result; + } + + /// + /// Reads MultiLineString from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether multilinestring beeing read has Z-dimension. + /// bool value indicating whether multilinestring beeing read has M-value. + /// MultiLineString read from the input + private static MultiLineString ReadMultiLineString(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); + + MultiLineString result = new MultiLineString(); + for (int i = 0; i < pointsCount; i++) + { + result.Geometries.Add(WkbReader.ReadLineString(reader, is3D, isMeasured)); + } + + return result; + } + + /// + /// Reads MultiPolygon from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether MultiPolygon beeing read has Z-dimension. + /// bool value indicating whether MultiPolygon beeing read has M-value. + /// MultiPolygon read from the input. + private static MultiPolygon ReadMultiPolygon(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); + + MultiPolygon result = new MultiPolygon(); + for (int i = 0; i < pointsCount; i++) + { + result.Geometries.Add(WkbReader.ReadPolygon(reader, is3D, isMeasured)); + } + + return result; + } + + /// + /// Reads GeometryCollection from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether GeometryCollection beeing read has Z-dimension. + /// bool value indicating whether GeometryCollection beeing read has M-value. + /// GeometryCollection read from the input. + private static GeometryCollection ReadGeometryCollection(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); + + GeometryCollection result = new GeometryCollection(); + for (int i = 0; i < pointsCount; i++) + { + result.Geometries.Add(WkbReader.ReadGeometry(reader)); + } + + return result; + } + + /// + /// Gets details form the WkbGeometryType value. + /// + /// The value to be examined. + /// Outputs type striped of dimension information. + /// Outputs bool value indicating whether type represents 3D geometry. + /// Outputs bool value indicating whether type represents measured geometry. + private static void GetGeometryTypeDetails(WkbGeometryType type, out WkbGeometryType basicType, out bool is3D, out bool isMeasured) + { + is3D = ((int)type > 1000 && (int)type < 2000) || (int)type > 3000; + isMeasured = (int)type > 2000; + basicType = (WkbGeometryType)((int)type % 1000); + } + + /// + /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (disposing) + { + _inputReader.Dispose(); + + if (_inputFileStream != null) + { + _inputFileStream.Dispose(); + } + } + + _disposed = true; + } + } + + } } diff --git a/src/SpatialLite.Core/IO/WkbWriter.cs b/src/SpatialLite.Core/IO/WkbWriter.cs index 703c8b3..982902d 100644 --- a/src/SpatialLite.Core/IO/WkbWriter.cs +++ b/src/SpatialLite.Core/IO/WkbWriter.cs @@ -4,314 +4,366 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Provides function for writing geometry objects into WKB format. /// - public class WkbWriter : IDisposable { - - private bool _disposed = false; - private BinaryWriter _writer = null; - private Stream _output = null; - - /// - /// Initializes a new instance of the WkbWriter class with specific settings. - /// - /// The settings defining behaviour of the writer. - protected WkbWriter(WkbWriterSettings settings) { - if (settings == null) { - throw new ArgumentNullException("settings"); - } - - if (settings.Encoding == BinaryEncoding.BigEndian) { - throw new NotSupportedException("BigEndian encoding is not supported in current version of the WkbWriter."); - } - - this.Settings = settings; - this.Settings.IsReadOnly = true; - } - - /// - /// Initializes a new instance of the WkbWriter class that writes geometries to a stream with specific settings. - /// - /// The stream to write geometries to. - /// The settings defining behaviour of the writer. - public WkbWriter(Stream stream, WkbWriterSettings settings) - : this(settings) { - if (stream == null) { - throw new ArgumentNullException("stream"); - } - - _writer = new BinaryWriter(stream); - } - - /// - /// Initializes a new instance of the WkbWriter class that writes geometreis to a file with specific settings. - /// - /// The path to the file to write geometrie to. - /// The settings defining behaviour of the writer. - public WkbWriter(string path, WkbWriterSettings settings) - : this(settings) { - if (path == null) { - throw new ArgumentNullException("path"); - } - - _output = new FileStream(path, FileMode.Create, FileAccess.Write); - _writer = new BinaryWriter(_output); - } - - /// - /// Gets the settings that detedmine behaviour of this instance of the WkbWriter. - /// - public WkbWriterSettings Settings { get; private set; } - - /// - /// Writes specified Geometry in the WKB format to a binary arrray using default WkbWriterSettings. - /// - /// The geometry to write. - /// The binary array with WKB representation of the Geometry. - public static byte[] WriteToArray(IGeometry geometry) { - using (MemoryStream dataStream = new MemoryStream()) { - using (BinaryWriter writer = new BinaryWriter(dataStream)) { - WkbWriterSettings defaultSettings = new WkbWriterSettings(); - - WkbWriter.WriteEncoding(writer, defaultSettings.Encoding); - WkbWriter.Write(geometry, writer); - - return dataStream.ToArray(); - } - } - } - - /// - /// Releases all resources used by the WkbWriter. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Writes specified Geometry in the WKB format to the output. - /// - /// The geometry to write. - public void Write(IGeometry geometry) { - WkbWriter.WriteEncoding(_writer, this.Settings.Encoding); - WkbWriter.Write(geometry, _writer); - } - - /// - /// Writes the Encoding byte defined by property to the output stream. - /// - /// The BinaryWriter to be used. - /// The encoding of binary data. - private static void WriteEncoding(BinaryWriter writer, BinaryEncoding encoding) { - writer.Write((byte)encoding); - } - - /// - /// Writes geometry to the output using specified writer. - /// - /// The geometry to write. - /// The BinaryWriter used to write geometry to the output. - private static void Write(IGeometry geometry, BinaryWriter writer) { - if (geometry is IPoint) { - WkbWriter.WritePoint((IPoint)geometry, writer); - } - else if (geometry is ILineString) { - WkbWriter.WriteLineString((ILineString)geometry, writer); - } - else if (geometry is IPolygon) { - WkbWriter.WritePolygon((IPolygon)geometry, writer); - } - else if (geometry is IMultiPoint) { - WkbWriter.WriteMultiPoint((IMultiPoint)geometry, writer); - } - else if (geometry is IMultiLineString) { - WkbWriter.WriteMultiLineString((IMultiLineString)geometry, writer); - } - else if (geometry is IMultiPolygon) { - WkbWriter.WriteMultiPolygon((IMultiPolygon)geometry, writer); - } - else if (geometry is IGeometryCollection) { - WkbWriter.WriteGeometryCollection((IGeometryCollection)geometry, writer); - } - } - - /// - /// Writes Coordinate to the output using specified writer. - /// - /// The Coordinate to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteCoordinate(Coordinate coordinate, BinaryWriter writer) { - writer.Write(coordinate.X); - writer.Write(coordinate.Y); - - if (coordinate.Is3D) { - writer.Write(coordinate.Z); - } - - if (coordinate.IsMeasured) { - writer.Write(coordinate.M); - } - } - - /// - /// Writes list of Coordinates to the output using specified writer. - /// - /// The list od Coordinates to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteCoordinates(ICoordinateList coordinates, BinaryWriter writer) { - writer.Write((uint)coordinates.Count); - - for (int i = 0; i < coordinates.Count; i++) { - WkbWriter.WriteCoordinate(coordinates[i], writer); - } - } - - /// - /// Writes Point to the output using specified writer. - /// - /// The Point to write. - /// The BinaryWriter used to write geometry to the output. - private static void WritePoint(IPoint point, BinaryWriter writer) { - if (point.Position.Equals(Coordinate.Empty)) { - writer.Write((uint)WkbGeometryType.GeometryCollection); - writer.Write(0u); - } - else { - writer.Write((uint)WkbWriter.AdjustGeometryType(point, WkbGeometryType.Point)); - WkbWriter.WriteCoordinate(point.Position, writer); - } - } - - /// - /// Writes LineString to the output using specified writer. - /// - /// The LineString to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteLineString(ILineString linestring, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(linestring, WkbGeometryType.LineString)); - WkbWriter.WriteCoordinates(linestring.Coordinates, writer); - } - - /// - /// Writes Polygon to the output using specified writer. - /// - /// The Polygon to write. - /// The BinaryWriter used to write geometry to the output. - private static void WritePolygon(IPolygon polygon, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(polygon, WkbGeometryType.Polygon)); - WkbWriter.WritePolygonContent(polygon, writer); - } - - /// - /// Writes content of the Polygon to the output using specified writer. - /// - /// The Polygon to write. - /// The BinaryWriter used to write geometry to the output. - private static void WritePolygonContent(IPolygon polygon, BinaryWriter writer) { - if (polygon.ExteriorRing.Count == 0) { - writer.Write(0u); - } - else { - writer.Write((uint)(1 + polygon.InteriorRings.Count())); - WkbWriter.WriteCoordinates(polygon.ExteriorRing, writer); - - foreach (var ring in polygon.InteriorRings) { - WkbWriter.WriteCoordinates(ring, writer); - } - } - } - - /// - /// Writes MultiPoint to the output using specified writer. - /// - /// The MultiPoint to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteMultiPoint(IMultiPoint multipoint, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multipoint, WkbGeometryType.MultiPoint)); - writer.Write((uint)multipoint.Geometries.Count()); - foreach (var point in multipoint.Geometries) { - WkbWriter.WriteCoordinate(point.Position, writer); - } - } - - /// - /// Writes MultiLineString to the output using specified writer. - /// - /// The MultiLineString to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteMultiLineString(IMultiLineString multiLineString, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multiLineString, WkbGeometryType.MultiLineString)); - writer.Write((uint)multiLineString.Geometries.Count()); - foreach (var linestring in multiLineString.Geometries) { - WkbWriter.WriteCoordinates(linestring.Coordinates, writer); - } - } - - /// - /// Writes MultiPolygon to the output using specified writer. - /// - /// The MultiPolygon to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteMultiPolygon(IMultiPolygon multiPolygon, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multiPolygon, WkbGeometryType.MultiPolygon)); - writer.Write((uint)multiPolygon.Geometries.Count()); - foreach (var polygon in multiPolygon.Geometries) { - WkbWriter.WritePolygonContent(polygon, writer); - } - } - - /// - /// Writes GeometryCollection to the output using specified writer. - /// - /// The GeometryCollection to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteGeometryCollection(IGeometryCollection collection, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(collection, WkbGeometryType.GeometryCollection)); - writer.Write((uint)collection.Geometries.Count()); - foreach (var geometry in collection.Geometries) { - WkbWriter.Write(geometry, writer); - } - } - - /// - /// Adjust WkbGeometryType according to the Geometry object dimensions. - /// - /// The geometry object. - /// WkbGeometryType for the 2D, non-measured version of the geometry object. - /// The WkbGeometryType of the geometry object. - private static WkbGeometryType AdjustGeometryType(IGeometry geometry, WkbGeometryType baseType) { - WkbGeometryType result = baseType; - - if (geometry.Is3D) { - result += 1000; - } - - if (geometry.IsMeasured) { - result += 2000; - } - - return result; - } - - /// - /// Releases the unmanaged resources used by the WkbWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!_disposed) { - if (disposing) { - _writer.Dispose(); - - if (_output != null) { - _output.Dispose(); - } - } - - _disposed = true; - } - } - } + public class WkbWriter : IDisposable + { + + private bool _disposed = false; + private BinaryWriter _writer = null; + private Stream _output = null; + + /// + /// Initializes a new instance of the WkbWriter class with specific settings. + /// + /// The settings defining behaviour of the writer. + protected WkbWriter(WkbWriterSettings settings) + { + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } + + if (settings.Encoding == BinaryEncoding.BigEndian) + { + throw new NotSupportedException("BigEndian encoding is not supported in current version of the WkbWriter."); + } + + this.Settings = settings; + this.Settings.IsReadOnly = true; + } + + /// + /// Initializes a new instance of the WkbWriter class that writes geometries to a stream with specific settings. + /// + /// The stream to write geometries to. + /// The settings defining behaviour of the writer. + public WkbWriter(Stream stream, WkbWriterSettings settings) + : this(settings) + { + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); + } + + _writer = new BinaryWriter(stream); + } + + /// + /// Initializes a new instance of the WkbWriter class that writes geometreis to a file with specific settings. + /// + /// The path to the file to write geometrie to. + /// The settings defining behaviour of the writer. + public WkbWriter(string path, WkbWriterSettings settings) + : this(settings) + { + if (path == null) + { + throw new ArgumentNullException(nameof(path)); + } + + _output = new FileStream(path, FileMode.Create, FileAccess.Write); + _writer = new BinaryWriter(_output); + } + + /// + /// Gets the settings that detedmine behaviour of this instance of the WkbWriter. + /// + public WkbWriterSettings Settings { get; private set; } + + /// + /// Writes specified Geometry in the WKB format to a binary arrray using default WkbWriterSettings. + /// + /// The geometry to write. + /// The binary array with WKB representation of the Geometry. + public static byte[] WriteToArray(IGeometry geometry) + { + using (MemoryStream dataStream = new MemoryStream()) + { + using (BinaryWriter writer = new BinaryWriter(dataStream)) + { + WkbWriterSettings defaultSettings = new WkbWriterSettings(); + + WkbWriter.WriteEncoding(writer, defaultSettings.Encoding); + WkbWriter.Write(geometry, writer); + + return dataStream.ToArray(); + } + } + } + + /// + /// Releases all resources used by the WkbWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Writes specified Geometry in the WKB format to the output. + /// + /// The geometry to write. + public void Write(IGeometry geometry) + { + WkbWriter.WriteEncoding(_writer, this.Settings.Encoding); + WkbWriter.Write(geometry, _writer); + } + + /// + /// Writes the Encoding byte defined by property to the output stream. + /// + /// The BinaryWriter to be used. + /// The encoding of binary data. + private static void WriteEncoding(BinaryWriter writer, BinaryEncoding encoding) + { + writer.Write((byte)encoding); + } + + /// + /// Writes geometry to the output using specified writer. + /// + /// The geometry to write. + /// The BinaryWriter used to write geometry to the output. + private static void Write(IGeometry geometry, BinaryWriter writer) + { + if (geometry is IPoint) + { + WkbWriter.WritePoint((IPoint)geometry, writer); + } + else if (geometry is ILineString) + { + WkbWriter.WriteLineString((ILineString)geometry, writer); + } + else if (geometry is IPolygon) + { + WkbWriter.WritePolygon((IPolygon)geometry, writer); + } + else if (geometry is IMultiPoint) + { + WkbWriter.WriteMultiPoint((IMultiPoint)geometry, writer); + } + else if (geometry is IMultiLineString) + { + WkbWriter.WriteMultiLineString((IMultiLineString)geometry, writer); + } + else if (geometry is IMultiPolygon) + { + WkbWriter.WriteMultiPolygon((IMultiPolygon)geometry, writer); + } + else if (geometry is IGeometryCollection) + { + WkbWriter.WriteGeometryCollection((IGeometryCollection)geometry, writer); + } + } + + /// + /// Writes Coordinate to the output using specified writer. + /// + /// The Coordinate to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteCoordinate(Coordinate coordinate, BinaryWriter writer) + { + writer.Write(coordinate.X); + writer.Write(coordinate.Y); + + if (coordinate.Is3D) + { + writer.Write(coordinate.Z); + } + + if (coordinate.IsMeasured) + { + writer.Write(coordinate.M); + } + } + + /// + /// Writes list of Coordinates to the output using specified writer. + /// + /// The list od Coordinates to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteCoordinates(ICoordinateList coordinates, BinaryWriter writer) + { + writer.Write((uint)coordinates.Count); + + for (int i = 0; i < coordinates.Count; i++) + { + WkbWriter.WriteCoordinate(coordinates[i], writer); + } + } + + /// + /// Writes Point to the output using specified writer. + /// + /// The Point to write. + /// The BinaryWriter used to write geometry to the output. + private static void WritePoint(IPoint point, BinaryWriter writer) + { + if (point.Position.Equals(Coordinate.Empty)) + { + writer.Write((uint)WkbGeometryType.GeometryCollection); + writer.Write(0u); + } + else + { + writer.Write((uint)WkbWriter.AdjustGeometryType(point, WkbGeometryType.Point)); + WkbWriter.WriteCoordinate(point.Position, writer); + } + } + + /// + /// Writes LineString to the output using specified writer. + /// + /// The LineString to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteLineString(ILineString linestring, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(linestring, WkbGeometryType.LineString)); + WkbWriter.WriteCoordinates(linestring.Coordinates, writer); + } + + /// + /// Writes Polygon to the output using specified writer. + /// + /// The Polygon to write. + /// The BinaryWriter used to write geometry to the output. + private static void WritePolygon(IPolygon polygon, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(polygon, WkbGeometryType.Polygon)); + WkbWriter.WritePolygonContent(polygon, writer); + } + + /// + /// Writes content of the Polygon to the output using specified writer. + /// + /// The Polygon to write. + /// The BinaryWriter used to write geometry to the output. + private static void WritePolygonContent(IPolygon polygon, BinaryWriter writer) + { + if (polygon.ExteriorRing.Count == 0) + { + writer.Write(0u); + } + else + { + writer.Write((uint)(1 + polygon.InteriorRings.Count())); + WkbWriter.WriteCoordinates(polygon.ExteriorRing, writer); + + foreach (var ring in polygon.InteriorRings) + { + WkbWriter.WriteCoordinates(ring, writer); + } + } + } + + /// + /// Writes MultiPoint to the output using specified writer. + /// + /// The MultiPoint to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteMultiPoint(IMultiPoint multipoint, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(multipoint, WkbGeometryType.MultiPoint)); + writer.Write((uint)multipoint.Geometries.Count()); + foreach (var point in multipoint.Geometries) + { + WkbWriter.WriteCoordinate(point.Position, writer); + } + } + + /// + /// Writes MultiLineString to the output using specified writer. + /// + /// The MultiLineString to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteMultiLineString(IMultiLineString multiLineString, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(multiLineString, WkbGeometryType.MultiLineString)); + writer.Write((uint)multiLineString.Geometries.Count()); + foreach (var linestring in multiLineString.Geometries) + { + WkbWriter.WriteCoordinates(linestring.Coordinates, writer); + } + } + + /// + /// Writes MultiPolygon to the output using specified writer. + /// + /// The MultiPolygon to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteMultiPolygon(IMultiPolygon multiPolygon, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(multiPolygon, WkbGeometryType.MultiPolygon)); + writer.Write((uint)multiPolygon.Geometries.Count()); + foreach (var polygon in multiPolygon.Geometries) + { + WkbWriter.WritePolygonContent(polygon, writer); + } + } + + /// + /// Writes GeometryCollection to the output using specified writer. + /// + /// The GeometryCollection to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteGeometryCollection(IGeometryCollection collection, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(collection, WkbGeometryType.GeometryCollection)); + writer.Write((uint)collection.Geometries.Count()); + foreach (var geometry in collection.Geometries) + { + WkbWriter.Write(geometry, writer); + } + } + + /// + /// Adjust WkbGeometryType according to the Geometry object dimensions. + /// + /// The geometry object. + /// WkbGeometryType for the 2D, non-measured version of the geometry object. + /// The WkbGeometryType of the geometry object. + private static WkbGeometryType AdjustGeometryType(IGeometry geometry, WkbGeometryType baseType) + { + WkbGeometryType result = baseType; + + if (geometry.Is3D) + { + result += 1000; + } + + if (geometry.IsMeasured) + { + result += 2000; + } + + return result; + } + + /// + /// Releases the unmanaged resources used by the WkbWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + _writer.Dispose(); + + if (_output != null) + { + _output.Dispose(); + } + } + + _disposed = true; + } + } + } } diff --git a/src/SpatialLite.Core/IO/WkbWriterSettings.cs b/src/SpatialLite.Core/IO/WkbWriterSettings.cs index f09aa4a..c2647df 100644 --- a/src/SpatialLite.Core/IO/WkbWriterSettings.cs +++ b/src/SpatialLite.Core/IO/WkbWriterSettings.cs @@ -1,45 +1,52 @@ using System; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Contains settings that determine behaviour of the WkbWriter /// - public class WkbWriterSettings { - - private BinaryEncoding _encoding; - - /// - /// Initializes a new instance of the WkbWriterSettings class with default values. - /// - public WkbWriterSettings() - : base() { - this.Encoding = BinaryEncoding.LittleEndian; - } - - /// - /// Gets or sets a encoding that WkbWriter will use for writing geometries. - /// - /// - /// BigEnndian encoding is not supported in current version of the class. - /// - public BinaryEncoding Encoding { - get { - return _encoding; - } - - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'Encoding' property. The WkbWriterSettings instance is read-only"); - } - - _encoding = value; - } - } - - /// - /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } - - } + public class WkbWriterSettings + { + + private BinaryEncoding _encoding; + + /// + /// Initializes a new instance of the WkbWriterSettings class with default values. + /// + public WkbWriterSettings() + : base() + { + this.Encoding = BinaryEncoding.LittleEndian; + } + + /// + /// Gets or sets a encoding that WkbWriter will use for writing geometries. + /// + /// + /// BigEnndian encoding is not supported in current version of the class. + /// + public BinaryEncoding Encoding + { + get + { + return _encoding; + } + + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'Encoding' property. The WkbWriterSettings instance is read-only"); + } + + _encoding = value; + } + } + + /// + /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } + + } } diff --git a/src/SpatialLite.Core/IO/WktParseException.cs b/src/SpatialLite.Core/IO/WktParseException.cs index 8765b85..7214207 100644 --- a/src/SpatialLite.Core/IO/WktParseException.cs +++ b/src/SpatialLite.Core/IO/WktParseException.cs @@ -1,16 +1,19 @@ using System; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Represents exception that can occur during WKT parsing. /// - public class WktParseException : Exception { - /// - /// Initializes a new instance of the WktParseException class. - /// - /// The message that describes the error. - public WktParseException(string message) - : base(message) { - } - } + public class WktParseException : Exception + { + /// + /// Initializes a new instance of the WktParseException class. + /// + /// The message that describes the error. + public WktParseException(string message) + : base(message) + { + } + } } diff --git a/src/SpatialLite.Core/IO/WktReader.cs b/src/SpatialLite.Core/IO/WktReader.cs index d9d96a2..c8d5768 100644 --- a/src/SpatialLite.Core/IO/WktReader.cs +++ b/src/SpatialLite.Core/IO/WktReader.cs @@ -7,699 +7,781 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Provides functions for reading and parsing geometries from WKT format. /// - public class WktReader : IDisposable { - - private static CultureInfo _invarianCulture = CultureInfo.InvariantCulture; - - private TextReader _inputReader; - private FileStream _inputFileStream; - private WktTokensBuffer _tokens; - - private bool _disposed = false; - - /// - /// Initializes a new instance of the WktReader class that reads data from specific stream. - /// - /// The stream to read data from. - public WktReader(Stream input) { - if (input == null) { - throw new ArgumentNullException("input", "Input stream cannot be null"); - } - - _inputReader = new StreamReader(input); - _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); - } - - /// - /// Initializes a new instance of the WktReader class that reads data from specific file. - /// - /// Path to the file to read data from. - public WktReader(string path) { - _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); - _inputReader = new StreamReader(_inputFileStream); - _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); - } - - /// - /// Parses a Geometry from WKT string. - /// - /// The string with WKT representation of a Geometry. - /// The parsed Geometry. - public static Geometry Parse(string wkt) { - WktTokensBuffer tokens = new WktTokensBuffer(WktTokenizer.Tokenize(wkt)); - return WktReader.ParseGeometryTaggedText(tokens); - } - - /// - /// Parses a Geometry of specific type from the WKT string. - /// - /// The type of the Geometry to be parsed. - /// The string with WKT representation of a Geometry. - /// The parsed Geometry of given type. - public static T Parse(string wkt) where T : Geometry { - Geometry parsed = WktReader.Parse(wkt); - - if (parsed != null) { - T result = parsed as T; - if (result == null) { - throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); - } - - return result; - } - else { - return null; - } - } - - /// - /// Reads next geometry from the input. - /// - /// The geometry object read from the reader or null if no more geometries are available. - public Geometry Read() { - return WktReader.ParseGeometryTaggedText(_tokens); - } - - /// - /// Reads next geometry from the input. - /// - /// The type of Geometry to be parsed. - /// The geometry object of specific type read from the reader or null if no more geometries are available. - public T Read() where T : Geometry { - Geometry parsed = WktReader.ParseGeometryTaggedText(_tokens); - - if (parsed != null) { - T result = parsed as T; - if (result == null) { - throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); - } - - return result; - } - else { - return null; - } - } - - /// - /// Releases all resources used by the ComponentLibrary. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Parses a geometry tagged text. - /// - /// The list of tokens. - /// A geometry specified by tokens. - private static Geometry ParseGeometryTaggedText(WktTokensBuffer tokens) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING) { - if (t.Value.ToUpperInvariant() == "POINT") { - return WktReader.ParsePointTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "LINESTRING") { - return WktReader.ParseLineStringTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "POLYGON") { - return WktReader.ParsePolygonTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "MULTIPOINT") { - return WktReader.ParseMultiPointTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "MULTILINESTRING") { - return WktReader.ParseMultiLineStringTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "MULTIPOLYGON") { - return WktReader.ParseMultiPolygonTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "GEOMETRYCOLLECTION") { - return WktReader.ParseGeometryCollectionTaggedText(tokens); - } - } - - if (t.Type == TokenType.END_OF_DATA) { - return null; - } - - throw new WktParseException(string.Format("Invalid geometry type '{0}'", t.Value)); - } - - /// - /// Parses a point tagged text. - /// - /// The list of tokens. - /// A point specified by tokens. - /// ::= point {z}{m} ]]> - private static Point ParsePointTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("point", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); - - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } - - return WktReader.ParsePointText(tokens, is3D, isMeasured); - } - - /// - /// Parses a point tagged text. - /// - /// The list of tokens. - /// bool value indicating whether point being parsed has z-coordinate. - /// bool value indicating whether point beeing parsed has m-value. - /// A point specified by tokens - /// | ]]> - private static Point ParsePointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - tokens.GetToken(true); - return new Point(); - } - - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - Point result = new Point(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - - return result; - } - - /// - /// Parses multiple Points separated by comma. - /// - /// The list of tokens. - /// bool value indicating whether point being parsed had z-coordinate. - /// bool value indicating whether point being parsed has m-value. - /// A list of point specified by tokens. - private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List points = new List(); - - points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); - - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) { - tokens.GetToken(true); - points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } - - return points; - } - - /// - /// Parses a coordinate. - /// - /// The list of tokens. - /// bool value indicating whether coordinate being parsed had z-coordinate. - /// bool value indicating whether coordinate beeing parsed has m-value. - /// A coordinate specified by tokens. - /// {} {}]]> - private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = WktReader.Expect(TokenType.NUMBER, tokens); - double x = double.Parse(t.Value, _invarianCulture); - - WktReader.Expect(TokenType.WHITESPACE, tokens); - - t = WktReader.Expect(TokenType.NUMBER, tokens); - double y = double.Parse(t.Value, _invarianCulture); - - double z = double.NaN; - double m = double.NaN; - - if (is3D) { - WktReader.Expect(TokenType.WHITESPACE, tokens); - - t = WktReader.Expect(TokenType.NUMBER, tokens); - z = double.Parse(t.Value, _invarianCulture); - } - - if (isMeasured) { - WktReader.Expect(TokenType.WHITESPACE, tokens); - - t = WktReader.Expect(TokenType.NUMBER, tokens); - m = double.Parse(t.Value, _invarianCulture); - } - - return new Coordinate(x, y, z, m); - } - - /// - /// Parses a series of coordinate. - /// - /// The list of tokens. - /// bool value indicating whether coordinate being parsed had z-coordinate. - /// bool value indicating whether coordinate beeing parsed has m-value. - /// A list of coordinates specified by tokens. - private static IEnumerable ParseCoordinates(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List coordinates = new List(); - - coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); - - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } - - return coordinates; - } - - /// - /// Parses a linestring tagged text. - /// - /// The list of tokens. - /// A linestring specified by tokens. - /// ::= linestring {z}{m} ]]> - private static LineString ParseLineStringTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("linestring", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); - - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } - - return WktReader.ParseLineStringText(tokens, is3D, isMeasured); - } - - /// - /// Parses a linestring text. - /// - /// The list of tokens. - /// bool value indicating whether linestring being parsed has z-coordinate. - /// bool value indicating whether linestring being parsed has m-value. - /// A linestring specified by tokens. - /// | { }* ]]> - private static LineString ParseLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - tokens.GetToken(true); - return new LineString(); - } - - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - IEnumerable coords = WktReader.ParseCoordinates(tokens, is3D, isMeasured); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - - return new LineString(coords); - } - - /// - /// Parses multiple LineStrings separated by comma. - /// - /// The list of tokens. - /// bool value indicating whether linestring being parsed had z-coordinate. - /// bool value indicating whether linestring being parsed has m-value. - /// A list of linestrings specified by tokens. - private static List ParseLineStrings(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List linestrigns = new List(); - - linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); - - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) { - tokens.GetToken(true); - linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } - - return linestrigns; - } - - /// - /// Parses a polygon tagged text. - /// - /// The list of tokens. - /// A polygon specified by tokens. - /// ::= polygon {z}{m} ]]> - private static Polygon ParsePolygonTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("polygon", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); - - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } - - return WktReader.ParsePolygonText(tokens, is3D, isMeasured); - } - - /// - /// Parses a polygon text. - /// - /// The list of tokens. - /// bool value indicating whether polygon being parsed has z-coordinate. - /// bool value indicating whether polygon being parsed has m-value. - /// A polygon specified by tokens. - /// | { }* ]]> - private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - tokens.GetToken(true); - return new Polygon(); - } - - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - - IEnumerable linestrings = WktReader.ParseLineStrings(tokens, is3D, isMeasured); - Polygon result = new Polygon(linestrings.First().Coordinates); - - foreach (var inner in linestrings.Skip(1)) { - result.InteriorRings.Add(inner.Coordinates); - } - - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - - return result; - } - - /// - /// Parses series of polygons. - /// - /// The list of tokens. - /// bool value indicating whether polygon being parsed has z-coordinate. - /// bool value indicating whether polygon being parsed has m-value. - /// A list of polygons specified by tokens. - private static IEnumerable ParsePolygons(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List polygons = new List(); - - polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); - - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) { - tokens.GetToken(true); - polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } - - return polygons; - } - - /// - /// Parses a multilinestring tagged text. - /// - /// The list of tokens. - /// A multilinestring specified by tokens. - /// ::= multilinestring {z}{m} ]]> - private static MultiLineString ParseMultiLineStringTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("multilinestring", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); - - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } - - return WktReader.ParseMultiLineStringText(tokens, is3D, isMeasured); - } - - /// - /// Parses a multilinestring text. - /// - /// The list of tokens. - /// bool value indicating whether multilinestring being parsed has z-coordinate. - /// bool value indicating whether multilinestring being parsed has m-value. - /// A multilinestring specified by tokens. - /// ::= | { }* ]]> - private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - tokens.GetToken(true); - return new MultiLineString(); - } - - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiLineString result = new MultiLineString(WktReader.ParseLineStrings(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - - return result; - } - - /// - /// Parses a multipoint tagged text. - /// - /// The list of tokens. - /// A multipoint specified by tokens. - /// ::= multipoint {z}{m} ]]> - private static MultiPoint ParseMultiPointTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("multipoint", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); - - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } - - return WktReader.ParseMultiPointText(tokens, is3D, isMeasured); - } - - /// - /// Parses a multipoint text. - /// - /// The list of tokens. - /// bool value indicating whether multipoint being parsed has z-coordinate. - /// bool value indicating whether multipoint being parsed has m-value. - /// A multipoint specified by tokens. - /// ::= | { }* ]]> - private static MultiPoint ParseMultiPointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - tokens.GetToken(true); - return new MultiPoint(); - } - - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPoint result = new MultiPoint(WktReader.ParsePoints(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - - return result; - } - - /// - /// Parses a multipolyugon tagged text. - /// - /// The list of tokens. - /// A multipolygon specified by tokens. - /// ::= multipolygon {z}{m} ]]> - private static MultiPolygon ParseMultiPolygonTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("multipolygon", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); - - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } - - return WktReader.ParseMultiPolygonText(tokens, is3D, isMeasured); - } - - /// - /// Parses a multipolygon text. - /// - /// The list of tokens. - /// bool value indicating whether multipolygon being parsed has z-coordinate. - /// bool value indicating whether multipolygon being parsed has m-value. - /// A multipolygon specified by tokens. - /// ::= | { }* ]]> - private static MultiPolygon ParseMultiPolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - tokens.GetToken(true); - return new MultiPolygon(); - } - - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPolygon result = new MultiPolygon(WktReader.ParsePolygons(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - - return result; - } - - /// - /// Parses a multipolyugon tagged text. - /// - /// The list of tokens. - /// A GeometryCollection specified by tokens. - /// ::= GeometryCollection {z}{m} ]]> - private static GeometryCollection ParseGeometryCollectionTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("geometrycollection", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); - - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } - - return WktReader.ParseGeometryCollectionText(tokens, is3D, isMeasured); - } - - /// - /// Parses a GeometryCollection text. - /// - /// The list of tokens. - /// bool value indicating whether GeometryCollection being parsed has z-coordinate. - /// bool value indicating whether GeometryCollection being parsed has m-value. - /// A GeometryCollection specified by tokens. - /// ::= | { }* ]]> - private static GeometryCollection ParseGeometryCollectionText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - tokens.GetToken(true); - return new GeometryCollection(); - } - - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - - GeometryCollection result = new GeometryCollection(); - result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); - - t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) { - tokens.GetToken(true); - result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); - t = tokens.Peek(true); - } - - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - - return result; - } - - /// - /// Retrieves the next token from the tokens and checks if it has expected type. - /// - /// Expected type of token. - /// The list of tokens. - /// The head of the tokens queue. - private static WktToken Expect(TokenType type, WktTokensBuffer tokens) { - bool ignoreWhitespace = type != TokenType.WHITESPACE; - - WktToken t = tokens.GetToken(ignoreWhitespace); - - if (t.Type != type) { - string expected = string.Empty; - switch (type) { - case TokenType.WHITESPACE: expected = " "; break; - case TokenType.LEFT_PARENTHESIS: expected = "("; break; - case TokenType.RIGHT_PARENTHESIS: expected = ")"; break; - case TokenType.STRING: expected = "STRING"; break; - case TokenType.NUMBER: expected = "NUMBER"; break; - } - - throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}'", expected, t.Value)); - } - - return t; - } - - /// - /// Retrieves the next token from tokens and checks if it is TokenType.STRING and if it has correct value. - /// - /// Expected string value of the token. - /// The list of tokens. - /// The head of the tokens queue. - /// String comparsion is not case-sensitive. - private static WktToken Expect(string value, WktTokensBuffer tokens) { - WktToken t = tokens.GetToken(true); - - if (t.Type != TokenType.STRING || string.Equals(value, t.Value, StringComparison.OrdinalIgnoreCase) == false) { - throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}", value, t.Value)); - } - - return t; - } - - /// - /// Examines the given token and tries to parse it as WKT dimensions text. - /// - /// The WKT token to parse. - /// Parameter that specified whether dimension text contains {z}. - /// Parameter that specified whether dimension text contains {m}. - /// true if token was successfuly parsed as WKT dimension text, oterwise returns false. - private static bool TryParseDimensions(WktToken token, out bool is3D, out bool isMeasured) { - is3D = false; - isMeasured = false; - - if (token.Type == TokenType.STRING) { - if (token.Value.ToUpperInvariant() == "Z") { - is3D = true; - } - else if (token.Value.ToUpperInvariant() == "M") { - isMeasured = true; - } - else if (token.Value.ToUpperInvariant() == "ZM") { - is3D = true; - isMeasured = true; - } - - return is3D || isMeasured; - } - else { - return false; - } - } - - /// - /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!this._disposed) { - if (disposing) { - _inputReader.Dispose(); - - if (_inputFileStream != null) { - _inputFileStream.Dispose(); - } - } - - _disposed = true; - } - } - } + public class WktReader : IDisposable + { + + private static CultureInfo _invarianCulture = CultureInfo.InvariantCulture; + + private TextReader _inputReader; + private FileStream _inputFileStream; + private WktTokensBuffer _tokens; + + private bool _disposed = false; + + /// + /// Initializes a new instance of the WktReader class that reads data from specific stream. + /// + /// The stream to read data from. + public WktReader(Stream input) + { + if (input == null) + { + throw new ArgumentNullException(nameof(input), "Input stream cannot be null"); + } + + _inputReader = new StreamReader(input); + _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); + } + + /// + /// Initializes a new instance of the WktReader class that reads data from specific file. + /// + /// Path to the file to read data from. + public WktReader(string path) + { + _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _inputReader = new StreamReader(_inputFileStream); + _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); + } + + /// + /// Parses a Geometry from WKT string. + /// + /// The string with WKT representation of a Geometry. + /// The parsed Geometry. + public static Geometry Parse(string wkt) + { + WktTokensBuffer tokens = new WktTokensBuffer(WktTokenizer.Tokenize(wkt)); + return WktReader.ParseGeometryTaggedText(tokens); + } + + /// + /// Parses a Geometry of specific type from the WKT string. + /// + /// The type of the Geometry to be parsed. + /// The string with WKT representation of a Geometry. + /// The parsed Geometry of given type. + public static T Parse(string wkt) where T : Geometry + { + Geometry parsed = WktReader.Parse(wkt); + + if (parsed != null) + { + T result = parsed as T; + if (result == null) + { + throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); + } + + return result; + } + else + { + return null; + } + } + + /// + /// Reads next geometry from the input. + /// + /// The geometry object read from the reader or null if no more geometries are available. + public Geometry Read() + { + return WktReader.ParseGeometryTaggedText(_tokens); + } + + /// + /// Reads next geometry from the input. + /// + /// The type of Geometry to be parsed. + /// The geometry object of specific type read from the reader or null if no more geometries are available. + public T Read() where T : Geometry + { + Geometry parsed = WktReader.ParseGeometryTaggedText(_tokens); + + if (parsed != null) + { + T result = parsed as T; + if (result == null) + { + throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); + } + + return result; + } + else + { + return null; + } + } + + /// + /// Releases all resources used by the ComponentLibrary. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Parses a geometry tagged text. + /// + /// The list of tokens. + /// A geometry specified by tokens. + private static Geometry ParseGeometryTaggedText(WktTokensBuffer tokens) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING) + { + if (t.Value.ToUpperInvariant() == "POINT") + { + return WktReader.ParsePointTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "LINESTRING") + { + return WktReader.ParseLineStringTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "POLYGON") + { + return WktReader.ParsePolygonTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "MULTIPOINT") + { + return WktReader.ParseMultiPointTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "MULTILINESTRING") + { + return WktReader.ParseMultiLineStringTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "MULTIPOLYGON") + { + return WktReader.ParseMultiPolygonTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "GEOMETRYCOLLECTION") + { + return WktReader.ParseGeometryCollectionTaggedText(tokens); + } + } + + if (t.Type == TokenType.END_OF_DATA) + { + return null; + } + + throw new WktParseException(string.Format("Invalid geometry type '{0}'", t.Value)); + } + + /// + /// Parses a point tagged text. + /// + /// The list of tokens. + /// A point specified by tokens. + /// ::= point {z}{m} ]]> + private static Point ParsePointTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("point", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + } + + return WktReader.ParsePointText(tokens, is3D, isMeasured); + } + + /// + /// Parses a point tagged text. + /// + /// The list of tokens. + /// bool value indicating whether point being parsed has z-coordinate. + /// bool value indicating whether point beeing parsed has m-value. + /// A point specified by tokens + /// | ]]> + private static Point ParsePointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new Point(); + } + + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + Point result = new Point(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + + return result; + } + + /// + /// Parses multiple Points separated by comma. + /// + /// The list of tokens. + /// bool value indicating whether point being parsed had z-coordinate. + /// bool value indicating whether point being parsed has m-value. + /// A list of point specified by tokens. + private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List points = new List(); + + points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); + + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) + { + tokens.GetToken(true); + points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } + + return points; + } + + /// + /// Parses a coordinate. + /// + /// The list of tokens. + /// bool value indicating whether coordinate being parsed had z-coordinate. + /// bool value indicating whether coordinate beeing parsed has m-value. + /// A coordinate specified by tokens. + /// {} {}]]> + private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = WktReader.Expect(TokenType.NUMBER, tokens); + double x = double.Parse(t.Value, _invarianCulture); + + WktReader.Expect(TokenType.WHITESPACE, tokens); + + t = WktReader.Expect(TokenType.NUMBER, tokens); + double y = double.Parse(t.Value, _invarianCulture); + + double z = double.NaN; + double m = double.NaN; + + if (is3D) + { + WktReader.Expect(TokenType.WHITESPACE, tokens); + + t = WktReader.Expect(TokenType.NUMBER, tokens); + z = double.Parse(t.Value, _invarianCulture); + } + + if (isMeasured) + { + WktReader.Expect(TokenType.WHITESPACE, tokens); + + t = WktReader.Expect(TokenType.NUMBER, tokens); + m = double.Parse(t.Value, _invarianCulture); + } + + return new Coordinate(x, y, z, m); + } + + /// + /// Parses a series of coordinate. + /// + /// The list of tokens. + /// bool value indicating whether coordinate being parsed had z-coordinate. + /// bool value indicating whether coordinate beeing parsed has m-value. + /// A list of coordinates specified by tokens. + private static IEnumerable ParseCoordinates(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List coordinates = new List(); + + coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); + + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } + + return coordinates; + } + + /// + /// Parses a linestring tagged text. + /// + /// The list of tokens. + /// A linestring specified by tokens. + /// ::= linestring {z}{m} ]]> + private static LineString ParseLineStringTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("linestring", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + } + + return WktReader.ParseLineStringText(tokens, is3D, isMeasured); + } + + /// + /// Parses a linestring text. + /// + /// The list of tokens. + /// bool value indicating whether linestring being parsed has z-coordinate. + /// bool value indicating whether linestring being parsed has m-value. + /// A linestring specified by tokens. + /// | { }* ]]> + private static LineString ParseLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new LineString(); + } + + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + IEnumerable coords = WktReader.ParseCoordinates(tokens, is3D, isMeasured); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + + return new LineString(coords); + } + + /// + /// Parses multiple LineStrings separated by comma. + /// + /// The list of tokens. + /// bool value indicating whether linestring being parsed had z-coordinate. + /// bool value indicating whether linestring being parsed has m-value. + /// A list of linestrings specified by tokens. + private static List ParseLineStrings(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List linestrigns = new List(); + + linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); + + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) + { + tokens.GetToken(true); + linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } + + return linestrigns; + } + + /// + /// Parses a polygon tagged text. + /// + /// The list of tokens. + /// A polygon specified by tokens. + /// ::= polygon {z}{m} ]]> + private static Polygon ParsePolygonTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("polygon", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + } + + return WktReader.ParsePolygonText(tokens, is3D, isMeasured); + } + + /// + /// Parses a polygon text. + /// + /// The list of tokens. + /// bool value indicating whether polygon being parsed has z-coordinate. + /// bool value indicating whether polygon being parsed has m-value. + /// A polygon specified by tokens. + /// | { }* ]]> + private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new Polygon(); + } + + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + + IEnumerable linestrings = WktReader.ParseLineStrings(tokens, is3D, isMeasured); + Polygon result = new Polygon(linestrings.First().Coordinates); + + foreach (var inner in linestrings.Skip(1)) + { + result.InteriorRings.Add(inner.Coordinates); + } + + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + + return result; + } + + /// + /// Parses series of polygons. + /// + /// The list of tokens. + /// bool value indicating whether polygon being parsed has z-coordinate. + /// bool value indicating whether polygon being parsed has m-value. + /// A list of polygons specified by tokens. + private static IEnumerable ParsePolygons(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List polygons = new List(); + + polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); + + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) + { + tokens.GetToken(true); + polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } + + return polygons; + } + + /// + /// Parses a multilinestring tagged text. + /// + /// The list of tokens. + /// A multilinestring specified by tokens. + /// ::= multilinestring {z}{m} ]]> + private static MultiLineString ParseMultiLineStringTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("multilinestring", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + } + + return WktReader.ParseMultiLineStringText(tokens, is3D, isMeasured); + } + + /// + /// Parses a multilinestring text. + /// + /// The list of tokens. + /// bool value indicating whether multilinestring being parsed has z-coordinate. + /// bool value indicating whether multilinestring being parsed has m-value. + /// A multilinestring specified by tokens. + /// ::= | { }* ]]> + private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new MultiLineString(); + } + + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiLineString result = new MultiLineString(WktReader.ParseLineStrings(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + + return result; + } + + /// + /// Parses a multipoint tagged text. + /// + /// The list of tokens. + /// A multipoint specified by tokens. + /// ::= multipoint {z}{m} ]]> + private static MultiPoint ParseMultiPointTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("multipoint", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + } + + return WktReader.ParseMultiPointText(tokens, is3D, isMeasured); + } + + /// + /// Parses a multipoint text. + /// + /// The list of tokens. + /// bool value indicating whether multipoint being parsed has z-coordinate. + /// bool value indicating whether multipoint being parsed has m-value. + /// A multipoint specified by tokens. + /// ::= | { }* ]]> + private static MultiPoint ParseMultiPointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new MultiPoint(); + } + + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiPoint result = new MultiPoint(WktReader.ParsePoints(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + + return result; + } + + /// + /// Parses a multipolyugon tagged text. + /// + /// The list of tokens. + /// A multipolygon specified by tokens. + /// ::= multipolygon {z}{m} ]]> + private static MultiPolygon ParseMultiPolygonTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("multipolygon", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + } + + return WktReader.ParseMultiPolygonText(tokens, is3D, isMeasured); + } + + /// + /// Parses a multipolygon text. + /// + /// The list of tokens. + /// bool value indicating whether multipolygon being parsed has z-coordinate. + /// bool value indicating whether multipolygon being parsed has m-value. + /// A multipolygon specified by tokens. + /// ::= | { }* ]]> + private static MultiPolygon ParseMultiPolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new MultiPolygon(); + } + + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiPolygon result = new MultiPolygon(WktReader.ParsePolygons(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + + return result; + } + + /// + /// Parses a multipolyugon tagged text. + /// + /// The list of tokens. + /// A GeometryCollection specified by tokens. + /// ::= GeometryCollection {z}{m} ]]> + private static GeometryCollection ParseGeometryCollectionTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("geometrycollection", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + { + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); + } + + return WktReader.ParseGeometryCollectionText(tokens, is3D, isMeasured); + } + + /// + /// Parses a GeometryCollection text. + /// + /// The list of tokens. + /// bool value indicating whether GeometryCollection being parsed has z-coordinate. + /// bool value indicating whether GeometryCollection being parsed has m-value. + /// A GeometryCollection specified by tokens. + /// ::= | { }* ]]> + private static GeometryCollection ParseGeometryCollectionText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); + + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new GeometryCollection(); + } + + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + + GeometryCollection result = new GeometryCollection(); + result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); + + t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) + { + tokens.GetToken(true); + result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); + t = tokens.Peek(true); + } + + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + + return result; + } + + /// + /// Retrieves the next token from the tokens and checks if it has expected type. + /// + /// Expected type of token. + /// The list of tokens. + /// The head of the tokens queue. + private static WktToken Expect(TokenType type, WktTokensBuffer tokens) + { + bool ignoreWhitespace = type != TokenType.WHITESPACE; + + WktToken t = tokens.GetToken(ignoreWhitespace); + + if (t.Type != type) + { + string expected = string.Empty; + switch (type) + { + case TokenType.WHITESPACE: expected = " "; break; + case TokenType.LEFT_PARENTHESIS: expected = "("; break; + case TokenType.RIGHT_PARENTHESIS: expected = ")"; break; + case TokenType.STRING: expected = "STRING"; break; + case TokenType.NUMBER: expected = "NUMBER"; break; + } + + throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}'", expected, t.Value)); + } + + return t; + } + + /// + /// Retrieves the next token from tokens and checks if it is TokenType.STRING and if it has correct value. + /// + /// Expected string value of the token. + /// The list of tokens. + /// The head of the tokens queue. + /// String comparsion is not case-sensitive. + private static WktToken Expect(string value, WktTokensBuffer tokens) + { + WktToken t = tokens.GetToken(true); + + if (t.Type != TokenType.STRING || string.Equals(value, t.Value, StringComparison.OrdinalIgnoreCase) == false) + { + throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}", value, t.Value)); + } + + return t; + } + + /// + /// Examines the given token and tries to parse it as WKT dimensions text. + /// + /// The WKT token to parse. + /// Parameter that specified whether dimension text contains {z}. + /// Parameter that specified whether dimension text contains {m}. + /// true if token was successfuly parsed as WKT dimension text, oterwise returns false. + private static bool TryParseDimensions(WktToken token, out bool is3D, out bool isMeasured) + { + is3D = false; + isMeasured = false; + + if (token.Type == TokenType.STRING) + { + if (token.Value.ToUpperInvariant() == "Z") + { + is3D = true; + } + else if (token.Value.ToUpperInvariant() == "M") + { + isMeasured = true; + } + else if (token.Value.ToUpperInvariant() == "ZM") + { + is3D = true; + isMeasured = true; + } + + return is3D || isMeasured; + } + else + { + return false; + } + } + + /// + /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (disposing) + { + _inputReader.Dispose(); + + if (_inputFileStream != null) + { + _inputFileStream.Dispose(); + } + } + + _disposed = true; + } + } + } } diff --git a/src/SpatialLite.Core/IO/WktToken.cs b/src/SpatialLite.Core/IO/WktToken.cs index b643b98..2adb04e 100644 --- a/src/SpatialLite.Core/IO/WktToken.cs +++ b/src/SpatialLite.Core/IO/WktToken.cs @@ -1,21 +1,23 @@ -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Represents token of the wkt string. /// - internal struct WktToken { - /// - /// Special token that represents end of available data. - /// - public static WktToken EndOfDataToken = new WktToken() { Type = TokenType.END_OF_DATA, Value = string.Empty }; + internal struct WktToken + { + /// + /// Special token that represents end of available data. + /// + public static WktToken EndOfDataToken = new WktToken() { Type = TokenType.END_OF_DATA, Value = string.Empty }; - /// - /// The type of the tooken. - /// - public TokenType Type; + /// + /// The type of the tooken. + /// + public TokenType Type; - /// - /// The string value of the token. - /// - public string Value; - } + /// + /// The string value of the token. + /// + public string Value; + } } diff --git a/src/SpatialLite.Core/IO/WktTokenizer.cs b/src/SpatialLite.Core/IO/WktTokenizer.cs index 7d89ef2..9d55735 100644 --- a/src/SpatialLite.Core/IO/WktTokenizer.cs +++ b/src/SpatialLite.Core/IO/WktTokenizer.cs @@ -3,83 +3,97 @@ using System.IO; using System.Text; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Implemets tokenizer that splits wkt string to list of tokens. /// - internal static class WktTokenizer { + internal static class WktTokenizer + { - /// - /// Splits text to tokens. - /// - /// The text to be splitted. - /// The list of parsed tokens of the input string. - public static IEnumerable Tokenize(string text) { - StringReader reader = new StringReader(text); - return WktTokenizer.Tokenize(reader); - } + /// + /// Splits text to tokens. + /// + /// The text to be splitted. + /// The list of parsed tokens of the input string. + public static IEnumerable Tokenize(string text) + { + StringReader reader = new StringReader(text); + return WktTokenizer.Tokenize(reader); + } - /// - /// Processes text from TextReader and splits it into tokens. - /// - /// The TextReader to read string from - /// The collection parsed tokens of the input string - public static IEnumerable Tokenize(TextReader reader) { - StringBuilder stringBuffer = new StringBuilder(); + /// + /// Processes text from TextReader and splits it into tokens. + /// + /// The TextReader to read string from + /// The collection parsed tokens of the input string + public static IEnumerable Tokenize(TextReader reader) + { + StringBuilder stringBuffer = new StringBuilder(); - if (reader.Peek() == -1) { - yield break; - } + if (reader.Peek() == -1) + { + yield break; + } - char ch = (char)reader.Read(); - stringBuffer.Append(ch); - TokenType lastToken = WktTokenizer.GetTokenType(ch); + char ch = (char)reader.Read(); + stringBuffer.Append(ch); + TokenType lastToken = WktTokenizer.GetTokenType(ch); - while (reader.Peek() != -1) { - ch = (char)reader.Read(); - TokenType token = WktTokenizer.GetTokenType(ch); + while (reader.Peek() != -1) + { + ch = (char)reader.Read(); + TokenType token = WktTokenizer.GetTokenType(ch); - // tokens COMMA, LEFT_PARENTHESIS and RIGHT_PARENTHESIS can not be grupped together - if ((token != lastToken) || token == TokenType.COMMA || token == TokenType.LEFT_PARENTHESIS || token == TokenType.RIGHT_PARENTHESIS) { - yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; + // tokens COMMA, LEFT_PARENTHESIS and RIGHT_PARENTHESIS can not be grupped together + if ((token != lastToken) || token == TokenType.COMMA || token == TokenType.LEFT_PARENTHESIS || token == TokenType.RIGHT_PARENTHESIS) + { + yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; - stringBuffer.Clear(); - lastToken = token; - } + stringBuffer.Clear(); + lastToken = token; + } - stringBuffer.Append(ch); - } + stringBuffer.Append(ch); + } - yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; - } + yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; + } - /// - /// Gets type of the token. - /// - /// Character to get type. - /// the type of token for ch. - /// In WKT can characters be divided into token types without context - every character is member of thne one token type only. - private static TokenType GetTokenType(char ch) { - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { - return TokenType.STRING; - } - else if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') { - return TokenType.WHITESPACE; - } - else if (ch == ',') { - return TokenType.COMMA; - } - else if (ch == '(') { - return TokenType.LEFT_PARENTHESIS; - } - else if (ch == ')') { - return TokenType.RIGHT_PARENTHESIS; - } - else if (ch == '-' || ch == '.' || (ch >= '0' && ch <= '9')) { - return TokenType.NUMBER; - } + /// + /// Gets type of the token. + /// + /// Character to get type. + /// the type of token for ch. + /// In WKT can characters be divided into token types without context - every character is member of thne one token type only. + private static TokenType GetTokenType(char ch) + { + if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) + { + return TokenType.STRING; + } + else if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') + { + return TokenType.WHITESPACE; + } + else if (ch == ',') + { + return TokenType.COMMA; + } + else if (ch == '(') + { + return TokenType.LEFT_PARENTHESIS; + } + else if (ch == ')') + { + return TokenType.RIGHT_PARENTHESIS; + } + else if (ch == '-' || ch == '.' || (ch >= '0' && ch <= '9')) + { + return TokenType.NUMBER; + } - throw new Exception(); - } - } + throw new Exception(); + } + } } diff --git a/src/SpatialLite.Core/IO/WktTokensBuffer.cs b/src/SpatialLite.Core/IO/WktTokensBuffer.cs index 5fc6214..5fceca9 100644 --- a/src/SpatialLite.Core/IO/WktTokensBuffer.cs +++ b/src/SpatialLite.Core/IO/WktTokensBuffer.cs @@ -1,123 +1,143 @@ using System.Collections.Generic; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Represents collection of WktToken obejcts with specialized methods to access it's items. /// - internal class WktTokensBuffer : IEnumerable { - - private List _buffer; - - /// - /// Initializes a new instance of the WktTokenBuffer class that is empty. - /// - public WktTokensBuffer() { - _buffer = new List(); - } - - /// - /// Initializes a new instance of the WktTokensBuffer class and fills it with specified tokens. - /// - /// Tokens to add to the buffer. - public WktTokensBuffer(IEnumerable tokens) { - _buffer = new List(tokens); - } - - /// - /// Gets number of items in the collection - /// - public int Count { - get { - return _buffer.Count; - } - } - - /// - /// Adds specific token to the end of tokens tokens - /// - /// The WktToken to add to the tokens - public void Add(WktToken item) { - _buffer.Add(item); - } - - /// - /// Adds tokens from specific collection to the ent of tokens - /// - /// The collection whose items to add to this collection - public void Add(IEnumerable items) { - _buffer.AddRange(items); - } - - /// - /// Removes all tokens from the collection - /// - public void Clear() { - _buffer.Clear(); - } - - /// - /// Gets next token from the tokens - /// - /// bool value indicating whether whitespace tokens should be ignored - /// Next token form the tokens - public WktToken Peek(bool ignoreWhitespace) { - if (this.Count == 0) { - return WktToken.EndOfDataToken; - } - - WktToken t = _buffer[0]; - if (t.Type == TokenType.WHITESPACE && ignoreWhitespace) { - int index = 0; - while (index < _buffer.Count && t.Type == TokenType.WHITESPACE) { - t = _buffer[index++]; - } - - if (t.Type == TokenType.WHITESPACE) { - return WktToken.EndOfDataToken; - } - - return t; - } - - return t; - } - - /// - /// Gets next token from the tokens and proceeds to the next token - /// - /// bool value indicating whether whitespace tokens should be ignored - /// Next token form the tokens - public WktToken GetToken(bool ignoreWhitespace) { - if (ignoreWhitespace) { - while (_buffer.Count > 0 && _buffer[0].Type == TokenType.WHITESPACE) { - _buffer.RemoveAt(0); - } - } - - if (_buffer.Count == 0) { - return WktToken.EndOfDataToken; - } - - WktToken result = _buffer[0]; - _buffer.RemoveAt(0); - - return result; - } - - /// - /// Returns an enumerator that iterates through the items of collection - /// - /// An enumerator that iterates through the collection - public IEnumerator GetEnumerator() { - return _buffer.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through the items of collection - /// - /// An enumerator that iterates through the collection - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return this.GetEnumerator(); - } - } + internal class WktTokensBuffer : IEnumerable + { + + private List _buffer; + + /// + /// Initializes a new instance of the WktTokenBuffer class that is empty. + /// + public WktTokensBuffer() + { + _buffer = new List(); + } + + /// + /// Initializes a new instance of the WktTokensBuffer class and fills it with specified tokens. + /// + /// Tokens to add to the buffer. + public WktTokensBuffer(IEnumerable tokens) + { + _buffer = new List(tokens); + } + + /// + /// Gets number of items in the collection + /// + public int Count + { + get + { + return _buffer.Count; + } + } + + /// + /// Adds specific token to the end of tokens tokens + /// + /// The WktToken to add to the tokens + public void Add(WktToken item) + { + _buffer.Add(item); + } + + /// + /// Adds tokens from specific collection to the ent of tokens + /// + /// The collection whose items to add to this collection + public void Add(IEnumerable items) + { + _buffer.AddRange(items); + } + + /// + /// Removes all tokens from the collection + /// + public void Clear() + { + _buffer.Clear(); + } + + /// + /// Gets next token from the tokens + /// + /// bool value indicating whether whitespace tokens should be ignored + /// Next token form the tokens + public WktToken Peek(bool ignoreWhitespace) + { + if (this.Count == 0) + { + return WktToken.EndOfDataToken; + } + + WktToken t = _buffer[0]; + if (t.Type == TokenType.WHITESPACE && ignoreWhitespace) + { + int index = 0; + while (index < _buffer.Count && t.Type == TokenType.WHITESPACE) + { + t = _buffer[index++]; + } + + if (t.Type == TokenType.WHITESPACE) + { + return WktToken.EndOfDataToken; + } + + return t; + } + + return t; + } + + /// + /// Gets next token from the tokens and proceeds to the next token + /// + /// bool value indicating whether whitespace tokens should be ignored + /// Next token form the tokens + public WktToken GetToken(bool ignoreWhitespace) + { + if (ignoreWhitespace) + { + while (_buffer.Count > 0 && _buffer[0].Type == TokenType.WHITESPACE) + { + _buffer.RemoveAt(0); + } + } + + if (_buffer.Count == 0) + { + return WktToken.EndOfDataToken; + } + + WktToken result = _buffer[0]; + _buffer.RemoveAt(0); + + return result; + } + + /// + /// Returns an enumerator that iterates through the items of collection + /// + /// An enumerator that iterates through the collection + public IEnumerator GetEnumerator() + { + return _buffer.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the items of collection + /// + /// An enumerator that iterates through the collection + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + } } diff --git a/src/SpatialLite.Core/IO/WktWriter.cs b/src/SpatialLite.Core/IO/WktWriter.cs index 3301000..762bcd0 100644 --- a/src/SpatialLite.Core/IO/WktWriter.cs +++ b/src/SpatialLite.Core/IO/WktWriter.cs @@ -3,474 +3,550 @@ using SpatialLite.Core.API; using System.Linq; -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Provides methods for writing Geomerty objects into WKT format. /// - public class WktWriter : IDisposable { - - private static System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; - - private bool _disposed = false; - private TextWriter _writer; - private Stream _outputStream; - - /// - /// Initializes a new instance of the WkbWriter class with specific settings. - /// - /// The settings defining behaviour of the writer. - protected WktWriter(WktWriterSettings settings) { - if (settings == null) { - throw new ArgumentNullException("settings"); - } - - this.Settings = settings; - this.Settings.IsReadOnly = true; - } - - /// - /// Initializes a new instance of the WktWriter class that writes geometries to stream with specific settings. - /// - /// The stream to write geometries to. - /// The settings defining behaviour of the writer. - public WktWriter(Stream stream, WktWriterSettings settings) - : this(settings) { - if (stream == null) { - throw new ArgumentNullException("stream"); - } - - _writer = new StreamWriter(stream); - } - - /// - /// Initializes a new instance of the WktWriter class that writes geometreis to file with specific settings. - /// - /// The path to the file to write geometries to. - /// The settings defining behaviour of the writer. - public WktWriter(string path, WktWriterSettings settings) - : this(settings) { - if (path == null) { - throw new ArgumentNullException("path"); - } - - _outputStream = new FileStream(path, FileMode.Create, FileAccess.Write); - _writer = new StreamWriter(_outputStream); - } - - /// - /// Gets the settings that determines behaviour of this instance of the WktWriter. - /// - public WktWriterSettings Settings { get; private set; } - - /// - /// Writes the Geometry object in the WKT format to the output. - /// - /// The geometry to write. - public void Write(IGeometry geometry) { - WktWriter.Write(geometry, _writer); - } - - /// - /// Releases all resources used by the WktWriter. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Writes the Geometry object to the string in WKT format. - /// - /// The Geometry to be written. - /// The WKT representation of the Geometry. - public static string WriteToString(IGeometry geometry) { - StringWriter tw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); - WktWriter.Write(geometry, tw); - - return tw.ToString(); - } - - /// - /// Writes specified Geometry to the TextWriter in WKT format. - /// - /// The geometry to be written. - /// The output Stream the Geometry will be written to. - protected static void Write(IGeometry geometry, TextWriter writer) { - if (geometry is IPoint) { - WktWriter.AppendPointTaggedText((IPoint)geometry, writer); - } - else if (geometry is ILineString) { - WktWriter.AppendLineStringTaggedText((ILineString)geometry, writer); - } - else if (geometry is IPolygon) { - WktWriter.AppendPolygonTaggedText((IPolygon)geometry, writer); - } - else if (geometry is IMultiPoint) { - WktWriter.AppendMultiPointTaggedText((IMultiPoint)geometry, writer); - } - else if (geometry is IMultiLineString) { - WktWriter.AppendMultiLineStringTaggedText((IMultiLineString)geometry, writer); - } - else if (geometry is IMultiPolygon) { - WktWriter.AppendMultiPolygonTaggetText((IMultiPolygon)geometry, writer); - } - else if (geometry is IGeometryCollection) { - WktWriter.AppendGeometryCollectionTaggedText((IGeometryCollection)geometry, writer); - } - } - - /// - /// Converts the Coordinate to the format used in WKT and appends it to the output Stream. - /// - /// The Coordinate to be converted. - /// The output Stream to Appent WKT representation to. - private static void AppendCoordinate(Coordinate coordinate, TextWriter writer) { - writer.Write(coordinate.X.ToString(_invariantCulture)); - writer.Write(' '); - writer.Write(coordinate.Y.ToString(_invariantCulture)); - - if (coordinate.Is3D) { - writer.Write(' '); - writer.Write(coordinate.Z.ToString(_invariantCulture)); - } - - if (coordinate.IsMeasured) { - writer.Write(' '); - writer.Write(coordinate.M.ToString(_invariantCulture)); - } - } - - /// - /// Converts the List of Coordinates to WKT format and appends it to output stream. - /// - /// The list of coordinates to be converted. - /// The output stream. - /// bool value indicating whether the list of coordinates should be enclosed in parathenes. - private static void AppendCoordinates(ICoordinateList coordinates, TextWriter writer, bool wrap) { - if (coordinates.Count == 0) { - return; - } - - if (wrap) { - writer.Write("("); - } - - WktWriter.AppendCoordinate(coordinates[0], writer); - - for (int i = 1; i < coordinates.Count; i++) { - writer.Write(", "); - WktWriter.AppendCoordinate(coordinates[i], writer); - } - - if (wrap) { - writer.Write(")"); - } - } - - /// - /// Converts Point to WKT format and appends WKT representation to the output stream. - /// - /// The Point to be converted. - /// The output Stream to append WKT representation to. - private static void AppendPointTaggedText(IPoint point, TextWriter writer) { - writer.Write("point "); - - string dimension = WktWriter.GetDimensionText(point); - if (string.IsNullOrEmpty(dimension) == false) { - writer.Write(dimension); - writer.Write(" "); - } - - WktWriter.AppendPointText(point, writer); - } - - /// - /// Converts Point's content to WKT format and appends it to the output stream. - /// - /// The Point to be converted. - /// The output Stream to append WKT representation to. - private static void AppendPointText(IPoint point, TextWriter writer) { - if (point.Position.Equals(Coordinate.Empty)) { - writer.Write("empty"); - } - else { - writer.Write("("); - WktWriter.AppendCoordinate(point.Position, writer); - writer.Write(")"); - } - } - - /// - /// Converts LineString to WKT format and appends WKT representation to the output stream. - /// - /// The LineString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendLineStringTaggedText(ILineString linestring, TextWriter writer) { - writer.Write("linestring "); - - string dimension = WktWriter.GetDimensionText(linestring); - if (string.IsNullOrEmpty(dimension) == false) { - writer.Write(dimension); - writer.Write(" "); - } - - WktWriter.AppendLineStringText(linestring, writer); - } - - /// - /// Converts LineString's content to WKT and appends it to the output stream. - /// - /// The LineString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendLineStringText(ILineString linestring, TextWriter writer) { - if (linestring.Coordinates.Count == 0) { - writer.Write("empty"); - } - else { - WktWriter.AppendCoordinates(linestring.Coordinates, writer, true); - } - } - - /// - /// Converts Polygon to WKT format and appends WKT representation to the output stream. - /// - /// The Polygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendPolygonTaggedText(IPolygon polygon, TextWriter writer) { - writer.Write("polygon "); - - string dimension = WktWriter.GetDimensionText(polygon); - if (string.IsNullOrEmpty(dimension) == false) { - writer.Write(dimension); - writer.Write(" "); - } - - WktWriter.AppendPolygonText(polygon, writer); - } - - /// - /// Converts Polygon's content to WKT format and appends WKT representation to the output stream. - /// - /// The Polygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendPolygonText(IPolygon polygon, TextWriter writer) { - if (polygon.ExteriorRing.Count == 0) { - writer.Write("empty"); - } - else { - writer.Write("("); - WktWriter.AppendCoordinates(polygon.ExteriorRing, writer, true); - - if (polygon.InteriorRings.Count() > 0) { - writer.Write(","); - WktWriter.AppendCoordinates(polygon.InteriorRings.First(), writer, true); - - foreach (var ring in polygon.InteriorRings.Skip(1)) { - writer.Write(","); - WktWriter.AppendCoordinates(ring, writer, true); - } - } - - writer.Write(")"); - } - } - - /// - /// Converts MultiPoint to WKT format and appends WKT representation to the output stream. - /// - /// The MultiPoint to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPointTaggedText(IMultiPoint multipoint, TextWriter writer) { - writer.Write("multipoint "); - - string dimension = WktWriter.GetDimensionText(multipoint); - if (string.IsNullOrEmpty(dimension) == false) { - writer.Write(dimension); - writer.Write(" "); - } - - WktWriter.AppendMultiPointText(multipoint, writer); - } - - /// - /// Converts MultiPoint's content to WKT format and appends WKT representation to the output stream. - /// - /// The MultiPoint to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPointText(IMultiPoint multipoint, TextWriter writer) { - if (multipoint.Geometries.Count() == 0) { - writer.Write("empty"); - } - else { - writer.Write("("); - - if (multipoint.Geometries.Count() > 0) { - WktWriter.AppendPointText(multipoint.Geometries.First(), writer); - - foreach (var point in multipoint.Geometries.Skip(1)) { - writer.Write(","); - WktWriter.AppendPointText(point, writer); - } - } - - writer.Write(")"); - } - } - - /// - /// Converts MultiLineString to WKT format and appends WKT representation to the output stream. - /// - /// The MultiLineString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiLineStringTaggedText(IMultiLineString mls, TextWriter writer) { - writer.Write("multilinestring "); - - string dimension = WktWriter.GetDimensionText(mls); - if (string.IsNullOrEmpty(dimension) == false) { - writer.Write(dimension); - writer.Write(" "); - } - - WktWriter.AppendMultiLineStringText(mls, writer); - } - - /// - /// Converts MultiLineString's content to WKT format and appends WKT representation to the output stream. - /// - /// The MultiLIneString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiLineStringText(IMultiLineString mls, TextWriter writer) { - if (mls.Geometries.Count() == 0) { - writer.Write("empty"); - } - else { - writer.Write("("); - - WktWriter.AppendLineStringText(mls.Geometries.First(), writer); - - foreach (var linestring in mls.Geometries.Skip(1)) { - writer.Write(","); - WktWriter.AppendLineStringText(linestring, writer); - } - - writer.Write(")"); - } - } - - /// - /// Converts MultiPolygon to WKT format and appends WKT representation to the output stream. - /// - /// The Multipolygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPolygonTaggetText(IMultiPolygon mp, TextWriter writer) { - writer.Write("multipolygon "); - - string dimension = WktWriter.GetDimensionText(mp); - if (string.IsNullOrEmpty(dimension) == false) { - writer.Write(dimension); - writer.Write(" "); - } - - WktWriter.AppendMultiPolygonText(mp, writer); - } - - /// - /// Converts MultiPolygon's content to WKT format and appends WKT representation to the output stream. - /// - /// The MultiPolygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPolygonText(IMultiPolygon multipolygon, TextWriter writer) { - if (multipolygon.Geometries.Count() == 0) { - writer.Write("empty"); - } - else { - writer.Write("("); - - WktWriter.AppendPolygonText(multipolygon.Geometries.First(), writer); - - foreach (var polygon in multipolygon.Geometries.Skip(1)) { - writer.Write(","); - WktWriter.AppendPolygonText(polygon, writer); - } - - writer.Write(")"); - } - } - - /// - /// Converts GeometryCollection to WKT format and appends WKT representation to the output stream. - /// - /// The GeometryCollection be converted. - /// The output Stream to Append WKT representation to. - private static void AppendGeometryCollectionTaggedText(IGeometryCollection collection, TextWriter writer) { - writer.Write("geometrycollection "); - - string dimension = WktWriter.GetDimensionText(collection); - if (string.IsNullOrEmpty(dimension) == false) { - writer.Write(dimension); - writer.Write(" "); - } - - WktWriter.AppendGeometryCollectionText(collection, writer); - } - - /// - /// Converts GeometryCollection's content to WKT format and appends WKT representation to the output stream. - /// - /// The GeometryCollection to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendGeometryCollectionText(IGeometryCollection collection, TextWriter writer) { - if (collection.Geometries.Count() == 0) { - writer.Write("empty"); - } - else { - writer.Write("("); - WktWriter.Write(collection.Geometries.First(), writer); - - foreach (var geometry in collection.Geometries.Skip(1)) { - writer.Write(","); - WktWriter.Write(geometry, writer); - } - - writer.Write(")"); - } - } - - /// - /// Gets string that represents dimension of the geometry. - /// - /// The geometry to examine. - /// The string representing dimension of the geometry - empty string for 2D geometry, 'm' for measured geometry, 'z' for 3D geometry. - private static string GetDimensionText(IGeometry geometry) { - string dimension = string.Empty; - - if (geometry.Is3D) { - dimension += "z"; - } - - if (geometry.IsMeasured) { - dimension += "m"; - } - - return dimension; - } - - /// - /// Releases the unmanaged resources used by the WktWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!_disposed) { - if (disposing) { - _writer.Dispose(); - - if (_outputStream != null) { - _outputStream.Dispose(); - } - } - - _disposed = true; - } - } - } + public class WktWriter : IDisposable + { + + private static System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + + private bool _disposed = false; + private TextWriter _writer; + private Stream _outputStream; + + /// + /// Initializes a new instance of the WkbWriter class with specific settings. + /// + /// The settings defining behaviour of the writer. + protected WktWriter(WktWriterSettings settings) + { + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } + + this.Settings = settings; + this.Settings.IsReadOnly = true; + } + + /// + /// Initializes a new instance of the WktWriter class that writes geometries to stream with specific settings. + /// + /// The stream to write geometries to. + /// The settings defining behaviour of the writer. + public WktWriter(Stream stream, WktWriterSettings settings) + : this(settings) + { + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); + } + + _writer = new StreamWriter(stream); + } + + /// + /// Initializes a new instance of the WktWriter class that writes geometreis to file with specific settings. + /// + /// The path to the file to write geometries to. + /// The settings defining behaviour of the writer. + public WktWriter(string path, WktWriterSettings settings) + : this(settings) + { + if (path == null) + { + throw new ArgumentNullException(nameof(path)); + } + + _outputStream = new FileStream(path, FileMode.Create, FileAccess.Write); + _writer = new StreamWriter(_outputStream); + } + + /// + /// Gets the settings that determines behaviour of this instance of the WktWriter. + /// + public WktWriterSettings Settings { get; private set; } + + /// + /// Writes the Geometry object in the WKT format to the output. + /// + /// The geometry to write. + public void Write(IGeometry geometry) + { + WktWriter.Write(geometry, _writer); + } + + /// + /// Releases all resources used by the WktWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Writes the Geometry object to the string in WKT format. + /// + /// The Geometry to be written. + /// The WKT representation of the Geometry. + public static string WriteToString(IGeometry geometry) + { + StringWriter tw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); + WktWriter.Write(geometry, tw); + + return tw.ToString(); + } + + /// + /// Writes specified Geometry to the TextWriter in WKT format. + /// + /// The geometry to be written. + /// The output Stream the Geometry will be written to. + protected static void Write(IGeometry geometry, TextWriter writer) + { + if (geometry is IPoint) + { + WktWriter.AppendPointTaggedText((IPoint)geometry, writer); + } + else if (geometry is ILineString) + { + WktWriter.AppendLineStringTaggedText((ILineString)geometry, writer); + } + else if (geometry is IPolygon) + { + WktWriter.AppendPolygonTaggedText((IPolygon)geometry, writer); + } + else if (geometry is IMultiPoint) + { + WktWriter.AppendMultiPointTaggedText((IMultiPoint)geometry, writer); + } + else if (geometry is IMultiLineString) + { + WktWriter.AppendMultiLineStringTaggedText((IMultiLineString)geometry, writer); + } + else if (geometry is IMultiPolygon) + { + WktWriter.AppendMultiPolygonTaggetText((IMultiPolygon)geometry, writer); + } + else if (geometry is IGeometryCollection) + { + WktWriter.AppendGeometryCollectionTaggedText((IGeometryCollection)geometry, writer); + } + } + + /// + /// Converts the Coordinate to the format used in WKT and appends it to the output Stream. + /// + /// The Coordinate to be converted. + /// The output Stream to Appent WKT representation to. + private static void AppendCoordinate(Coordinate coordinate, TextWriter writer) + { + writer.Write(coordinate.X.ToString(_invariantCulture)); + writer.Write(' '); + writer.Write(coordinate.Y.ToString(_invariantCulture)); + + if (coordinate.Is3D) + { + writer.Write(' '); + writer.Write(coordinate.Z.ToString(_invariantCulture)); + } + + if (coordinate.IsMeasured) + { + writer.Write(' '); + writer.Write(coordinate.M.ToString(_invariantCulture)); + } + } + + /// + /// Converts the List of Coordinates to WKT format and appends it to output stream. + /// + /// The list of coordinates to be converted. + /// The output stream. + /// bool value indicating whether the list of coordinates should be enclosed in parathenes. + private static void AppendCoordinates(ICoordinateList coordinates, TextWriter writer, bool wrap) + { + if (coordinates.Count == 0) + { + return; + } + + if (wrap) + { + writer.Write("("); + } + + WktWriter.AppendCoordinate(coordinates[0], writer); + + for (int i = 1; i < coordinates.Count; i++) + { + writer.Write(", "); + WktWriter.AppendCoordinate(coordinates[i], writer); + } + + if (wrap) + { + writer.Write(")"); + } + } + + /// + /// Converts Point to WKT format and appends WKT representation to the output stream. + /// + /// The Point to be converted. + /// The output Stream to append WKT representation to. + private static void AppendPointTaggedText(IPoint point, TextWriter writer) + { + writer.Write("point "); + + string dimension = WktWriter.GetDimensionText(point); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } + + WktWriter.AppendPointText(point, writer); + } + + /// + /// Converts Point's content to WKT format and appends it to the output stream. + /// + /// The Point to be converted. + /// The output Stream to append WKT representation to. + private static void AppendPointText(IPoint point, TextWriter writer) + { + if (point.Position.Equals(Coordinate.Empty)) + { + writer.Write("empty"); + } + else + { + writer.Write("("); + WktWriter.AppendCoordinate(point.Position, writer); + writer.Write(")"); + } + } + + /// + /// Converts LineString to WKT format and appends WKT representation to the output stream. + /// + /// The LineString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendLineStringTaggedText(ILineString linestring, TextWriter writer) + { + writer.Write("linestring "); + + string dimension = WktWriter.GetDimensionText(linestring); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } + + WktWriter.AppendLineStringText(linestring, writer); + } + + /// + /// Converts LineString's content to WKT and appends it to the output stream. + /// + /// The LineString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendLineStringText(ILineString linestring, TextWriter writer) + { + if (linestring.Coordinates.Count == 0) + { + writer.Write("empty"); + } + else + { + WktWriter.AppendCoordinates(linestring.Coordinates, writer, true); + } + } + + /// + /// Converts Polygon to WKT format and appends WKT representation to the output stream. + /// + /// The Polygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendPolygonTaggedText(IPolygon polygon, TextWriter writer) + { + writer.Write("polygon "); + + string dimension = WktWriter.GetDimensionText(polygon); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } + + WktWriter.AppendPolygonText(polygon, writer); + } + + /// + /// Converts Polygon's content to WKT format and appends WKT representation to the output stream. + /// + /// The Polygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendPolygonText(IPolygon polygon, TextWriter writer) + { + if (polygon.ExteriorRing.Count == 0) + { + writer.Write("empty"); + } + else + { + writer.Write("("); + WktWriter.AppendCoordinates(polygon.ExteriorRing, writer, true); + + if (polygon.InteriorRings.Count() > 0) + { + writer.Write(","); + WktWriter.AppendCoordinates(polygon.InteriorRings.First(), writer, true); + + foreach (var ring in polygon.InteriorRings.Skip(1)) + { + writer.Write(","); + WktWriter.AppendCoordinates(ring, writer, true); + } + } + + writer.Write(")"); + } + } + + /// + /// Converts MultiPoint to WKT format and appends WKT representation to the output stream. + /// + /// The MultiPoint to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPointTaggedText(IMultiPoint multipoint, TextWriter writer) + { + writer.Write("multipoint "); + + string dimension = WktWriter.GetDimensionText(multipoint); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } + + WktWriter.AppendMultiPointText(multipoint, writer); + } + + /// + /// Converts MultiPoint's content to WKT format and appends WKT representation to the output stream. + /// + /// The MultiPoint to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPointText(IMultiPoint multipoint, TextWriter writer) + { + if (multipoint.Geometries.Count() == 0) + { + writer.Write("empty"); + } + else + { + writer.Write("("); + + if (multipoint.Geometries.Count() > 0) + { + WktWriter.AppendPointText(multipoint.Geometries.First(), writer); + + foreach (var point in multipoint.Geometries.Skip(1)) + { + writer.Write(","); + WktWriter.AppendPointText(point, writer); + } + } + + writer.Write(")"); + } + } + + /// + /// Converts MultiLineString to WKT format and appends WKT representation to the output stream. + /// + /// The MultiLineString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiLineStringTaggedText(IMultiLineString mls, TextWriter writer) + { + writer.Write("multilinestring "); + + string dimension = WktWriter.GetDimensionText(mls); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } + + WktWriter.AppendMultiLineStringText(mls, writer); + } + + /// + /// Converts MultiLineString's content to WKT format and appends WKT representation to the output stream. + /// + /// The MultiLIneString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiLineStringText(IMultiLineString mls, TextWriter writer) + { + if (mls.Geometries.Count() == 0) + { + writer.Write("empty"); + } + else + { + writer.Write("("); + + WktWriter.AppendLineStringText(mls.Geometries.First(), writer); + + foreach (var linestring in mls.Geometries.Skip(1)) + { + writer.Write(","); + WktWriter.AppendLineStringText(linestring, writer); + } + + writer.Write(")"); + } + } + + /// + /// Converts MultiPolygon to WKT format and appends WKT representation to the output stream. + /// + /// The Multipolygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPolygonTaggetText(IMultiPolygon mp, TextWriter writer) + { + writer.Write("multipolygon "); + + string dimension = WktWriter.GetDimensionText(mp); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } + + WktWriter.AppendMultiPolygonText(mp, writer); + } + + /// + /// Converts MultiPolygon's content to WKT format and appends WKT representation to the output stream. + /// + /// The MultiPolygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPolygonText(IMultiPolygon multipolygon, TextWriter writer) + { + if (multipolygon.Geometries.Count() == 0) + { + writer.Write("empty"); + } + else + { + writer.Write("("); + + WktWriter.AppendPolygonText(multipolygon.Geometries.First(), writer); + + foreach (var polygon in multipolygon.Geometries.Skip(1)) + { + writer.Write(","); + WktWriter.AppendPolygonText(polygon, writer); + } + + writer.Write(")"); + } + } + + /// + /// Converts GeometryCollection to WKT format and appends WKT representation to the output stream. + /// + /// The GeometryCollection be converted. + /// The output Stream to Append WKT representation to. + private static void AppendGeometryCollectionTaggedText(IGeometryCollection collection, TextWriter writer) + { + writer.Write("geometrycollection "); + + string dimension = WktWriter.GetDimensionText(collection); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } + + WktWriter.AppendGeometryCollectionText(collection, writer); + } + + /// + /// Converts GeometryCollection's content to WKT format and appends WKT representation to the output stream. + /// + /// The GeometryCollection to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendGeometryCollectionText(IGeometryCollection collection, TextWriter writer) + { + if (collection.Geometries.Count() == 0) + { + writer.Write("empty"); + } + else + { + writer.Write("("); + WktWriter.Write(collection.Geometries.First(), writer); + + foreach (var geometry in collection.Geometries.Skip(1)) + { + writer.Write(","); + WktWriter.Write(geometry, writer); + } + + writer.Write(")"); + } + } + + /// + /// Gets string that represents dimension of the geometry. + /// + /// The geometry to examine. + /// The string representing dimension of the geometry - empty string for 2D geometry, 'm' for measured geometry, 'z' for 3D geometry. + private static string GetDimensionText(IGeometry geometry) + { + string dimension = string.Empty; + + if (geometry.Is3D) + { + dimension += "z"; + } + + if (geometry.IsMeasured) + { + dimension += "m"; + } + + return dimension; + } + + /// + /// Releases the unmanaged resources used by the WktWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + _writer.Dispose(); + + if (_outputStream != null) + { + _outputStream.Dispose(); + } + } + + _disposed = true; + } + } + } } diff --git a/src/SpatialLite.Core/IO/WktWriterSettings.cs b/src/SpatialLite.Core/IO/WktWriterSettings.cs index b2e529d..7c2b381 100644 --- a/src/SpatialLite.Core/IO/WktWriterSettings.cs +++ b/src/SpatialLite.Core/IO/WktWriterSettings.cs @@ -1,19 +1,22 @@ -namespace SpatialLite.Core.IO { +namespace SpatialLite.Core.IO +{ /// /// Specifies settings that determine behaviour of the WkbWriter. /// - public class WktWriterSettings { + public class WktWriterSettings + { - /// - /// Initializes a new instance of the WkbWriterSettings class with default values. - /// - public WktWriterSettings() - : base() { - } + /// + /// Initializes a new instance of the WkbWriterSettings class with default values. + /// + public WktWriterSettings() + : base() + { + } - /// - /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } - } + /// + /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } + } } diff --git a/src/SpatialLite.Core/Measurements.cs b/src/SpatialLite.Core/Measurements.cs index 2bb114c..56161af 100644 --- a/src/SpatialLite.Core/Measurements.cs +++ b/src/SpatialLite.Core/Measurements.cs @@ -3,180 +3,207 @@ using SpatialLite.Core.API; using SpatialLite.Core.Algorithms; -namespace SpatialLite.Core { +namespace SpatialLite.Core +{ /// /// Provides methods for measuring geometry objects. /// - public class Measurements { - - private static readonly Measurements _euclidean2D; - private static readonly Measurements _sphere2D; - - /// - /// Initializes static members of the Measurements class. - /// - static Measurements() { - _euclidean2D = new Measurements(new Euclidean2DCalculator()); - _sphere2D = new Measurements(new Sphere2DCalculator()); - } - - /// - /// Initializes a new instance of the Measurements class that uses specific IDistanceCalculator. - /// - /// The IDistance calculator to be used. - public Measurements(IDimensionsCalculator distanceCalculator) { - this.DimensionsCalculator = distanceCalculator; - } - - /// - /// Gets Measurments class instance that uses 2D Euclidean space. - /// - public static Measurements Euclidean2D { - get { - return _euclidean2D; - } - } - - /// - /// Gets Measurements class instance that uses sphere approximation of the Earth and ignores Z coordinates. - /// - public static Measurements Sphere2D { - get { - return _sphere2D; - } - } - - /// - /// Gets IDistanceCalculator object used by this Measurements to compute dimensions of geometries. - /// - public IDimensionsCalculator DimensionsCalculator { get; private set; } - - /// - /// Computes distance between two points - /// - /// The first point - /// The second point - /// distance between two point - public double ComputeDistance(Coordinate c1, Coordinate c2) { - return this.DimensionsCalculator.CalculateDistance(c1, c2); - } - - /// - /// Computes distance of a point from LineString - /// - /// The point - /// The LineString - /// The distance of the point from the LineString - public double ComputeDistance(IPoint point, ILineString linestring) { - if (point.Position == Coordinate.Empty || linestring.Coordinates.Count == 0) { - return double.NaN; - } - - double minDistance = double.PositiveInfinity; - - for (int i = 1; i < linestring.Coordinates.Count; i++) { - double distance = this.DimensionsCalculator.CalculateDistance(point.Position, linestring.Coordinates[i - 1], linestring.Coordinates[i], LineMode.LineSegment); - if (distance < minDistance) { - minDistance = distance; - } - } - - return minDistance; - } - - /// - /// Computes distance of a point from MultiLineString - /// - /// The point - /// The MultiLineString - /// The distance of the point from the MultiLineString - public double ComputeDistance(IPoint point, IMultiLineString multilinestring) { - if (point.Position == Coordinate.Empty || multilinestring.Geometries.Count() == 0) { - return double.NaN; - } - - double minDistance = double.PositiveInfinity; - foreach (var linestring in multilinestring.Geometries) { - double distance = this.ComputeDistance(point, linestring); - if (distance < minDistance) { - minDistance = distance; - } - } - - return minDistance; - } - - /// - /// Computes distance between two points - /// - /// The first point - /// The second point - /// distance between two point - public double ComputeDistance(IPoint p1, IPoint p2) { - if (p1.Position == Coordinate.Empty || p2.Position == Coordinate.Empty) { - return double.NaN; - } - - return this.DimensionsCalculator.CalculateDistance(p1.Position, p2.Position); - } - - /// - /// Compute length of the linestring - /// - /// The linestring to measure - /// The length of the Linestring - public double ComputeLength(ILineString line) { - double length = 0; - for (int i = 1; i < line.Coordinates.Count; i++) { - length += this.DimensionsCalculator.CalculateDistance(line.Coordinates[i - 1], line.Coordinates[i]); - } - - return length; - } - - /// - /// Compute length of all linestrings in specific multilinestring - /// - /// The MultiLineString to measure - /// The length of the Linestring - public double ComputeLength(IMultiLineString multilinestring) { - double length = 0; - - foreach (var line in multilinestring.Geometries) { - length += this.ComputeLength(line); - } - - return length; - } - - /// - /// Computes area of the Polygon - /// - /// Polygon to be measured - /// The area of the Polygon - public double ComputeArea(IPolygon polygon) { - double area = this.DimensionsCalculator.CalculateArea(polygon.ExteriorRing); - - foreach (var interiorRing in polygon.InteriorRings) { - area -= this.DimensionsCalculator.CalculateArea(interiorRing); - } - - return area; - } - - /// - /// Computes area of the MultiPolygon - /// - /// MultiPolygon to be measured - /// The area of the MultiPolygon - public double ComputeArea(IMultiPolygon multiPolygon) { - double area = 0; - - foreach (var polygon in multiPolygon.Geometries) { - area += this.ComputeArea(polygon); - } - - return area; - } - } + public class Measurements + { + + private static readonly Measurements _euclidean2D; + private static readonly Measurements _sphere2D; + + /// + /// Initializes static members of the Measurements class. + /// + static Measurements() + { + _euclidean2D = new Measurements(new Euclidean2DCalculator()); + _sphere2D = new Measurements(new Sphere2DCalculator()); + } + + /// + /// Initializes a new instance of the Measurements class that uses specific IDistanceCalculator. + /// + /// The IDistance calculator to be used. + public Measurements(IDimensionsCalculator distanceCalculator) + { + this.DimensionsCalculator = distanceCalculator; + } + + /// + /// Gets Measurments class instance that uses 2D Euclidean space. + /// + public static Measurements Euclidean2D + { + get + { + return _euclidean2D; + } + } + + /// + /// Gets Measurements class instance that uses sphere approximation of the Earth and ignores Z coordinates. + /// + public static Measurements Sphere2D + { + get + { + return _sphere2D; + } + } + + /// + /// Gets IDistanceCalculator object used by this Measurements to compute dimensions of geometries. + /// + public IDimensionsCalculator DimensionsCalculator { get; private set; } + + /// + /// Computes distance between two points + /// + /// The first point + /// The second point + /// distance between two point + public double ComputeDistance(Coordinate c1, Coordinate c2) + { + return this.DimensionsCalculator.CalculateDistance(c1, c2); + } + + /// + /// Computes distance of a point from LineString + /// + /// The point + /// The LineString + /// The distance of the point from the LineString + public double ComputeDistance(IPoint point, ILineString linestring) + { + if (point.Position == Coordinate.Empty || linestring.Coordinates.Count == 0) + { + return double.NaN; + } + + double minDistance = double.PositiveInfinity; + + for (int i = 1; i < linestring.Coordinates.Count; i++) + { + double distance = this.DimensionsCalculator.CalculateDistance(point.Position, linestring.Coordinates[i - 1], linestring.Coordinates[i], LineMode.LineSegment); + if (distance < minDistance) + { + minDistance = distance; + } + } + + return minDistance; + } + + /// + /// Computes distance of a point from MultiLineString + /// + /// The point + /// The MultiLineString + /// The distance of the point from the MultiLineString + public double ComputeDistance(IPoint point, IMultiLineString multilinestring) + { + if (point.Position == Coordinate.Empty || multilinestring.Geometries.Count() == 0) + { + return double.NaN; + } + + double minDistance = double.PositiveInfinity; + foreach (var linestring in multilinestring.Geometries) + { + double distance = this.ComputeDistance(point, linestring); + if (distance < minDistance) + { + minDistance = distance; + } + } + + return minDistance; + } + + /// + /// Computes distance between two points + /// + /// The first point + /// The second point + /// distance between two point + public double ComputeDistance(IPoint p1, IPoint p2) + { + if (p1.Position == Coordinate.Empty || p2.Position == Coordinate.Empty) + { + return double.NaN; + } + + return this.DimensionsCalculator.CalculateDistance(p1.Position, p2.Position); + } + + /// + /// Compute length of the linestring + /// + /// The linestring to measure + /// The length of the Linestring + public double ComputeLength(ILineString line) + { + double length = 0; + for (int i = 1; i < line.Coordinates.Count; i++) + { + length += this.DimensionsCalculator.CalculateDistance(line.Coordinates[i - 1], line.Coordinates[i]); + } + + return length; + } + + /// + /// Compute length of all linestrings in specific multilinestring + /// + /// The MultiLineString to measure + /// The length of the Linestring + public double ComputeLength(IMultiLineString multilinestring) + { + double length = 0; + + foreach (var line in multilinestring.Geometries) + { + length += this.ComputeLength(line); + } + + return length; + } + + /// + /// Computes area of the Polygon + /// + /// Polygon to be measured + /// The area of the Polygon + public double ComputeArea(IPolygon polygon) + { + double area = this.DimensionsCalculator.CalculateArea(polygon.ExteriorRing); + + foreach (var interiorRing in polygon.InteriorRings) + { + area -= this.DimensionsCalculator.CalculateArea(interiorRing); + } + + return area; + } + + /// + /// Computes area of the MultiPolygon + /// + /// MultiPolygon to be measured + /// The area of the MultiPolygon + public double ComputeArea(IMultiPolygon multiPolygon) + { + double area = 0; + + foreach (var polygon in multiPolygon.Geometries) + { + area += this.ComputeArea(polygon); + } + + return area; + } + } } diff --git a/src/SpatialLite.Core/Properties/AssemblyInfo.cs b/src/SpatialLite.Core/Properties/AssemblyInfo.cs index 6a37585..c63ae8a 100644 --- a/src/SpatialLite.Core/Properties/AssemblyInfo.cs +++ b/src/SpatialLite.Core/Properties/AssemblyInfo.cs @@ -15,4 +15,4 @@ // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -[assembly: InternalsVisibleTo("Tests.SpatialLite.Core")] \ No newline at end of file +[assembly: InternalsVisibleTo("Tests.SpatialLite.Core")] diff --git a/src/SpatialLite.Core/Topology.cs b/src/SpatialLite.Core/Topology.cs index c69e0e1..30b89df 100644 --- a/src/SpatialLite.Core/Topology.cs +++ b/src/SpatialLite.Core/Topology.cs @@ -3,130 +3,153 @@ using SpatialLite.Core.Algorithms; using SpatialLite.Core.API; -namespace SpatialLite.Core { +namespace SpatialLite.Core +{ /// /// Provides methods for basic topology analysis of geometry objects and relationships among them. /// - public class Topology { - - private static Topology _euclidean2D; - - /// - /// Initializes static members of the Topology class. - /// - static Topology() { - _euclidean2D = new Topology(new Euclidean2DLocator()); - } - - /// - /// Gets Topology class instance that uses Euclidean2DLocator to determine relationships among geometries. - /// - public static Topology Euclidean2D { - get { - return _euclidean2D; - } - } - - /// - /// Initializes a new instance of the Topology class with specific geometry locator. - /// - /// The IGeometryLocator object to use. - public Topology(IGeometryLocator geometryLocator) { - if (geometryLocator == null) { - throw new ArgumentNullException("geometryLocator", "GeometryLocator can't be null"); - } - - this.GeometryLocator = geometryLocator; - } - - /// - /// Gets IGeometryLocator that this Topology class instance uses to determine relationships among geometries. - /// - public IGeometryLocator GeometryLocator { get; private set; } - - /// - /// Determines whether specific Coordinate is in the given polygon. - /// - /// The coordinate to chec.k - /// The polygon to check coordinate against. - /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. - /// true if coordinate lies inside outer polygon boundary and outside polygon's inner boundaries (holes), otherwise returns false. - public bool IsInside(Coordinate c, IPolygon polygon, bool includeBoundaries) { - bool insideExterior = this.GeometryLocator.IsInRing(c, polygon.ExteriorRing); - - if (insideExterior == false) { - if (includeBoundaries) { - return this.GeometryLocator.IsOnLine(c, polygon.ExteriorRing); - } - else { - return false; - } - } - else { - foreach (var ring in polygon.InteriorRings) { - if (this.GeometryLocator.IsInRing(c, ring)) { - return false; - } - else if (includeBoundaries && this.GeometryLocator.IsOnLine(c, ring)) { - return true; - } - } - } - - return true; - } - - /// - /// Determines whether specific Coordinate is in the given multipolygon. - /// - /// The coordinate to check. - /// The multipolygon to check coordinate against. - /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. - /// true if coordinate lies inside any polygon of the given multipolygon, otherwise false. - public bool IsInside(Coordinate c, IMultiPolygon multipolygon, bool includeBoundaries) { - foreach (var polygon in multipolygon.Geometries) { - if (this.IsInside(c, polygon, includeBoundaries)) { - return true; - } - } - - return false; - } - - /// - /// Determines whether specific Coordinate is on the given polyline. - /// - /// The coordinate to check. - /// The line to check coordinate against. - /// true if coordinate lies on the polyline, otherwise false. - public bool IsOnLine(Coordinate c, ILineString line) { - return this.GeometryLocator.IsOnLine(c, line.Coordinates); - } - - /// - /// Determines whether specific Coordinate in on the given multiline. - /// - /// The coordinate to check. - /// The multiline to check coordinate against. - /// true if coordinate lies on any line of the given multiline, otherwise false. - public bool IsOnLine(Coordinate c, IMultiLineString multiline) { - foreach (var line in multiline.Geometries) { - if (this.IsOnLine(c, line)) { - return true; - } - } - - return false; - } - - /// - /// Determines whether two polylines defined by series of coordinates intersects. - /// - /// The first polyline to test. - /// The second polyline to test. - /// true if polylines intersets, otherwise false. - public bool Intersects(ILineString line1, ILineString line2) { - return this.GeometryLocator.Intersects(line1.Coordinates, line2.Coordinates); - } - } + public class Topology + { + + private static Topology _euclidean2D; + + /// + /// Initializes static members of the Topology class. + /// + static Topology() + { + _euclidean2D = new Topology(new Euclidean2DLocator()); + } + + /// + /// Gets Topology class instance that uses Euclidean2DLocator to determine relationships among geometries. + /// + public static Topology Euclidean2D + { + get + { + return _euclidean2D; + } + } + + /// + /// Initializes a new instance of the Topology class with specific geometry locator. + /// + /// The IGeometryLocator object to use. + public Topology(IGeometryLocator geometryLocator) + { + if (geometryLocator == null) + { + throw new ArgumentNullException(nameof(geometryLocator), "GeometryLocator can't be null"); + } + + this.GeometryLocator = geometryLocator; + } + + /// + /// Gets IGeometryLocator that this Topology class instance uses to determine relationships among geometries. + /// + public IGeometryLocator GeometryLocator { get; private set; } + + /// + /// Determines whether specific Coordinate is in the given polygon. + /// + /// The coordinate to chec.k + /// The polygon to check coordinate against. + /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. + /// true if coordinate lies inside outer polygon boundary and outside polygon's inner boundaries (holes), otherwise returns false. + public bool IsInside(Coordinate c, IPolygon polygon, bool includeBoundaries) + { + bool insideExterior = this.GeometryLocator.IsInRing(c, polygon.ExteriorRing); + + if (insideExterior == false) + { + if (includeBoundaries) + { + return this.GeometryLocator.IsOnLine(c, polygon.ExteriorRing); + } + else + { + return false; + } + } + else + { + foreach (var ring in polygon.InteriorRings) + { + if (this.GeometryLocator.IsInRing(c, ring)) + { + return false; + } + else if (includeBoundaries && this.GeometryLocator.IsOnLine(c, ring)) + { + return true; + } + } + } + + return true; + } + + /// + /// Determines whether specific Coordinate is in the given multipolygon. + /// + /// The coordinate to check. + /// The multipolygon to check coordinate against. + /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. + /// true if coordinate lies inside any polygon of the given multipolygon, otherwise false. + public bool IsInside(Coordinate c, IMultiPolygon multipolygon, bool includeBoundaries) + { + foreach (var polygon in multipolygon.Geometries) + { + if (this.IsInside(c, polygon, includeBoundaries)) + { + return true; + } + } + + return false; + } + + /// + /// Determines whether specific Coordinate is on the given polyline. + /// + /// The coordinate to check. + /// The line to check coordinate against. + /// true if coordinate lies on the polyline, otherwise false. + public bool IsOnLine(Coordinate c, ILineString line) + { + return this.GeometryLocator.IsOnLine(c, line.Coordinates); + } + + /// + /// Determines whether specific Coordinate in on the given multiline. + /// + /// The coordinate to check. + /// The multiline to check coordinate against. + /// true if coordinate lies on any line of the given multiline, otherwise false. + public bool IsOnLine(Coordinate c, IMultiLineString multiline) + { + foreach (var line in multiline.Geometries) + { + if (this.IsOnLine(c, line)) + { + return true; + } + } + + return false; + } + + /// + /// Determines whether two polylines defined by series of coordinates intersects. + /// + /// The first polyline to test. + /// The second polyline to test. + /// true if polylines intersets, otherwise false. + public bool Intersects(ILineString line1, ILineString line2) + { + return this.GeometryLocator.Intersects(line1.Coordinates, line2.Coordinates); + } + } } diff --git a/src/SpatialLite.Gps/Geometries/GpsFix.cs b/src/SpatialLite.Gps/Geometries/GpsFix.cs index 7487bc9..ab0a184 100644 --- a/src/SpatialLite.Gps/Geometries/GpsFix.cs +++ b/src/SpatialLite.Gps/Geometries/GpsFix.cs @@ -1,31 +1,33 @@ -namespace SpatialLite.Gps.Geometries { - /// - /// Defines type of the GPS fix - /// - public enum GpsFix { - /// - /// No fix - /// - None, - - /// - /// Position only - /// - Fix2D, - - /// - /// Position and elevation - /// - Fix3D, - - /// - /// Differential GPS - /// - Dgps, - - /// - /// Military signal used - /// - Pps - } -} +namespace SpatialLite.Gps.Geometries +{ + /// + /// Defines type of the GPS fix + /// + public enum GpsFix + { + /// + /// No fix + /// + None, + + /// + /// Position only + /// + Fix2D, + + /// + /// Position and elevation + /// + Fix3D, + + /// + /// Differential GPS + /// + Dgps, + + /// + /// Military signal used + /// + Pps + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpsPoint.cs b/src/SpatialLite.Gps/Geometries/GpsPoint.cs index c5335fe..5dc2015 100644 --- a/src/SpatialLite.Gps/Geometries/GpsPoint.cs +++ b/src/SpatialLite.Gps/Geometries/GpsPoint.cs @@ -1,52 +1,58 @@ -using System; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace SpatialLite.Gps.Geometries { - /// - /// Represents location on the earth surface with timestamp that defines time when the point was recorded - /// - public class GpsPoint : Point, IGpsPoint { - - /// - /// Creates a new, empty instance of the GpsPoint - /// - public GpsPoint() { - } - - /// - /// Creates a new instance of the GpsPoint with given position - /// - /// The position of the point - public GpsPoint(Coordinate position) - : base(position) { - } - - /// - /// Creates a new instance of the GpsPoint with given coordinates and timestamp - /// - /// The longitude of the point - /// The latitude of the point - /// The elevation of the point - /// The time when the point was recorded - public GpsPoint(double longitude, double latitude, double elevation, DateTime time) - : base(longitude, latitude, elevation) { - Timestamp = time; - } - - /// - /// Creates a new instance of the GpsPoint with given position and time - /// - /// The position of the point - /// The time when the point was recorded - public GpsPoint(Coordinate position, DateTime time) - : base(position) { - Timestamp = time; - } - - /// - /// Gets or sets time when the point was recorded. - /// - public DateTime? Timestamp { get; set; } - } -} +using System; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Represents location on the earth surface with timestamp that defines time when the point was recorded + /// + public class GpsPoint : Point, IGpsPoint + { + + /// + /// Creates a new, empty instance of the GpsPoint + /// + public GpsPoint() + { + } + + /// + /// Creates a new instance of the GpsPoint with given position + /// + /// The position of the point + public GpsPoint(Coordinate position) + : base(position) + { + } + + /// + /// Creates a new instance of the GpsPoint with given coordinates and timestamp + /// + /// The longitude of the point + /// The latitude of the point + /// The elevation of the point + /// The time when the point was recorded + public GpsPoint(double longitude, double latitude, double elevation, DateTime time) + : base(longitude, latitude, elevation) + { + Timestamp = time; + } + + /// + /// Creates a new instance of the GpsPoint with given position and time + /// + /// The position of the point + /// The time when the point was recorded + public GpsPoint(Coordinate position, DateTime time) + : base(position) + { + Timestamp = time; + } + + /// + /// Gets or sets time when the point was recorded. + /// + public DateTime? Timestamp { get; set; } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs b/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs index c70f045..505c627 100644 --- a/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs +++ b/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs @@ -1,42 +1,48 @@ -using System.Collections.Generic; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace SpatialLite.Gps.Geometries { - /// - /// Represents base class for Gps tracks - /// - /// The type of the Gps points - public class GpsTrackBase : LineString where T : IGpsPoint { - private ICoordinateList _coordinatesAdapter; - - /// - /// Creates a new instance of the GpsTrackBase class - /// - public GpsTrackBase() : this(new T[] {}) { - } - - /// - /// Creates a new instance of GpsTrackBase with given points - /// - /// The points of the track - public GpsTrackBase(IEnumerable points) { - this.Points = new List(points); - _coordinatesAdapter = new ReadOnlyCoordinateList(this.Points); - } - - /// - /// Gets the collection of track points of this track - /// - public List Points { get; private set; } - - /// - /// Gets the list of çoordinates of this track. - /// - public override ICoordinateList Coordinates { - get { - return _coordinatesAdapter; - } - } - } -} +using System.Collections.Generic; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Represents base class for Gps tracks + /// + /// The type of the Gps points + public class GpsTrackBase : LineString where T : IGpsPoint + { + private ICoordinateList _coordinatesAdapter; + + /// + /// Creates a new instance of the GpsTrackBase class + /// + public GpsTrackBase() : this(new T[] { }) + { + } + + /// + /// Creates a new instance of GpsTrackBase with given points + /// + /// The points of the track + public GpsTrackBase(IEnumerable points) + { + this.Points = new List(points); + _coordinatesAdapter = new ReadOnlyCoordinateList(this.Points); + } + + /// + /// Gets the collection of track points of this track + /// + public List Points { get; private set; } + + /// + /// Gets the list of çoordinates of this track. + /// + public override ICoordinateList Coordinates + { + get + { + return _coordinatesAdapter; + } + } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs b/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs index 34b2ce8..6a18c74 100644 --- a/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs +++ b/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs @@ -1,40 +1,46 @@ -namespace SpatialLite.Gps.Geometries { - /// - /// Contains helper function for parsing / formating GpxFix enum - /// - public static class GpxFixHelper { - /// - /// Converts string representation of the GpsFix to it's GpxFix enum equivalent. - /// - /// A string containing a value to convert - /// A GpxFix enum equivalent of the s parameter or null if s can not be converted to GpsFix enum - /// ParseGpsFix should be used instead Enum.Parse function becouse string representation of the GpsFix values do not equal to their names. - public static GpsFix? ParseGpsFix(string s) { - switch (s) { - case "none": return GpsFix.None; - case "2d": return GpsFix.Fix2D; - case "3d": return GpsFix.Fix3D; - case "dgps": return GpsFix.Dgps; - case "pps": return GpsFix.Pps; - default: return null; - } - } - - /// - /// Converts GpsFix enum value to it's string equivalent - /// - /// A GpxFix value to convert - /// A string equivalent of the fix parameter - /// ConvertGpsFixToString shoul be used instead ToString() function becouse string representation of the GpsFix values if GPX schema do not equal to their names. - public static string GpsFixToString(GpsFix fix) { - switch (fix) { - case GpsFix.None: return "none"; - case GpsFix.Fix2D: return "2d"; - case GpsFix.Fix3D: return "3d"; - case GpsFix.Dgps: return "dgps"; - case GpsFix.Pps: return "pps"; - default: return null; - } - } - } -} +namespace SpatialLite.Gps.Geometries +{ + /// + /// Contains helper function for parsing / formating GpxFix enum + /// + public static class GpxFixHelper + { + /// + /// Converts string representation of the GpsFix to it's GpxFix enum equivalent. + /// + /// A string containing a value to convert + /// A GpxFix enum equivalent of the s parameter or null if s can not be converted to GpsFix enum + /// ParseGpsFix should be used instead Enum.Parse function becouse string representation of the GpsFix values do not equal to their names. + public static GpsFix? ParseGpsFix(string s) + { + switch (s) + { + case "none": return GpsFix.None; + case "2d": return GpsFix.Fix2D; + case "3d": return GpsFix.Fix3D; + case "dgps": return GpsFix.Dgps; + case "pps": return GpsFix.Pps; + default: return null; + } + } + + /// + /// Converts GpsFix enum value to it's string equivalent + /// + /// A GpxFix value to convert + /// A string equivalent of the fix parameter + /// ConvertGpsFixToString shoul be used instead ToString() function becouse string representation of the GpsFix values if GPX schema do not equal to their names. + public static string GpsFixToString(GpsFix fix) + { + switch (fix) + { + case GpsFix.None: return "none"; + case GpsFix.Fix2D: return "2d"; + case GpsFix.Fix3D: return "3d"; + case GpsFix.Dgps: return "dgps"; + case GpsFix.Pps: return "pps"; + default: return null; + } + } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxLink.cs b/src/SpatialLite.Gps/Geometries/GpxLink.cs index a4531f3..0e90bb8 100644 --- a/src/SpatialLite.Gps/Geometries/GpxLink.cs +++ b/src/SpatialLite.Gps/Geometries/GpxLink.cs @@ -1,32 +1,35 @@ -using System; - -namespace SpatialLite.Gps.Geometries { - /// - /// Represents a link to an external resource (Web page, digital photo, video clip, etc) with additional information. - /// - public class GpxLink { - - /// - /// Gets the URL of the link - /// - public Uri Url { get; set; } - - /// - /// Gets the text of the hyperlink - /// - public string Text { get; set; } - - /// - /// Gets the mime type of the linked content - /// - public string Type { get; set; } - - /// - /// Creates a new instance of the GpxLink with given url - /// - /// The url of the link - public GpxLink(Uri url) { - Url = url; - } - } -} +using System; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Represents a link to an external resource (Web page, digital photo, video clip, etc) with additional information. + /// + public class GpxLink + { + + /// + /// Gets the URL of the link + /// + public Uri Url { get; set; } + + /// + /// Gets the text of the hyperlink + /// + public string Text { get; set; } + + /// + /// Gets the mime type of the linked content + /// + public string Type { get; set; } + + /// + /// Creates a new instance of the GpxLink with given url + /// + /// The url of the link + public GpxLink(Uri url) + { + Url = url; + } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxMetadata.cs b/src/SpatialLite.Gps/Geometries/GpxMetadata.cs index 092f2e5..b44a335 100644 --- a/src/SpatialLite.Gps/Geometries/GpxMetadata.cs +++ b/src/SpatialLite.Gps/Geometries/GpxMetadata.cs @@ -1,40 +1,43 @@ -using System.Collections.Generic; - -namespace SpatialLite.Gps.Geometries { - /// - /// Contains additional information about Gpx entity - /// - public abstract class GpxMetadata { - /// - /// Gets or sets the name of the entity - /// - public string Name { get; set; } - - /// - /// Gets or sets the comment for the entity - /// - public string Comment { get; set; } - - /// - /// Gets or sets the description of the entity. Holds additional information about the element intended for the user, not the GPS. - /// - public string Description { get; set; } - - /// - /// Gets or sets the source of the data. Included to give user some idea of reliability and accuracy of data. - /// - public string Source { get; set; } - - /// - /// Get or sets the list of link associated with the entity - /// - public ICollection Links { get; set; } - - /// - /// Creates a new instance of the GpxMetadata class and initializes it's properties to default values. - /// - protected GpxMetadata() { - Links = new List(); - } - } -} +using System.Collections.Generic; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Contains additional information about Gpx entity + /// + public abstract class GpxMetadata + { + /// + /// Gets or sets the name of the entity + /// + public string Name { get; set; } + + /// + /// Gets or sets the comment for the entity + /// + public string Comment { get; set; } + + /// + /// Gets or sets the description of the entity. Holds additional information about the element intended for the user, not the GPS. + /// + public string Description { get; set; } + + /// + /// Gets or sets the source of the data. Included to give user some idea of reliability and accuracy of data. + /// + public string Source { get; set; } + + /// + /// Get or sets the list of link associated with the entity + /// + public ICollection Links { get; set; } + + /// + /// Creates a new instance of the GpxMetadata class and initializes it's properties to default values. + /// + protected GpxMetadata() + { + Links = new List(); + } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxPoint.cs b/src/SpatialLite.Gps/Geometries/GpxPoint.cs index b64fa3d..7111b2f 100644 --- a/src/SpatialLite.Gps/Geometries/GpxPoint.cs +++ b/src/SpatialLite.Gps/Geometries/GpxPoint.cs @@ -1,57 +1,64 @@ -using System; -using SpatialLite.Core.API; - -namespace SpatialLite.Gps.Geometries { - /// - /// Represents a Gpx point - /// - public class GpxPoint : GpsPoint, IGpxGeometry { - - /// - /// Creates a new, empty instance of the GpxPoint - /// - public GpxPoint() { - } - - /// - /// Creates a new instance of the GpxPoint with given position - /// - /// The position of the point - public GpxPoint(Coordinate position) - : base(position) { - } - - /// - /// Creates a new instance of the GpxPoint with given coordinates and timestamp - /// - /// The longitude of the point - /// The latitude of the point - /// The elevation of the point - /// The time when the point was recorded - public GpxPoint(double longitude, double latitude, double elevation, DateTime time) - : base(longitude, latitude, elevation, time) { - } - - /// - /// Creates a new instance of the GpxPoint with given position and time - /// - /// The position of the point - /// The time when the point was recorded - public GpxPoint(Coordinate position, DateTime time) - : base(position) { - Timestamp = time; - } - - /// - /// Gets or sets additional information about point - /// - public GpxPointMetadata Metadata { get; set; } - - /// - /// Get the type of geometry - /// - public GpxGeometryType GeometryType { - get { return GpxGeometryType.Waypoint; } - } - } -} +using System; +using SpatialLite.Core.API; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Represents a Gpx point + /// + public class GpxPoint : GpsPoint, IGpxGeometry + { + + /// + /// Creates a new, empty instance of the GpxPoint + /// + public GpxPoint() + { + } + + /// + /// Creates a new instance of the GpxPoint with given position + /// + /// The position of the point + public GpxPoint(Coordinate position) + : base(position) + { + } + + /// + /// Creates a new instance of the GpxPoint with given coordinates and timestamp + /// + /// The longitude of the point + /// The latitude of the point + /// The elevation of the point + /// The time when the point was recorded + public GpxPoint(double longitude, double latitude, double elevation, DateTime time) + : base(longitude, latitude, elevation, time) + { + } + + /// + /// Creates a new instance of the GpxPoint with given position and time + /// + /// The position of the point + /// The time when the point was recorded + public GpxPoint(Coordinate position, DateTime time) + : base(position) + { + Timestamp = time; + } + + /// + /// Gets or sets additional information about point + /// + public GpxPointMetadata Metadata { get; set; } + + /// + /// Get the type of geometry + /// + public GpxGeometryType GeometryType + { + get { return GpxGeometryType.Waypoint; } + } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs b/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs index 16d5e89..7570d7c 100644 --- a/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs +++ b/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs @@ -1,56 +1,58 @@ -namespace SpatialLite.Gps.Geometries { - /// - /// Contains additional information about Gpx point - /// - public class GpxPointMetadata : GpxMetadata { - /// - /// Gets or sets magnetic variation (in degrees) at the point - /// - public double? MagVar { get; set; } - - /// - /// Gets or sets height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message. - /// - public double? GeoidHeight { get; set; } - - /// - /// Gets or sets text of GPS symbol name. - /// - public string Symbol { get; set; } - - /// - /// Gets or sets type of the Gps fix. To signify "the fix info is unknown", set value to null. - /// - public GpsFix? Fix { get; set; } - - /// - /// Gets or sets number of satellites used to calculate the GPX fix. - /// - public int? SatellitesCount { get; set; } - - /// - /// Gets or sets horizontal dilution of precision. - /// - public double? Hdop { get; set; } - - /// - /// Gets or sets vertical dilution of precision. - /// - public double? Vdop { get; set; } - - /// - /// Gets or sets position dilution of precision. - /// - public double? Pdop { get; set; } - - /// - /// Gets or sets age of DGPS data - a number of seconds since last DGPS update. - /// - public double? AgeOfDgpsData { get; set; } - - /// - /// Gets or sets ID of DGPS station used in differential correction. - /// - public int? DgpsId { get; set; } - } -} +namespace SpatialLite.Gps.Geometries +{ + /// + /// Contains additional information about Gpx point + /// + public class GpxPointMetadata : GpxMetadata + { + /// + /// Gets or sets magnetic variation (in degrees) at the point + /// + public double? MagVar { get; set; } + + /// + /// Gets or sets height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message. + /// + public double? GeoidHeight { get; set; } + + /// + /// Gets or sets text of GPS symbol name. + /// + public string Symbol { get; set; } + + /// + /// Gets or sets type of the Gps fix. To signify "the fix info is unknown", set value to null. + /// + public GpsFix? Fix { get; set; } + + /// + /// Gets or sets number of satellites used to calculate the GPX fix. + /// + public int? SatellitesCount { get; set; } + + /// + /// Gets or sets horizontal dilution of precision. + /// + public double? Hdop { get; set; } + + /// + /// Gets or sets vertical dilution of precision. + /// + public double? Vdop { get; set; } + + /// + /// Gets or sets position dilution of precision. + /// + public double? Pdop { get; set; } + + /// + /// Gets or sets age of DGPS data - a number of seconds since last DGPS update. + /// + public double? AgeOfDgpsData { get; set; } + + /// + /// Gets or sets ID of DGPS station used in differential correction. + /// + public int? DgpsId { get; set; } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxRoute.cs b/src/SpatialLite.Gps/Geometries/GpxRoute.cs index 97efa18..6c70e9e 100644 --- a/src/SpatialLite.Gps/Geometries/GpxRoute.cs +++ b/src/SpatialLite.Gps/Geometries/GpxRoute.cs @@ -1,35 +1,40 @@ -using System.Collections.Generic; - -namespace SpatialLite.Gps.Geometries { - /// - /// Represents route - an ordered list of waypoints representing a series of turn points leading to a destination. - /// - public class GpxRoute : GpxTrackSegment, IGpxGeometry { - /// - /// Get or sets additional info about the route - /// - public GpxTrackMetadata Metadata { get; set; } - - /// - /// Get the type of geometry - /// - public GpxGeometryType GeometryType { - get { return GpxGeometryType.Route; } - } - - /// - /// Creates a new, empty instance of the GpxRoute class - /// - public GpxRoute() - : base() { - } - - /// - /// Creates a new instance of the GpxRoute class with given points - /// - /// The points to be added to the route - public GpxRoute(IEnumerable points) - : base(points) { - } - } -} +using System.Collections.Generic; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Represents route - an ordered list of waypoints representing a series of turn points leading to a destination. + /// + public class GpxRoute : GpxTrackSegment, IGpxGeometry + { + /// + /// Get or sets additional info about the route + /// + public GpxTrackMetadata Metadata { get; set; } + + /// + /// Get the type of geometry + /// + public GpxGeometryType GeometryType + { + get { return GpxGeometryType.Route; } + } + + /// + /// Creates a new, empty instance of the GpxRoute class + /// + public GpxRoute() + : base() + { + } + + /// + /// Creates a new instance of the GpxRoute class with given points + /// + /// The points to be added to the route + public GpxRoute(IEnumerable points) + : base(points) + { + } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxTrack.cs b/src/SpatialLite.Gps/Geometries/GpxTrack.cs index 651f363..5b92815 100644 --- a/src/SpatialLite.Gps/Geometries/GpxTrack.cs +++ b/src/SpatialLite.Gps/Geometries/GpxTrack.cs @@ -1,37 +1,42 @@ -using System.Collections.Generic; -using SpatialLite.Core.Geometries; - -namespace SpatialLite.Gps.Geometries { - /// - /// Represents a track - an ordered list of points describing a path. Points can be gouped in more GpxTrackSegments. - /// - public class GpxTrack : GeometryCollection, IGpxGeometry { - - /// - /// Creates a new, empty instance of the GpxTrack class instance. - /// - public GpxTrack() - : base() { - } - - /// - /// Creates a new instance of the GpxTrack with given segments - /// - /// The segments to add into track - public GpxTrack(IEnumerable segments) - : base(segments) { - } - - /// - /// Get or sets additional info about GPX entity - /// - public GpxTrackMetadata Metadata { get; set; } - - /// - /// Get the type of geometry - /// - public GpxGeometryType GeometryType { - get { return GpxGeometryType.Track; } - } - } -} +using System.Collections.Generic; +using SpatialLite.Core.Geometries; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Represents a track - an ordered list of points describing a path. Points can be gouped in more GpxTrackSegments. + /// + public class GpxTrack : GeometryCollection, IGpxGeometry + { + + /// + /// Creates a new, empty instance of the GpxTrack class instance. + /// + public GpxTrack() + : base() + { + } + + /// + /// Creates a new instance of the GpxTrack with given segments + /// + /// The segments to add into track + public GpxTrack(IEnumerable segments) + : base(segments) + { + } + + /// + /// Get or sets additional info about GPX entity + /// + public GpxTrackMetadata Metadata { get; set; } + + /// + /// Get the type of geometry + /// + public GpxGeometryType GeometryType + { + get { return GpxGeometryType.Track; } + } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs b/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs index e87cc29..fd90c8d 100644 --- a/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs +++ b/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs @@ -1,11 +1,13 @@ -namespace SpatialLite.Gps.Geometries { - /// - /// Contains additional information about Gpx tracks and routes - /// - public class GpxTrackMetadata : GpxMetadata { - /// - /// Gets or sets yype (classification) of route. - /// - public string Type { get; set; } - } -} +namespace SpatialLite.Gps.Geometries +{ + /// + /// Contains additional information about Gpx tracks and routes + /// + public class GpxTrackMetadata : GpxMetadata + { + /// + /// Gets or sets yype (classification) of route. + /// + public string Type { get; set; } + } +} diff --git a/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs b/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs index ab0554b..0c637fd 100644 --- a/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs +++ b/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs @@ -1,26 +1,30 @@ -using System.Collections.Generic; - -namespace SpatialLite.Gps.Geometries { - /// - /// Holds a list of track points which are logically connected in order. - /// - /// - /// To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data. - /// - public class GpxTrackSegment : GpsTrackBase { - /// - /// Creates a new instance of the empty GpxTrackSegment - /// - public GpxTrackSegment() { - } - - /// - /// Creates a new instance of GpxTrackSegment with given points - /// - /// The points of the track segment - public GpxTrackSegment(IEnumerable points) - : base(points) { - } - } - -} +using System.Collections.Generic; + +namespace SpatialLite.Gps.Geometries +{ + /// + /// Holds a list of track points which are logically connected in order. + /// + /// + /// To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data. + /// + public class GpxTrackSegment : GpsTrackBase + { + /// + /// Creates a new instance of the empty GpxTrackSegment + /// + public GpxTrackSegment() + { + } + + /// + /// Creates a new instance of GpxTrackSegment with given points + /// + /// The points of the track segment + public GpxTrackSegment(IEnumerable points) + : base(points) + { + } + } + +} diff --git a/src/SpatialLite.Gps/GpxDocument.cs b/src/SpatialLite.Gps/GpxDocument.cs index 9e2962a..f6b60e1 100644 --- a/src/SpatialLite.Gps/GpxDocument.cs +++ b/src/SpatialLite.Gps/GpxDocument.cs @@ -1,124 +1,142 @@ -using System; -using System.Collections.Generic; -using SpatialLite.Gps.Geometries; -using SpatialLite.Gps.IO; - -namespace SpatialLite.Gps { - /// - /// Represents an in-memory GPX document with it's waypoints, routes and tracks - /// - public class GpxDocument { - /// - /// Initializes a new instance of the GpxDocument class that is empty - /// - public GpxDocument() { - this.Waypoints = new List(); - this.Routes = new List(); - this.Tracks = new List(); - } - - /// - /// Initializes a new instance of the GpxDocument class with given GPX entities - /// - /// A collection of waypoints to add to the document. - /// A collection of routes to add to the document. - /// A collection of tracks to add to the document. - public GpxDocument(IEnumerable waypoints, IEnumerable routes, IEnumerable tracks) { - this.Waypoints = new List(waypoints); - this.Routes = new List(routes); - this.Tracks = new List(tracks); - } - - /// - /// Gets collection of waypoints from the document. - /// - public List Waypoints { get; private set; } - - /// - /// Gets collection of routes from the document. - /// - public List Routes { get;private set; } - - /// - /// Gets collection of tracks from the document. - /// - public List Tracks { get; private set; } - - /// - /// Saves content of the GpxDocument to file. - /// - /// Path to the file. - public void Save(string path) { - using (GpxWriter writer = new GpxWriter(path, new GpxWriterSettings() {WriteMetadata = true})) { - this.Save(writer); - } - } - - /// - /// Saves content of the GpxDocument using suplied writer. - /// - /// GpxWriter to be used - public void Save(IGpxWriter writer) { - if (writer == null) { - throw new ArgumentNullException("writer"); - } - - foreach (var waypoint in this.Waypoints) { - writer.Write(waypoint); - } - - foreach (var route in this.Routes) { - writer.Write(route); - } - - foreach (var track in this.Tracks) { - writer.Write(track); - } - } - - /// - /// Loads Gpx data from reader to this instance of the GpxDocument class - /// - /// The reader to read data from - private void LoadFromReader(IGpxReader reader) { - IGpxGeometry geometry = null; - while ((geometry = reader.Read()) != null) { - switch (geometry.GeometryType) { - case GpxGeometryType.Waypoint: this.Waypoints.Add((GpxPoint)geometry); break; - case GpxGeometryType.Route: this.Routes.Add((GpxRoute)geometry); break; - case GpxGeometryType.Track: this.Tracks.Add((GpxTrack)geometry); break; - } - } - } - - /// - /// Loads Gpx data from a file. - /// - /// Path to the GPX file. - /// GpxDocument instance with data from GPX file - public static GpxDocument Load(string path) { - GpxDocument result = new GpxDocument(); - - using (GpxReader reader = new GpxReader(path, new GpxReaderSettings() { ReadMetadata = true })) { - result.LoadFromReader(reader); - } - - return result; - } - - /// - /// Loads Gpx data from IGpxReader - /// - /// The reader to read data from - /// GpxDocument instance with data from GpxReader - public static GpxDocument Load(IGpxReader reader) { - if (reader == null) { - throw new ArgumentNullException("reader"); - } - - GpxDocument result = new GpxDocument(); - result.LoadFromReader(reader); - return result; - } - } -} +using System; +using System.Collections.Generic; +using SpatialLite.Gps.Geometries; +using SpatialLite.Gps.IO; + +namespace SpatialLite.Gps +{ + /// + /// Represents an in-memory GPX document with it's waypoints, routes and tracks + /// + public class GpxDocument + { + /// + /// Initializes a new instance of the GpxDocument class that is empty + /// + public GpxDocument() + { + this.Waypoints = new List(); + this.Routes = new List(); + this.Tracks = new List(); + } + + /// + /// Initializes a new instance of the GpxDocument class with given GPX entities + /// + /// A collection of waypoints to add to the document. + /// A collection of routes to add to the document. + /// A collection of tracks to add to the document. + public GpxDocument(IEnumerable waypoints, IEnumerable routes, IEnumerable tracks) + { + this.Waypoints = new List(waypoints); + this.Routes = new List(routes); + this.Tracks = new List(tracks); + } + + /// + /// Gets collection of waypoints from the document. + /// + public List Waypoints { get; private set; } + + /// + /// Gets collection of routes from the document. + /// + public List Routes { get; private set; } + + /// + /// Gets collection of tracks from the document. + /// + public List Tracks { get; private set; } + + /// + /// Saves content of the GpxDocument to file. + /// + /// Path to the file. + public void Save(string path) + { + using (GpxWriter writer = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = true })) + { + this.Save(writer); + } + } + + /// + /// Saves content of the GpxDocument using suplied writer. + /// + /// GpxWriter to be used + public void Save(IGpxWriter writer) + { + if (writer == null) + { + throw new ArgumentNullException(nameof(writer)); + } + + foreach (var waypoint in this.Waypoints) + { + writer.Write(waypoint); + } + + foreach (var route in this.Routes) + { + writer.Write(route); + } + + foreach (var track in this.Tracks) + { + writer.Write(track); + } + } + + /// + /// Loads Gpx data from reader to this instance of the GpxDocument class + /// + /// The reader to read data from + private void LoadFromReader(IGpxReader reader) + { + IGpxGeometry geometry = null; + while ((geometry = reader.Read()) != null) + { + switch (geometry.GeometryType) + { + case GpxGeometryType.Waypoint: this.Waypoints.Add((GpxPoint)geometry); break; + case GpxGeometryType.Route: this.Routes.Add((GpxRoute)geometry); break; + case GpxGeometryType.Track: this.Tracks.Add((GpxTrack)geometry); break; + } + } + } + + /// + /// Loads Gpx data from a file. + /// + /// Path to the GPX file. + /// GpxDocument instance with data from GPX file + public static GpxDocument Load(string path) + { + GpxDocument result = new GpxDocument(); + + using (GpxReader reader = new GpxReader(path, new GpxReaderSettings() { ReadMetadata = true })) + { + result.LoadFromReader(reader); + } + + return result; + } + + /// + /// Loads Gpx data from IGpxReader + /// + /// The reader to read data from + /// GpxDocument instance with data from GpxReader + public static GpxDocument Load(IGpxReader reader) + { + if (reader == null) + { + throw new ArgumentNullException(nameof(reader)); + } + + GpxDocument result = new GpxDocument(); + result.LoadFromReader(reader); + return result; + } + } +} diff --git a/src/SpatialLite.Gps/GpxGeometryType.cs b/src/SpatialLite.Gps/GpxGeometryType.cs index 0378088..d2d36ec 100644 --- a/src/SpatialLite.Gps/GpxGeometryType.cs +++ b/src/SpatialLite.Gps/GpxGeometryType.cs @@ -1,21 +1,23 @@ -namespace SpatialLite.Gps { - /// - /// Defines possible types of GpxGeometry - /// - public enum GpxGeometryType { - /// - /// Waypoint - /// - Waypoint, - - /// - /// Route - /// - Route, - - /// - /// Recorder track - /// - Track - } -} +namespace SpatialLite.Gps +{ + /// + /// Defines possible types of GpxGeometry + /// + public enum GpxGeometryType + { + /// + /// Waypoint + /// + Waypoint, + + /// + /// Route + /// + Route, + + /// + /// Recorder track + /// + Track + } +} diff --git a/src/SpatialLite.Gps/IGpsPoint.cs b/src/SpatialLite.Gps/IGpsPoint.cs index f02bc99..becc437 100644 --- a/src/SpatialLite.Gps/IGpsPoint.cs +++ b/src/SpatialLite.Gps/IGpsPoint.cs @@ -1,14 +1,16 @@ -using System; -using SpatialLite.Core.API; - -namespace SpatialLite.Gps { - /// - /// Represents location on the earth surface with timestamp that defines time when the point was recorded - /// - public interface IGpsPoint : IPoint { - /// - /// Gets or sets time when the point was recorded. - /// - DateTime? Timestamp { get; set; } - } -} +using System; +using SpatialLite.Core.API; + +namespace SpatialLite.Gps +{ + /// + /// Represents location on the earth surface with timestamp that defines time when the point was recorded + /// + public interface IGpsPoint : IPoint + { + /// + /// Gets or sets time when the point was recorded. + /// + DateTime? Timestamp { get; set; } + } +} diff --git a/src/SpatialLite.Gps/IGpxGeometry.cs b/src/SpatialLite.Gps/IGpxGeometry.cs index a5c8e92..3294c47 100644 --- a/src/SpatialLite.Gps/IGpxGeometry.cs +++ b/src/SpatialLite.Gps/IGpxGeometry.cs @@ -1,13 +1,15 @@ -using SpatialLite.Core.API; - -namespace SpatialLite.Gps { - /// - /// Defines common properties for all GpxGeometry types - /// - public interface IGpxGeometry : IGeometry { - /// - /// Get the type of geometry - /// - GpxGeometryType GeometryType { get; } - } -} \ No newline at end of file +using SpatialLite.Core.API; + +namespace SpatialLite.Gps +{ + /// + /// Defines common properties for all GpxGeometry types + /// + public interface IGpxGeometry : IGeometry + { + /// + /// Get the type of geometry + /// + GpxGeometryType GeometryType { get; } + } +} diff --git a/src/SpatialLite.Gps/IO/GpxReader.cs b/src/SpatialLite.Gps/IO/GpxReader.cs index 0837072..31c44c3 100644 --- a/src/SpatialLite.Gps/IO/GpxReader.cs +++ b/src/SpatialLite.Gps/IO/GpxReader.cs @@ -1,397 +1,451 @@ -using System; -using System.IO; -using System.Xml; -using SpatialLite.Gps.Geometries; - -namespace SpatialLite.Gps.IO { - /// - /// Implements data reader that can read GPX data from streams and files. - /// - public class GpxReader : IGpxReader, IDisposable { - - private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; - - private bool _disposed = false; - private XmlReader _xmlReader; - - /// - /// Underlaying stream to read data from - /// - private Stream _input; - private bool _ownsInputStream = false; - - private bool _insideGpx = false; - - /// - /// Initializes a new instance of the GpxReader class that reads data from the specified file. - /// - /// Path to the .gpx file. - /// The GpxReaderSettings object that determines behaviour of the reader. - public GpxReader(string path, GpxReaderSettings settings) { - _input = new FileStream(path, FileMode.Open, FileAccess.Read); - _ownsInputStream = true; - - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); - } - - /// - /// Initializes a new instance of the GpxReader class that reads data from the specified stream. - /// - /// The stream with osm xml data. - /// The GpxReaderSettings object that determines behaviour of the reader. - public GpxReader(Stream stream, GpxReaderSettings settings) { - _input = stream; - - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); - } - - /// - /// Gets GpxReaderSettings object that determines behaviour of the reader. - /// - public GpxReaderSettings Settings { get; private set; } - - /// - /// Releases all resources used by the GpxReader. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Parses next element of the GPX file - /// - public IGpxGeometry Read() { - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "gpx") == false) { - switch (_xmlReader.Name) { - case "wpt": - return ReadPoint("wpt"); - case "trk": - return ReadTrack(); - case "rte": - return ReadRoute(); - default: - _xmlReader.Read(); - break; - } - } - - return null; - } - - /// - /// Reads a GPX point from the internal XmlReader - /// - /// The name of the surrounding xml element - /// the point parsed from the XmlReader - private GpxPoint ReadPoint(string pointElementName) { - string latValue = _xmlReader.GetAttribute("lat"); - if (string.IsNullOrEmpty(latValue)) - throw new InvalidDataException("Requested attribute 'lat' not found."); - double lat = double.Parse(latValue, _invariantCulture); - - string lonValue = _xmlReader.GetAttribute("lon"); - if (string.IsNullOrEmpty(lonValue)) - throw new InvalidDataException("Requested attribute 'lon' not found."); - double lon = double.Parse(lonValue, _invariantCulture); - - double ele = double.NaN; - DateTime timestamp = new DateTime(); - - GpxPointMetadata metadata = null; - if (this.Settings.ReadMetadata) { - metadata = new GpxPointMetadata(); - } - - if (_xmlReader.IsEmptyElement == false) { - _xmlReader.Read(); - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == pointElementName) == false) { - bool elementParsed = false; - - if (_xmlReader.Name == "ele") { - string eleValue = _xmlReader.ReadElementContentAsString(); - ele = double.Parse(eleValue, _invariantCulture); - elementParsed = true; - } - - if (_xmlReader.Name == "time") { - string timeValue = _xmlReader.ReadElementContentAsString(); - timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture); - elementParsed = true; - } - - if (this.Settings.ReadMetadata) { - elementParsed = elementParsed || this.TryReadPointMetadata(metadata); - } - - if (!elementParsed) { - _xmlReader.Skip(); - } - } - } - _xmlReader.Skip(); - - GpxPoint result = new GpxPoint(lon, lat, ele, timestamp); - result.Metadata = metadata; - - return result; - } - - /// - /// Reades a GPX track from the internal XmlReader - /// - /// the track parsed form the XmlReader - private GpxTrack ReadTrack() { - GpxTrack result = new GpxTrack(); - - if (_xmlReader.IsEmptyElement == false) { - _xmlReader.Read(); - - GpxTrackMetadata metadata = null; - if (this.Settings.ReadMetadata) { - metadata = new GpxTrackMetadata(); - } - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trk") == false) { - bool elementParsed = false; - if (_xmlReader.Name == "trkseg") { - GpxTrackSegment segment = ReadTrackSegment(); - result.Geometries.Add(segment); - elementParsed = true; - } - - if (this.Settings.ReadMetadata) { - elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); - } - - if (!elementParsed) { - _xmlReader.Skip(); - } - } - - result.Metadata = metadata; - } - _xmlReader.Skip(); - - return result; - } - - /// - /// Reads a GPX traxk segment from the intrnal XmlReader. - /// - /// the track parsed from the XmlReader - private GpxTrackSegment ReadTrackSegment() { - GpxTrackSegment result = new GpxTrackSegment(); - - if (_xmlReader.IsEmptyElement == false) { - _xmlReader.Read(); - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trkseg") == false) { - if (_xmlReader.Name == "trkpt") { - GpxPoint point = ReadPoint("trkpt"); - result.Points.Add(point); - } else { - _xmlReader.Skip(); - } - } - } - _xmlReader.Skip(); - - return result; - } - - /// - /// Reads a GPX route from the internal XmlReader - /// - /// the route parsed from the XmlReader - private GpxRoute ReadRoute() { - GpxRoute result = new GpxRoute(); - - if (_xmlReader.IsEmptyElement == false) { - _xmlReader.Read(); - - GpxTrackMetadata metadata = null; - if (this.Settings.ReadMetadata) { - metadata = new GpxTrackMetadata(); - } - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "rte") == false) { - bool elementParsed = false; - - if (_xmlReader.Name == "rtept") { - result.Points.Add(ReadPoint("rtept")); - elementParsed = true; - } - - if (this.Settings.ReadMetadata) { - elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); - } - - if (!elementParsed) { - _xmlReader.Skip(); - } - } - - result.Metadata = metadata; - } - _xmlReader.Skip(); - - return result; - } - - /// - /// Initializes internal properties - /// - private void InitializeReader() { - XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); - xmlReaderSettings.IgnoreComments = true; - xmlReaderSettings.IgnoreProcessingInstructions = true; - xmlReaderSettings.IgnoreWhitespace = true; - - _xmlReader = XmlReader.Create(_input, xmlReaderSettings); - - _xmlReader.Read(); - while (_xmlReader.EOF == false && _insideGpx == false) { - if (_xmlReader.NodeType == XmlNodeType.Element) { - if (_xmlReader.Name != "gpx") { - throw new InvalidDataException("Invalid gpx root element. Expected ."); - } - - string version = _xmlReader.GetAttribute("version"); - if (version == null || (version != "1.0" && version != "1.1")) - throw new InvalidDataException(String.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); - - _insideGpx = true; - - } else { - _xmlReader.Read(); - } - } - } - - /// - /// Reads a GPX Link from the internal XmlReader - /// - /// the link parsed from the XmlReader - private GpxLink ReadLink() { - string href = _xmlReader.GetAttribute("href"); - string linkText = null; - string linkType = null; - - if (_xmlReader.IsEmptyElement == false) { - _xmlReader.Read(); - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "link") == false) { - switch (_xmlReader.Name) { - case "text": - linkText = _xmlReader.ReadElementContentAsString(); break; - case "type": - linkType = _xmlReader.ReadElementContentAsString(); break; - default: - _xmlReader.Read(); - break; - } - } - } - _xmlReader.Skip(); - - return new GpxLink(new Uri(href)) { Text = linkText, Type = linkType }; - } - - /// - /// Reads track/route metadata from the internal XmlReader. - /// - /// Objecto to store read metadata - /// true if piece of metadata was read, otherwise returns false - private bool TryReadTrackMetadata(GpxTrackMetadata metadata) { - switch (_xmlReader.Name) { - case "name": - metadata.Name = _xmlReader.ReadElementContentAsString(); return true; - case "cmt": - metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; - case "desc": - metadata.Description = _xmlReader.ReadElementContentAsString(); return true; - case "src": - metadata.Source = _xmlReader.ReadElementContentAsString(); return true; - case "type": - metadata.Type = _xmlReader.ReadElementContentAsString(); return true; - case "link": - metadata.Links.Add(ReadLink()); return true; - } - - return false; - } - - /// - /// Reads waypoint metadata from the internal XmlReader. - /// - /// Objecto to store read metadata - /// true if piece of metadata was read, otherwise returns false - private bool TryReadPointMetadata(GpxPointMetadata metadata) { - switch (_xmlReader.Name) { - case "name": - metadata.Name = _xmlReader.ReadElementContentAsString(); return true; - case "cmt": - metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; - case "desc": - metadata.Description = _xmlReader.ReadElementContentAsString(); return true; - case "src": - metadata.Source = _xmlReader.ReadElementContentAsString(); return true; - case "link": - metadata.Links.Add(ReadLink()); return true; - case "magvar": - string magvarValue = _xmlReader.ReadElementContentAsString(); - metadata.MagVar = double.Parse(magvarValue, _invariantCulture); return true; - case "geoidheight": - string geoidHeightValue = _xmlReader.ReadElementContentAsString(); - metadata.GeoidHeight = double.Parse(geoidHeightValue, _invariantCulture); return true; - case "hdop": - string HdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Hdop = double.Parse(HdopValue, _invariantCulture); return true; - case "vdop": - string vdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Vdop = double.Parse(vdopValue, _invariantCulture); return true; - case "pdop": - string pdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Pdop = double.Parse(pdopValue, _invariantCulture); return true; - case "ageofdgpsdata": - string ageValue = _xmlReader.ReadElementContentAsString(); - metadata.AgeOfDgpsData = double.Parse(ageValue, _invariantCulture); return true; - case "sat": - string satValue = _xmlReader.ReadElementContentAsString(); - metadata.SatellitesCount = int.Parse(satValue, _invariantCulture); return true; - case "dgpsid": - string dgpsidValue = _xmlReader.ReadElementContentAsString(); - metadata.DgpsId = int.Parse(dgpsidValue, _invariantCulture); return true; - case "fix": - string fixValue = _xmlReader.ReadElementContentAsString(); - metadata.Fix = GpxFixHelper.ParseGpsFix(fixValue); return true; - } - - return false; - } - - /// - /// Releases the unmanaged resources used by the GpxReader and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!this._disposed) { - if (disposing) { - _xmlReader.Dispose(); - - if (_ownsInputStream) { - _input.Dispose(); - } - } - - _disposed = true; - } - } - } -} +using System; +using System.IO; +using System.Xml; +using SpatialLite.Gps.Geometries; + +namespace SpatialLite.Gps.IO +{ + /// + /// Implements data reader that can read GPX data from streams and files. + /// + public class GpxReader : IGpxReader, IDisposable + { + + private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + + private bool _disposed = false; + private XmlReader _xmlReader; + + /// + /// Underlaying stream to read data from + /// + private Stream _input; + private bool _ownsInputStream = false; + + private bool _insideGpx = false; + + /// + /// Initializes a new instance of the GpxReader class that reads data from the specified file. + /// + /// Path to the .gpx file. + /// The GpxReaderSettings object that determines behaviour of the reader. + public GpxReader(string path, GpxReaderSettings settings) + { + _input = new FileStream(path, FileMode.Open, FileAccess.Read); + _ownsInputStream = true; + + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } + + /// + /// Initializes a new instance of the GpxReader class that reads data from the specified stream. + /// + /// The stream with osm xml data. + /// The GpxReaderSettings object that determines behaviour of the reader. + public GpxReader(Stream stream, GpxReaderSettings settings) + { + _input = stream; + + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } + + /// + /// Gets GpxReaderSettings object that determines behaviour of the reader. + /// + public GpxReaderSettings Settings { get; private set; } + + /// + /// Releases all resources used by the GpxReader. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Parses next element of the GPX file + /// + public IGpxGeometry Read() + { + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "gpx") == false) + { + switch (_xmlReader.Name) + { + case "wpt": + return ReadPoint("wpt"); + case "trk": + return ReadTrack(); + case "rte": + return ReadRoute(); + default: + _xmlReader.Read(); + break; + } + } + + return null; + } + + /// + /// Reads a GPX point from the internal XmlReader + /// + /// The name of the surrounding xml element + /// the point parsed from the XmlReader + private GpxPoint ReadPoint(string pointElementName) + { + string latValue = _xmlReader.GetAttribute("lat"); + if (string.IsNullOrEmpty(latValue)) + throw new InvalidDataException("Requested attribute 'lat' not found."); + double lat = double.Parse(latValue, _invariantCulture); + + string lonValue = _xmlReader.GetAttribute("lon"); + if (string.IsNullOrEmpty(lonValue)) + throw new InvalidDataException("Requested attribute 'lon' not found."); + double lon = double.Parse(lonValue, _invariantCulture); + + double ele = double.NaN; + DateTime timestamp = new DateTime(); + + GpxPointMetadata metadata = null; + if (this.Settings.ReadMetadata) + { + metadata = new GpxPointMetadata(); + } + + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); + + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == pointElementName) == false) + { + bool elementParsed = false; + + if (_xmlReader.Name == "ele") + { + string eleValue = _xmlReader.ReadElementContentAsString(); + ele = double.Parse(eleValue, _invariantCulture); + elementParsed = true; + } + + if (_xmlReader.Name == "time") + { + string timeValue = _xmlReader.ReadElementContentAsString(); + timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture); + elementParsed = true; + } + + if (this.Settings.ReadMetadata) + { + elementParsed = elementParsed || this.TryReadPointMetadata(metadata); + } + + if (!elementParsed) + { + _xmlReader.Skip(); + } + } + } + _xmlReader.Skip(); + + GpxPoint result = new GpxPoint(lon, lat, ele, timestamp); + result.Metadata = metadata; + + return result; + } + + /// + /// Reades a GPX track from the internal XmlReader + /// + /// the track parsed form the XmlReader + private GpxTrack ReadTrack() + { + GpxTrack result = new GpxTrack(); + + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); + + GpxTrackMetadata metadata = null; + if (this.Settings.ReadMetadata) + { + metadata = new GpxTrackMetadata(); + } + + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trk") == false) + { + bool elementParsed = false; + if (_xmlReader.Name == "trkseg") + { + GpxTrackSegment segment = ReadTrackSegment(); + result.Geometries.Add(segment); + elementParsed = true; + } + + if (this.Settings.ReadMetadata) + { + elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); + } + + if (!elementParsed) + { + _xmlReader.Skip(); + } + } + + result.Metadata = metadata; + } + _xmlReader.Skip(); + + return result; + } + + /// + /// Reads a GPX traxk segment from the intrnal XmlReader. + /// + /// the track parsed from the XmlReader + private GpxTrackSegment ReadTrackSegment() + { + GpxTrackSegment result = new GpxTrackSegment(); + + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); + + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trkseg") == false) + { + if (_xmlReader.Name == "trkpt") + { + GpxPoint point = ReadPoint("trkpt"); + result.Points.Add(point); + } + else + { + _xmlReader.Skip(); + } + } + } + _xmlReader.Skip(); + + return result; + } + + /// + /// Reads a GPX route from the internal XmlReader + /// + /// the route parsed from the XmlReader + private GpxRoute ReadRoute() + { + GpxRoute result = new GpxRoute(); + + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); + + GpxTrackMetadata metadata = null; + if (this.Settings.ReadMetadata) + { + metadata = new GpxTrackMetadata(); + } + + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "rte") == false) + { + bool elementParsed = false; + + if (_xmlReader.Name == "rtept") + { + result.Points.Add(ReadPoint("rtept")); + elementParsed = true; + } + + if (this.Settings.ReadMetadata) + { + elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); + } + + if (!elementParsed) + { + _xmlReader.Skip(); + } + } + + result.Metadata = metadata; + } + _xmlReader.Skip(); + + return result; + } + + /// + /// Initializes internal properties + /// + private void InitializeReader() + { + XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); + xmlReaderSettings.IgnoreComments = true; + xmlReaderSettings.IgnoreProcessingInstructions = true; + xmlReaderSettings.IgnoreWhitespace = true; + + _xmlReader = XmlReader.Create(_input, xmlReaderSettings); + + _xmlReader.Read(); + while (_xmlReader.EOF == false && _insideGpx == false) + { + if (_xmlReader.NodeType == XmlNodeType.Element) + { + if (_xmlReader.Name != "gpx") + { + throw new InvalidDataException("Invalid gpx root element. Expected ."); + } + + string version = _xmlReader.GetAttribute("version"); + if (version == null || (version != "1.0" && version != "1.1")) + throw new InvalidDataException(String.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); + + _insideGpx = true; + + } + else + { + _xmlReader.Read(); + } + } + } + + /// + /// Reads a GPX Link from the internal XmlReader + /// + /// the link parsed from the XmlReader + private GpxLink ReadLink() + { + string href = _xmlReader.GetAttribute("href"); + string linkText = null; + string linkType = null; + + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); + + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "link") == false) + { + switch (_xmlReader.Name) + { + case "text": + linkText = _xmlReader.ReadElementContentAsString(); break; + case "type": + linkType = _xmlReader.ReadElementContentAsString(); break; + default: + _xmlReader.Read(); + break; + } + } + } + _xmlReader.Skip(); + + return new GpxLink(new Uri(href)) { Text = linkText, Type = linkType }; + } + + /// + /// Reads track/route metadata from the internal XmlReader. + /// + /// Objecto to store read metadata + /// true if piece of metadata was read, otherwise returns false + private bool TryReadTrackMetadata(GpxTrackMetadata metadata) + { + switch (_xmlReader.Name) + { + case "name": + metadata.Name = _xmlReader.ReadElementContentAsString(); return true; + case "cmt": + metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; + case "desc": + metadata.Description = _xmlReader.ReadElementContentAsString(); return true; + case "src": + metadata.Source = _xmlReader.ReadElementContentAsString(); return true; + case "type": + metadata.Type = _xmlReader.ReadElementContentAsString(); return true; + case "link": + metadata.Links.Add(ReadLink()); return true; + } + + return false; + } + + /// + /// Reads waypoint metadata from the internal XmlReader. + /// + /// Objecto to store read metadata + /// true if piece of metadata was read, otherwise returns false + private bool TryReadPointMetadata(GpxPointMetadata metadata) + { + switch (_xmlReader.Name) + { + case "name": + metadata.Name = _xmlReader.ReadElementContentAsString(); return true; + case "cmt": + metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; + case "desc": + metadata.Description = _xmlReader.ReadElementContentAsString(); return true; + case "src": + metadata.Source = _xmlReader.ReadElementContentAsString(); return true; + case "link": + metadata.Links.Add(ReadLink()); return true; + case "magvar": + string magvarValue = _xmlReader.ReadElementContentAsString(); + metadata.MagVar = double.Parse(magvarValue, _invariantCulture); return true; + case "geoidheight": + string geoidHeightValue = _xmlReader.ReadElementContentAsString(); + metadata.GeoidHeight = double.Parse(geoidHeightValue, _invariantCulture); return true; + case "hdop": + string HdopValue = _xmlReader.ReadElementContentAsString(); + metadata.Hdop = double.Parse(HdopValue, _invariantCulture); return true; + case "vdop": + string vdopValue = _xmlReader.ReadElementContentAsString(); + metadata.Vdop = double.Parse(vdopValue, _invariantCulture); return true; + case "pdop": + string pdopValue = _xmlReader.ReadElementContentAsString(); + metadata.Pdop = double.Parse(pdopValue, _invariantCulture); return true; + case "ageofdgpsdata": + string ageValue = _xmlReader.ReadElementContentAsString(); + metadata.AgeOfDgpsData = double.Parse(ageValue, _invariantCulture); return true; + case "sat": + string satValue = _xmlReader.ReadElementContentAsString(); + metadata.SatellitesCount = int.Parse(satValue, _invariantCulture); return true; + case "dgpsid": + string dgpsidValue = _xmlReader.ReadElementContentAsString(); + metadata.DgpsId = int.Parse(dgpsidValue, _invariantCulture); return true; + case "fix": + string fixValue = _xmlReader.ReadElementContentAsString(); + metadata.Fix = GpxFixHelper.ParseGpsFix(fixValue); return true; + } + + return false; + } + + /// + /// Releases the unmanaged resources used by the GpxReader and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (disposing) + { + _xmlReader.Dispose(); + + if (_ownsInputStream) + { + _input.Dispose(); + } + } + + _disposed = true; + } + } + } +} diff --git a/src/SpatialLite.Gps/IO/GpxReaderSettings.cs b/src/SpatialLite.Gps/IO/GpxReaderSettings.cs index 4508bc8..5d12d77 100644 --- a/src/SpatialLite.Gps/IO/GpxReaderSettings.cs +++ b/src/SpatialLite.Gps/IO/GpxReaderSettings.cs @@ -1,39 +1,46 @@ -using System; - -namespace SpatialLite.Gps.IO { - /// - /// Contains settings that determine behaviour of GpxReader. - /// - public class GpxReaderSettings { - - bool _readMetadata = true; - - /// - /// Initializes a new instance of the GpxReaderSettings class with default values. - /// - public GpxReaderSettings() { - this.ReadMetadata = true; - } - - /// - /// Gets a value indicating whether GpxReader should read and parse metadata. - /// - public bool ReadMetadata { - get { - return _readMetadata; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'ReadMetadata' property GpxReaderSettings is read-only."); - } - - _readMetadata = value; - } - } - - /// - /// Gets or sets value indicating whether properties of the current GpxReaderSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } - } -} +using System; + +namespace SpatialLite.Gps.IO +{ + /// + /// Contains settings that determine behaviour of GpxReader. + /// + public class GpxReaderSettings + { + + bool _readMetadata = true; + + /// + /// Initializes a new instance of the GpxReaderSettings class with default values. + /// + public GpxReaderSettings() + { + this.ReadMetadata = true; + } + + /// + /// Gets a value indicating whether GpxReader should read and parse metadata. + /// + public bool ReadMetadata + { + get + { + return _readMetadata; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'ReadMetadata' property GpxReaderSettings is read-only."); + } + + _readMetadata = value; + } + } + + /// + /// Gets or sets value indicating whether properties of the current GpxReaderSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } + } +} diff --git a/src/SpatialLite.Gps/IO/GpxWriter.cs b/src/SpatialLite.Gps/IO/GpxWriter.cs index e9ff4ba..461484c 100644 --- a/src/SpatialLite.Gps/IO/GpxWriter.cs +++ b/src/SpatialLite.Gps/IO/GpxWriter.cs @@ -1,265 +1,307 @@ -using System; -using System.IO; -using System.Text; -using System.Xml; -using SpatialLite.Gps.Geometries; - -namespace SpatialLite.Gps.IO { - /// - /// Implements data writer that can write GPX data to streams and files. - /// - public class GpxWriter : IDisposable, IGpxWriter { - private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; - - private XmlWriter _xmlWriter; - private StreamWriter _streamWriter; - private bool _disposed = false; - - /// - /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified stream. - /// - /// The Stream to write GPX entities to. - /// The settings defining behaviour of the writer. - public GpxWriter(Stream stream, GpxWriterSettings settings) { - this.Settings = settings; - settings.IsReadOnly = true; - - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; - - _streamWriter = new StreamWriter(stream, new UTF8Encoding(false)); - _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); - - StartDocument(); - } - - /// - /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified file. - /// - /// Path to the GPX file. - /// The settings defining behaviour of the writer. - /// If the file exists, it is overwritten, otherwise, a new file is created. - public GpxWriter(string path, GpxWriterSettings settings) { - this.Settings = settings; - settings.IsReadOnly = true; - - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; - - var fileStream = new FileStream(path, FileMode.Create); - _streamWriter = new StreamWriter(fileStream, new UTF8Encoding(false)); - _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); - - StartDocument(); - } - - /// - /// Creates root element in the output stream - /// - private void StartDocument() { - _xmlWriter.WriteStartDocument(); - _xmlWriter.WriteStartElement("gpx", "http://www.topografix.com/GPX/1/1"); - _xmlWriter.WriteAttributeString("version", "1.1"); - _xmlWriter.WriteAttributeString("creator", this.Settings.GeneratorName ?? "SpatialLite"); - } - - /// - /// Gets settings of the writer - /// - public GpxWriterSettings Settings { get; private set; } - - /// - /// Writes the given waypoint to the output stream - /// - /// The waypoint to write - public void Write(GpxPoint waypoint) { - WritePoint(waypoint, "wpt"); - } - - /// - /// Writes the given route to the output stream - /// - /// The route to write - public void Write(GpxRoute route) { - _xmlWriter.WriteStartElement("rte"); - - for (int i = 0; i < route.Points.Count; i++) { - WritePoint(route.Points[i], "rtept"); - } - if (this.Settings.WriteMetadata) { - this.WriteTrackMetadata(route.Metadata); - } - - _xmlWriter.WriteEndElement(); - } - - /// - /// Writes the given track to the output stream - /// - /// The track to write - public void Write(GpxTrack track) { - _xmlWriter.WriteStartElement("trk"); - - for (int i = 0; i < track.Geometries.Count; i++) { - _xmlWriter.WriteStartElement("trkseg"); - - for (int ii = 0; ii < track.Geometries[i].Points.Count; ii++) { - WritePoint(track.Geometries[i].Points[ii], "trkpt"); - } - - _xmlWriter.WriteEndElement(); - } - - if (this.Settings.WriteMetadata) { - this.WriteTrackMetadata(track.Metadata); - } - - _xmlWriter.WriteEndElement(); - } - - /// - /// Releases all resources used by the GpxWriter. - /// - public void Dispose() { - Dispose(true); - - GC.SuppressFinalize(this); - } - - /// - /// Writes the given point to the output stream - /// - /// The point to be written - /// The name of the XML element the point is to be written to - private void WritePoint(GpxPoint point, string pointElementName) { - _xmlWriter.WriteStartElement(pointElementName); - _xmlWriter.WriteAttributeString("lat", point.Position.Y.ToString(_invariantCulture)); - _xmlWriter.WriteAttributeString("lon", point.Position.X.ToString(_invariantCulture)); - - if (!double.IsNaN(point.Position.Z)) { - _xmlWriter.WriteElementString("ele", point.Position.Z.ToString(_invariantCulture)); - } - - if (point.Timestamp != null) { - _xmlWriter.WriteElementString("time", point.Timestamp.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture)); - } - - if (this.Settings.WriteMetadata) { - this.WritePointMetadata(point.Metadata); - } - - _xmlWriter.WriteEndElement(); - } - - /// - /// Writes content of the GpxEntityDetails class to the current position of output stream - /// - /// A GpxEntityDetails object to be written - private void WriteTrackMetadata(GpxTrackMetadata metadata) { - if (metadata != null) { - if (metadata.Name != null) - _xmlWriter.WriteElementString("name", metadata.Name); - if (metadata.Comment != null) - _xmlWriter.WriteElementString("cmt", metadata.Comment); - if (metadata.Description != null) - _xmlWriter.WriteElementString("desc", metadata.Description); - if (metadata.Source != null) - _xmlWriter.WriteElementString("src", metadata.Source); - foreach (var link in metadata.Links) { - this.WriteLink(link); - } - if (metadata.Comment != null) - _xmlWriter.WriteElementString("type", metadata.Type); - } - } - - /// - /// Writes content of the GpxPointDetails class to the current position of output stream - /// - /// A GpxEntityDetails object to be written - private void WritePointMetadata(GpxPointMetadata metadata) { - if (metadata != null) { - if (metadata.Name != null) { - _xmlWriter.WriteElementString("name", metadata.Name); - } - if (metadata.Comment != null) { - _xmlWriter.WriteElementString("cmt", metadata.Comment); - } - if (metadata.Description != null) { - _xmlWriter.WriteElementString("desc", metadata.Description); - } - if (metadata.Source != null) { - _xmlWriter.WriteElementString("src", metadata.Source); - } - - foreach (var link in metadata.Links) { - this.WriteLink(link); - } - - if (metadata.MagVar.HasValue) { - _xmlWriter.WriteElementString("magvar", metadata.MagVar.Value.ToString(_invariantCulture)); - } - if (metadata.GeoidHeight.HasValue) { - _xmlWriter.WriteElementString("geoidheight", (metadata.GeoidHeight ?? 0).ToString(_invariantCulture)); - } - if (metadata.Symbol != null) { - _xmlWriter.WriteElementString("sym", metadata.Symbol); - } - if (metadata.Fix.HasValue) { - _xmlWriter.WriteElementString("fix", GpxFixHelper.GpsFixToString(metadata.Fix.Value)); - } - if (metadata.SatellitesCount.HasValue) { - _xmlWriter.WriteElementString("sat", metadata.SatellitesCount.Value.ToString(_invariantCulture)); - } - if (metadata.Hdop.HasValue) { - _xmlWriter.WriteElementString("hdop", metadata.Hdop.Value.ToString(_invariantCulture)); - } - if (metadata.Vdop.HasValue) { - _xmlWriter.WriteElementString("vdop", metadata.Vdop.Value.ToString(_invariantCulture)); - } - if (metadata.Pdop.HasValue) { - _xmlWriter.WriteElementString("pdop", metadata.Pdop.Value.ToString(_invariantCulture)); - } - if (metadata.AgeOfDgpsData.HasValue) { - _xmlWriter.WriteElementString("ageofdgpsdata", metadata.AgeOfDgpsData.Value.ToString(_invariantCulture)); - } - if (metadata.DgpsId.HasValue) { - _xmlWriter.WriteElementString("dgpsid", metadata.DgpsId.Value.ToString(_invariantCulture)); - } - } - } - - /// - /// Writes the given link to the output stream - /// - /// The link to be written - private void WriteLink(GpxLink link) { - _xmlWriter.WriteStartElement("link"); - _xmlWriter.WriteAttributeString("href", link.Url.OriginalString); - - if (link.Text != null) - _xmlWriter.WriteElementString("text", link.Text); - if (link.Type != null) - _xmlWriter.WriteElementString("type", link.Type); - - _xmlWriter.WriteEndElement(); - } - - /// - /// Releases the unmanaged resources used by the GpxWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!this._disposed) { - if (disposing) { - _xmlWriter.Dispose(); - - if (_streamWriter != null) - _streamWriter.Dispose(); - } - - _disposed = true; - } - } - } -} +using System; +using System.IO; +using System.Text; +using System.Xml; +using SpatialLite.Gps.Geometries; + +namespace SpatialLite.Gps.IO +{ + /// + /// Implements data writer that can write GPX data to streams and files. + /// + public class GpxWriter : IDisposable, IGpxWriter + { + private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + + private XmlWriter _xmlWriter; + private StreamWriter _streamWriter; + private bool _disposed = false; + + /// + /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified stream. + /// + /// The Stream to write GPX entities to. + /// The settings defining behaviour of the writer. + public GpxWriter(Stream stream, GpxWriterSettings settings) + { + this.Settings = settings; + settings.IsReadOnly = true; + + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; + + _streamWriter = new StreamWriter(stream, new UTF8Encoding(false)); + _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); + + StartDocument(); + } + + /// + /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified file. + /// + /// Path to the GPX file. + /// The settings defining behaviour of the writer. + /// If the file exists, it is overwritten, otherwise, a new file is created. + public GpxWriter(string path, GpxWriterSettings settings) + { + this.Settings = settings; + settings.IsReadOnly = true; + + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; + + var fileStream = new FileStream(path, FileMode.Create); + _streamWriter = new StreamWriter(fileStream, new UTF8Encoding(false)); + _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); + + StartDocument(); + } + + /// + /// Creates root element in the output stream + /// + private void StartDocument() + { + _xmlWriter.WriteStartDocument(); + _xmlWriter.WriteStartElement("gpx", "http://www.topografix.com/GPX/1/1"); + _xmlWriter.WriteAttributeString("version", "1.1"); + _xmlWriter.WriteAttributeString("creator", this.Settings.GeneratorName ?? "SpatialLite"); + } + + /// + /// Gets settings of the writer + /// + public GpxWriterSettings Settings { get; private set; } + + /// + /// Writes the given waypoint to the output stream + /// + /// The waypoint to write + public void Write(GpxPoint waypoint) + { + WritePoint(waypoint, "wpt"); + } + + /// + /// Writes the given route to the output stream + /// + /// The route to write + public void Write(GpxRoute route) + { + _xmlWriter.WriteStartElement("rte"); + + for (int i = 0; i < route.Points.Count; i++) + { + WritePoint(route.Points[i], "rtept"); + } + if (this.Settings.WriteMetadata) + { + this.WriteTrackMetadata(route.Metadata); + } + + _xmlWriter.WriteEndElement(); + } + + /// + /// Writes the given track to the output stream + /// + /// The track to write + public void Write(GpxTrack track) + { + _xmlWriter.WriteStartElement("trk"); + + for (int i = 0; i < track.Geometries.Count; i++) + { + _xmlWriter.WriteStartElement("trkseg"); + + for (int ii = 0; ii < track.Geometries[i].Points.Count; ii++) + { + WritePoint(track.Geometries[i].Points[ii], "trkpt"); + } + + _xmlWriter.WriteEndElement(); + } + + if (this.Settings.WriteMetadata) + { + this.WriteTrackMetadata(track.Metadata); + } + + _xmlWriter.WriteEndElement(); + } + + /// + /// Releases all resources used by the GpxWriter. + /// + public void Dispose() + { + Dispose(true); + + GC.SuppressFinalize(this); + } + + /// + /// Writes the given point to the output stream + /// + /// The point to be written + /// The name of the XML element the point is to be written to + private void WritePoint(GpxPoint point, string pointElementName) + { + _xmlWriter.WriteStartElement(pointElementName); + _xmlWriter.WriteAttributeString("lat", point.Position.Y.ToString(_invariantCulture)); + _xmlWriter.WriteAttributeString("lon", point.Position.X.ToString(_invariantCulture)); + + if (!double.IsNaN(point.Position.Z)) + { + _xmlWriter.WriteElementString("ele", point.Position.Z.ToString(_invariantCulture)); + } + + if (point.Timestamp != null) + { + _xmlWriter.WriteElementString("time", point.Timestamp.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture)); + } + + if (this.Settings.WriteMetadata) + { + this.WritePointMetadata(point.Metadata); + } + + _xmlWriter.WriteEndElement(); + } + + /// + /// Writes content of the GpxEntityDetails class to the current position of output stream + /// + /// A GpxEntityDetails object to be written + private void WriteTrackMetadata(GpxTrackMetadata metadata) + { + if (metadata != null) + { + if (metadata.Name != null) + _xmlWriter.WriteElementString("name", metadata.Name); + if (metadata.Comment != null) + _xmlWriter.WriteElementString("cmt", metadata.Comment); + if (metadata.Description != null) + _xmlWriter.WriteElementString("desc", metadata.Description); + if (metadata.Source != null) + _xmlWriter.WriteElementString("src", metadata.Source); + foreach (var link in metadata.Links) + { + this.WriteLink(link); + } + if (metadata.Comment != null) + _xmlWriter.WriteElementString("type", metadata.Type); + } + } + + /// + /// Writes content of the GpxPointDetails class to the current position of output stream + /// + /// A GpxEntityDetails object to be written + private void WritePointMetadata(GpxPointMetadata metadata) + { + if (metadata != null) + { + if (metadata.Name != null) + { + _xmlWriter.WriteElementString("name", metadata.Name); + } + if (metadata.Comment != null) + { + _xmlWriter.WriteElementString("cmt", metadata.Comment); + } + if (metadata.Description != null) + { + _xmlWriter.WriteElementString("desc", metadata.Description); + } + if (metadata.Source != null) + { + _xmlWriter.WriteElementString("src", metadata.Source); + } + + foreach (var link in metadata.Links) + { + this.WriteLink(link); + } + + if (metadata.MagVar.HasValue) + { + _xmlWriter.WriteElementString("magvar", metadata.MagVar.Value.ToString(_invariantCulture)); + } + if (metadata.GeoidHeight.HasValue) + { + _xmlWriter.WriteElementString("geoidheight", (metadata.GeoidHeight ?? 0).ToString(_invariantCulture)); + } + if (metadata.Symbol != null) + { + _xmlWriter.WriteElementString("sym", metadata.Symbol); + } + if (metadata.Fix.HasValue) + { + _xmlWriter.WriteElementString("fix", GpxFixHelper.GpsFixToString(metadata.Fix.Value)); + } + if (metadata.SatellitesCount.HasValue) + { + _xmlWriter.WriteElementString("sat", metadata.SatellitesCount.Value.ToString(_invariantCulture)); + } + if (metadata.Hdop.HasValue) + { + _xmlWriter.WriteElementString("hdop", metadata.Hdop.Value.ToString(_invariantCulture)); + } + if (metadata.Vdop.HasValue) + { + _xmlWriter.WriteElementString("vdop", metadata.Vdop.Value.ToString(_invariantCulture)); + } + if (metadata.Pdop.HasValue) + { + _xmlWriter.WriteElementString("pdop", metadata.Pdop.Value.ToString(_invariantCulture)); + } + if (metadata.AgeOfDgpsData.HasValue) + { + _xmlWriter.WriteElementString("ageofdgpsdata", metadata.AgeOfDgpsData.Value.ToString(_invariantCulture)); + } + if (metadata.DgpsId.HasValue) + { + _xmlWriter.WriteElementString("dgpsid", metadata.DgpsId.Value.ToString(_invariantCulture)); + } + } + } + + /// + /// Writes the given link to the output stream + /// + /// The link to be written + private void WriteLink(GpxLink link) + { + _xmlWriter.WriteStartElement("link"); + _xmlWriter.WriteAttributeString("href", link.Url.OriginalString); + + if (link.Text != null) + _xmlWriter.WriteElementString("text", link.Text); + if (link.Type != null) + _xmlWriter.WriteElementString("type", link.Type); + + _xmlWriter.WriteEndElement(); + } + + /// + /// Releases the unmanaged resources used by the GpxWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (disposing) + { + _xmlWriter.Dispose(); + + if (_streamWriter != null) + _streamWriter.Dispose(); + } + + _disposed = true; + } + } + } +} diff --git a/src/SpatialLite.Gps/IO/GpxWriterSettings.cs b/src/SpatialLite.Gps/IO/GpxWriterSettings.cs index a04148b..43a7e11 100644 --- a/src/SpatialLite.Gps/IO/GpxWriterSettings.cs +++ b/src/SpatialLite.Gps/IO/GpxWriterSettings.cs @@ -1,55 +1,66 @@ -using System; - -namespace SpatialLite.Gps.IO { - /// - /// Contains settings that determine behaviour of the GpxWriter. - /// - public class GpxWriterSettings { - - bool _writeMetadata = true; - string _generatorName; - - /// - /// Initializes a new instance of the GpxWriterSettings class with default values. - /// - public GpxWriterSettings() { - } - - /// - /// Gets or sets a value indicating whether GpxWriter should write entity metadata. - /// - public bool WriteMetadata { - get { - return _writeMetadata; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - GpxWriterSettings is read-only."); - } - - _writeMetadata = value; - } - } - - /// - /// Gets or sets the name of the program that will be save to the output file. - /// - public string GeneratorName { - get { - return _generatorName; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'GeneratorName' property - GpxWriterSettings is read-only."); - } - - _generatorName = value; - } - } - - /// - /// Gets or sets value indicating whether properties of the current GpxWriterSettings instance can be changed. - /// - public bool IsReadOnly { get; internal set; } - } -} +using System; + +namespace SpatialLite.Gps.IO +{ + /// + /// Contains settings that determine behaviour of the GpxWriter. + /// + public class GpxWriterSettings + { + + bool _writeMetadata = true; + string _generatorName; + + /// + /// Initializes a new instance of the GpxWriterSettings class with default values. + /// + public GpxWriterSettings() + { + } + + /// + /// Gets or sets a value indicating whether GpxWriter should write entity metadata. + /// + public bool WriteMetadata + { + get + { + return _writeMetadata; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - GpxWriterSettings is read-only."); + } + + _writeMetadata = value; + } + } + + /// + /// Gets or sets the name of the program that will be save to the output file. + /// + public string GeneratorName + { + get + { + return _generatorName; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'GeneratorName' property - GpxWriterSettings is read-only."); + } + + _generatorName = value; + } + } + + /// + /// Gets or sets value indicating whether properties of the current GpxWriterSettings instance can be changed. + /// + public bool IsReadOnly { get; internal set; } + } +} diff --git a/src/SpatialLite.Gps/IO/IGpxReader.cs b/src/SpatialLite.Gps/IO/IGpxReader.cs index 4cfc886..a3342e4 100644 --- a/src/SpatialLite.Gps/IO/IGpxReader.cs +++ b/src/SpatialLite.Gps/IO/IGpxReader.cs @@ -1,11 +1,13 @@ -namespace SpatialLite.Gps.IO { - /// - /// Defines functions and properties for classes that can read GPX entities from a source. - /// - public interface IGpxReader { - /// - /// Parses next element of the GPX file - /// - IGpxGeometry Read(); - } -} +namespace SpatialLite.Gps.IO +{ + /// + /// Defines functions and properties for classes that can read GPX entities from a source. + /// + public interface IGpxReader + { + /// + /// Parses next element of the GPX file + /// + IGpxGeometry Read(); + } +} diff --git a/src/SpatialLite.Gps/IO/IGpxWriter.cs b/src/SpatialLite.Gps/IO/IGpxWriter.cs index 2594100..d47f928 100644 --- a/src/SpatialLite.Gps/IO/IGpxWriter.cs +++ b/src/SpatialLite.Gps/IO/IGpxWriter.cs @@ -1,26 +1,28 @@ -using SpatialLite.Gps.Geometries; - -namespace SpatialLite.Gps.IO { - /// - /// Defines functions and properties for classes that can writes GPX entities to a destination. - /// - public interface IGpxWriter { - /// - /// Writes GpxWaypoint - /// - /// The waypoint to write. - void Write(GpxPoint waypoint); - - /// - /// Writes GpxRoute - /// - /// The route to write - void Write(GpxRoute route); - - /// - /// Writes GpxTrack - /// - /// The track to write - void Write(GpxTrack track); - } -} +using SpatialLite.Gps.Geometries; + +namespace SpatialLite.Gps.IO +{ + /// + /// Defines functions and properties for classes that can writes GPX entities to a destination. + /// + public interface IGpxWriter + { + /// + /// Writes GpxWaypoint + /// + /// The waypoint to write. + void Write(GpxPoint waypoint); + + /// + /// Writes GpxRoute + /// + /// The route to write + void Write(GpxRoute route); + + /// + /// Writes GpxTrack + /// + /// The track to write + void Write(GpxTrack track); + } +} diff --git a/src/SpatialLite.Gps/Properties/AssemblyInfo.cs b/src/SpatialLite.Gps/Properties/AssemblyInfo.cs index d354c84..261ebf1 100644 --- a/src/SpatialLite.Gps/Properties/AssemblyInfo.cs +++ b/src/SpatialLite.Gps/Properties/AssemblyInfo.cs @@ -9,4 +9,4 @@ [assembly: AssemblyProduct("SpatialLite.Gps")] [assembly: AssemblyTrademark("")] -[assembly: InternalsVisibleTo("Tests.SpatialLite.Gps")] \ No newline at end of file +[assembly: InternalsVisibleTo("Tests.SpatialLite.Gps")] diff --git a/src/SpatialLite.Osm/EntityCollection.cs b/src/SpatialLite.Osm/EntityCollection.cs index 89bf3c8..d2c162b 100644 --- a/src/SpatialLite.Osm/EntityCollection.cs +++ b/src/SpatialLite.Osm/EntityCollection.cs @@ -1,157 +1,182 @@ using System; using System.Collections.Generic; -namespace SpatialLite.Osm { - /// - /// Represents collection of the OSM entities that optimized for access speed. - /// - /// The type of the entities in the collection. - public class EntityCollection : ITypedEntityCollection where T : IOsmEntity { - - private Dictionary _storage = null; - - /// - /// Initializes a new instance of the EntityCollection class that is empty. - /// - public EntityCollection() { - _storage = new Dictionary(); - } - - /// - /// Initializes a new instance of the EntityCollection class with specified entities. - /// - /// Collection of entities to be populated into this EntityCollection. - public EntityCollection(IEnumerable entities) { - _storage = new Dictionary(); - - foreach (var entity in entities) { - _storage.Add(entity.ID, entity); - } - } - - /// - /// Gets the number of entities in the collection. - /// - public int Count { - get { - return _storage.Count; - } - } - - /// - /// Gets a value indicating whether the collection is read-only. - /// - public bool IsReadOnly { - get { - return false; - } - } - - /// - /// Gets an entity with specific ID from the collection. - /// - /// The ID of the entity to get. - /// entity with the specific ID or null if such entity is not present in the collection. - public T this[long id] { - get { - if (_storage.ContainsKey(id)) { - return _storage[id]; - } - - return default(T); - } - } - - /// - /// Adds specific entity to the collection. - /// - /// The entity to add to the collection. - public void Add(T entity) { - if (entity == null) { - throw new ArgumentNullException("entity", "Cannot add null to EntityCollection"); - } - - if (_storage.ContainsKey(entity.ID)) { - throw new ArgumentException("An entity with the same ID has already been added."); - } - - _storage.Add(entity.ID, entity); - } - - /// - /// Removes all entities form the collection. - /// - public void Clear() { - _storage.Clear(); - } - - /// - /// Determines whether the EntityICollection contains a specific entity. - /// - /// The entity to locate in the EntityCollection - /// true if entity is found in the collection, otherwise false. - public bool Contains(T item) { - if (item == null) { - return false; - } - - return _storage.ContainsKey(item.ID); - } - - /// - /// Determines whether the EntityICollection contains an entity with specific ID. - /// - /// The ID of the entity to locate in the EntityCollection. - /// true if entity is found in the collection, otherwise false. - public bool Contains(long id) { - return _storage.ContainsKey(id); - } - - /// - /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. - /// The zero-based index in array at which copying begins. - public void CopyTo(T[] array, int arrayIndex) { - _storage.Values.CopyTo(array, arrayIndex); - } - - /// - /// Removes the specific entity from the collection. - /// - /// The entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(T entity) { - if (entity == null) { - return false; - } - - return _storage.Remove(entity.ID); - } - - /// - /// Removes an entity with the specific ID from the collection. - /// - /// The ID of the entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(long id) { - return _storage.Remove(id); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator<T> that can be used to iterate through the collection. - public IEnumerator GetEnumerator() { - return _storage.Values.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return this.GetEnumerator(); - } - } +namespace SpatialLite.Osm +{ + /// + /// Represents collection of the OSM entities that optimized for access speed. + /// + /// The type of the entities in the collection. + public class EntityCollection : ITypedEntityCollection where T : IOsmEntity + { + + private Dictionary _storage = null; + + /// + /// Initializes a new instance of the EntityCollection class that is empty. + /// + public EntityCollection() + { + _storage = new Dictionary(); + } + + /// + /// Initializes a new instance of the EntityCollection class with specified entities. + /// + /// Collection of entities to be populated into this EntityCollection. + public EntityCollection(IEnumerable entities) + { + _storage = new Dictionary(); + + foreach (var entity in entities) + { + _storage.Add(entity.ID, entity); + } + } + + /// + /// Gets the number of entities in the collection. + /// + public int Count + { + get + { + return _storage.Count; + } + } + + /// + /// Gets a value indicating whether the collection is read-only. + /// + public bool IsReadOnly + { + get + { + return false; + } + } + + /// + /// Gets an entity with specific ID from the collection. + /// + /// The ID of the entity to get. + /// entity with the specific ID or null if such entity is not present in the collection. + public T this[long id] + { + get + { + if (_storage.TryGetValue(id, out T value)) + { + return value; + } + + return default(T); + } + } + + /// + /// Adds specific entity to the collection. + /// + /// The entity to add to the collection. + public void Add(T entity) + { + if (entity == null) + { + throw new ArgumentNullException(nameof(entity), "Cannot add null to EntityCollection"); + } + + if (_storage.ContainsKey(entity.ID)) + { + throw new ArgumentException("An entity with the same ID has already been added."); + } + + _storage.Add(entity.ID, entity); + } + + /// + /// Removes all entities form the collection. + /// + public void Clear() + { + _storage.Clear(); + } + + /// + /// Determines whether the EntityICollection contains a specific entity. + /// + /// The entity to locate in the EntityCollection + /// true if entity is found in the collection, otherwise false. + public bool Contains(T item) + { + if (item == null) + { + return false; + } + + return _storage.ContainsKey(item.ID); + } + + /// + /// Determines whether the EntityICollection contains an entity with specific ID. + /// + /// The ID of the entity to locate in the EntityCollection. + /// true if entity is found in the collection, otherwise false. + public bool Contains(long id) + { + return _storage.ContainsKey(id); + } + + /// + /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. + /// + /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. + /// The zero-based index in array at which copying begins. + public void CopyTo(T[] array, int arrayIndex) + { + _storage.Values.CopyTo(array, arrayIndex); + } + + /// + /// Removes the specific entity from the collection. + /// + /// The entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(T entity) + { + if (entity == null) + { + return false; + } + + return _storage.Remove(entity.ID); + } + + /// + /// Removes an entity with the specific ID from the collection. + /// + /// The ID of the entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(long id) + { + return _storage.Remove(id); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator<T> that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return _storage.Values.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + } } diff --git a/src/SpatialLite.Osm/EntityMetadata.cs b/src/SpatialLite.Osm/EntityMetadata.cs index 15c6780..e9e6047 100644 --- a/src/SpatialLite.Osm/EntityMetadata.cs +++ b/src/SpatialLite.Osm/EntityMetadata.cs @@ -1,39 +1,41 @@ -using System; - -namespace SpatialLite.Osm { - /// - /// Contains additional information about OSM entities such as Author, Version, Timesptam of the last change and others. - /// - public class EntityMetadata { - - /// - /// Gets or sets version of the object. - /// - public int Version { get; set; } - - /// - /// Gets or sets date and time when the entity was modified. - /// - public DateTime Timestamp { get; set; } - - /// - /// Gets or sets if of the user who made last modification to the entity. - /// - public int Uid { get; set; } - - /// - /// Gets or sets username of the person who made last modification to the entity. - /// - public string User { get; set; } - - /// - /// Gets or sets changeset id. - /// - public int Changeset { get; set; } - - /// - /// Gets or sets visibility of this item. - /// - public bool Visible { get; set; } - } -} +using System; + +namespace SpatialLite.Osm +{ + /// + /// Contains additional information about OSM entities such as Author, Version, Timesptam of the last change and others. + /// + public class EntityMetadata + { + + /// + /// Gets or sets version of the object. + /// + public int Version { get; set; } + + /// + /// Gets or sets date and time when the entity was modified. + /// + public DateTime Timestamp { get; set; } + + /// + /// Gets or sets if of the user who made last modification to the entity. + /// + public int Uid { get; set; } + + /// + /// Gets or sets username of the person who made last modification to the entity. + /// + public string User { get; set; } + + /// + /// Gets or sets changeset id. + /// + public int Changeset { get; set; } + + /// + /// Gets or sets visibility of this item. + /// + public bool Visible { get; set; } + } +} diff --git a/src/SpatialLite.Osm/EntityType.cs b/src/SpatialLite.Osm/EntityType.cs index e52a4e0..79a1a24 100644 --- a/src/SpatialLite.Osm/EntityType.cs +++ b/src/SpatialLite.Osm/EntityType.cs @@ -1,23 +1,25 @@ -namespace SpatialLite.Osm { - /// - /// Defines possible type of object that IOsmGeometryInfo can represent. - /// - public enum EntityType { - /// - /// Unknown type of the entity. - /// - Unknown, - /// - /// Node - /// - Node, - /// - /// Way - /// - Way, - /// - /// Relation - /// - Relation - } -} +namespace SpatialLite.Osm +{ + /// + /// Defines possible type of object that IOsmGeometryInfo can represent. + /// + public enum EntityType + { + /// + /// Unknown type of the entity. + /// + Unknown, + /// + /// Node + /// + Node, + /// + /// Way + /// + Way, + /// + /// Relation + /// + Relation + } +} diff --git a/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs b/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs index 28d289d..95f4d71 100644 --- a/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs +++ b/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs @@ -1,9 +1,11 @@ -using SpatialLite.Core.API; - -namespace SpatialLite.Osm.Geometries { - /// - /// Represents OSM entity that implements IGeometry interface. - /// - public interface IOsmGeometry : IOsmEntity, IGeometry { - } -} +using SpatialLite.Core.API; + +namespace SpatialLite.Osm.Geometries +{ + /// + /// Represents OSM entity that implements IGeometry interface. + /// + public interface IOsmGeometry : IOsmEntity, IGeometry + { + } +} diff --git a/src/SpatialLite.Osm/Geometries/Node.cs b/src/SpatialLite.Osm/Geometries/Node.cs index e21a66d..77fc39f 100644 --- a/src/SpatialLite.Osm/Geometries/Node.cs +++ b/src/SpatialLite.Osm/Geometries/Node.cs @@ -1,91 +1,100 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Osm.Geometries { +namespace SpatialLite.Osm.Geometries +{ /// /// Represents OSM node. /// - public class Node : Point, IOsmGeometry { + public class Node : Point, IOsmGeometry + { - /// - /// Initializes a new instance of the Node class with specified ID. - /// - /// The ID of the node. - public Node(long id) - : this(id, Coordinate.Empty, new TagsCollection()) { - } + /// + /// Initializes a new instance of the Node class with specified ID. + /// + /// The ID of the node. + public Node(long id) + : this(id, Coordinate.Empty, new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Node class with specified ID, Longitude and Latitude. - /// - /// The ID of the node. - /// The longitude of the Node. - /// The latitude of the Node. - public Node(long id, double longitude, double latitude) - : this(id, new Coordinate(longitude, latitude), new TagsCollection()) { - } + /// + /// Initializes a new instance of the Node class with specified ID, Longitude and Latitude. + /// + /// The ID of the node. + /// The longitude of the Node. + /// The latitude of the Node. + public Node(long id, double longitude, double latitude) + : this(id, new Coordinate(longitude, latitude), new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Node class with specified ID, Longitude, Latitude and Tags. - /// - /// The ID of the node. - /// The longitude of the Node. - /// The latitude of the Node. - /// The collection of tags associated with the Node. - public Node(long id, double longitude, double latitude, TagsCollection tags) - : this(id, new Coordinate(longitude, latitude), tags) { - } + /// + /// Initializes a new instance of the Node class with specified ID, Longitude, Latitude and Tags. + /// + /// The ID of the node. + /// The longitude of the Node. + /// The latitude of the Node. + /// The collection of tags associated with the Node. + public Node(long id, double longitude, double latitude, TagsCollection tags) + : this(id, new Coordinate(longitude, latitude), tags) + { + } - /// - /// Initializes a new instance of the Node class with specified ID and Position. - /// - /// The ID of the node. - /// The position of the Node. - public Node(long id, Coordinate position) - : this(id, position, new TagsCollection()) { - } + /// + /// Initializes a new instance of the Node class with specified ID and Position. + /// + /// The ID of the node. + /// The position of the Node. + public Node(long id, Coordinate position) + : this(id, position, new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Node class with specified ID, Position and Tags. - /// - /// The ID of the node. - /// The position of the Node. - /// The collection of tags associated with the Node. - public Node(long id, Coordinate position, TagsCollection tags) - : base(position) { - this.ID = id; - this.Tags = tags; - } + /// + /// Initializes a new instance of the Node class with specified ID, Position and Tags. + /// + /// The ID of the node. + /// The position of the Node. + /// The collection of tags associated with the Node. + public Node(long id, Coordinate position, TagsCollection tags) + : base(position) + { + this.ID = id; + this.Tags = tags; + } - /// - /// Creates a new instance of the Node class with data from NodeInfo object - /// - /// NodeInfo object that contains data about node - /// Node object with data from specific NodeInfo object - public static Node FromNodeInfo(NodeInfo info) { - return new Node(info.ID, info.Longitude, info.Latitude, info.Tags) { Metadata = info.Metadata }; - } + /// + /// Creates a new instance of the Node class with data from NodeInfo object + /// + /// NodeInfo object that contains data about node + /// Node object with data from specific NodeInfo object + public static Node FromNodeInfo(NodeInfo info) + { + return new Node(info.ID, info.Longitude, info.Latitude, info.Tags) { Metadata = info.Metadata }; + } - /// - /// Gets or sets ID of the Node. - /// - public long ID { get; set; } + /// + /// Gets or sets ID of the Node. + /// + public long ID { get; set; } - /// - /// Gets or sets the collection of tags associated with the Node. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets or sets the collection of tags associated with the Node. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets or sets metadata of the Node. - /// - public EntityMetadata Metadata { get; set; } + /// + /// Gets or sets metadata of the Node. + /// + public EntityMetadata Metadata { get; set; } - /// - /// Gets type of this entity. - /// - public EntityType EntityType { - get { return EntityType.Node; } - } - } + /// + /// Gets type of this entity. + /// + public EntityType EntityType + { + get { return EntityType.Node; } + } + } } diff --git a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs index 81e60ca..0d1c2a8 100644 --- a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs +++ b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs @@ -1,93 +1,110 @@ -using System; -using System.Collections.Generic; - -using SpatialLite.Osm.IO; - -namespace SpatialLite.Osm.Geometries { - /// - /// Represents in-memory OSM entities database that contains entities as IOsmGeometry objects. - /// - public class OsmGeometryDatabase : OsmDatabase { - - /// - /// Initializes a new instance of the OsmGeometryDatabase class that is empty. - /// - public OsmGeometryDatabase() - : base() { - } - - /// - /// Initializes a new instance of the OsmGeometryDatabase class with specific entities. - /// - /// Entities to add to the database. - public OsmGeometryDatabase(IEnumerable entities) - : base(entities) { - } - - /// - /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. - /// - /// The IOsmReader to read data from. - /// A value indicatings whether Load function should skip geometries that reference miising geometries. - /// New instance of the OsmDatabase class with data loaded from specified reader. - public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferentialErrors) { - OsmGeometryDatabase db = new OsmGeometryDatabase(); - - List relations = new List(); - - IEntityInfo entityInfo = null; - while ((entityInfo = reader.Read()) != null) { - switch (entityInfo.EntityType) { - case EntityType.Node: db.Nodes.Add(Node.FromNodeInfo(entityInfo as NodeInfo)); break; - case EntityType.Way: - Way toAdd = Way.FromWayInfo(entityInfo as WayInfo, db, !ignoreReferentialErrors); - if (toAdd == null) { - if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format("Way (ID = {0}) references missing node.", entityInfo.ID)); - } - } - else { - db.Ways.Add(toAdd); - } - - break; - case EntityType.Relation: - RelationInfo ri = entityInfo as RelationInfo; - db.Relations.Add(new Relation(ri.ID) { Tags = ri.Tags, Metadata = ri.Metadata }); - relations.Add(ri); - break; - } - } - - foreach (var relationInfo in relations) { - Relation relation = db.Relations[relationInfo.ID]; - - foreach (var memberInfo in relationInfo.Members) { - RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, db, false); - if (member == null) { - if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format("Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); - } - - db.Relations.Remove(relation); - } - else { - relation.Geometries.Add(member); - } - } - } - - return db; - } - - /// - /// Saves entities from the database to the specific writer. - /// - /// The IOsmWriter to save entities to. - public override void Save(IOsmWriter writer) { - foreach (var entity in this) { - writer.Write(entity); - } - } - } -} +using System; +using System.Collections.Generic; + +using SpatialLite.Osm.IO; + +namespace SpatialLite.Osm.Geometries +{ + /// + /// Represents in-memory OSM entities database that contains entities as IOsmGeometry objects. + /// + public class OsmGeometryDatabase : OsmDatabase + { + + /// + /// Initializes a new instance of the OsmGeometryDatabase class that is empty. + /// + public OsmGeometryDatabase() + : base() + { + } + + /// + /// Initializes a new instance of the OsmGeometryDatabase class with specific entities. + /// + /// Entities to add to the database. + public OsmGeometryDatabase(IEnumerable entities) + : base(entities) + { + } + + /// + /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. + /// + /// The IOsmReader to read data from. + /// A value indicatings whether Load function should skip geometries that reference miising geometries. + /// New instance of the OsmDatabase class with data loaded from specified reader. + public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferentialErrors) + { + OsmGeometryDatabase db = new OsmGeometryDatabase(); + + List relations = new List(); + + IEntityInfo entityInfo = null; + while ((entityInfo = reader.Read()) != null) + { + switch (entityInfo.EntityType) + { + case EntityType.Node: db.Nodes.Add(Node.FromNodeInfo(entityInfo as NodeInfo)); break; + case EntityType.Way: + Way toAdd = Way.FromWayInfo(entityInfo as WayInfo, db, !ignoreReferentialErrors); + if (toAdd == null) + { + if (!ignoreReferentialErrors) + { + throw new ArgumentException(string.Format("Way (ID = {0}) references missing node.", entityInfo.ID)); + } + } + else + { + db.Ways.Add(toAdd); + } + + break; + case EntityType.Relation: + RelationInfo ri = entityInfo as RelationInfo; + db.Relations.Add(new Relation(ri.ID) { Tags = ri.Tags, Metadata = ri.Metadata }); + relations.Add(ri); + break; + } + } + + foreach (var relationInfo in relations) + { + Relation relation = db.Relations[relationInfo.ID]; + + foreach (var memberInfo in relationInfo.Members) + { + RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, db, false); + if (member == null) + { + if (!ignoreReferentialErrors) + { + throw new ArgumentException(string.Format("Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); + } + + db.Relations.Remove(relation); + } + else + { + relation.Geometries.Add(member); + } + } + } + + return db; + } + + /// + /// Saves entities from the database to the specific writer. + /// + /// The IOsmWriter to save entities to. + public override void Save(IOsmWriter writer) + { + foreach (var entity in this) + { + writer.Write(entity); + } + } + } +} diff --git a/src/SpatialLite.Osm/Geometries/Relation.cs b/src/SpatialLite.Osm/Geometries/Relation.cs index 391d76f..990e9aa 100644 --- a/src/SpatialLite.Osm/Geometries/Relation.cs +++ b/src/SpatialLite.Osm/Geometries/Relation.cs @@ -2,84 +2,93 @@ using SpatialLite.Core.Geometries; -namespace SpatialLite.Osm.Geometries { +namespace SpatialLite.Osm.Geometries +{ /// /// Represents OSM relation. /// - public class Relation : GeometryCollection, IOsmGeometry { + public class Relation : GeometryCollection, IOsmGeometry + { - /// - /// Initializes a new instance of the Relation class with the specified ID. - /// - /// The ID of the Relation. - public Relation(long id) - : this(id, new RelationMember[] { }, new TagsCollection()) { - } + /// + /// Initializes a new instance of the Relation class with the specified ID. + /// + /// The ID of the Relation. + public Relation(long id) + : this(id, new RelationMember[] { }, new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Relation class with the specified ID and Members. - /// - /// The ID of the Relation. - /// The memberes of the relation. - public Relation(long id, IEnumerable members) - : this(id, members, new TagsCollection()) { - } + /// + /// Initializes a new instance of the Relation class with the specified ID and Members. + /// + /// The ID of the Relation. + /// The memberes of the relation. + public Relation(long id, IEnumerable members) + : this(id, members, new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Relation class with the specified ID, Members and tags. - /// - /// The ID of the Relation. - /// The memberes of the relation. - /// The collectoin of tags associated with the relation. - public Relation(long id, IEnumerable members, TagsCollection tags) - : base(members) { - this.ID = id; - this.Tags = tags; - } + /// + /// Initializes a new instance of the Relation class with the specified ID, Members and tags. + /// + /// The ID of the Relation. + /// The memberes of the relation. + /// The collectoin of tags associated with the relation. + public Relation(long id, IEnumerable members, TagsCollection tags) + : base(members) + { + this.ID = id; + this.Tags = tags; + } - /// - /// Gets or sets ID of the Relation. - /// - public long ID { get; set; } + /// + /// Gets or sets ID of the Relation. + /// + public long ID { get; set; } - /// - /// Gets or sets the collection of tags associated with the Relation. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets or sets the collection of tags associated with the Relation. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets or sets metadata of the Relation. - /// - public EntityMetadata Metadata { get; set; } + /// + /// Gets or sets metadata of the Relation. + /// + public EntityMetadata Metadata { get; set; } - /// - /// Gets type of this entity. - /// - public EntityType EntityType { - get { return EntityType.Relation; } - } + /// + /// Gets type of this entity. + /// + public EntityType EntityType + { + get { return EntityType.Relation; } + } - /// - /// Creates a new instance of the Relation class with data from RelationInfo object. - /// - /// The RelationInfo object that contains data about relation. - /// The collection of entities that can be referenced by the relation. - /// bool value indicating whether references to the missing entities should cause exception. - /// The Relation object created from RelationInfo or null if referenced entity is missing. - public static Relation FromRelationInfo(RelationInfo info, IEntityCollection entities, bool throwOnMissing) { - Relation result = new Relation(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; + /// + /// Creates a new instance of the Relation class with data from RelationInfo object. + /// + /// The RelationInfo object that contains data about relation. + /// The collection of entities that can be referenced by the relation. + /// bool value indicating whether references to the missing entities should cause exception. + /// The Relation object created from RelationInfo or null if referenced entity is missing. + public static Relation FromRelationInfo(RelationInfo info, IEntityCollection entities, bool throwOnMissing) + { + Relation result = new Relation(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; - result.Geometries.Capacity = info.Members.Count; - foreach (var memberInfo in info.Members) { - RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, entities, throwOnMissing); - if (member == null) { - return null; - } + result.Geometries.Capacity = info.Members.Count; + foreach (var memberInfo in info.Members) + { + RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, entities, throwOnMissing); + if (member == null) + { + return null; + } - result.Geometries.Add(member); - } + result.Geometries.Add(member); + } - return result; - } - } + return result; + } + } } diff --git a/src/SpatialLite.Osm/Geometries/RelationMember.cs b/src/SpatialLite.Osm/Geometries/RelationMember.cs index e74afeb..2ff7cba 100644 --- a/src/SpatialLite.Osm/Geometries/RelationMember.cs +++ b/src/SpatialLite.Osm/Geometries/RelationMember.cs @@ -1,129 +1,150 @@ -using System; -using System.Collections.Generic; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace SpatialLite.Osm.Geometries { - /// - /// Ecapsules member of the OSM relation and it's role in the relation. - /// - public class RelationMember : Geometry { - - /// - /// Initializes a new instance of the RelationMember class with empty Role and specified Member. - /// - /// The member of this RelatioinMember. - public RelationMember(IOsmGeometry member) - : this(member, null) { - } - - /// - /// Initializes a new instance of the RelationMember class with specified Role and Member. - /// - /// The member of this RelationMember. - /// The Role of this member in the relation. - public RelationMember(IOsmGeometry member, string role) - : base() { - if (member == null) { - throw new ArgumentNullException("member"); - } - - this.Member = member; - this.Role = role; - - if (member is Node) { - this.MemberType = EntityType.Node; - } - else if (member is Way) { - this.MemberType = EntityType.Way; - } - else if (member is Relation) { - this.MemberType = EntityType.Relation; - } - else { - throw new ArgumentException("Unknown member type."); - } - } - - /// - /// Gets the actual member. - /// - public IOsmGeometry Member { get; private set; } - - /// - /// Gets or sets role of the member in the relation. - /// - public string Role { get; set; } - - /// - /// Gets the type of the Member. - /// - public EntityType MemberType { get; private set; } - - /// - /// Gets a value indicating whether this has Z coordinates. - /// - public override bool Is3D { - get { - return ((Geometry)this.Member).Is3D; - } - } - - /// - /// Gets a value indicating whether this has M values. - /// - public override bool IsMeasured { - get { - return ((Geometry)this.Member).IsMeasured; - } - } - - /// - /// Creates a new instance of the RelationMember class based on the data from RelationInfo object. - /// - /// The RelationMemberInfo object that contains data about member. - /// The entities that can be referenced by RelationMember. - /// bool value indicating whether references to the missing entity should cause exception. - /// The RelationMember object created from RelationMemberInfo or null if referenced node is missing. - public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEntityCollection entities, bool throwOnMissing) { - if (info.MemberType == EntityType.Unknown) { - throw new ArgumentException("info.MemberType cannot be EntityType.Unknown"); - } - - if (entities.Contains(info.Reference, info.MemberType) == false) { - if (throwOnMissing) { - throw new ArgumentException(string.Format("Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); - } - else { - return null; - } - } - - RelationMember result = new RelationMember(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; - if (result.Member.EntityType != info.MemberType) { - throw new ArgumentException("Type of the referenced entity doesn't match type of the entity in the collection."); - } - - return result; - } - - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the Geometry object. - /// - public override Envelope GetEnvelope() { - return ((Geometry)this.Member).GetEnvelope(); - } - - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - public override IEnumerable GetCoordinates() { - return this.Member.GetCoordinates(); - } - } -} +using System; +using System.Collections.Generic; + +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace SpatialLite.Osm.Geometries +{ + /// + /// Ecapsules member of the OSM relation and it's role in the relation. + /// + public class RelationMember : Geometry + { + + /// + /// Initializes a new instance of the RelationMember class with empty Role and specified Member. + /// + /// The member of this RelatioinMember. + public RelationMember(IOsmGeometry member) + : this(member, null) + { + } + + /// + /// Initializes a new instance of the RelationMember class with specified Role and Member. + /// + /// The member of this RelationMember. + /// The Role of this member in the relation. + public RelationMember(IOsmGeometry member, string role) + : base() + { + if (member == null) + { + throw new ArgumentNullException(nameof(member)); + } + + this.Member = member; + this.Role = role; + + if (member is Node) + { + this.MemberType = EntityType.Node; + } + else if (member is Way) + { + this.MemberType = EntityType.Way; + } + else if (member is Relation) + { + this.MemberType = EntityType.Relation; + } + else + { + throw new ArgumentException("Unknown member type."); + } + } + + /// + /// Gets the actual member. + /// + public IOsmGeometry Member { get; private set; } + + /// + /// Gets or sets role of the member in the relation. + /// + public string Role { get; set; } + + /// + /// Gets the type of the Member. + /// + public EntityType MemberType { get; private set; } + + /// + /// Gets a value indicating whether this has Z coordinates. + /// + public override bool Is3D + { + get + { + return ((Geometry)this.Member).Is3D; + } + } + + /// + /// Gets a value indicating whether this has M values. + /// + public override bool IsMeasured + { + get + { + return ((Geometry)this.Member).IsMeasured; + } + } + + /// + /// Creates a new instance of the RelationMember class based on the data from RelationInfo object. + /// + /// The RelationMemberInfo object that contains data about member. + /// The entities that can be referenced by RelationMember. + /// bool value indicating whether references to the missing entity should cause exception. + /// The RelationMember object created from RelationMemberInfo or null if referenced node is missing. + public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEntityCollection entities, bool throwOnMissing) + { + if (info.MemberType == EntityType.Unknown) + { + throw new ArgumentException("info.MemberType cannot be EntityType.Unknown"); + } + + if (entities.Contains(info.Reference, info.MemberType) == false) + { + if (throwOnMissing) + { + throw new ArgumentException(string.Format("Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); + } + else + { + return null; + } + } + + RelationMember result = new RelationMember(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; + if (result.Member.EntityType != info.MemberType) + { + throw new ArgumentException("Type of the referenced entity doesn't match type of the entity in the collection."); + } + + return result; + } + + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the Geometry object. + /// + public override Envelope GetEnvelope() + { + return ((Geometry)this.Member).GetEnvelope(); + } + + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + public override IEnumerable GetCoordinates() + { + return this.Member.GetCoordinates(); + } + } +} diff --git a/src/SpatialLite.Osm/Geometries/Way.cs b/src/SpatialLite.Osm/Geometries/Way.cs index 916cb64..92c4511 100644 --- a/src/SpatialLite.Osm/Geometries/Way.cs +++ b/src/SpatialLite.Osm/Geometries/Way.cs @@ -4,108 +4,121 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Osm.Geometries { +namespace SpatialLite.Osm.Geometries +{ /// /// Represents OSM way. /// - public class Way : LineString, IOsmGeometry { - - private WayCoordinateList _coordinatesAdapter; - - /// - /// Initializes a new instance of the Way class with specified ID. - /// - /// The ID of the Way. - public Way(long id) - : this(id, new Node[] { }, new TagsCollection()) { - } - - /// - /// Initializes a new instance of the Way class with specified ID and given Nodes. - /// - /// The ID of the Way. - /// The colection of Nodes to add to this Way. - public Way(long id, IEnumerable nodes) - : this(id, nodes, new TagsCollection()) { - } - - /// - /// Initializes a new instance of the Way class with specified ID, Nodes and collection of tags. - /// - /// The ID of the Way. - /// The colection of Nodes to add to this Way. - /// The collection of tags associated with the way. - public Way(long id, IEnumerable nodes, TagsCollection tags) - : base() { - this.ID = id; - this.Tags = tags; - this.Nodes = new List(nodes); - - _coordinatesAdapter = new WayCoordinateList(this.Nodes); - } - - /// - /// Gets or sets ID of the Node. - /// - public long ID { get; set; } - - /// - /// Gets or sets the collection of tags associated with the Node. - /// - public TagsCollection Tags { get; set; } - - /// - /// Gets or sets metadata of the Node. - /// - public EntityMetadata Metadata { get; set; } - - /// - /// Gets collection of Nodes of this Way. - /// - public List Nodes { get; private set; } - - /// - /// Gets the list of çoordinates of this Way. - /// - public override ICoordinateList Coordinates { - get { - return _coordinatesAdapter; - } - } - - /// - /// Gets type of this entity. - /// - public EntityType EntityType { - get { return EntityType.Way; } - } - - /// - /// Creates a new instance of the Way class based on data from WayInfo object - /// - /// The WayInfo object that contains data about way - /// The entities that can be referenced by way - /// bool value indicating whether references to the missing nodes should cause exception - /// The Way object created from WayInfo or null if referenced node is missing - public static Way FromWayInfo(WayInfo info, IEntityCollection entities, bool throwOnMissing) { - Way result = new Way(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; - - result.Nodes.Capacity = info.Nodes.Count; - foreach (var nodeID in info.Nodes) { - Node node = entities[nodeID, EntityType.Node] as Node; - if (node != null) { - result.Nodes.Add(node); - } - else { - if (throwOnMissing) { - throw new ArgumentException(string.Format("Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); - } - - return null; - } - } - - return result; - } - } + public class Way : LineString, IOsmGeometry + { + + private WayCoordinateList _coordinatesAdapter; + + /// + /// Initializes a new instance of the Way class with specified ID. + /// + /// The ID of the Way. + public Way(long id) + : this(id, new Node[] { }, new TagsCollection()) + { + } + + /// + /// Initializes a new instance of the Way class with specified ID and given Nodes. + /// + /// The ID of the Way. + /// The colection of Nodes to add to this Way. + public Way(long id, IEnumerable nodes) + : this(id, nodes, new TagsCollection()) + { + } + + /// + /// Initializes a new instance of the Way class with specified ID, Nodes and collection of tags. + /// + /// The ID of the Way. + /// The colection of Nodes to add to this Way. + /// The collection of tags associated with the way. + public Way(long id, IEnumerable nodes, TagsCollection tags) + : base() + { + this.ID = id; + this.Tags = tags; + this.Nodes = new List(nodes); + + _coordinatesAdapter = new WayCoordinateList(this.Nodes); + } + + /// + /// Gets or sets ID of the Node. + /// + public long ID { get; set; } + + /// + /// Gets or sets the collection of tags associated with the Node. + /// + public TagsCollection Tags { get; set; } + + /// + /// Gets or sets metadata of the Node. + /// + public EntityMetadata Metadata { get; set; } + + /// + /// Gets collection of Nodes of this Way. + /// + public List Nodes { get; private set; } + + /// + /// Gets the list of çoordinates of this Way. + /// + public override ICoordinateList Coordinates + { + get + { + return _coordinatesAdapter; + } + } + + /// + /// Gets type of this entity. + /// + public EntityType EntityType + { + get { return EntityType.Way; } + } + + /// + /// Creates a new instance of the Way class based on data from WayInfo object + /// + /// The WayInfo object that contains data about way + /// The entities that can be referenced by way + /// bool value indicating whether references to the missing nodes should cause exception + /// The Way object created from WayInfo or null if referenced node is missing + public static Way FromWayInfo(WayInfo info, IEntityCollection entities, bool throwOnMissing) + { + Way result = new Way(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; + + result.Nodes.Capacity = info.Nodes.Count; + foreach (var nodeID in info.Nodes) + { + Node node = entities[nodeID, EntityType.Node] as Node; + if (node != null) + { + result.Nodes.Add(node); + } + else + { + if (throwOnMissing) + { + throw new ArgumentException(string.Format("Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); + } + + return null; + } + } + + return result; + } + } } diff --git a/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs b/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs index 3d625c9..0ebf435 100644 --- a/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs +++ b/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs @@ -1,108 +1,124 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -using SpatialLite.Core.API; - -namespace SpatialLite.Osm.Geometries { - /// - /// Provides a read-only wrapper around list of Nodes that implements ICoordinateList interface. - /// - internal class WayCoordinateList : ICoordinateList { - - /// - /// Initializes a new instance of the WayCoordinateList class with specified source list fo nodes - /// - /// The list of Nodes to be used as source for this WayCoordinateList - public WayCoordinateList(IList source) { - this.Source = source; - } - - /// - /// Gets number of Coordinates in the list. - /// - public int Count { - get { - return this.Source.Count; - } - } - - /// - /// Gets the List of Nodes used as source for this WayCoordinateList. - /// - public IList Source { get; private set; } - - /// - /// Gets or sets Coordinate at the given index. - /// - /// The zero-based index of the Coordinate to get or set. - /// The element at the specified index. - public Coordinate this[int index] { - get { - return this.Source[index].Position; - } - set { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } - } - - /// - /// Adds Coordinate to the end of the list. - /// - /// The Coordinate to add to the list. - public void Add(Coordinate coord) { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } - - /// - /// Adds collection of coordinates to the end of the list. - /// - /// The collection of coordinates to add to the list. - public void Add(IEnumerable coords) { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } - - /// - /// Insertes Coordinate to the list at the specified index. - /// - /// The zero-based index at which coord should be inserted. - /// The Coordinate to insert into list. - /// If index equals the number of items in the list, then item is appended to the list. - public void Insert(int index, Coordinate coord) { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } - - /// - /// Removes Coordinate at the specified index from the list. - /// - /// The zero-based index of the Coordinate to remove. - public void RemoveAt(int index) { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } - - /// - /// Removes all Coordinates from the collection. - /// - public void Clear() { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } - - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - public IEnumerator GetEnumerator() { - foreach (var node in this.Source) { - yield return node.Position; - } - } - - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - IEnumerator IEnumerable.GetEnumerator() { - return this.GetEnumerator(); - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; + +using SpatialLite.Core.API; + +namespace SpatialLite.Osm.Geometries +{ + /// + /// Provides a read-only wrapper around list of Nodes that implements ICoordinateList interface. + /// + internal class WayCoordinateList : ICoordinateList + { + + /// + /// Initializes a new instance of the WayCoordinateList class with specified source list fo nodes + /// + /// The list of Nodes to be used as source for this WayCoordinateList + public WayCoordinateList(IList source) + { + this.Source = source; + } + + /// + /// Gets number of Coordinates in the list. + /// + public int Count + { + get + { + return this.Source.Count; + } + } + + /// + /// Gets the List of Nodes used as source for this WayCoordinateList. + /// + public IList Source { get; private set; } + + /// + /// Gets or sets Coordinate at the given index. + /// + /// The zero-based index of the Coordinate to get or set. + /// The element at the specified index. + public Coordinate this[int index] + { + get + { + return this.Source[index].Position; + } + set + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } + } + + /// + /// Adds Coordinate to the end of the list. + /// + /// The Coordinate to add to the list. + public void Add(Coordinate coord) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } + + /// + /// Adds collection of coordinates to the end of the list. + /// + /// The collection of coordinates to add to the list. + public void Add(IEnumerable coords) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } + + /// + /// Insertes Coordinate to the list at the specified index. + /// + /// The zero-based index at which coord should be inserted. + /// The Coordinate to insert into list. + /// If index equals the number of items in the list, then item is appended to the list. + public void Insert(int index, Coordinate coord) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } + + /// + /// Removes Coordinate at the specified index from the list. + /// + /// The zero-based index of the Coordinate to remove. + public void RemoveAt(int index) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } + + /// + /// Removes all Coordinates from the collection. + /// + public void Clear() + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } + + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + public IEnumerator GetEnumerator() + { + foreach (var node in this.Source) + { + yield return node.Position; + } + } + + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + } +} diff --git a/src/SpatialLite.Osm/IEntityCollection.cs b/src/SpatialLite.Osm/IEntityCollection.cs index 3e85ec6..2e389cb 100644 --- a/src/SpatialLite.Osm/IEntityCollection.cs +++ b/src/SpatialLite.Osm/IEntityCollection.cs @@ -1,11 +1,13 @@ using System.Collections.Generic; -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Defines methods and properties for collection of the OSM entities where entities can be accessed by their ID and type. /// /// The type of the entitie in the collection. - public interface IEntityCollection : ICollection where T : IOsmEntity { + public interface IEntityCollection : ICollection where T : IOsmEntity + { /// /// Gets an entity with specific ID from the collection. /// diff --git a/src/SpatialLite.Osm/IEntityInfo.cs b/src/SpatialLite.Osm/IEntityInfo.cs index 55832d3..216baf8 100644 --- a/src/SpatialLite.Osm/IEntityInfo.cs +++ b/src/SpatialLite.Osm/IEntityInfo.cs @@ -1,7 +1,9 @@ -namespace SpatialLite.Osm { - /// - /// Defines common properties for nodes, ways and relations in serialized form. - /// - public interface IEntityInfo : IOsmEntity { - } -} +namespace SpatialLite.Osm +{ + /// + /// Defines common properties for nodes, ways and relations in serialized form. + /// + public interface IEntityInfo : IOsmEntity + { + } +} diff --git a/src/SpatialLite.Osm/IO/CompressionMode.cs b/src/SpatialLite.Osm/IO/CompressionMode.cs index 9271e24..87fb6e8 100644 --- a/src/SpatialLite.Osm/IO/CompressionMode.cs +++ b/src/SpatialLite.Osm/IO/CompressionMode.cs @@ -1,16 +1,18 @@ -namespace SpatialLite.Osm.IO { - /// - /// Defines compressions that can be used in the PBF format. - /// - public enum CompressionMode { - /// - /// No compresion is used. - /// - None, - - /// - /// Zlib compression. - /// - ZlibDeflate - } -} +namespace SpatialLite.Osm.IO +{ + /// + /// Defines compressions that can be used in the PBF format. + /// + public enum CompressionMode + { + /// + /// No compresion is used. + /// + None, + + /// + /// Zlib compression. + /// + ZlibDeflate + } +} diff --git a/src/SpatialLite.Osm/IO/IOsmReader.cs b/src/SpatialLite.Osm/IO/IOsmReader.cs index 28d6976..82ac06b 100644 --- a/src/SpatialLite.Osm/IO/IOsmReader.cs +++ b/src/SpatialLite.Osm/IO/IOsmReader.cs @@ -1,14 +1,16 @@ -using System; - -namespace SpatialLite.Osm.IO { - /// - /// Defines functions and properties for classes that can read OSM entities from various sources. - /// - public interface IOsmReader : IDisposable { - /// - /// Reads the next Osm entity from a source. - /// - /// IEntityInfo object with information about entity, or null if no more entities are available. - IEntityInfo Read(); - } -} \ No newline at end of file +using System; + +namespace SpatialLite.Osm.IO +{ + /// + /// Defines functions and properties for classes that can read OSM entities from various sources. + /// + public interface IOsmReader : IDisposable + { + /// + /// Reads the next Osm entity from a source. + /// + /// IEntityInfo object with information about entity, or null if no more entities are available. + IEntityInfo Read(); + } +} diff --git a/src/SpatialLite.Osm/IO/IOsmWriter.cs b/src/SpatialLite.Osm/IO/IOsmWriter.cs index 40d29ad..e6d0cc3 100644 --- a/src/SpatialLite.Osm/IO/IOsmWriter.cs +++ b/src/SpatialLite.Osm/IO/IOsmWriter.cs @@ -1,26 +1,28 @@ -using System; -using SpatialLite.Osm.Geometries; - -namespace SpatialLite.Osm.IO { - /// - /// Defines functions and properties for classes that can write OSM entities to various destinations. - /// - public interface IOsmWriter : IDisposable { - /// - /// Writes entity to the destination. - /// - /// The entity to write. - void Write(IOsmGeometry entity); - - /// - /// Writes entity info object to the target. - /// - /// The entity info object to wrirte. - void Write(IEntityInfo info); - - /// - /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. - /// - void Flush(); - } -} +using System; +using SpatialLite.Osm.Geometries; + +namespace SpatialLite.Osm.IO +{ + /// + /// Defines functions and properties for classes that can write OSM entities to various destinations. + /// + public interface IOsmWriter : IDisposable + { + /// + /// Writes entity to the destination. + /// + /// The entity to write. + void Write(IOsmGeometry entity); + + /// + /// Writes entity info object to the target. + /// + /// The entity info object to wrirte. + void Write(IEntityInfo info); + + /// + /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. + /// + void Flush(); + } +} diff --git a/src/SpatialLite.Osm/IO/OsmReaderSettings.cs b/src/SpatialLite.Osm/IO/OsmReaderSettings.cs index ea4957d..5f6c547 100644 --- a/src/SpatialLite.Osm/IO/OsmReaderSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmReaderSettings.cs @@ -1,39 +1,46 @@ -using System; - -namespace SpatialLite.Osm.IO { - /// - /// Contains settings that determine behaviour of OsmReaders. - /// - public class OsmReaderSettings { - - bool _readMetadata = true; - - /// - /// Initializes a new instance of the OsmReaderSettings class with default values. - /// - public OsmReaderSettings() { - this.ReadMetadata = true; - } - - /// - /// Gets a value indicating whether OsmReader should read and parse entity metadata. - /// - public bool ReadMetadata { - get { - return _readMetadata; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'ReadMetadata' property OsmReaderSettings is read-only."); - } - - _readMetadata = value; - } - } - - /// - /// Gets or sets value indicating whether properties of the current OsmReaderSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } - } -} +using System; + +namespace SpatialLite.Osm.IO +{ + /// + /// Contains settings that determine behaviour of OsmReaders. + /// + public class OsmReaderSettings + { + + bool _readMetadata = true; + + /// + /// Initializes a new instance of the OsmReaderSettings class with default values. + /// + public OsmReaderSettings() + { + this.ReadMetadata = true; + } + + /// + /// Gets a value indicating whether OsmReader should read and parse entity metadata. + /// + public bool ReadMetadata + { + get + { + return _readMetadata; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'ReadMetadata' property OsmReaderSettings is read-only."); + } + + _readMetadata = value; + } + } + + /// + /// Gets or sets value indicating whether properties of the current OsmReaderSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } + } +} diff --git a/src/SpatialLite.Osm/IO/OsmWriterSettings.cs b/src/SpatialLite.Osm/IO/OsmWriterSettings.cs index 40a715c..7dd04ad 100644 --- a/src/SpatialLite.Osm/IO/OsmWriterSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmWriterSettings.cs @@ -1,56 +1,67 @@ -using System; - -namespace SpatialLite.Osm.IO { - /// - /// Contains settings that determine behaviour of the OsmWriterWriter. - /// - public class OsmWriterSettings { - - bool _writeMetadata = true; - string _programName = "SpatialLITE"; - - /// - /// Initializes a new instance of the OsmReaderSettings class with default values. - /// - public OsmWriterSettings() { - this.WriteMetadata = true; - } - - /// - /// Gets or sets a value indicating whether OsmWriter should write entity metadata. - /// - public bool WriteMetadata { - get { - return _writeMetadata; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - OsmWriterSettings is read-only."); - } - - _writeMetadata = value; - } - } - - /// - /// Gets or sets the name of the program that will be save to the output file. - /// - public string ProgramName { - get { - return _programName; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'ProgramName' property - OsmWriterSettings is read-only."); - } - - _programName = value; - } - } - - /// - /// Gets or sets value indicating whether properties of the current OsmWriterSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } - } -} +using System; + +namespace SpatialLite.Osm.IO +{ + /// + /// Contains settings that determine behaviour of the OsmWriterWriter. + /// + public class OsmWriterSettings + { + + bool _writeMetadata = true; + string _programName = "SpatialLITE"; + + /// + /// Initializes a new instance of the OsmReaderSettings class with default values. + /// + public OsmWriterSettings() + { + this.WriteMetadata = true; + } + + /// + /// Gets or sets a value indicating whether OsmWriter should write entity metadata. + /// + public bool WriteMetadata + { + get + { + return _writeMetadata; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - OsmWriterSettings is read-only."); + } + + _writeMetadata = value; + } + } + + /// + /// Gets or sets the name of the program that will be save to the output file. + /// + public string ProgramName + { + get + { + return _programName; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'ProgramName' property - OsmWriterSettings is read-only."); + } + + _programName = value; + } + } + + /// + /// Gets or sets value indicating whether properties of the current OsmWriterSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } + } +} diff --git a/src/SpatialLite.Osm/IO/OsmXmlReader.cs b/src/SpatialLite.Osm/IO/OsmXmlReader.cs index 5c7d4e1..e56a08f 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReader.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReader.cs @@ -3,438 +3,505 @@ using System.IO; using Sys = System.Xml; -namespace SpatialLite.Osm.IO { +namespace SpatialLite.Osm.IO +{ /// /// Represents a OsmReader, that can read OSM entities saved in the XML format. /// - public class OsmXmlReader : IOsmReader { - - private bool _disposed = false; - private Sys.XmlReader _xmlReader; - - /// - /// Underlaying stream to read data from - /// - private Stream _input; - private bool _ownsInputStream = false; - - /// - /// Contains bool value indicating whether XmlReader is inside osm element - /// - private bool _insideOsm; - - /// - /// Initializes a new instance of the OsmXmlReader class that reads data from the specified file. - /// - /// Path to the .osm file. - /// The OsmReaderSettings object that determines behaviour of XmlReader. - public OsmXmlReader(string path, OsmXmlReaderSettings settings) { - _input = new FileStream(path, FileMode.Open, FileAccess.Read); - _ownsInputStream = true; - - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); - } - - /// - /// Initializes a new instance of the OsmXmlReader class that reads data from the specified stream. - /// - /// The stream with osm xml data. - /// The OsmReaderSettings object that determines behaviour of XmlReader. - public OsmXmlReader(Stream stream, OsmXmlReaderSettings settings) { - _input = stream; - - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); - } - - /// - /// Gets OsmReaderSettings object that contains properties which determine behaviour of the reader. - /// - public OsmXmlReaderSettings Settings { get; private set; } - - /// - /// Reads the next OSM entity from the stream. - /// - /// IEntityInfo object with information about entity read from the stream, or null if no more entities are available. - public IEntityInfo Read() { - IEntityInfo result = null; - - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement && result == null) { - switch (_xmlReader.Name) { - case "node": - result = this.ReadNode(); - break; - case "way": - result = this.ReadWay(); - break; - case "relation": - result = this.ReadRelation(); - break; - default: - _xmlReader.Read(); - break; - } - } - - return result; - } - - /// - /// Releases all resources used by the OsmXmlReader. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Reads Node from the currnt element in the _xmlReader. - /// - /// Information about parsed node. - private NodeInfo ReadNode() { - // id - string attId = _xmlReader.GetAttribute("id"); - if (attId == null) { - throw new Sys.XmlException("Attribute 'id' is missing."); - } - - var nodeId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); - - // latitude - string attLat = _xmlReader.GetAttribute("lat"); - if (attLat == null) { - throw new Sys.XmlException("Attribute 'lat' is missing."); - } - - double nodeLat = double.Parse(attLat, System.Globalization.CultureInfo.InvariantCulture); - - // longitude - string attLon = _xmlReader.GetAttribute("lon"); - if (attLon == null) { - throw new Sys.XmlException("Attribute 'lon'is missing."); - } - - double nodeLon = double.Parse(attLon, System.Globalization.CultureInfo.InvariantCulture); - - EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) { - additionalInfo = this.ReadMetadata(); - } - - NodeInfo result = new NodeInfo(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); - - if (_xmlReader.IsEmptyElement == false) { - _xmlReader.Read(); - - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) { - if (_xmlReader.NodeType == Sys.XmlNodeType.Element && _xmlReader.Name == "tag") { - result.Tags.Add(this.ReadTag()); - } - else { - _xmlReader.Skip(); - } - } - } - - _xmlReader.Skip(); - return result; - } - - /// - /// Reads Way from the currnt element in the _xmlReader. - /// - /// Information about parsed way. - private WayInfo ReadWay() { - string attId = _xmlReader.GetAttribute("id"); - if (attId == null) { - throw new Sys.XmlException("Attribute 'id' is missing."); - } - - var wayId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); - - EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) { - additionalInfo = this.ReadMetadata(); - } - - WayInfo way = new WayInfo(wayId, new TagsCollection(), new List(), additionalInfo); - - if (_xmlReader.IsEmptyElement == false) { - _xmlReader.Read(); - - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) { - switch (_xmlReader.NodeType) { - case Sys.XmlNodeType.Element: - switch (_xmlReader.Name) { - case "nd": - way.Nodes.Add(this.ReadWayNd()); - continue; - case "tag": - way.Tags.Add(this.ReadTag()); - continue; - default: - _xmlReader.Skip(); - continue; - } - - default: - _xmlReader.Skip(); - break; - } - } - } - - _xmlReader.Skip(); - return way; - } - - /// - /// Reads Node reference from the currnt Way element in the _xmlReader. - /// - /// Reference to the node. - private long ReadWayNd() { - string attRef = _xmlReader.GetAttribute("ref"); - if (string.IsNullOrEmpty(attRef)) { - throw new Sys.XmlException("Attribute 'ref' is missing."); - } - - var nodeId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); - - _xmlReader.Skip(); - - return nodeId; - } - - /// - /// Reads Relation from the currnt element in the _xmlReader. - /// - /// Information about parsed relation. - private RelationInfo ReadRelation() { - string attId = _xmlReader.GetAttribute("id"); - if (attId == null) { - throw new Sys.XmlException("Attribute 'id' is missing."); - } - - var relationId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); - - EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) { - additionalInfo = this.ReadMetadata(); - } - - RelationInfo relation = new RelationInfo(relationId, new TagsCollection(), new List(), additionalInfo); - - if (false == _xmlReader.IsEmptyElement) { - _xmlReader.Read(); - - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) { - switch (_xmlReader.NodeType) { - case Sys.XmlNodeType.Element: - switch (_xmlReader.Name) { - case "member": - relation.Members.Add(this.ReadRelationMember()); - continue; - case "tag": - relation.Tags.Add(this.ReadTag()); - continue; - default: - _xmlReader.Skip(); - continue; - } - - default: - _xmlReader.Skip(); - break; - } - } - } - - _xmlReader.Skip(); - - return relation; - } - - /// - /// Reads RelationMember from the current Relation in the _xmlReader. - /// - /// Information about parsed relation member - private RelationMemberInfo ReadRelationMember() { - string attType = _xmlReader.GetAttribute("type"); - if (string.IsNullOrEmpty(attType)) { - throw new Sys.XmlException("Attribute 'type' is missing."); - } - - string attRef = _xmlReader.GetAttribute("ref"); - if (string.IsNullOrEmpty(attRef)) { - throw new Sys.XmlException("Attribute 'ref' is missing."); - } - - var refId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); - - string attRole = _xmlReader.GetAttribute("role"); - - EntityType memberType; - switch (attType) { - case "node": - memberType = EntityType.Node; - break; - case "way": - memberType = EntityType.Way; - break; - case "relation": - memberType = EntityType.Relation; - break; - default: - throw new Sys.XmlException("Unknown relation member type"); - } - - _xmlReader.Skip(); - - return new RelationMemberInfo() { MemberType = memberType, Reference = refId, Role = attRole }; - } - - /// - /// Reads Tag from the current element in the _xmlReader. - /// - /// the parsed Tag. - private Tag ReadTag() { - string attK = _xmlReader.GetAttribute("k"); - if (attK == null) { - throw new Sys.XmlException("Attribute 'k' is missing."); - } - - string attV = _xmlReader.GetAttribute("v"); - if (attV == null) { - throw new Sys.XmlException("Attribute 'v' is missing."); - } - - _xmlReader.Skip(); - - return new Tag(attK, attV); - } - - /// - /// Reads metadata of the osm entity - /// - /// Metadata of the entity read from the reader. - private EntityMetadata ReadMetadata() { - EntityMetadata result = new EntityMetadata(); - - // version - string attVersion = _xmlReader.GetAttribute("version"); - if (attVersion == null) { - if (this.Settings.StrictMode) { - throw new Sys.XmlException("Attribute 'version' is missing."); - } - } - else { - result.Version = int.Parse(attVersion, System.Globalization.CultureInfo.InvariantCulture); - } - - // changeset - string attChangeset = _xmlReader.GetAttribute("changeset"); - if (attChangeset == null) { - if (this.Settings.StrictMode) { - throw new Sys.XmlException("Attribute 'changeset' is missing."); - } - } - else { - result.Changeset = int.Parse(attChangeset, System.Globalization.CultureInfo.InvariantCulture); - } - - // uid - string attUid = _xmlReader.GetAttribute("uid"); - if (attUid == null) { - if (this.Settings.StrictMode) { - throw new Sys.XmlException("Attribute 'uid' is missing."); - } - } - else { - result.Uid = int.Parse(attUid, System.Globalization.CultureInfo.InvariantCulture); - } - - // user - string attrUser = _xmlReader.GetAttribute("user"); - if (attrUser == null) { - if (this.Settings.StrictMode) { - throw new Sys.XmlException("Attribute 'user' is missing."); - } - } - else { - result.User = attrUser; - } - - // visible - string attVisible = _xmlReader.GetAttribute("visible"); - if (attVisible == null) { - if (this.Settings.StrictMode) { - result.Visible = true; - } - } - else { - result.Visible = bool.Parse(attVisible); - } - - // timestamp - string attTimestamp = _xmlReader.GetAttribute("timestamp"); - if (attTimestamp == null) { - if (this.Settings.StrictMode) { - throw new Sys.XmlException("Attribute 'timestamp' is missing."); - } - } - else { - result.Timestamp = DateTime.ParseExact(attTimestamp, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", System.Globalization.CultureInfo.InvariantCulture); - } - - return result; - } - - /// - /// Initializes internal properties - /// - private void InitializeReader() { - Sys.XmlReaderSettings xmlReaderSettings = new Sys.XmlReaderSettings(); - xmlReaderSettings.IgnoreComments = true; - xmlReaderSettings.IgnoreProcessingInstructions = true; - xmlReaderSettings.IgnoreWhitespace = true; - - _xmlReader = Sys.XmlReader.Create(_input, xmlReaderSettings); - - _xmlReader.Read(); - while (_xmlReader.EOF == false && _insideOsm == false) { - switch (_xmlReader.NodeType) { - case Sys.XmlNodeType.Element: - if (_xmlReader.Name != "osm") { - throw new Sys.XmlException("Invalid xml root element. Expected ."); - } - - _insideOsm = true; - break; - - default: - _xmlReader.Read(); - break; - } - } - } - - /// - /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!this._disposed) { - if (disposing) { - if (_ownsInputStream) { - _input.Dispose(); - } - } - - _disposed = true; - } - } - } + public class OsmXmlReader : IOsmReader + { + + private bool _disposed = false; + private Sys.XmlReader _xmlReader; + + /// + /// Underlaying stream to read data from + /// + private Stream _input; + private bool _ownsInputStream = false; + + /// + /// Contains bool value indicating whether XmlReader is inside osm element + /// + private bool _insideOsm; + + /// + /// Initializes a new instance of the OsmXmlReader class that reads data from the specified file. + /// + /// Path to the .osm file. + /// The OsmReaderSettings object that determines behaviour of XmlReader. + public OsmXmlReader(string path, OsmXmlReaderSettings settings) + { + _input = new FileStream(path, FileMode.Open, FileAccess.Read); + _ownsInputStream = true; + + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } + + /// + /// Initializes a new instance of the OsmXmlReader class that reads data from the specified stream. + /// + /// The stream with osm xml data. + /// The OsmReaderSettings object that determines behaviour of XmlReader. + public OsmXmlReader(Stream stream, OsmXmlReaderSettings settings) + { + _input = stream; + + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } + + /// + /// Gets OsmReaderSettings object that contains properties which determine behaviour of the reader. + /// + public OsmXmlReaderSettings Settings { get; private set; } + + /// + /// Reads the next OSM entity from the stream. + /// + /// IEntityInfo object with information about entity read from the stream, or null if no more entities are available. + public IEntityInfo Read() + { + IEntityInfo result = null; + + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement && result == null) + { + switch (_xmlReader.Name) + { + case "node": + result = this.ReadNode(); + break; + case "way": + result = this.ReadWay(); + break; + case "relation": + result = this.ReadRelation(); + break; + default: + _xmlReader.Read(); + break; + } + } + + return result; + } + + /// + /// Releases all resources used by the OsmXmlReader. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Reads Node from the currnt element in the _xmlReader. + /// + /// Information about parsed node. + private NodeInfo ReadNode() + { + // id + string attId = _xmlReader.GetAttribute("id"); + if (attId == null) + { + throw new Sys.XmlException("Attribute 'id' is missing."); + } + + var nodeId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); + + // latitude + string attLat = _xmlReader.GetAttribute("lat"); + if (attLat == null) + { + throw new Sys.XmlException("Attribute 'lat' is missing."); + } + + double nodeLat = double.Parse(attLat, System.Globalization.CultureInfo.InvariantCulture); + + // longitude + string attLon = _xmlReader.GetAttribute("lon"); + if (attLon == null) + { + throw new Sys.XmlException("Attribute 'lon'is missing."); + } + + double nodeLon = double.Parse(attLon, System.Globalization.CultureInfo.InvariantCulture); + + EntityMetadata additionalInfo = null; + if (this.Settings.ReadMetadata) + { + additionalInfo = this.ReadMetadata(); + } + + NodeInfo result = new NodeInfo(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); + + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); + + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + { + if (_xmlReader.NodeType == Sys.XmlNodeType.Element && _xmlReader.Name == "tag") + { + result.Tags.Add(this.ReadTag()); + } + else + { + _xmlReader.Skip(); + } + } + } + + _xmlReader.Skip(); + return result; + } + + /// + /// Reads Way from the currnt element in the _xmlReader. + /// + /// Information about parsed way. + private WayInfo ReadWay() + { + string attId = _xmlReader.GetAttribute("id"); + if (attId == null) + { + throw new Sys.XmlException("Attribute 'id' is missing."); + } + + var wayId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); + + EntityMetadata additionalInfo = null; + if (this.Settings.ReadMetadata) + { + additionalInfo = this.ReadMetadata(); + } + + WayInfo way = new WayInfo(wayId, new TagsCollection(), new List(), additionalInfo); + + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); + + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + { + switch (_xmlReader.NodeType) + { + case Sys.XmlNodeType.Element: + switch (_xmlReader.Name) + { + case "nd": + way.Nodes.Add(this.ReadWayNd()); + continue; + case "tag": + way.Tags.Add(this.ReadTag()); + continue; + default: + _xmlReader.Skip(); + continue; + } + + default: + _xmlReader.Skip(); + break; + } + } + } + + _xmlReader.Skip(); + return way; + } + + /// + /// Reads Node reference from the currnt Way element in the _xmlReader. + /// + /// Reference to the node. + private long ReadWayNd() + { + string attRef = _xmlReader.GetAttribute("ref"); + if (string.IsNullOrEmpty(attRef)) + { + throw new Sys.XmlException("Attribute 'ref' is missing."); + } + + var nodeId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); + + _xmlReader.Skip(); + + return nodeId; + } + + /// + /// Reads Relation from the currnt element in the _xmlReader. + /// + /// Information about parsed relation. + private RelationInfo ReadRelation() + { + string attId = _xmlReader.GetAttribute("id"); + if (attId == null) + { + throw new Sys.XmlException("Attribute 'id' is missing."); + } + + var relationId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); + + EntityMetadata additionalInfo = null; + if (this.Settings.ReadMetadata) + { + additionalInfo = this.ReadMetadata(); + } + + RelationInfo relation = new RelationInfo(relationId, new TagsCollection(), new List(), additionalInfo); + + if (false == _xmlReader.IsEmptyElement) + { + _xmlReader.Read(); + + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + { + switch (_xmlReader.NodeType) + { + case Sys.XmlNodeType.Element: + switch (_xmlReader.Name) + { + case "member": + relation.Members.Add(this.ReadRelationMember()); + continue; + case "tag": + relation.Tags.Add(this.ReadTag()); + continue; + default: + _xmlReader.Skip(); + continue; + } + + default: + _xmlReader.Skip(); + break; + } + } + } + + _xmlReader.Skip(); + + return relation; + } + + /// + /// Reads RelationMember from the current Relation in the _xmlReader. + /// + /// Information about parsed relation member + private RelationMemberInfo ReadRelationMember() + { + string attType = _xmlReader.GetAttribute("type"); + if (string.IsNullOrEmpty(attType)) + { + throw new Sys.XmlException("Attribute 'type' is missing."); + } + + string attRef = _xmlReader.GetAttribute("ref"); + if (string.IsNullOrEmpty(attRef)) + { + throw new Sys.XmlException("Attribute 'ref' is missing."); + } + + var refId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); + + string attRole = _xmlReader.GetAttribute("role"); + + EntityType memberType; + switch (attType) + { + case "node": + memberType = EntityType.Node; + break; + case "way": + memberType = EntityType.Way; + break; + case "relation": + memberType = EntityType.Relation; + break; + default: + throw new Sys.XmlException("Unknown relation member type"); + } + + _xmlReader.Skip(); + + return new RelationMemberInfo() { MemberType = memberType, Reference = refId, Role = attRole }; + } + + /// + /// Reads Tag from the current element in the _xmlReader. + /// + /// the parsed Tag. + private Tag ReadTag() + { + string attK = _xmlReader.GetAttribute("k"); + if (attK == null) + { + throw new Sys.XmlException("Attribute 'k' is missing."); + } + + string attV = _xmlReader.GetAttribute("v"); + if (attV == null) + { + throw new Sys.XmlException("Attribute 'v' is missing."); + } + + _xmlReader.Skip(); + + return new Tag(attK, attV); + } + + /// + /// Reads metadata of the osm entity + /// + /// Metadata of the entity read from the reader. + private EntityMetadata ReadMetadata() + { + EntityMetadata result = new EntityMetadata(); + + // version + string attVersion = _xmlReader.GetAttribute("version"); + if (attVersion == null) + { + if (this.Settings.StrictMode) + { + throw new Sys.XmlException("Attribute 'version' is missing."); + } + } + else + { + result.Version = int.Parse(attVersion, System.Globalization.CultureInfo.InvariantCulture); + } + + // changeset + string attChangeset = _xmlReader.GetAttribute("changeset"); + if (attChangeset == null) + { + if (this.Settings.StrictMode) + { + throw new Sys.XmlException("Attribute 'changeset' is missing."); + } + } + else + { + result.Changeset = int.Parse(attChangeset, System.Globalization.CultureInfo.InvariantCulture); + } + + // uid + string attUid = _xmlReader.GetAttribute("uid"); + if (attUid == null) + { + if (this.Settings.StrictMode) + { + throw new Sys.XmlException("Attribute 'uid' is missing."); + } + } + else + { + result.Uid = int.Parse(attUid, System.Globalization.CultureInfo.InvariantCulture); + } + + // user + string attrUser = _xmlReader.GetAttribute("user"); + if (attrUser == null) + { + if (this.Settings.StrictMode) + { + throw new Sys.XmlException("Attribute 'user' is missing."); + } + } + else + { + result.User = attrUser; + } + + // visible + string attVisible = _xmlReader.GetAttribute("visible"); + if (attVisible == null) + { + if (this.Settings.StrictMode) + { + result.Visible = true; + } + } + else + { + result.Visible = bool.Parse(attVisible); + } + + // timestamp + string attTimestamp = _xmlReader.GetAttribute("timestamp"); + if (attTimestamp == null) + { + if (this.Settings.StrictMode) + { + throw new Sys.XmlException("Attribute 'timestamp' is missing."); + } + } + else + { + result.Timestamp = DateTime.ParseExact(attTimestamp, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", System.Globalization.CultureInfo.InvariantCulture); + } + + return result; + } + + /// + /// Initializes internal properties + /// + private void InitializeReader() + { + Sys.XmlReaderSettings xmlReaderSettings = new Sys.XmlReaderSettings(); + xmlReaderSettings.IgnoreComments = true; + xmlReaderSettings.IgnoreProcessingInstructions = true; + xmlReaderSettings.IgnoreWhitespace = true; + + _xmlReader = Sys.XmlReader.Create(_input, xmlReaderSettings); + + _xmlReader.Read(); + while (_xmlReader.EOF == false && _insideOsm == false) + { + switch (_xmlReader.NodeType) + { + case Sys.XmlNodeType.Element: + if (_xmlReader.Name != "osm") + { + throw new Sys.XmlException("Invalid xml root element. Expected ."); + } + + _insideOsm = true; + break; + + default: + _xmlReader.Read(); + break; + } + } + } + + /// + /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (disposing) + { + if (_ownsInputStream) + { + _input.Dispose(); + } + } + + _disposed = true; + } + } + } } diff --git a/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs b/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs index 31b4ddb..797901f 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs @@ -1,35 +1,41 @@ -using System; - -namespace SpatialLite.Osm.IO { - /// - /// Contains settings that determine behaviour of the OsmXmlReader. - /// - public class OsmXmlReaderSettings : OsmReaderSettings { - - private bool _strictMode = true; - - /// - /// Gets or sets a value indicating whether OsmXmlReader should run in strct mode. - /// - /// - /// - /// Default value is true. - /// - /// - /// In strict mode missing attributes for entity metadata causes OsmXmlReader to throw an exception. If strict mode is off and some metadata attributes are missing, missing attributes are set to their default values. - /// - /// - public bool StrictMode { - get { - return _strictMode; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'StrictMode' property - OsmXmlReaderSettings is read-only."); - } - - _strictMode = value; - } - } - } -} +using System; + +namespace SpatialLite.Osm.IO +{ + /// + /// Contains settings that determine behaviour of the OsmXmlReader. + /// + public class OsmXmlReaderSettings : OsmReaderSettings + { + + private bool _strictMode = true; + + /// + /// Gets or sets a value indicating whether OsmXmlReader should run in strct mode. + /// + /// + /// + /// Default value is true. + /// + /// + /// In strict mode missing attributes for entity metadata causes OsmXmlReader to throw an exception. If strict mode is off and some metadata attributes are missing, missing attributes are set to their default values. + /// + /// + public bool StrictMode + { + get + { + return _strictMode; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'StrictMode' property - OsmXmlReaderSettings is read-only."); + } + + _strictMode = value; + } + } + } +} diff --git a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs index 2ae388b..e482bc2 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs @@ -1,267 +1,303 @@ -using System; -using System.Text; -using System.IO; -using System.Xml; - -using SpatialLite.Osm.Geometries; - -namespace SpatialLite.Osm.IO { - /// - /// Represents an IOsmWriter, that can write OSM entities to XML format. - /// - public class OsmXmlWriter : IOsmWriter { - - private System.Globalization.CultureInfo _culture = System.Globalization.CultureInfo.InvariantCulture; - private Stream _output; - private bool _ownsOutputStream; - - private XmlWriter _writer; - private bool _isInsideOsm = false; - private bool _disposed = false; - - // underlaying stream writer for writing to files - private StreamWriter _streamWriter; - - /// - /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified stream. - /// - /// The Stream to write OSM entities to. - /// The settings defining behaviour of the writer. - public OsmXmlWriter(Stream stream, OsmWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; - - _output = stream; - _ownsOutputStream = false; - - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; - - _writer = XmlWriter.Create(stream, writerSetting); - } - - /// - /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified file. - /// - /// Path to the OSM file. - /// The settings defining behaviour of the writer. - /// If the file exists, it is overwritten, otherwise, a new file is created. - public OsmXmlWriter(string path, OsmWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; - - _output = new FileStream(path, FileMode.Create, FileAccess.Write); - _ownsOutputStream = true; - - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; - - _streamWriter = new StreamWriter(_output, new UTF8Encoding(false)); - _writer = XmlWriter.Create(_streamWriter, writerSetting); - } - - /// - /// Gets settings used by this XmlWriter. - /// - public OsmWriterSettings Settings { get; private set; } - - /// - /// Releases all resources used by the OsmXmlWriter. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Writes specified entity object in XML format to the underlaying stream. - /// - /// Entity to write. - public void Write(IOsmGeometry entity) { - if (entity == null) { - throw new ArgumentNullException("Entity cannot be null", "entity"); - } - - if (_isInsideOsm == false) { - this.StartDocument(); - } - - switch (entity.EntityType) { - case EntityType.Node: this.Write(new NodeInfo((Node)entity)); break; - case EntityType.Way: this.Write(new WayInfo((Way)entity)); break; - case EntityType.Relation: this.Write(new RelationInfo((Relation)entity)); break; - } - } - - /// - /// Writes specified entity data-transfer object in XML format to the underlaying stream. - /// - /// Entity data-transfer object to write. - public void Write(IEntityInfo info) { - if (this.Settings.WriteMetadata) { - if (info.Metadata == null) { - throw new ArgumentException("Entity doesn't contain metadata object, but writer was created with WriteMetadata setting."); - } - } - - if (_isInsideOsm == false) { - this.StartDocument(); - } - - switch (info.EntityType) { - case EntityType.Node: this.WriteNode((NodeInfo)info); break; - case EntityType.Way: this.WriteWay((WayInfo)info); break; - case EntityType.Relation: this.WriteRelation((RelationInfo)info); break; - } - } - - /// - /// Causes any buffered data to be written to the underlaying storage. - /// - public void Flush() { - _writer.Flush(); - } - - /// - /// Writes <osm> start element to the output stream. - /// - private void StartDocument() { - _writer.WriteStartElement("osm"); - if (string.IsNullOrEmpty(this.Settings.ProgramName) == false) { - _writer.WriteAttributeString("generator", this.Settings.ProgramName); - } - - _isInsideOsm = true; - } - - /// - /// Writes <osm> end element to the output stream. - /// - private void EndDocument() { - _writer.WriteEndElement(); - _isInsideOsm = false; - } - - /// - /// Writes node to the output streram. - /// - /// The Node to be written. - private void WriteNode(NodeInfo info) { - _writer.WriteStartElement("node"); - _writer.WriteAttributeString("lon", info.Longitude.ToString(_culture)); - _writer.WriteAttributeString("lat", info.Latitude.ToString(_culture)); - _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - - if (this.Settings.WriteMetadata) { - this.WriteMetadata(info.Metadata); - } - - this.WriteTags(info.Tags); - - _writer.WriteEndElement(); - } - - /// - /// Writes way to the output stream - /// - /// The Way to be written - private void WriteWay(WayInfo info) { - _writer.WriteStartElement("way"); - _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - - if (this.Settings.WriteMetadata) { - this.WriteMetadata(info.Metadata); - } - - this.WriteTags(info.Tags); - - for (int i = 0; i < info.Nodes.Count; i++) { - _writer.WriteStartElement("nd"); - _writer.WriteAttributeString("ref", info.Nodes[i].ToString(_culture)); - _writer.WriteEndElement(); - } - - _writer.WriteEndElement(); - } - - /// - /// Writes relation to the output stream. - /// - /// The relation to be written. - private void WriteRelation(RelationInfo info) { - _writer.WriteStartElement("relation"); - _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - - if (this.Settings.WriteMetadata) { - this.WriteMetadata(info.Metadata); - } - - this.WriteTags(info.Tags); - - for (int i = 0; i < info.Members.Count; i++) { - _writer.WriteStartElement("member"); - _writer.WriteAttributeString("ref", info.Members[i].Reference.ToString(_culture)); - _writer.WriteAttributeString("role", info.Members[i].Role); - _writer.WriteAttributeString("type", info.Members[i].MemberType.ToString().ToLower()); - _writer.WriteEndElement(); - } - - _writer.WriteEndElement(); - } - - /// - /// Writes collection of tags to the output stream. - /// - /// The collection of tags to write. - private void WriteTags(TagsCollection tags) { - foreach (var tag in tags) { - _writer.WriteStartElement("tag"); - _writer.WriteAttributeString("k", tag.Key); - _writer.WriteAttributeString("v", tag.Value); - _writer.WriteEndElement(); - } - } - - /// - /// Writes detailed attributes of the OSM entity. - /// - /// The entity whose attributes to be written. - private void WriteMetadata(EntityMetadata medatata) { - _writer.WriteAttributeString("version", medatata.Version.ToString(_culture)); - _writer.WriteAttributeString("changeset", medatata.Changeset.ToString(_culture)); - - //HACK ? write only valid user data - if (medatata.Uid > 0) { - _writer.WriteAttributeString("uid", medatata.Uid.ToString(_culture)); - _writer.WriteAttributeString("user", medatata.User); - } - - _writer.WriteAttributeString("visible", medatata.Visible.ToString().ToLower()); - _writer.WriteAttributeString("timestamp", medatata.Timestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'")); - } - - /// - /// Releases the unmanaged resources used by the OsmXmlWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!this._disposed) { - if (_writer != null) { - _writer.Dispose(); - } - - if (disposing) { - if (_streamWriter != null) { - _streamWriter.Dispose(); - } - - if (_ownsOutputStream) { - _output.Dispose(); - } - } - - _disposed = true; - } - } - } -} +using System; +using System.Text; +using System.IO; +using System.Xml; + +using SpatialLite.Osm.Geometries; + +namespace SpatialLite.Osm.IO +{ + /// + /// Represents an IOsmWriter, that can write OSM entities to XML format. + /// + public class OsmXmlWriter : IOsmWriter + { + + private System.Globalization.CultureInfo _culture = System.Globalization.CultureInfo.InvariantCulture; + private Stream _output; + private bool _ownsOutputStream; + + private XmlWriter _writer; + private bool _isInsideOsm = false; + private bool _disposed = false; + + // underlaying stream writer for writing to files + private StreamWriter _streamWriter; + + /// + /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified stream. + /// + /// The Stream to write OSM entities to. + /// The settings defining behaviour of the writer. + public OsmXmlWriter(Stream stream, OsmWriterSettings settings) + { + this.Settings = settings; + this.Settings.IsReadOnly = true; + + _output = stream; + _ownsOutputStream = false; + + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; + + _writer = XmlWriter.Create(stream, writerSetting); + } + + /// + /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified file. + /// + /// Path to the OSM file. + /// The settings defining behaviour of the writer. + /// If the file exists, it is overwritten, otherwise, a new file is created. + public OsmXmlWriter(string path, OsmWriterSettings settings) + { + this.Settings = settings; + this.Settings.IsReadOnly = true; + + _output = new FileStream(path, FileMode.Create, FileAccess.Write); + _ownsOutputStream = true; + + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; + + _streamWriter = new StreamWriter(_output, new UTF8Encoding(false)); + _writer = XmlWriter.Create(_streamWriter, writerSetting); + } + + /// + /// Gets settings used by this XmlWriter. + /// + public OsmWriterSettings Settings { get; private set; } + + /// + /// Releases all resources used by the OsmXmlWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Writes specified entity object in XML format to the underlaying stream. + /// + /// Entity to write. + public void Write(IOsmGeometry entity) + { + if (entity == null) + { + throw new ArgumentNullException(nameof(entity), "Entity cannot be null"); + } + + if (_isInsideOsm == false) + { + this.StartDocument(); + } + + switch (entity.EntityType) + { + case EntityType.Node: this.Write(new NodeInfo((Node)entity)); break; + case EntityType.Way: this.Write(new WayInfo((Way)entity)); break; + case EntityType.Relation: this.Write(new RelationInfo((Relation)entity)); break; + } + } + + /// + /// Writes specified entity data-transfer object in XML format to the underlaying stream. + /// + /// Entity data-transfer object to write. + public void Write(IEntityInfo info) + { + if (this.Settings.WriteMetadata) + { + if (info.Metadata == null) + { + throw new ArgumentException("Entity doesn't contain metadata object, but writer was created with WriteMetadata setting."); + } + } + + if (_isInsideOsm == false) + { + this.StartDocument(); + } + + switch (info.EntityType) + { + case EntityType.Node: this.WriteNode((NodeInfo)info); break; + case EntityType.Way: this.WriteWay((WayInfo)info); break; + case EntityType.Relation: this.WriteRelation((RelationInfo)info); break; + } + } + + /// + /// Causes any buffered data to be written to the underlaying storage. + /// + public void Flush() + { + _writer.Flush(); + } + + /// + /// Writes <osm> start element to the output stream. + /// + private void StartDocument() + { + _writer.WriteStartElement("osm"); + if (string.IsNullOrEmpty(this.Settings.ProgramName) == false) + { + _writer.WriteAttributeString("generator", this.Settings.ProgramName); + } + + _isInsideOsm = true; + } + + /// + /// Writes <osm> end element to the output stream. + /// + private void EndDocument() + { + _writer.WriteEndElement(); + _isInsideOsm = false; + } + + /// + /// Writes node to the output streram. + /// + /// The Node to be written. + private void WriteNode(NodeInfo info) + { + _writer.WriteStartElement("node"); + _writer.WriteAttributeString("lon", info.Longitude.ToString(_culture)); + _writer.WriteAttributeString("lat", info.Latitude.ToString(_culture)); + _writer.WriteAttributeString("id", info.ID.ToString(_culture)); + + if (this.Settings.WriteMetadata) + { + this.WriteMetadata(info.Metadata); + } + + this.WriteTags(info.Tags); + + _writer.WriteEndElement(); + } + + /// + /// Writes way to the output stream + /// + /// The Way to be written + private void WriteWay(WayInfo info) + { + _writer.WriteStartElement("way"); + _writer.WriteAttributeString("id", info.ID.ToString(_culture)); + + if (this.Settings.WriteMetadata) + { + this.WriteMetadata(info.Metadata); + } + + this.WriteTags(info.Tags); + + for (int i = 0; i < info.Nodes.Count; i++) + { + _writer.WriteStartElement("nd"); + _writer.WriteAttributeString("ref", info.Nodes[i].ToString(_culture)); + _writer.WriteEndElement(); + } + + _writer.WriteEndElement(); + } + + /// + /// Writes relation to the output stream. + /// + /// The relation to be written. + private void WriteRelation(RelationInfo info) + { + _writer.WriteStartElement("relation"); + _writer.WriteAttributeString("id", info.ID.ToString(_culture)); + + if (this.Settings.WriteMetadata) + { + this.WriteMetadata(info.Metadata); + } + + this.WriteTags(info.Tags); + + for (int i = 0; i < info.Members.Count; i++) + { + _writer.WriteStartElement("member"); + _writer.WriteAttributeString("ref", info.Members[i].Reference.ToString(_culture)); + _writer.WriteAttributeString("role", info.Members[i].Role); + _writer.WriteAttributeString("type", info.Members[i].MemberType.ToString().ToLower()); + _writer.WriteEndElement(); + } + + _writer.WriteEndElement(); + } + + /// + /// Writes collection of tags to the output stream. + /// + /// The collection of tags to write. + private void WriteTags(TagsCollection tags) + { + foreach (var tag in tags) + { + _writer.WriteStartElement("tag"); + _writer.WriteAttributeString("k", tag.Key); + _writer.WriteAttributeString("v", tag.Value); + _writer.WriteEndElement(); + } + } + + /// + /// Writes detailed attributes of the OSM entity. + /// + /// The entity whose attributes to be written. + private void WriteMetadata(EntityMetadata medatata) + { + _writer.WriteAttributeString("version", medatata.Version.ToString(_culture)); + _writer.WriteAttributeString("changeset", medatata.Changeset.ToString(_culture)); + + //HACK ? write only valid user data + if (medatata.Uid > 0) + { + _writer.WriteAttributeString("uid", medatata.Uid.ToString(_culture)); + _writer.WriteAttributeString("user", medatata.User); + } + + _writer.WriteAttributeString("visible", medatata.Visible.ToString().ToLower()); + _writer.WriteAttributeString("timestamp", medatata.Timestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'")); + } + + /// + /// Releases the unmanaged resources used by the OsmXmlWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (_writer != null) + { + _writer.Dispose(); + } + + if (disposing) + { + if (_streamWriter != null) + { + _streamWriter.Dispose(); + } + + if (_ownsOutputStream) + { + _output.Dispose(); + } + } + + _disposed = true; + } + } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/Blob.cs b/src/SpatialLite.Osm/IO/Pbf/Blob.cs index 626a9c0..e9558bf 100644 --- a/src/SpatialLite.Osm/IO/Pbf/Blob.cs +++ b/src/SpatialLite.Osm/IO/Pbf/Blob.cs @@ -1,29 +1,31 @@ -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represents content of the file block. - /// - [ProtoContract] - internal class Blob { - - /// - /// Gets or sets blob content if no compression is used. - /// - [ProtoMember(1, IsRequired = false, Name = "raw")] - public byte[] Raw { get; set; } - - /// - /// Gets or sets uncopressed size of the blob content if ZLIB compression is used. - /// - [ProtoMember(2, IsRequired = false, Name = "raw_size")] - public int? RawSize { get; set; } - - /// - /// Gets or sets blob content if ZLIB compression is used. - /// - [ProtoMember(3, IsRequired = false, Name = "zlib_data")] - public byte[] ZlibData { get; set; } - - } -} +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represents content of the file block. + /// + [ProtoContract] + internal class Blob + { + + /// + /// Gets or sets blob content if no compression is used. + /// + [ProtoMember(1, IsRequired = false, Name = "raw")] + public byte[] Raw { get; set; } + + /// + /// Gets or sets uncopressed size of the blob content if ZLIB compression is used. + /// + [ProtoMember(2, IsRequired = false, Name = "raw_size")] + public int? RawSize { get; set; } + + /// + /// Gets or sets blob content if ZLIB compression is used. + /// + [ProtoMember(3, IsRequired = false, Name = "zlib_data")] + public byte[] ZlibData { get; set; } + + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs b/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs index 9321d01..7384d9f 100644 --- a/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs +++ b/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs @@ -1,32 +1,34 @@ -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represents header of the fileblock. - /// - [ProtoContract] - internal class BlobHeader { - - /// - /// Gets or sets type of the fileblock. - /// - /// - /// Supported values are 'OSMHeader' and 'OSMData'. - /// S - [ProtoMember(1, IsRequired = true, Name = "type")] - public string Type { get; set; } - - /// - /// Gets or sets an arbitrary blob that may include metadata about the following blob. For future use. - /// - [ProtoMember(2, IsRequired = false, Name = "indexdata")] - public byte[] IndexData { get; set; } - - /// - /// Gets or sets size of the subsequent Blob message. - /// - [ProtoMember(3, IsRequired = true, Name = "datasize")] - public int DataSize { get; set; } - - } -} +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represents header of the fileblock. + /// + [ProtoContract] + internal class BlobHeader + { + + /// + /// Gets or sets type of the fileblock. + /// + /// + /// Supported values are 'OSMHeader' and 'OSMData'. + /// S + [ProtoMember(1, IsRequired = true, Name = "type")] + public string Type { get; set; } + + /// + /// Gets or sets an arbitrary blob that may include metadata about the following blob. For future use. + /// + [ProtoMember(2, IsRequired = false, Name = "indexdata")] + public byte[] IndexData { get; set; } + + /// + /// Gets or sets size of the subsequent Blob message. + /// + [ProtoMember(3, IsRequired = true, Name = "datasize")] + public int DataSize { get; set; } + + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs index 6b48752..d3a7f47 100644 --- a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs +++ b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs @@ -1,152 +1,174 @@ -using System.Collections.Generic; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Stores entities to be written to output PBF. - /// - /// The type of entities to store. - internal class EntityInfoBuffer : IStringTableBuilder, IEnumerable where T : class, IEntityInfo { - - private List _storage = null; - private Dictionary _stringTable; - - private int _stringTableSize = 0; - private int _estimatedEntityDataSize = 0; - private bool _writeMetadata; - - /// - /// Initializes a new instance of the EntityInfoBuffer class. - /// - /// A value indicating whether writer is writing entity metadata (neccessary for size estimation). - public EntityInfoBuffer(bool writeMetadata) { - _storage = new List(10000); - _stringTable = new Dictionary(); - - _stringTableSize = 0; - _estimatedEntityDataSize = 0; - - _writeMetadata = writeMetadata; - - //add dummy value to the string table to get rid of 0 index - this.GetStringIndex(string.Empty); - } - - /// - /// Get maximal estimated size of data in buffer. - /// - /// - /// Actual size of the data should be smaller because proto buffer library compresess data. - /// - public int EstimatedMaxSize { - get { - return _estimatedEntityDataSize + _stringTableSize; - } - } - - /// - /// Gets number of entities in the buffer. - /// - public int Count { - get { - return _storage.Count; - } - } - - /// - /// Adds specific entity to buffer - /// - /// The entity to add - public void Add(T item) { - _storage.Add(item); - - foreach (var tag in item.Tags) { - this.GetStringIndex(tag.Key); - this.GetStringIndex(tag.Value); - - _estimatedEntityDataSize += 8; - } - - if (item.EntityType == EntityType.Node) { - _estimatedEntityDataSize += 3 * 8; - } - else if (item.EntityType == EntityType.Way) { - WayInfo wayItem = item as WayInfo; - _estimatedEntityDataSize += 8 + wayItem.Nodes.Count * 8; - } - else if (item.EntityType == EntityType.Relation) { - RelationInfo relationItem = item as RelationInfo; - _estimatedEntityDataSize += 8 + relationItem.Members.Count * 12; - } - - if (_writeMetadata) { - _estimatedEntityDataSize += 28; - } - } - - /// - /// Remove all data from buffer. - /// - public void Clear() { - _storage.Clear(); - _stringTable.Clear(); - - _estimatedEntityDataSize = 0; - _stringTableSize = 0; - - //add dummy value to the string table to get rid of 0 index - this.GetStringIndex(string.Empty); - } - - /// - /// Gets index of the string in StringTable being constructed. - /// - /// The string to locate in StringTable. - /// Index of the string in the StringTable. - public uint GetStringIndex(string str) { - if (_stringTable.ContainsKey(str)) { - return _stringTable[str]; - } - else { - uint index = (uint)_stringTable.Count; - _stringTable.Add(str, index); - _stringTableSize += str.Length; - - return index; - } - } - - /// - /// Creates a StringTable object with data from StringTable object. - /// - /// The StringTable object with data from the buffer. - public StringTable BuildStringTable() { - StringTable result = new StringTable(); - result.Storage = new List(_stringTable.Count); - for (int i = 0; i < _stringTable.Count; i++) { - result.Storage.Add(new byte[0]); - } - - foreach (var item in _stringTable) { - result[item.Value] = item.Key; - } - - return result; - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator<T> that can be used to iterate through the collection. - public IEnumerator GetEnumerator() { - return _storage.GetEnumerator(); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return _storage.GetEnumerator(); - } - } -} +using System.Collections.Generic; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Stores entities to be written to output PBF. + /// + /// The type of entities to store. + internal class EntityInfoBuffer : IStringTableBuilder, IEnumerable where T : class, IEntityInfo + { + + private List _storage = null; + private Dictionary _stringTable; + + private int _stringTableSize = 0; + private int _estimatedEntityDataSize = 0; + private bool _writeMetadata; + + /// + /// Initializes a new instance of the EntityInfoBuffer class. + /// + /// A value indicating whether writer is writing entity metadata (neccessary for size estimation). + public EntityInfoBuffer(bool writeMetadata) + { + _storage = new List(10000); + _stringTable = new Dictionary(); + + _stringTableSize = 0; + _estimatedEntityDataSize = 0; + + _writeMetadata = writeMetadata; + + //add dummy value to the string table to get rid of 0 index + this.GetStringIndex(string.Empty); + } + + /// + /// Get maximal estimated size of data in buffer. + /// + /// + /// Actual size of the data should be smaller because proto buffer library compresess data. + /// + public int EstimatedMaxSize + { + get + { + return _estimatedEntityDataSize + _stringTableSize; + } + } + + /// + /// Gets number of entities in the buffer. + /// + public int Count + { + get + { + return _storage.Count; + } + } + + /// + /// Adds specific entity to buffer + /// + /// The entity to add + public void Add(T item) + { + _storage.Add(item); + + foreach (var tag in item.Tags) + { + this.GetStringIndex(tag.Key); + this.GetStringIndex(tag.Value); + + _estimatedEntityDataSize += 8; + } + + if (item.EntityType == EntityType.Node) + { + _estimatedEntityDataSize += 3 * 8; + } + else if (item.EntityType == EntityType.Way) + { + WayInfo wayItem = item as WayInfo; + _estimatedEntityDataSize += 8 + wayItem.Nodes.Count * 8; + } + else if (item.EntityType == EntityType.Relation) + { + RelationInfo relationItem = item as RelationInfo; + _estimatedEntityDataSize += 8 + relationItem.Members.Count * 12; + } + + if (_writeMetadata) + { + _estimatedEntityDataSize += 28; + } + } + + /// + /// Remove all data from buffer. + /// + public void Clear() + { + _storage.Clear(); + _stringTable.Clear(); + + _estimatedEntityDataSize = 0; + _stringTableSize = 0; + + //add dummy value to the string table to get rid of 0 index + this.GetStringIndex(string.Empty); + } + + /// + /// Gets index of the string in StringTable being constructed. + /// + /// The string to locate in StringTable. + /// Index of the string in the StringTable. + public uint GetStringIndex(string str) + { + if (_stringTable.TryGetValue(str, out uint value)) + { + return value; + } + else + { + uint index = (uint)_stringTable.Count; + _stringTable.Add(str, index); + _stringTableSize += str.Length; + + return index; + } + } + + /// + /// Creates a StringTable object with data from StringTable object. + /// + /// The StringTable object with data from the buffer. + public StringTable BuildStringTable() + { + StringTable result = new StringTable(); + result.Storage = new List(_stringTable.Count); + for (int i = 0; i < _stringTable.Count; i++) + { + result.Storage.Add(new byte[0]); + } + + foreach (var item in _stringTable) + { + result[item.Value] = item.Key; + } + + return result; + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator<T> that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return _storage.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return _storage.GetEnumerator(); + } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs b/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs index d4617e0..177c262 100644 --- a/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs +++ b/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs @@ -1,35 +1,37 @@ -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represents rectangular envelope of data. - /// - [ProtoContract(Name = "HeaderBBox")] - internal class HeaderBBox { - - /// - /// Gets or sets Bootom boundary of the BBox. - /// - [ProtoMember(4, Name = "bottom", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Bottom { get; set; } - - /// - /// Gets or sets Left boundary of the BBox. - /// - [ProtoMember(1, Name = "left", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Left { get; set; } - - /// - /// Gets or sets Right boundary of the BBox. - /// - [ProtoMember(2, Name = "right", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Right { get; set; } - - /// - /// Gets or sets Top boundary of the BBox. - /// - [ProtoMember(3, Name = "top", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Top { get; set; } - - } -} +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represents rectangular envelope of data. + /// + [ProtoContract(Name = "HeaderBBox")] + internal class HeaderBBox + { + + /// + /// Gets or sets Bootom boundary of the BBox. + /// + [ProtoMember(4, Name = "bottom", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Bottom { get; set; } + + /// + /// Gets or sets Left boundary of the BBox. + /// + [ProtoMember(1, Name = "left", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Left { get; set; } + + /// + /// Gets or sets Right boundary of the BBox. + /// + [ProtoMember(2, Name = "right", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Right { get; set; } + + /// + /// Gets or sets Top boundary of the BBox. + /// + [ProtoMember(3, Name = "top", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Top { get; set; } + + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs b/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs index 3090bd1..915e2e7 100644 --- a/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs +++ b/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs @@ -1,19 +1,21 @@ -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Defines function for object that can be used to build StringTables. - /// - internal interface IStringTableBuilder { - /// - /// Gets index of the string in StringTable being constructed. - /// - /// The string to locate in StringTable. - /// Index of the string in the StringTable. - uint GetStringIndex(string str); - - /// - /// Creates a StringTable object with data from StringTable object. - /// - /// The StringTable object with data from the IStringBuilder. - StringTable BuildStringTable(); - } -} +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Defines function for object that can be used to build StringTables. + /// + internal interface IStringTableBuilder + { + /// + /// Gets index of the string in StringTable being constructed. + /// + /// The string to locate in StringTable. + /// Index of the string in the StringTable. + uint GetStringIndex(string str); + + /// + /// Creates a StringTable object with data from StringTable object. + /// + /// The StringTable object with data from the IStringBuilder. + StringTable BuildStringTable(); + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs b/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs index 4e7da96..ad6c74c 100644 --- a/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs +++ b/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs @@ -1,50 +1,54 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represents header message of the PBF file. - /// - [ProtoContract(Name = "HeaderBlock")] - internal class OsmHeader { - private IList _optionalFeatures = new List(); - private IList _requiredFeatures = new List(); - - /// - /// Gets or sets bounding box of the data in the file - /// - [ProtoMember(1, Name = "bbox", IsRequired = false)] - public HeaderBBox BBox { get; set; } - - /// - /// Gets or sets collection of optional features that parser could take advantege of - /// - [ProtoMember(5, Name = "optional_features")] - public IList OptionalFeatures { - get { return _optionalFeatures; } - set { _optionalFeatures = value; } - } - - /// - /// Gets or sets collection of required features that parser must suppor to process the file - /// - [ProtoMember(4, Name = "required_features")] - public IList RequiredFeatures { - get { return _requiredFeatures; } - set { _requiredFeatures = value; } - } - - /// - /// Gets or sets source of the data - /// - [ProtoMember(0x11, Name = "source", IsRequired = false)] - public string Source { get; set; } - - /// - /// Gets or sets identification of writing program - /// - [ProtoMember(0x10, Name = "writingprogram", IsRequired = false)] - public string WritingProgram { get; set; } - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represents header message of the PBF file. + /// + [ProtoContract(Name = "HeaderBlock")] + internal class OsmHeader + { + private IList _optionalFeatures = new List(); + private IList _requiredFeatures = new List(); + + /// + /// Gets or sets bounding box of the data in the file + /// + [ProtoMember(1, Name = "bbox", IsRequired = false)] + public HeaderBBox BBox { get; set; } + + /// + /// Gets or sets collection of optional features that parser could take advantege of + /// + [ProtoMember(5, Name = "optional_features")] + public IList OptionalFeatures + { + get { return _optionalFeatures; } + set { _optionalFeatures = value; } + } + + /// + /// Gets or sets collection of required features that parser must suppor to process the file + /// + [ProtoMember(4, Name = "required_features")] + public IList RequiredFeatures + { + get { return _requiredFeatures; } + set { _requiredFeatures = value; } + } + + /// + /// Gets or sets source of the data + /// + [ProtoMember(0x11, Name = "source", IsRequired = false)] + public string Source { get; set; } + + /// + /// Gets or sets identification of writing program + /// + [ProtoMember(0x10, Name = "writingprogram", IsRequired = false)] + public string WritingProgram { get; set; } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs b/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs index 3781b3c..fea8171 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs @@ -1,17 +1,19 @@ -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represetns data transfer object used by PBF serializer for changesets. - /// - [ProtoContract(Name = "ChangeSet")] - public class PbfChangeset { - - /// - /// Gets or sets id of the changeset. - /// - [ProtoMember(1, IsRequired = true, Name = "id")] - public long ID { get; set; } - - } -} +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represetns data transfer object used by PBF serializer for changesets. + /// + [ProtoContract(Name = "ChangeSet")] + public class PbfChangeset + { + + /// + /// Gets or sets id of the changeset. + /// + [ProtoMember(1, IsRequired = true, Name = "id")] + public long ID { get; set; } + + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs b/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs index 18d40dd..bfd9e74 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs @@ -1,100 +1,110 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represetns data transfer object used by PBF serializer for metadata in dense format. - /// - [ProtoContract(Name = "DenseInfo")] - internal class PbfDenseMetadata { - private IList _changeset = new List(); - private IList _timestamp = new List(); - private IList _userId = new List(); - private IList _userNameIndex = new List(); - private IList _version = new List(); - private IList _visible = new List(); - - /// - /// Initializes a new instance of the DenseInfo class with internal fields initialized to default capacity. - /// - public PbfDenseMetadata() { - _changeset = new List(); - _timestamp = new List(); - _userId = new List(); - _userNameIndex = new List(); - _version = new List(); - _visible = new List(); - } - - /// - /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfDenseMetadata(int capacity) { - _changeset = new List(capacity); - _timestamp = new List(capacity); - _userId = new List(capacity); - _userNameIndex = new List(capacity); - _version = new List(capacity); - _visible = new List(capacity); - } - - /// - /// Gets or sets changeset id for corresponding node in DenseNodes. Property is delta encoded. - /// - [ProtoMember(3, Name = "changeset", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList Changeset { - get { return _changeset; } - set { _changeset = value; } - } - - /// - /// Gets or sets timestamp as number of DateGranularity from UNIX 1970 epoch for the corresponding node in DenseNodes. Property is delta encoded. - /// - /// - /// DateTime LastChange = _unixEpoch.AddMilliseconds(timestamp * block.DateGranularity). - /// - [ProtoMember(2, Name = "timestamp", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList Timestamp { - get { return _timestamp; } - set { _timestamp = value; } - } - - /// - /// Gets or sets UserId for corresponding node in DenseNodes. Property is delta encoded. - /// - [ProtoMember(4, Name = "uid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList UserId { - get { return _userId; } - set { _userId = value; } - } - - /// - /// Gets or sets index of the UserName in StringTable for corresponding node in DenseNodes. Property is delta encoded. - /// - [ProtoMember(5, Name = "user_sid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList UserNameIndex { - get { return _userNameIndex; } - set { _userNameIndex = value; } - } - - /// - /// Gets or sets version of the corresponding node in DenseNodes. - /// - [ProtoMember(1, Name = "version", Options = MemberSerializationOptions.Packed)] - public IList Version { - get { return _version; } - set { _version = value; } - } - - /// - /// Gets or sets visible attribute for corresponding node in DenseNodes. - /// - [ProtoMember(6, Name = "visible", Options = MemberSerializationOptions.Packed)] - public IList Visible { - get { return _visible; } - set { _visible = value; } - } - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represetns data transfer object used by PBF serializer for metadata in dense format. + /// + [ProtoContract(Name = "DenseInfo")] + internal class PbfDenseMetadata + { + private IList _changeset = new List(); + private IList _timestamp = new List(); + private IList _userId = new List(); + private IList _userNameIndex = new List(); + private IList _version = new List(); + private IList _visible = new List(); + + /// + /// Initializes a new instance of the DenseInfo class with internal fields initialized to default capacity. + /// + public PbfDenseMetadata() + { + _changeset = new List(); + _timestamp = new List(); + _userId = new List(); + _userNameIndex = new List(); + _version = new List(); + _visible = new List(); + } + + /// + /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfDenseMetadata(int capacity) + { + _changeset = new List(capacity); + _timestamp = new List(capacity); + _userId = new List(capacity); + _userNameIndex = new List(capacity); + _version = new List(capacity); + _visible = new List(capacity); + } + + /// + /// Gets or sets changeset id for corresponding node in DenseNodes. Property is delta encoded. + /// + [ProtoMember(3, Name = "changeset", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList Changeset + { + get { return _changeset; } + set { _changeset = value; } + } + + /// + /// Gets or sets timestamp as number of DateGranularity from UNIX 1970 epoch for the corresponding node in DenseNodes. Property is delta encoded. + /// + /// + /// DateTime LastChange = _unixEpoch.AddMilliseconds(timestamp * block.DateGranularity). + /// + [ProtoMember(2, Name = "timestamp", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList Timestamp + { + get { return _timestamp; } + set { _timestamp = value; } + } + + /// + /// Gets or sets UserId for corresponding node in DenseNodes. Property is delta encoded. + /// + [ProtoMember(4, Name = "uid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList UserId + { + get { return _userId; } + set { _userId = value; } + } + + /// + /// Gets or sets index of the UserName in StringTable for corresponding node in DenseNodes. Property is delta encoded. + /// + [ProtoMember(5, Name = "user_sid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList UserNameIndex + { + get { return _userNameIndex; } + set { _userNameIndex = value; } + } + + /// + /// Gets or sets version of the corresponding node in DenseNodes. + /// + [ProtoMember(1, Name = "version", Options = MemberSerializationOptions.Packed)] + public IList Version + { + get { return _version; } + set { _version = value; } + } + + /// + /// Gets or sets visible attribute for corresponding node in DenseNodes. + /// + [ProtoMember(6, Name = "visible", Options = MemberSerializationOptions.Packed)] + public IList Visible + { + get { return _visible; } + set { _visible = value; } + } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs b/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs index 5769501..8cb6c94 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs @@ -1,89 +1,97 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represetns data transfer object used by PBF serializer for nodes saved in dense format. - /// - [ProtoContract(Name = "DenseNodes")] - internal class PbfDenseNodes { - - private IList _id = null; - private IList _latitude = null; - private IList _longitude = null; - private IList _keysVals = null; - - /// - /// Initializes a new instance of the DenseNodes class with internal fields initialized to default capacity. - /// - public PbfDenseNodes() { - _id = new List(); - _latitude = new List(); - _longitude = new List(); - _keysVals = new List(); - } - - /// - /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfDenseNodes(int capacity) { - _id = new List(capacity); - _latitude = new List(capacity); - _longitude = new List(capacity); - _keysVals = new List(capacity); - } - - /// - /// Gets or sets ids of the nodes. This property is delta encoded. - /// - [ProtoMember(1, Name = "id", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] - public IList Id { - get { return _id; } - set { _id = value; } - } - - /// - /// Gets or sets latitudes of the nodes as number of granularity steps from the LatOffset. This property is delta encoded. - /// - /// - /// double nodeLat = 1E-09 * (block.LatOffset + (block.Granularity * Latitude)); - /// - [ProtoMember(8, Name = "lat", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] - public IList Latitude { - get { return _latitude; } - set { _latitude = value; } - } - - /// - /// Gets or sets longitude of the nodes as number of granularity steps from the LonOffset. This property is delta encoded. - /// - /// - /// double nodeLon = 1E-09 * (block.LonOffset + (block.Granularity * Longitude)); - /// - [ProtoMember(9, Name = "lon", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] - public IList Longitude { - get { return _longitude; } - set { _longitude = value; } - } - - /// - /// Gets or sets entities metadata encoded in the DenseInfo object - /// - [ProtoMember(5, Name = "denseinfo", IsRequired = false)] - public PbfDenseMetadata DenseInfo { get; set; } - - /// - /// Gets or sets tags for nodes. - /// - /// - /// Tags are saved as (KeyIndex, ValueIndex) pairs. Tags for concesutive nodes are seprated by 0. - /// - [ProtoMember(10, Name = "keys_vals", Options = MemberSerializationOptions.Packed)] - public IList KeysVals { - get { return _keysVals; } - set { _keysVals = value; } - } - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represetns data transfer object used by PBF serializer for nodes saved in dense format. + /// + [ProtoContract(Name = "DenseNodes")] + internal class PbfDenseNodes + { + + private IList _id = null; + private IList _latitude = null; + private IList _longitude = null; + private IList _keysVals = null; + + /// + /// Initializes a new instance of the DenseNodes class with internal fields initialized to default capacity. + /// + public PbfDenseNodes() + { + _id = new List(); + _latitude = new List(); + _longitude = new List(); + _keysVals = new List(); + } + + /// + /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfDenseNodes(int capacity) + { + _id = new List(capacity); + _latitude = new List(capacity); + _longitude = new List(capacity); + _keysVals = new List(capacity); + } + + /// + /// Gets or sets ids of the nodes. This property is delta encoded. + /// + [ProtoMember(1, Name = "id", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] + public IList Id + { + get { return _id; } + set { _id = value; } + } + + /// + /// Gets or sets latitudes of the nodes as number of granularity steps from the LatOffset. This property is delta encoded. + /// + /// + /// double nodeLat = 1E-09 * (block.LatOffset + (block.Granularity * Latitude)); + /// + [ProtoMember(8, Name = "lat", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] + public IList Latitude + { + get { return _latitude; } + set { _latitude = value; } + } + + /// + /// Gets or sets longitude of the nodes as number of granularity steps from the LonOffset. This property is delta encoded. + /// + /// + /// double nodeLon = 1E-09 * (block.LonOffset + (block.Granularity * Longitude)); + /// + [ProtoMember(9, Name = "lon", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] + public IList Longitude + { + get { return _longitude; } + set { _longitude = value; } + } + + /// + /// Gets or sets entities metadata encoded in the DenseInfo object + /// + [ProtoMember(5, Name = "denseinfo", IsRequired = false)] + public PbfDenseMetadata DenseInfo { get; set; } + + /// + /// Gets or sets tags for nodes. + /// + /// + /// Tags are saved as (KeyIndex, ValueIndex) pairs. Tags for concesutive nodes are seprated by 0. + /// + [ProtoMember(10, Name = "keys_vals", Options = MemberSerializationOptions.Packed)] + public IList KeysVals + { + get { return _keysVals; } + set { _keysVals = value; } + } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs b/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs index 2f3160c..8de0575 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs @@ -1,41 +1,43 @@ -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represetns data transfer object used by PBF serializer for Entity metadata. - /// - [ProtoContract(Name = "Info")] - internal class PbfMetadata { - - /// - /// Gets or sets changeset ID. - /// - [ProtoMember(3, Name = "changeset", IsRequired = false)] - public long? Changeset { get; set; } - - /// - /// Gets or sets Timestamp. - /// - [ProtoMember(2, Name = "timestamp", IsRequired = false)] - public long? Timestamp { get; set; } - - /// - /// Gets or sets UserID. - /// - [ProtoMember(4, Name = "uid", IsRequired = false)] - public int? UserID { get; set; } - - /// - /// Gets or sets index of the username in string table. - /// - [ProtoMember(5, Name = "user_sid", IsRequired = false)] - public int? UserNameIndex { get; set; } - - /// - /// Gets or sets version of the entity. - /// - [ProtoMember(1, Name = "version", IsRequired = false)] - public int? Version { get; set; } - - } -} +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represetns data transfer object used by PBF serializer for Entity metadata. + /// + [ProtoContract(Name = "Info")] + internal class PbfMetadata + { + + /// + /// Gets or sets changeset ID. + /// + [ProtoMember(3, Name = "changeset", IsRequired = false)] + public long? Changeset { get; set; } + + /// + /// Gets or sets Timestamp. + /// + [ProtoMember(2, Name = "timestamp", IsRequired = false)] + public long? Timestamp { get; set; } + + /// + /// Gets or sets UserID. + /// + [ProtoMember(4, Name = "uid", IsRequired = false)] + public int? UserID { get; set; } + + /// + /// Gets or sets index of the username in string table. + /// + [ProtoMember(5, Name = "user_sid", IsRequired = false)] + public int? UserNameIndex { get; set; } + + /// + /// Gets or sets version of the entity. + /// + [ProtoMember(1, Name = "version", IsRequired = false)] + public int? Version { get; set; } + + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs b/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs index ad9fd2c..c9697c5 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs @@ -1,49 +1,51 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represetns data transfer object used by PBF serializer for nodes. - /// - [ProtoContract(Name = "Node")] - internal class PbfNode { - - /// - /// Gets or sets ID of the node. - /// - [ProtoMember(1, IsRequired = true, Name = "id", DataFormat = DataFormat.ZigZag)] - public long ID { get; set; } - - /// - /// Gets or sets indexes of tag's keys in string table. - /// - [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] - public List Keys { get; set; } - - /// - /// Gets or sets indexes of tag's values in string table. - /// - [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] - public List Values { get; set; } - - /// - /// Gets or sets entity metadata. - /// - [ProtoMember(4, IsRequired = false, Name = "info")] - public PbfMetadata Metadata { get; set; } - - /// - /// Gets or sets Latitude of the node as number of granularity steps from LatOffset. - /// - [ProtoMember(8, IsRequired = true, Name = "lat", DataFormat = DataFormat.ZigZag)] - public long Latitude { get; set; } - - /// - /// Gets or sets Longitude of the node as number of granularity steps from LonOffset. - /// - [ProtoMember(9, IsRequired = true, Name = "lon", DataFormat = DataFormat.ZigZag)] - public long Longitude { get; set; } - - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represetns data transfer object used by PBF serializer for nodes. + /// + [ProtoContract(Name = "Node")] + internal class PbfNode + { + + /// + /// Gets or sets ID of the node. + /// + [ProtoMember(1, IsRequired = true, Name = "id", DataFormat = DataFormat.ZigZag)] + public long ID { get; set; } + + /// + /// Gets or sets indexes of tag's keys in string table. + /// + [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] + public List Keys { get; set; } + + /// + /// Gets or sets indexes of tag's values in string table. + /// + [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] + public List Values { get; set; } + + /// + /// Gets or sets entity metadata. + /// + [ProtoMember(4, IsRequired = false, Name = "info")] + public PbfMetadata Metadata { get; set; } + + /// + /// Gets or sets Latitude of the node as number of granularity steps from LatOffset. + /// + [ProtoMember(8, IsRequired = true, Name = "lat", DataFormat = DataFormat.ZigZag)] + public long Latitude { get; set; } + + /// + /// Gets or sets Longitude of the node as number of granularity steps from LonOffset. + /// + [ProtoMember(9, IsRequired = true, Name = "lon", DataFormat = DataFormat.ZigZag)] + public long Longitude { get; set; } + + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs b/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs index 5201ca8..4d7085a 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs @@ -1,86 +1,93 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represetns data transfer object used by PBF serializer for relations. - /// - [ProtoContract(Name = "Relation")] - internal class PbfRelation { - - private IList _memberIds = null; - private IList _rolesIndexes = null; - private IList _types = null; - - /// - /// Initializes a new instance of the PbfRelation class with internal fields initialized to default capacity. - /// - public PbfRelation() { - _memberIds = new List(); - _rolesIndexes = new List(); - _types = new List(); - } - - /// - /// Initializes a new instance of the PbfRelation class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfRelation(int capacity) { - _memberIds = new List(capacity); - _rolesIndexes = new List(capacity); - _types = new List(capacity); - } - - /// - /// Gets or sets ID of the relation. - /// - [ProtoMember(1, Name = "id", IsRequired = true)] - public long ID { get; set; } - - /// - /// Gets or sets relation metadata. - /// - [ProtoMember(4, Name = "info", IsRequired = false)] - public PbfMetadata Metadata { get; set; } - - /// - /// Gets or sets indexes of tag's keys in string table. - /// - [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] - public IList Keys { get; set; } - - /// - /// Gets or sets indexes of tag's values in string table. - /// - [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] - public IList Values { get; set; } - - /// - /// Gets or sets IDs of the relation members. This propeerty is delta encoded. - /// - [ProtoMember(9, Name = "memids", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList MemberIds { - get { return _memberIds; } - set { _memberIds = value; } - } - - /// - /// Gets or sets index of the role in string table for appropriate members. - /// - [ProtoMember(8, Name = "roles_sid", Options = MemberSerializationOptions.Packed)] - public IList RolesIndexes { - get { return _rolesIndexes; } - set { _rolesIndexes = value; } - } - - /// - /// Gets or sets type of the relation members. - /// - [ProtoMember(10, Name = "types", Options = MemberSerializationOptions.Packed)] - public IList Types { - get { return _types; } - set { _types = value; } - } - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represetns data transfer object used by PBF serializer for relations. + /// + [ProtoContract(Name = "Relation")] + internal class PbfRelation + { + + private IList _memberIds = null; + private IList _rolesIndexes = null; + private IList _types = null; + + /// + /// Initializes a new instance of the PbfRelation class with internal fields initialized to default capacity. + /// + public PbfRelation() + { + _memberIds = new List(); + _rolesIndexes = new List(); + _types = new List(); + } + + /// + /// Initializes a new instance of the PbfRelation class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfRelation(int capacity) + { + _memberIds = new List(capacity); + _rolesIndexes = new List(capacity); + _types = new List(capacity); + } + + /// + /// Gets or sets ID of the relation. + /// + [ProtoMember(1, Name = "id", IsRequired = true)] + public long ID { get; set; } + + /// + /// Gets or sets relation metadata. + /// + [ProtoMember(4, Name = "info", IsRequired = false)] + public PbfMetadata Metadata { get; set; } + + /// + /// Gets or sets indexes of tag's keys in string table. + /// + [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] + public IList Keys { get; set; } + + /// + /// Gets or sets indexes of tag's values in string table. + /// + [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] + public IList Values { get; set; } + + /// + /// Gets or sets IDs of the relation members. This propeerty is delta encoded. + /// + [ProtoMember(9, Name = "memids", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList MemberIds + { + get { return _memberIds; } + set { _memberIds = value; } + } + + /// + /// Gets or sets index of the role in string table for appropriate members. + /// + [ProtoMember(8, Name = "roles_sid", Options = MemberSerializationOptions.Packed)] + public IList RolesIndexes + { + get { return _rolesIndexes; } + set { _rolesIndexes = value; } + } + + /// + /// Gets or sets type of the relation members. + /// + [ProtoMember(10, Name = "types", Options = MemberSerializationOptions.Packed)] + public IList Types + { + get { return _types; } + set { _types = value; } + } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs b/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs index 61b9564..eafe4f1 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs @@ -1,19 +1,21 @@ -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Defines possible types of the relation member. - /// - public enum PbfRelationMemberType { - /// - /// Relation member is Node. - /// - Node, - /// - /// Relation member is Way. - /// - Way, - /// - /// Relation member is Relation. - /// - Relation - } -} +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Defines possible types of the relation member. + /// + public enum PbfRelationMemberType + { + /// + /// Relation member is Node. + /// + Node, + /// + /// Relation member is Way. + /// + Way, + /// + /// Relation member is Relation. + /// + Relation + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs b/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs index 1b8d028..eebe3fe 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs @@ -1,62 +1,67 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represetns data transfer object used by PBF serializer for Ways. - /// - [ ProtoContract(Name = "Way")] - internal class PbfWay { - - private IList _refs = null; - - /// - /// Initializes a new instance of the PbfWay class with internal fields initialized to default capacity. - /// - public PbfWay() { - _refs = new List(); - } - - /// - /// Initializes a new instance of the PbfWay class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfWay(int capacity) { - _refs = new List(capacity); - } - - /// - /// Gets or sets ID of the way. - /// - [ProtoMember(1, Name = "id", IsRequired = true)] - public long ID { get; set; } - - /// - /// Gets or sets indexes of tag's keys in string table. - /// - [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] - public IList Keys { get; set; } - - /// - /// Gets or sets indexes of tag's values in string table. - /// - [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] - public IList Values { get; set; } - - /// - /// Gets or sets entity metadata . - /// - [ProtoMember(4, Name = "info", IsRequired = false)] - public PbfMetadata Metadata { get; set; } - - /// - /// Gets or sets IDs of nodes referenced by the way. This property is delta encoded. - /// - [ProtoMember(8, Name = "refs", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList Refs { - get { return _refs; } - set { _refs = value; } - } - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represetns data transfer object used by PBF serializer for Ways. + /// + [ProtoContract(Name = "Way")] + internal class PbfWay + { + + private IList _refs = null; + + /// + /// Initializes a new instance of the PbfWay class with internal fields initialized to default capacity. + /// + public PbfWay() + { + _refs = new List(); + } + + /// + /// Initializes a new instance of the PbfWay class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfWay(int capacity) + { + _refs = new List(capacity); + } + + /// + /// Gets or sets ID of the way. + /// + [ProtoMember(1, Name = "id", IsRequired = true)] + public long ID { get; set; } + + /// + /// Gets or sets indexes of tag's keys in string table. + /// + [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] + public IList Keys { get; set; } + + /// + /// Gets or sets indexes of tag's values in string table. + /// + [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] + public IList Values { get; set; } + + /// + /// Gets or sets entity metadata . + /// + [ProtoMember(4, Name = "info", IsRequired = false)] + public PbfMetadata Metadata { get; set; } + + /// + /// Gets or sets IDs of nodes referenced by the way. This property is delta encoded. + /// + [ProtoMember(8, Name = "refs", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList Refs + { + get { return _refs; } + set { _refs = value; } + } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs b/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs index 4e664ee..d7fea79 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs @@ -1,57 +1,61 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represents content of the fileblock's data stream. - /// - [ProtoContract(Name = "PrimitiveBlock")] - internal class PrimitiveBlock { - - private int _granularity = 100; - private int _date_granularity = 1000; - - /// - /// Gets or sets StringTable with all strings used in the block. - /// - [ProtoMember(1, IsRequired = true, Name = "stringtable")] - public StringTable StringTable { get; set; } - - /// - /// Gets or sets PrimitiveGroup object with OSM entities. - /// - [ProtoMember(2, Name = "primitivegroup")] - public List PrimitiveGroup { get; set; } - - /// - /// Gets or sets granularity of the position data. Default value is 1000. - /// - [ProtoMember(16, IsRequired = false, Name = "granularity")] - public int Granularity { - get { return _granularity; } - set { _granularity = value; } - } - - /// - /// Gets or sets latitude offset. - /// - [ProtoMember(19, IsRequired = false, Name = "lat_offset")] - public long LatOffset { get; set; } - - /// - /// Gets or sets longitude offset. - /// - [ProtoMember(20, IsRequired = false, Name = "lon_offset")] - public long LonOffset { get; set; } - - /// - /// Gets or sets granularity of the DateTime data. Default value is 100. - /// - [ProtoMember(18, IsRequired = false, Name = "date_granularity")] - public int DateGranularity { - get { return _date_granularity; } - set { _date_granularity = value; } - } - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represents content of the fileblock's data stream. + /// + [ProtoContract(Name = "PrimitiveBlock")] + internal class PrimitiveBlock + { + + private int _granularity = 100; + private int _date_granularity = 1000; + + /// + /// Gets or sets StringTable with all strings used in the block. + /// + [ProtoMember(1, IsRequired = true, Name = "stringtable")] + public StringTable StringTable { get; set; } + + /// + /// Gets or sets PrimitiveGroup object with OSM entities. + /// + [ProtoMember(2, Name = "primitivegroup")] + public List PrimitiveGroup { get; set; } + + /// + /// Gets or sets granularity of the position data. Default value is 1000. + /// + [ProtoMember(16, IsRequired = false, Name = "granularity")] + public int Granularity + { + get { return _granularity; } + set { _granularity = value; } + } + + /// + /// Gets or sets latitude offset. + /// + [ProtoMember(19, IsRequired = false, Name = "lat_offset")] + public long LatOffset { get; set; } + + /// + /// Gets or sets longitude offset. + /// + [ProtoMember(20, IsRequired = false, Name = "lon_offset")] + public long LonOffset { get; set; } + + /// + /// Gets or sets granularity of the DateTime data. Default value is 100. + /// + [ProtoMember(18, IsRequired = false, Name = "date_granularity")] + public int DateGranularity + { + get { return _date_granularity; } + set { _date_granularity = value; } + } + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs b/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs index 94af545..191c663 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs @@ -1,43 +1,45 @@ -using System.Collections.Generic; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Represents container for PBF data transfer objects for OSM entities. - /// - [ProtoContract(Name = "PrimitiveGroup")] - internal class PrimitiveGroup { - - /// - /// Gets or sets collection of nodes. - /// - [ProtoMember(1, Name = "nodes")] - public List Nodes { get; set; } - - /// - /// Gets or sets collection of nodes serialized in dense format. - /// - [ProtoMember(2, IsRequired = false, Name = "dense")] - public PbfDenseNodes DenseNodes { get; set; } - - /// - /// Gets or sets collection of way. - /// - [ProtoMember(3, Name = "ways")] - public List Ways { get; set; } - - /// - /// Gets or sets collection of relations. - /// - [ProtoMember(4, Name = "relations")] - public List Relations { get; set; } - - /// - /// Gets or sets collection of changesets. - /// - [ProtoMember(5, Name = "changesets")] - public List Changesets { get; set; } - - } -} +using System.Collections.Generic; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Represents container for PBF data transfer objects for OSM entities. + /// + [ProtoContract(Name = "PrimitiveGroup")] + internal class PrimitiveGroup + { + + /// + /// Gets or sets collection of nodes. + /// + [ProtoMember(1, Name = "nodes")] + public List Nodes { get; set; } + + /// + /// Gets or sets collection of nodes serialized in dense format. + /// + [ProtoMember(2, IsRequired = false, Name = "dense")] + public PbfDenseNodes DenseNodes { get; set; } + + /// + /// Gets or sets collection of way. + /// + [ProtoMember(3, Name = "ways")] + public List Ways { get; set; } + + /// + /// Gets or sets collection of relations. + /// + [ProtoMember(4, Name = "relations")] + public List Relations { get; set; } + + /// + /// Gets or sets collection of changesets. + /// + [ProtoMember(5, Name = "changesets")] + public List Changesets { get; set; } + + } +} diff --git a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs index 0650961..406ea12 100644 --- a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs +++ b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs @@ -1,63 +1,74 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using ProtoBuf; - -namespace SpatialLite.Osm.IO.Pbf { - /// - /// Stores all strings for Primitive block. - /// - [ProtoContract(Name = "StringTable")] - public class StringTable { - - private List _s = new List(); - - /// - /// Gets or sets collection of strings serialized as byte array. - /// - [ProtoMember(1, Name = "s", DataFormat = DataFormat.Default)] - public List Storage { - get { return _s; } - set { _s = value; } - } - - /// - /// Gets or sets string at specified position. - /// - /// The index of the string. - /// string at specified position. - [ProtoIgnore] - public string this[int index] { - get { - if (index >= this.Storage.Count) { - throw new ArgumentOutOfRangeException("index"); - } - - return Encoding.UTF8.GetString(this.Storage[index], 0, this.Storage[index].Length); - } - set { - if (index >= this.Storage.Count) { - throw new ArgumentOutOfRangeException("index"); - } - - this.Storage[index] = Encoding.UTF8.GetBytes(value); - } - } - - /// - /// Gets or sets string at specified position. - /// - /// The index of the string. - /// string at specified position. - [ProtoIgnore] - public string this[uint index] { - get { - return this[(int)index]; - } - set { - this[(int)index] = value; - } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +using ProtoBuf; + +namespace SpatialLite.Osm.IO.Pbf +{ + /// + /// Stores all strings for Primitive block. + /// + [ProtoContract(Name = "StringTable")] + public class StringTable + { + + private List _s = new List(); + + /// + /// Gets or sets collection of strings serialized as byte array. + /// + [ProtoMember(1, Name = "s", DataFormat = DataFormat.Default)] + public List Storage + { + get { return _s; } + set { _s = value; } + } + + /// + /// Gets or sets string at specified position. + /// + /// The index of the string. + /// string at specified position. + [ProtoIgnore] + public string this[int index] + { + get + { + if (index >= this.Storage.Count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + + return Encoding.UTF8.GetString(this.Storage[index], 0, this.Storage[index].Length); + } + set + { + if (index >= this.Storage.Count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + + this.Storage[index] = Encoding.UTF8.GetBytes(value); + } + } + + /// + /// Gets or sets string at specified position. + /// + /// The index of the string. + /// string at specified position. + [ProtoIgnore] + public string this[uint index] + { + get + { + return this[(int)index]; + } + set + { + this[(int)index] = value; + } + } + } +} diff --git a/src/SpatialLite.Osm/IO/PbfReader.cs b/src/SpatialLite.Osm/IO/PbfReader.cs index 1f23dd6..08e64b4 100644 --- a/src/SpatialLite.Osm/IO/PbfReader.cs +++ b/src/SpatialLite.Osm/IO/PbfReader.cs @@ -5,11 +5,13 @@ using ProtoBuf; using SpatialLite.Osm.IO.Pbf; -namespace SpatialLite.Osm.IO { +namespace SpatialLite.Osm.IO +{ /// /// Represents IOsmReader that can read OSM entities from PBF format. /// - public class PbfReader : IOsmReader { + public class PbfReader : IOsmReader + { /// /// Defines maximal allowed size of uncompressed OsmData block. Larger blocks are considered invalid. @@ -31,7 +33,8 @@ public class PbfReader : IOsmReader { /// /// The input stream. /// The OsmReaderSettings object that determines behaviour of PbfReader. - public PbfReader(Stream input, OsmReaderSettings settings) { + public PbfReader(Stream input, OsmReaderSettings settings) + { _input = input; _cache = new Queue(); @@ -39,18 +42,27 @@ public PbfReader(Stream input, OsmReaderSettings settings) { this.Settings.IsReadOnly = true; BlobHeader blobHeader = null; - while ((blobHeader = this.ReadBlobHeader()) != null) { - try { - if (blobHeader.Type == "OSMHeader") { + while ((blobHeader = this.ReadBlobHeader()) != null) + { + try + { + if (blobHeader.Type == "OSMHeader") + { OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); this.ProcessOsmHeader(osmHeader); return; - } else if (blobHeader.Type == "OSMData") { + } + else if (blobHeader.Type == "OSMData") + { throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block before 'OSMData' block."); - } else { + } + else + { _input.Seek(blobHeader.DataSize, SeekOrigin.Current); } - } catch (ProtoException ex) { + } + catch (ProtoException ex) + { throw new InvalidDataException("Input stream contains unsupported data", ex); } } @@ -63,7 +75,8 @@ public PbfReader(Stream input, OsmReaderSettings settings) { /// /// The path to the input file. /// The OsmReaderSettings object that determines behaviour of PbfReader. - public PbfReader(string path, OsmReaderSettings settings) { + public PbfReader(string path, OsmReaderSettings settings) + { _input = new FileStream(path, FileMode.Open, FileAccess.Read); _cache = new Queue(); @@ -71,18 +84,27 @@ public PbfReader(string path, OsmReaderSettings settings) { this.Settings.IsReadOnly = true; BlobHeader blobHeader = null; - while ((blobHeader = this.ReadBlobHeader()) != null) { - try { - if (blobHeader.Type == "OSMHeader") { + while ((blobHeader = this.ReadBlobHeader()) != null) + { + try + { + if (blobHeader.Type == "OSMHeader") + { OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); this.ProcessOsmHeader(osmHeader); return; - } else if (blobHeader.Type == "OSMData") { + } + else if (blobHeader.Type == "OSMData") + { throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block before 'OSMData' block."); - } else { + } + else + { _input.Seek(blobHeader.DataSize, SeekOrigin.Current); } - } catch (ProtoException ex) { + } + catch (ProtoException ex) + { throw new InvalidDataException("Input stream contains unsupported data", ex); } } @@ -99,24 +121,34 @@ public PbfReader(string path, OsmReaderSettings settings) { /// Reads next OSM entity from the stream. /// /// Parsed OSM entity from the stream or null if no other entity is available. - public IEntityInfo Read() { - if (_cache.Count > 0) { + public IEntityInfo Read() + { + if (_cache.Count > 0) + { return _cache.Dequeue(); - } else { + } + else + { BlobHeader blobHeader = null; - while (_cache.Count == 0 && (blobHeader = this.ReadBlobHeader()) != null) { + while (_cache.Count == 0 && (blobHeader = this.ReadBlobHeader()) != null) + { PrimitiveBlock data = this.ReadBlob(blobHeader) as PrimitiveBlock; - if (data != null) { - foreach (PrimitiveGroup group in data.PrimitiveGroup) { + if (data != null) + { + foreach (PrimitiveGroup group in data.PrimitiveGroup) + { this.ProcessPrimitiveGroup(data, group); } } } } - if (_cache.Count > 0) { + if (_cache.Count > 0) + { return _cache.Dequeue(); - } else { + } + else + { return null; } } @@ -124,7 +156,8 @@ public IEntityInfo Read() { /// /// Releases all resources used by the PbfReader. /// - public void Dispose() { + public void Dispose() + { Dispose(true); GC.SuppressFinalize(this); @@ -134,8 +167,10 @@ public void Dispose() { /// Reads and deserializes a BlobHeader from input stream. /// /// Deserialized BlobHeader object or null if end of the stream is reached. - private BlobHeader ReadBlobHeader() { - if (_input.Position < _input.Length) { + private BlobHeader ReadBlobHeader() + { + if (_input.Position < _input.Length) + { return Serializer.DeserializeWithLengthPrefix(_input, PrefixStyle.Fixed32BigEndian); } @@ -147,42 +182,58 @@ private BlobHeader ReadBlobHeader() { /// /// Header of the blob. /// Deserialized content of the read blob or null if blob contains unknown data. - private object ReadBlob(BlobHeader header) { + private object ReadBlob(BlobHeader header) + { byte[] buffer = new byte[header.DataSize]; _input.Read(buffer, 0, header.DataSize); Blob blob = Serializer.Deserialize(new MemoryStream(buffer)); Stream blobContentStream; - if (blob.Raw != null) { + if (blob.Raw != null) + { blobContentStream = new MemoryStream(blob.Raw); - } else if (blob.ZlibData != null) { + } + else if (blob.ZlibData != null) + { MemoryStream deflateStreamData = new MemoryStream(blob.ZlibData); //skip ZLIB header deflateStreamData.Seek(2, SeekOrigin.Begin); blobContentStream = new System.IO.Compression.DeflateStream(deflateStreamData, System.IO.Compression.CompressionMode.Decompress); - } else { + } + else + { throw new NotSupportedException(); } - if (header.Type.Equals("OSMData", StringComparison.OrdinalIgnoreCase)) { - if ((blob.RawSize.HasValue && blob.RawSize > MaxDataBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxDataBlockSize)) { + if (header.Type.Equals("OSMData", StringComparison.OrdinalIgnoreCase)) + { + if ((blob.RawSize.HasValue && blob.RawSize > MaxDataBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxDataBlockSize)) + { throw new InvalidDataException("Invalid OSMData block"); } return Serializer.Deserialize(blobContentStream); - } else if (header.Type.Equals("OSMHeader", StringComparison.OrdinalIgnoreCase)) { - if ((blob.RawSize.HasValue && blob.RawSize > MaxHeaderBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxHeaderBlockSize)) { + } + else if (header.Type.Equals("OSMHeader", StringComparison.OrdinalIgnoreCase)) + { + if ((blob.RawSize.HasValue && blob.RawSize > MaxHeaderBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxHeaderBlockSize)) + { throw new InvalidDataException("Invalid OSMHeader block"); } - try { + try + { return Serializer.Deserialize(blobContentStream); - } catch (ProtoException ex) { + } + catch (ProtoException ex) + { throw new InvalidDataException("Invalid OSMData block", ex); } - } else { + } + else + { return null; } } @@ -191,10 +242,13 @@ private object ReadBlob(BlobHeader header) { /// Checks OsmHeader required features and if any of required features isn't supported, NotSupportedException is thrown. /// /// OsmHeader object to process. - private void ProcessOsmHeader(OsmHeader header) { + private void ProcessOsmHeader(OsmHeader header) + { string[] supportedFeatures = new string[] { "OsmSchema-V0.6", "DenseNodes" }; - foreach (var required in header.RequiredFeatures) { - if (supportedFeatures.Contains(required) == false) { + foreach (var required in header.RequiredFeatures) + { + if (supportedFeatures.Contains(required) == false) + { throw new NotSupportedException(string.Format("Processing specified PBF file requires '{0}' feature which isn't supported by PbfReader.", required)); } } @@ -205,7 +259,8 @@ private void ProcessOsmHeader(OsmHeader header) { /// /// The PrimitiveBlock that contains specified PrimitiveGroup. /// The PrimitiveGroup to process. - private void ProcessPrimitiveGroup(PrimitiveBlock block, PrimitiveGroup group) { + private void ProcessPrimitiveGroup(PrimitiveBlock block, PrimitiveGroup group) + { this.ProcessNodes(block, group); this.ProcessDenseNodes(block, group); this.ProcessWays(block, group); @@ -217,18 +272,23 @@ private void ProcessPrimitiveGroup(PrimitiveBlock block, PrimitiveGroup group) { /// /// The PrimitiveBlock that contains specified PrimitiveGroup. /// The PrimitiveGroup with nodes to process. - private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) { - if (group.Nodes == null) { + private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.Nodes == null) + { return; } - foreach (PbfNode node in group.Nodes) { + foreach (PbfNode node in group.Nodes) + { double lat = 1E-09 * (block.LatOffset + (block.Granularity * node.Latitude)); double lon = 1E-09 * (block.LonOffset + (block.Granularity * node.Longitude)); List tags = new List(); - if (node.Keys != null) { - for (int i = 0; i < node.Keys.Count; i++) { + if (node.Keys != null) + { + for (int i = 0; i < node.Keys.Count; i++) + { tags.Add(new Tag(block.StringTable[node.Keys[i]], block.StringTable[node.Values[i]])); } } @@ -245,8 +305,10 @@ private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) { /// /// The PrimitiveBlock that contains specified PrimitiveGroup. /// The PrimitiveGroup with nodes to process. - private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) { - if (group.DenseNodes == null) { + private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.DenseNodes == null) + { return; } @@ -261,7 +323,8 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) { int userIdStore = 0; int usernameIdStore = 0; - for (int i = 0; i < group.DenseNodes.Id.Count; i++) { + for (int i = 0; i < group.DenseNodes.Id.Count; i++) + { idStore += group.DenseNodes.Id[i]; lonStore += group.DenseNodes.Longitude[i]; latStore += group.DenseNodes.Latitude[i]; @@ -270,8 +333,10 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) { double lon = 1E-09 * (block.LonOffset + (block.Granularity * lonStore)); List tags = new List(); - if (group.DenseNodes.KeysVals.Count > 0) { - while (group.DenseNodes.KeysVals[keyValueIndex] != 0) { + if (group.DenseNodes.KeysVals.Count > 0) + { + while (group.DenseNodes.KeysVals[keyValueIndex] != 0) + { string key = block.StringTable[group.DenseNodes.KeysVals[keyValueIndex++]]; string value = block.StringTable[group.DenseNodes.KeysVals[keyValueIndex++]]; @@ -283,13 +348,15 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) { } EntityMetadata metadata = null; - if (this.Settings.ReadMetadata && group.DenseNodes.DenseInfo != null) { + if (this.Settings.ReadMetadata && group.DenseNodes.DenseInfo != null) + { timestampStore += group.DenseNodes.DenseInfo.Timestamp[i]; changesetStore += group.DenseNodes.DenseInfo.Changeset[i]; userIdStore += group.DenseNodes.DenseInfo.UserId[i]; usernameIdStore += group.DenseNodes.DenseInfo.UserNameIndex[i]; - metadata = new EntityMetadata() { + metadata = new EntityMetadata() + { Changeset = (int)changesetStore, Timestamp = _unixEpoch.AddMilliseconds(timestampStore * block.DateGranularity), Uid = userIdStore, @@ -298,7 +365,8 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) { Visible = true }; - if (group.DenseNodes.DenseInfo.Visible.Count > 0) { + if (group.DenseNodes.DenseInfo.Visible.Count > 0) + { metadata.Visible = group.DenseNodes.DenseInfo.Visible[i]; } } @@ -313,23 +381,29 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) { /// /// The PrimitiveBlock that contains specified PrimitiveGroup. /// The PrimitiveGroup with nodes to process. - private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) { - if (group.Ways == null) { + private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.Ways == null) + { return; } - foreach (var way in group.Ways) { + foreach (var way in group.Ways) + { long refStore = 0; List refs = new List(way.Refs.Count); - for (int i = 0; i < way.Refs.Count; i++) { + for (int i = 0; i < way.Refs.Count; i++) + { refStore += (long)way.Refs[i]; refs.Add(refStore); } List tags = new List(); - if (way.Keys != null) { - for (int i = 0; i < way.Keys.Count; i++) { + if (way.Keys != null) + { + for (int i = 0; i < way.Keys.Count; i++) + { tags.Add(new Tag(block.StringTable[way.Keys[i]], block.StringTable[way.Values[i]])); } } @@ -346,21 +420,26 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) { /// /// The PrimitiveBlock that contains specified PrimitiveGroup. /// The PrimitiveGroup with nodes to process. - private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) { - if (group.Relations == null) { + private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.Relations == null) + { return; } - foreach (var relation in group.Relations) { + foreach (var relation in group.Relations) + { long memberRefStore = 0; List members = new List(); - for (int i = 0; i < relation.MemberIds.Count; i++) { + for (int i = 0; i < relation.MemberIds.Count; i++) + { memberRefStore += (long)relation.MemberIds[i]; string role = block.StringTable[relation.RolesIndexes[i]]; EntityType memberType = 0; - switch (relation.Types[i]) { + switch (relation.Types[i]) + { case PbfRelationMemberType.Node: memberType = EntityType.Node; break; case PbfRelationMemberType.Way: memberType = EntityType.Way; break; case PbfRelationMemberType.Relation: memberType = EntityType.Relation; break; @@ -370,8 +449,10 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) { } List tags = new List(); - if (relation.Keys != null) { - for (int i = 0; i < relation.Keys.Count; i++) { + if (relation.Keys != null) + { + for (int i = 0; i < relation.Keys.Count; i++) + { tags.Add(new Tag(block.StringTable[relation.Keys[i]], block.StringTable[relation.Values[i]])); } } @@ -389,29 +470,36 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) { /// Serilized metadata. /// PrimitiveBlock that contains metadata being processed. /// Parsed metadata. - private EntityMetadata ProcessMetadata(PbfMetadata serializedMetadata, PrimitiveBlock block) { + private EntityMetadata ProcessMetadata(PbfMetadata serializedMetadata, PrimitiveBlock block) + { EntityMetadata metadata = null; - if (this.Settings.ReadMetadata && serializedMetadata != null) { + if (this.Settings.ReadMetadata && serializedMetadata != null) + { //PBF has no field for 'visible' property, true is default value for OSM entity read from PBF file metadata = new EntityMetadata() { Visible = true }; - if (serializedMetadata.Changeset.HasValue) { + if (serializedMetadata.Changeset.HasValue) + { metadata.Changeset = (int)serializedMetadata.Changeset.Value; } - if (serializedMetadata.Timestamp.HasValue) { + if (serializedMetadata.Timestamp.HasValue) + { metadata.Timestamp = _unixEpoch.AddMilliseconds(serializedMetadata.Timestamp.Value * block.DateGranularity); } - if (serializedMetadata.UserID.HasValue) { + if (serializedMetadata.UserID.HasValue) + { metadata.Uid = serializedMetadata.UserID.Value; } - if (serializedMetadata.UserNameIndex.HasValue) { + if (serializedMetadata.UserNameIndex.HasValue) + { metadata.User = block.StringTable[serializedMetadata.UserNameIndex.Value]; } - if (serializedMetadata.Version.HasValue) { + if (serializedMetadata.Version.HasValue) + { metadata.Version = serializedMetadata.Version.Value; } } @@ -423,10 +511,14 @@ private EntityMetadata ProcessMetadata(PbfMetadata serializedMetadata, Primitive /// Releases the unmanaged resources used by the PbfReader and optionally releases the managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!this._disposed) { - if (disposing) { - if (_input != null) { + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (disposing) + { + if (_input != null) + { _input.Dispose(); } } diff --git a/src/SpatialLite.Osm/IO/PbfWriter.cs b/src/SpatialLite.Osm/IO/PbfWriter.cs index d4440d4..d690db7 100644 --- a/src/SpatialLite.Osm/IO/PbfWriter.cs +++ b/src/SpatialLite.Osm/IO/PbfWriter.cs @@ -1,569 +1,639 @@ -using System; -using System.Collections.Generic; -using System.IO; - -using ProtoBuf; -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm.IO.Pbf; - -namespace SpatialLite.Osm.IO { - /// - /// Represents IOsmWriter that writes OSM entities to Pbf format. - /// - public class PbfWriter : IOsmWriter { - - /// - /// Defines maximal allowed size of uncompressed OsmData block. Larger blocks are considered invalid. - /// - public const int MaxDataBlockSize = 16 * 1024 * 1024; - - private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); - - private bool _disposed = false; - private Stream _output; - private bool _ownsOutputStream; - - private EntityInfoBuffer _nodesBuffer; - private EntityInfoBuffer _wayBuffer; - private EntityInfoBuffer _relationBuffer; - - /// - /// Initializes a new instance of the PbfWriter class that writes entities to specified stream with given settings. - /// - /// The stream to write entities to. - /// The settings defining behaviour of the writer. - public PbfWriter(Stream stream, PbfWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; - _output = stream; - _ownsOutputStream = false; - - this.InitializeBuffers(); - this.WriteHeader(); - } - - /// - /// Initializes a new instance of the PbfWriter class that writes entities to specified file with given settings. - /// - /// Path to the file to write entities to. - /// The settings defining behaviour of the writer. - public PbfWriter(string filename, PbfWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; - _output = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite); - _ownsOutputStream = true; - - this.InitializeBuffers(); - this.WriteHeader(); - } - - /// - /// Gets settings used by this PbfWriter. - /// - public PbfWriterSettings Settings { get; private set; } - - /// - /// Writes specified entity in PBF format to the underlaying stream. - /// - /// Entity to write. - /// - /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. - /// - public void Write(IEntityInfo entity) { - if (this.Settings.WriteMetadata) { - if (entity.Metadata == null) { - throw new ArgumentException("Entity doesn't contain metadata obejct, but writer was created with WriteMetadata setting."); - } - - if (entity.Metadata.User == null) { - throw new ArgumentNullException("Entity.Metadata.User cannot be null."); - } - } - - switch (entity.EntityType) { - case EntityType.Node: _nodesBuffer.Add(entity as NodeInfo); break; - case EntityType.Way: _wayBuffer.Add(entity as WayInfo); break; - case EntityType.Relation: _relationBuffer.Add(entity as RelationInfo); break; - } - - if (_nodesBuffer.EstimatedMaxSize > MaxDataBlockSize) { - this.Flush(EntityType.Node); - } - - if (_wayBuffer.EstimatedMaxSize > MaxDataBlockSize) { - this.Flush(EntityType.Way); - } - - if (_relationBuffer.EstimatedMaxSize > MaxDataBlockSize) { - this.Flush(EntityType.Relation); - } - } - - /// - /// Writes specific IOsmGeometry in PBF format to the underlaying stream. - /// - /// Entity to write. - /// - /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. - /// - public void Write(IOsmGeometry entity) { - if (entity == null) { - throw new ArgumentNullException("Entity cannot be null", "entity"); - } - - switch (entity.EntityType) { - case EntityType.Node: this.Write(new NodeInfo((Geometries.Node)entity)); break; - case EntityType.Way: this.Write(new WayInfo((Geometries.Way)entity)); break; - case EntityType.Relation: this.Write(new RelationInfo((Geometries.Relation)entity)); break; - } - } - - /// - /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. - /// - public void Flush() { - this.Flush(EntityType.Node); - this.Flush(EntityType.Way); - this.Flush(EntityType.Relation); - } - - /// - /// Releases all resources used by the PbfWriter. - /// - public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Creates internal buffers and initializes them to default capacity. - /// - private void InitializeBuffers() { - _nodesBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); - _wayBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); - _relationBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); - } - - /// - /// Clears internal buffer for specified EntityType and writes all buffered data the underlaying storage. - /// - /// The type of entity to process - private void Flush(EntityType entityType) { - PrimitiveBlock primitiveBlock = this.BuildPrimitiveBlock(entityType); - if (primitiveBlock == null) { - return; - } - - MemoryStream primitiveBlockStream = new MemoryStream(); - Serializer.Serialize(primitiveBlockStream, primitiveBlock); - - //byte[] buffer = new byte[primitiveBlockStream.Length]; - //Array.Copy(primitiveBlockStream.GetBuffer(), buffer, primitiveBlockStream.Length); - - this.WriteBlob("OSMData", primitiveBlockStream.ToArray()); - } - - /// - /// Writes PBF file header to the underlaying stream. - /// - private void WriteHeader() { - OsmHeader header = new OsmHeader(); - header.RequiredFeatures.Add("OsmSchema-V0.6"); - - if (this.Settings.UseDenseFormat) { - header.RequiredFeatures.Add("DenseNodes"); - } - - if (this.Settings.WriteMetadata) { - header.OptionalFeatures.Add("Has_Metadata"); - } - - using (MemoryStream stream = new MemoryStream()) { - Serializer.Serialize(stream, header); - - //byte[] buffer = new byte[stream.Length]; - //Array.Copy(stream.GetBuffer(), buffer, stream.Length); - - this.WriteBlob("OSMHeader", stream.ToArray()); - } - } - - /// - /// Writes blob and it's header to the underlaying stream. - /// - /// The type of the blob. - /// The pbf serialized content of the blob. - private void WriteBlob(string blobType, byte[] blobContent) { - Blob blob = new Blob(); - if (this.Settings.Compression == CompressionMode.None) { - blob.Raw = blobContent; - } - else if (this.Settings.Compression == CompressionMode.ZlibDeflate) { - MemoryStream zlibStream = new MemoryStream(); - - //ZLIB header - zlibStream.WriteByte(120); - zlibStream.WriteByte(156); - - using (System.IO.Compression.DeflateStream deflateSteram = new System.IO.Compression.DeflateStream(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) { - deflateSteram.Write(blobContent, 0, blobContent.Length); - } - - blob.RawSize = (int)blobContent.Length; - blob.ZlibData = zlibStream.ToArray(); - } - - MemoryStream blobStream = new MemoryStream(); - Serializer.Serialize(blobStream, blob); - - BlobHeader header = new BlobHeader(); - header.Type = blobType; - header.DataSize = (int)blobStream.Length; - Serializer.SerializeWithLengthPrefix(_output, header, PrefixStyle.Fixed32BigEndian); - - blobStream.WriteTo(_output); - } - - /// - /// Creates a PrimitiveBlock with entities of specified type from data in tokens. - /// - /// The type of entity to include in PrimitiveBlock. - /// PrimitiveBlock with entities of specified type or null if tokens doesn't contain any entities of specified type. - private PrimitiveBlock BuildPrimitiveBlock(EntityType entityType) { - PrimitiveBlock result = new PrimitiveBlock(); - - result.PrimitiveGroup = new List(); - PrimitiveGroup entityGroup = null; - switch (entityType) { - case EntityType.Node: - entityGroup = this.BuildNodesPrimitiveGroup(result.DateGranularity, result.Granularity, result.LatOffset, result.LonOffset); - result.StringTable = _nodesBuffer.BuildStringTable(); - _nodesBuffer.Clear(); - break; - case EntityType.Way: - entityGroup = this.BuildWaysPrimitiveGroup(result.DateGranularity); - result.StringTable = _wayBuffer.BuildStringTable(); - _wayBuffer.Clear(); - break; - case EntityType.Relation: - entityGroup = this.BuildRelationsPrimitiveGroup(result.DateGranularity); - result.StringTable = _relationBuffer.BuildStringTable(); - _relationBuffer.Clear(); - break; - } - - if (entityGroup == null) { - return null; - } - - result.PrimitiveGroup.Add(entityGroup); - - return result; - } - - /// - /// Creates a PrimitiveGroup with serialized nodes from tokens. - /// - /// Timestamp granularity defined in PrimitiveBlock. - /// Granularity defined in PrimitiveBlock. - /// Latitude offset defined in PrimitiveBlock. - /// Longitude offset defined in PrimitiveBlock. - /// PrimitiveGroup with nodes from tokens or null if tokens is empty. - private PrimitiveGroup BuildNodesPrimitiveGroup(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) { - PrimitiveGroup result = null; - - if (_nodesBuffer.Count > 0) { - result = new PrimitiveGroup(); - - if (this.Settings.UseDenseFormat) { - result.DenseNodes = this.BuildDenseNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); - } - else { - result.Nodes = this.BuildNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); - } - } - - return result; - } - - /// - /// Creates a PrimitiveGroup with serialized ways from tokens. - /// - /// Timestamp granularity defined in PrimitiveBlock. - /// PrimitiveGroup with ways from tokens or null if tokens is empty. - private PrimitiveGroup BuildWaysPrimitiveGroup(int timestampGranularity) { - PrimitiveGroup result = null; - - if (_wayBuffer.Count > 0) { - result = new PrimitiveGroup(); - - result.Ways = this.BuildWays(timestampGranularity); - } - - return result; - } - - /// - /// Creates a PrimitiveGroup with serialized relations objects from relation tokens. - /// - /// Timestamp granularity defined in PrimitiveBlock. - /// PrimitiveGroup with relations from tokens or null if tokens is empty. - private PrimitiveGroup BuildRelationsPrimitiveGroup(int timestampGranularity) { - PrimitiveGroup result = null; - - if (_relationBuffer.Count > 0) { - result = new PrimitiveGroup(); - - result.Relations = this.BuildRelations(timestampGranularity); - } - - return result; - } - - /// - /// Creates a collection of Node objects from nodes in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// Granularity as defined in PrimitiveBlock. - /// Latitude offset as defined in PrimitiveBlock. - /// Longitude offset as defined in PrimitiveBlock. - /// The DenseNode obejct with data from nodes in tokens. - private List BuildNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) { - List result = new List(_nodesBuffer.Count); - foreach (var node in _nodesBuffer) { - PbfNode toAdd = new PbfNode(); - - toAdd.ID = node.ID; - toAdd.Latitude = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); - toAdd.Longitude = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); - - if (node.Tags.Count > 0) { - toAdd.Keys = new List(); - toAdd.Values = new List(); - - foreach (var tag in node.Tags) { - toAdd.Keys.Add(_nodesBuffer.GetStringIndex(tag.Key)); - toAdd.Values.Add(_nodesBuffer.GetStringIndex(tag.Value)); - } - } - - if (node.Metadata != null && this.Settings.WriteMetadata) { - toAdd.Metadata = this.BuildInfo(node.Metadata, timestampGranularity, _nodesBuffer); - } - - result.Add(toAdd); - } - - return result; - } - - /// - /// Creates DenseNode obejcet from nodes in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// Granularity as defined in PrimitiveBlock. - /// Latitude offset as defined in PrimitiveBlock. - /// Longitude offset as defined in PrimitiveBlock. - /// The DenseNode obejct with data from nodes in tokens. - private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) { - PbfDenseNodes result = new PbfDenseNodes(_nodesBuffer.Count); - - long lastID = 0; - long lastLat = 0; - long lastLon = 0; - - foreach (var node in _nodesBuffer) { - result.Id.Add(node.ID - lastID); - lastID = node.ID; - - long latValue = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); - result.Latitude.Add(latValue - lastLat); - lastLat = latValue; - - long lonValue = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); - result.Longitude.Add(lonValue - lastLon); - lastLon = lonValue; - - foreach (var tag in node.Tags) { - result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Key)); - result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Value)); - } - - result.KeysVals.Add(0); - } - - if (this.Settings.WriteMetadata) { - result.DenseInfo = this.BuildDenseInfo(timestampGranularity); - } - - return result; - } - - /// - /// Creates collection of PbfWay objects from ways in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// The collection of PbfWay objects created from relations in tokens. - private List BuildWays(int timestampGranularity) { - List result = new List(); - - foreach (var way in _wayBuffer) { - long lastRef = 0; - - PbfWay toAdd = new PbfWay(); - - toAdd.ID = way.ID; - - if (way.Nodes.Count > 0) { - toAdd.Refs = new List(way.Nodes.Count); - - for (int i = 0; i < way.Nodes.Count; i++) { - toAdd.Refs.Add(way.Nodes[i] - lastRef); - lastRef = way.Nodes[i]; - } - } - - if (way.Tags.Count > 0) { - toAdd.Keys = new List(); - toAdd.Values = new List(); - - foreach (var tag in way.Tags) { - toAdd.Keys.Add(_wayBuffer.GetStringIndex(tag.Key)); - toAdd.Values.Add(_wayBuffer.GetStringIndex(tag.Value)); - } - } - - if (way.Metadata != null && this.Settings.WriteMetadata) { - toAdd.Metadata = this.BuildInfo(way.Metadata, timestampGranularity, _wayBuffer); - } - - result.Add(toAdd); - } - - return result; - } - - /// - /// Creates collection of PbfRelation objects from relations in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// The collection of PbfRelation objects created from relations in tokens. - private List BuildRelations(int timestampGranularity) { - List result = new List(); - - foreach (var relation in _relationBuffer) { - PbfRelation toAdd = new PbfRelation(); - toAdd.ID = relation.ID; - - long lastRef = 0; - foreach (var member in relation.Members) { - toAdd.MemberIds.Add(member.Reference - lastRef); - lastRef = member.Reference; - - toAdd.RolesIndexes.Add((int)_relationBuffer.GetStringIndex(member.Role ?? string.Empty)); - PbfRelationMemberType memberType = 0; - switch (member.MemberType) { - case EntityType.Node: memberType = PbfRelationMemberType.Node; break; - case EntityType.Way: memberType = PbfRelationMemberType.Way; break; - case EntityType.Relation: memberType = PbfRelationMemberType.Relation; break; - } - - toAdd.Types.Add(memberType); - } - - toAdd.Keys = new List(relation.Tags.Count); - toAdd.Values = new List(relation.Tags.Count); - - if (relation.Tags.Count > 0) { - foreach (var tag in relation.Tags) { - toAdd.Keys.Add(_relationBuffer.GetStringIndex(tag.Key)); - toAdd.Values.Add(_relationBuffer.GetStringIndex(tag.Value)); - } - } - - if (relation.Metadata != null && this.Settings.WriteMetadata) { - toAdd.Metadata = this.BuildInfo(relation.Metadata, timestampGranularity, _relationBuffer); - } - - result.Add(toAdd); - } - - return result; - } - - /// - /// Creates a DenseInfo object with metadata for nodes in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// DenseInfo object with metadata for noes in tokens. - private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) { - PbfDenseMetadata result = new PbfDenseMetadata(_nodesBuffer.Count); - - long lastChangeset = 0; - long lastTimestamp = 0; - int lastUid = 0; - int lastUserNameIndex = 0; - - foreach (var node in _nodesBuffer) { - EntityMetadata metadata = node.Metadata ?? new EntityMetadata(); - - result.Changeset.Add(metadata.Changeset - lastChangeset); - lastChangeset = metadata.Changeset; - - long timestampValue = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); - result.Timestamp.Add(timestampValue - lastTimestamp); - lastTimestamp = timestampValue; - - result.UserId.Add(metadata.Uid - lastUid); - lastUid = metadata.Uid; - - int userNameIndex = (int)_nodesBuffer.GetStringIndex(metadata.User); - result.UserNameIndex.Add(userNameIndex - lastUserNameIndex); - lastUserNameIndex = userNameIndex; - - result.Version.Add(metadata.Version); - result.Visible.Add(metadata.Visible); - } - - return result; - } - - /// - /// Creates an PbfMetadata obejct from given Metadata. - /// - /// Metadata obejct to be used as source of data. - /// Timestamp granularity as defined in PrimitiveBlock. - /// IStrignTable object to save string values to. - /// PbfMetadata obejct with data from specified metadata object. - private PbfMetadata BuildInfo(EntityMetadata metadata, int timestampGranularity, IStringTableBuilder stringTableBuilder) { - PbfMetadata result = new PbfMetadata(); - result.Changeset = metadata.Changeset; - result.Timestamp = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); - result.UserID = metadata.Uid; - result.UserNameIndex = (int)stringTableBuilder.GetStringIndex(metadata.User); - result.Version = metadata.Version; - - return result; - } - - /// - /// Releases the unmanaged resources used by the PbfWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) { - if (!_disposed) { - if (disposing) { - this.Flush(); - - if (_output != null) { - if (_ownsOutputStream) { - _output.Dispose(); - } - } - } - - _disposed = true; - } - } - } -} +using System; +using System.Collections.Generic; +using System.IO; + +using ProtoBuf; +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.IO.Pbf; + +namespace SpatialLite.Osm.IO +{ + /// + /// Represents IOsmWriter that writes OSM entities to Pbf format. + /// + public class PbfWriter : IOsmWriter + { + + /// + /// Defines maximal allowed size of uncompressed OsmData block. Larger blocks are considered invalid. + /// + public const int MaxDataBlockSize = 16 * 1024 * 1024; + + private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); + + private bool _disposed = false; + private Stream _output; + private bool _ownsOutputStream; + + private EntityInfoBuffer _nodesBuffer; + private EntityInfoBuffer _wayBuffer; + private EntityInfoBuffer _relationBuffer; + + /// + /// Initializes a new instance of the PbfWriter class that writes entities to specified stream with given settings. + /// + /// The stream to write entities to. + /// The settings defining behaviour of the writer. + public PbfWriter(Stream stream, PbfWriterSettings settings) + { + this.Settings = settings; + this.Settings.IsReadOnly = true; + _output = stream; + _ownsOutputStream = false; + + this.InitializeBuffers(); + this.WriteHeader(); + } + + /// + /// Initializes a new instance of the PbfWriter class that writes entities to specified file with given settings. + /// + /// Path to the file to write entities to. + /// The settings defining behaviour of the writer. + public PbfWriter(string filename, PbfWriterSettings settings) + { + this.Settings = settings; + this.Settings.IsReadOnly = true; + _output = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite); + _ownsOutputStream = true; + + this.InitializeBuffers(); + this.WriteHeader(); + } + + /// + /// Gets settings used by this PbfWriter. + /// + public PbfWriterSettings Settings { get; private set; } + + /// + /// Writes specified entity in PBF format to the underlaying stream. + /// + /// Entity to write. + /// + /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. + /// + public void Write(IEntityInfo entity) + { + if (this.Settings.WriteMetadata) + { + if (entity.Metadata == null) + { + throw new ArgumentException("Entity doesn't contain metadata obejct, but writer was created with WriteMetadata setting."); + } + + if (entity.Metadata.User == null) + { + throw new ArgumentNullException("Entity.Metadata.User cannot be null."); + } + } + + switch (entity.EntityType) + { + case EntityType.Node: _nodesBuffer.Add(entity as NodeInfo); break; + case EntityType.Way: _wayBuffer.Add(entity as WayInfo); break; + case EntityType.Relation: _relationBuffer.Add(entity as RelationInfo); break; + } + + if (_nodesBuffer.EstimatedMaxSize > MaxDataBlockSize) + { + this.Flush(EntityType.Node); + } + + if (_wayBuffer.EstimatedMaxSize > MaxDataBlockSize) + { + this.Flush(EntityType.Way); + } + + if (_relationBuffer.EstimatedMaxSize > MaxDataBlockSize) + { + this.Flush(EntityType.Relation); + } + } + + /// + /// Writes specific IOsmGeometry in PBF format to the underlaying stream. + /// + /// Entity to write. + /// + /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. + /// + public void Write(IOsmGeometry entity) + { + if (entity == null) + { + throw new ArgumentNullException(nameof(entity), "Entity cannot be null"); + } + + switch (entity.EntityType) + { + case EntityType.Node: this.Write(new NodeInfo((Geometries.Node)entity)); break; + case EntityType.Way: this.Write(new WayInfo((Geometries.Way)entity)); break; + case EntityType.Relation: this.Write(new RelationInfo((Geometries.Relation)entity)); break; + } + } + + /// + /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. + /// + public void Flush() + { + this.Flush(EntityType.Node); + this.Flush(EntityType.Way); + this.Flush(EntityType.Relation); + } + + /// + /// Releases all resources used by the PbfWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Creates internal buffers and initializes them to default capacity. + /// + private void InitializeBuffers() + { + _nodesBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + _wayBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + _relationBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + } + + /// + /// Clears internal buffer for specified EntityType and writes all buffered data the underlaying storage. + /// + /// The type of entity to process + private void Flush(EntityType entityType) + { + PrimitiveBlock primitiveBlock = this.BuildPrimitiveBlock(entityType); + if (primitiveBlock == null) + { + return; + } + + MemoryStream primitiveBlockStream = new MemoryStream(); + Serializer.Serialize(primitiveBlockStream, primitiveBlock); + + //byte[] buffer = new byte[primitiveBlockStream.Length]; + //Array.Copy(primitiveBlockStream.GetBuffer(), buffer, primitiveBlockStream.Length); + + this.WriteBlob("OSMData", primitiveBlockStream.ToArray()); + } + + /// + /// Writes PBF file header to the underlaying stream. + /// + private void WriteHeader() + { + OsmHeader header = new OsmHeader(); + header.RequiredFeatures.Add("OsmSchema-V0.6"); + + if (this.Settings.UseDenseFormat) + { + header.RequiredFeatures.Add("DenseNodes"); + } + + if (this.Settings.WriteMetadata) + { + header.OptionalFeatures.Add("Has_Metadata"); + } + + using (MemoryStream stream = new MemoryStream()) + { + Serializer.Serialize(stream, header); + + //byte[] buffer = new byte[stream.Length]; + //Array.Copy(stream.GetBuffer(), buffer, stream.Length); + + this.WriteBlob("OSMHeader", stream.ToArray()); + } + } + + /// + /// Writes blob and it's header to the underlaying stream. + /// + /// The type of the blob. + /// The pbf serialized content of the blob. + private void WriteBlob(string blobType, byte[] blobContent) + { + Blob blob = new Blob(); + if (this.Settings.Compression == CompressionMode.None) + { + blob.Raw = blobContent; + } + else if (this.Settings.Compression == CompressionMode.ZlibDeflate) + { + MemoryStream zlibStream = new MemoryStream(); + + //ZLIB header + zlibStream.WriteByte(120); + zlibStream.WriteByte(156); + + using (System.IO.Compression.DeflateStream deflateSteram = new System.IO.Compression.DeflateStream(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) + { + deflateSteram.Write(blobContent, 0, blobContent.Length); + } + + blob.RawSize = (int)blobContent.Length; + blob.ZlibData = zlibStream.ToArray(); + } + + MemoryStream blobStream = new MemoryStream(); + Serializer.Serialize(blobStream, blob); + + BlobHeader header = new BlobHeader(); + header.Type = blobType; + header.DataSize = (int)blobStream.Length; + Serializer.SerializeWithLengthPrefix(_output, header, PrefixStyle.Fixed32BigEndian); + + blobStream.WriteTo(_output); + } + + /// + /// Creates a PrimitiveBlock with entities of specified type from data in tokens. + /// + /// The type of entity to include in PrimitiveBlock. + /// PrimitiveBlock with entities of specified type or null if tokens doesn't contain any entities of specified type. + private PrimitiveBlock BuildPrimitiveBlock(EntityType entityType) + { + PrimitiveBlock result = new PrimitiveBlock(); + + result.PrimitiveGroup = new List(); + PrimitiveGroup entityGroup = null; + switch (entityType) + { + case EntityType.Node: + entityGroup = this.BuildNodesPrimitiveGroup(result.DateGranularity, result.Granularity, result.LatOffset, result.LonOffset); + result.StringTable = _nodesBuffer.BuildStringTable(); + _nodesBuffer.Clear(); + break; + case EntityType.Way: + entityGroup = this.BuildWaysPrimitiveGroup(result.DateGranularity); + result.StringTable = _wayBuffer.BuildStringTable(); + _wayBuffer.Clear(); + break; + case EntityType.Relation: + entityGroup = this.BuildRelationsPrimitiveGroup(result.DateGranularity); + result.StringTable = _relationBuffer.BuildStringTable(); + _relationBuffer.Clear(); + break; + } + + if (entityGroup == null) + { + return null; + } + + result.PrimitiveGroup.Add(entityGroup); + + return result; + } + + /// + /// Creates a PrimitiveGroup with serialized nodes from tokens. + /// + /// Timestamp granularity defined in PrimitiveBlock. + /// Granularity defined in PrimitiveBlock. + /// Latitude offset defined in PrimitiveBlock. + /// Longitude offset defined in PrimitiveBlock. + /// PrimitiveGroup with nodes from tokens or null if tokens is empty. + private PrimitiveGroup BuildNodesPrimitiveGroup(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) + { + PrimitiveGroup result = null; + + if (_nodesBuffer.Count > 0) + { + result = new PrimitiveGroup(); + + if (this.Settings.UseDenseFormat) + { + result.DenseNodes = this.BuildDenseNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); + } + else + { + result.Nodes = this.BuildNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); + } + } + + return result; + } + + /// + /// Creates a PrimitiveGroup with serialized ways from tokens. + /// + /// Timestamp granularity defined in PrimitiveBlock. + /// PrimitiveGroup with ways from tokens or null if tokens is empty. + private PrimitiveGroup BuildWaysPrimitiveGroup(int timestampGranularity) + { + PrimitiveGroup result = null; + + if (_wayBuffer.Count > 0) + { + result = new PrimitiveGroup(); + + result.Ways = this.BuildWays(timestampGranularity); + } + + return result; + } + + /// + /// Creates a PrimitiveGroup with serialized relations objects from relation tokens. + /// + /// Timestamp granularity defined in PrimitiveBlock. + /// PrimitiveGroup with relations from tokens or null if tokens is empty. + private PrimitiveGroup BuildRelationsPrimitiveGroup(int timestampGranularity) + { + PrimitiveGroup result = null; + + if (_relationBuffer.Count > 0) + { + result = new PrimitiveGroup(); + + result.Relations = this.BuildRelations(timestampGranularity); + } + + return result; + } + + /// + /// Creates a collection of Node objects from nodes in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// Granularity as defined in PrimitiveBlock. + /// Latitude offset as defined in PrimitiveBlock. + /// Longitude offset as defined in PrimitiveBlock. + /// The DenseNode obejct with data from nodes in tokens. + private List BuildNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) + { + List result = new List(_nodesBuffer.Count); + foreach (var node in _nodesBuffer) + { + PbfNode toAdd = new PbfNode(); + + toAdd.ID = node.ID; + toAdd.Latitude = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); + toAdd.Longitude = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); + + if (node.Tags.Count > 0) + { + toAdd.Keys = new List(); + toAdd.Values = new List(); + + foreach (var tag in node.Tags) + { + toAdd.Keys.Add(_nodesBuffer.GetStringIndex(tag.Key)); + toAdd.Values.Add(_nodesBuffer.GetStringIndex(tag.Value)); + } + } + + if (node.Metadata != null && this.Settings.WriteMetadata) + { + toAdd.Metadata = this.BuildInfo(node.Metadata, timestampGranularity, _nodesBuffer); + } + + result.Add(toAdd); + } + + return result; + } + + /// + /// Creates DenseNode obejcet from nodes in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// Granularity as defined in PrimitiveBlock. + /// Latitude offset as defined in PrimitiveBlock. + /// Longitude offset as defined in PrimitiveBlock. + /// The DenseNode obejct with data from nodes in tokens. + private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) + { + PbfDenseNodes result = new PbfDenseNodes(_nodesBuffer.Count); + + long lastID = 0; + long lastLat = 0; + long lastLon = 0; + + foreach (var node in _nodesBuffer) + { + result.Id.Add(node.ID - lastID); + lastID = node.ID; + + long latValue = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); + result.Latitude.Add(latValue - lastLat); + lastLat = latValue; + + long lonValue = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); + result.Longitude.Add(lonValue - lastLon); + lastLon = lonValue; + + foreach (var tag in node.Tags) + { + result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Key)); + result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Value)); + } + + result.KeysVals.Add(0); + } + + if (this.Settings.WriteMetadata) + { + result.DenseInfo = this.BuildDenseInfo(timestampGranularity); + } + + return result; + } + + /// + /// Creates collection of PbfWay objects from ways in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// The collection of PbfWay objects created from relations in tokens. + private List BuildWays(int timestampGranularity) + { + List result = new List(); + + foreach (var way in _wayBuffer) + { + long lastRef = 0; + + PbfWay toAdd = new PbfWay(); + + toAdd.ID = way.ID; + + if (way.Nodes.Count > 0) + { + toAdd.Refs = new List(way.Nodes.Count); + + for (int i = 0; i < way.Nodes.Count; i++) + { + toAdd.Refs.Add(way.Nodes[i] - lastRef); + lastRef = way.Nodes[i]; + } + } + + if (way.Tags.Count > 0) + { + toAdd.Keys = new List(); + toAdd.Values = new List(); + + foreach (var tag in way.Tags) + { + toAdd.Keys.Add(_wayBuffer.GetStringIndex(tag.Key)); + toAdd.Values.Add(_wayBuffer.GetStringIndex(tag.Value)); + } + } + + if (way.Metadata != null && this.Settings.WriteMetadata) + { + toAdd.Metadata = this.BuildInfo(way.Metadata, timestampGranularity, _wayBuffer); + } + + result.Add(toAdd); + } + + return result; + } + + /// + /// Creates collection of PbfRelation objects from relations in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// The collection of PbfRelation objects created from relations in tokens. + private List BuildRelations(int timestampGranularity) + { + List result = new List(); + + foreach (var relation in _relationBuffer) + { + PbfRelation toAdd = new PbfRelation(); + toAdd.ID = relation.ID; + + long lastRef = 0; + foreach (var member in relation.Members) + { + toAdd.MemberIds.Add(member.Reference - lastRef); + lastRef = member.Reference; + + toAdd.RolesIndexes.Add((int)_relationBuffer.GetStringIndex(member.Role ?? string.Empty)); + PbfRelationMemberType memberType = 0; + switch (member.MemberType) + { + case EntityType.Node: memberType = PbfRelationMemberType.Node; break; + case EntityType.Way: memberType = PbfRelationMemberType.Way; break; + case EntityType.Relation: memberType = PbfRelationMemberType.Relation; break; + } + + toAdd.Types.Add(memberType); + } + + toAdd.Keys = new List(relation.Tags.Count); + toAdd.Values = new List(relation.Tags.Count); + + if (relation.Tags.Count > 0) + { + foreach (var tag in relation.Tags) + { + toAdd.Keys.Add(_relationBuffer.GetStringIndex(tag.Key)); + toAdd.Values.Add(_relationBuffer.GetStringIndex(tag.Value)); + } + } + + if (relation.Metadata != null && this.Settings.WriteMetadata) + { + toAdd.Metadata = this.BuildInfo(relation.Metadata, timestampGranularity, _relationBuffer); + } + + result.Add(toAdd); + } + + return result; + } + + /// + /// Creates a DenseInfo object with metadata for nodes in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// DenseInfo object with metadata for noes in tokens. + private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) + { + PbfDenseMetadata result = new PbfDenseMetadata(_nodesBuffer.Count); + + long lastChangeset = 0; + long lastTimestamp = 0; + int lastUid = 0; + int lastUserNameIndex = 0; + + foreach (var node in _nodesBuffer) + { + EntityMetadata metadata = node.Metadata ?? new EntityMetadata(); + + result.Changeset.Add(metadata.Changeset - lastChangeset); + lastChangeset = metadata.Changeset; + + long timestampValue = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); + result.Timestamp.Add(timestampValue - lastTimestamp); + lastTimestamp = timestampValue; + + result.UserId.Add(metadata.Uid - lastUid); + lastUid = metadata.Uid; + + int userNameIndex = (int)_nodesBuffer.GetStringIndex(metadata.User); + result.UserNameIndex.Add(userNameIndex - lastUserNameIndex); + lastUserNameIndex = userNameIndex; + + result.Version.Add(metadata.Version); + result.Visible.Add(metadata.Visible); + } + + return result; + } + + /// + /// Creates an PbfMetadata obejct from given Metadata. + /// + /// Metadata obejct to be used as source of data. + /// Timestamp granularity as defined in PrimitiveBlock. + /// IStrignTable object to save string values to. + /// PbfMetadata obejct with data from specified metadata object. + private PbfMetadata BuildInfo(EntityMetadata metadata, int timestampGranularity, IStringTableBuilder stringTableBuilder) + { + PbfMetadata result = new PbfMetadata(); + result.Changeset = metadata.Changeset; + result.Timestamp = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); + result.UserID = metadata.Uid; + result.UserNameIndex = (int)stringTableBuilder.GetStringIndex(metadata.User); + result.Version = metadata.Version; + + return result; + } + + /// + /// Releases the unmanaged resources used by the PbfWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + this.Flush(); + + if (_output != null) + { + if (_ownsOutputStream) + { + _output.Dispose(); + } + } + } + + _disposed = true; + } + } + } +} diff --git a/src/SpatialLite.Osm/IO/PbfWriterSettings.cs b/src/SpatialLite.Osm/IO/PbfWriterSettings.cs index 432b207..9b35e7f 100644 --- a/src/SpatialLite.Osm/IO/PbfWriterSettings.cs +++ b/src/SpatialLite.Osm/IO/PbfWriterSettings.cs @@ -1,53 +1,64 @@ -using System; - -namespace SpatialLite.Osm.IO { - /// - /// Contains settings that determine behaviour of the PbfWriter. - /// - public class PbfWriterSettings : OsmWriterSettings { - - private bool _useDenseFormat; - private CompressionMode _compression; - - /// - /// Initializes a new instance of the PbfWriterSettings class with default values. - /// - public PbfWriterSettings() - : base() { - this.UseDenseFormat = true; - this.Compression = CompressionMode.ZlibDeflate; - } - - /// - /// Gets or sets a value indicating whether PbfWriter should use dense format for serializing nodes. - /// - public bool UseDenseFormat { - get { - return _useDenseFormat; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'UseDenseFromat' property - PbfReaderSettings is read-only"); - } - - _useDenseFormat = value; - } - } - - /// - /// Gets or sets a compression to be used by PbfWriter. - /// - public CompressionMode Compression { - get { - return _compression; - } - set { - if (this.IsReadOnly) { - throw new InvalidOperationException("Cannot change the 'Compression' property - PbfReaderSettings is read-only"); - } - - _compression = value; - } - } - } -} +using System; + +namespace SpatialLite.Osm.IO +{ + /// + /// Contains settings that determine behaviour of the PbfWriter. + /// + public class PbfWriterSettings : OsmWriterSettings + { + + private bool _useDenseFormat; + private CompressionMode _compression; + + /// + /// Initializes a new instance of the PbfWriterSettings class with default values. + /// + public PbfWriterSettings() + : base() + { + this.UseDenseFormat = true; + this.Compression = CompressionMode.ZlibDeflate; + } + + /// + /// Gets or sets a value indicating whether PbfWriter should use dense format for serializing nodes. + /// + public bool UseDenseFormat + { + get + { + return _useDenseFormat; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'UseDenseFromat' property - PbfReaderSettings is read-only"); + } + + _useDenseFormat = value; + } + } + + /// + /// Gets or sets a compression to be used by PbfWriter. + /// + public CompressionMode Compression + { + get + { + return _compression; + } + set + { + if (this.IsReadOnly) + { + throw new InvalidOperationException("Cannot change the 'Compression' property - PbfReaderSettings is read-only"); + } + + _compression = value; + } + } + } +} diff --git a/src/SpatialLite.Osm/IOsmEntity.cs b/src/SpatialLite.Osm/IOsmEntity.cs index 462fb2f..155f051 100644 --- a/src/SpatialLite.Osm/IOsmEntity.cs +++ b/src/SpatialLite.Osm/IOsmEntity.cs @@ -1,28 +1,30 @@ -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Defines properties for all OSM entities. /// - public interface IOsmEntity { + public interface IOsmEntity + { - /// - /// Gets or sets ID of the object. - /// - long ID { get; set; } + /// + /// Gets or sets ID of the object. + /// + long ID { get; set; } - /// - /// Gets or sets the collection of tags associated with the IOsmGeometry. - /// - TagsCollection Tags { get; set; } + /// + /// Gets or sets the collection of tags associated with the IOsmGeometry. + /// + TagsCollection Tags { get; set; } - /// - /// Gets or sets detailed information about OSM entity. - /// - EntityMetadata Metadata { get; set; } + /// + /// Gets or sets detailed information about OSM entity. + /// + EntityMetadata Metadata { get; set; } - /// - /// Gets type of the entity. - /// - EntityType EntityType { get; } + /// + /// Gets type of the entity. + /// + EntityType EntityType { get; } - } + } } diff --git a/src/SpatialLite.Osm/ITypedEntityCollection.cs b/src/SpatialLite.Osm/ITypedEntityCollection.cs index 66f7714..31de979 100644 --- a/src/SpatialLite.Osm/ITypedEntityCollection.cs +++ b/src/SpatialLite.Osm/ITypedEntityCollection.cs @@ -1,30 +1,32 @@ using System.Collections.Generic; -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Defines methods and properties for collection of the OSM entities of single where entities can be accessed by their ID. /// /// The type of the entitie in the collection. - public interface ITypedEntityCollection : ICollection where T : IOsmEntity { - /// - /// Gets an entity with specific ID from the collection. - /// - /// The ID of the entity to get. - /// entity with the specific ID or null if such entity is not present in the collection. - T this[long id] { get; } + public interface ITypedEntityCollection : ICollection where T : IOsmEntity + { + /// + /// Gets an entity with specific ID from the collection. + /// + /// The ID of the entity to get. + /// entity with the specific ID or null if such entity is not present in the collection. + T this[long id] { get; } - /// - /// Removes an entity with the specific ID from the collection. - /// - /// The ID of the entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - bool Remove(long id); + /// + /// Removes an entity with the specific ID from the collection. + /// + /// The ID of the entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + bool Remove(long id); - /// - /// Determines whether the EntityICollection contains an entity with specific ID. - /// - /// The ID of the entity to locate in the EntityCollection. - /// true if entity is found in the collection, otherwise false. - bool Contains(long id); - } + /// + /// Determines whether the EntityICollection contains an entity with specific ID. + /// + /// The ID of the entity to locate in the EntityCollection. + /// true if entity is found in the collection, otherwise false. + bool Contains(long id); + } } diff --git a/src/SpatialLite.Osm/NodeInfo.cs b/src/SpatialLite.Osm/NodeInfo.cs index 1461d2a..cac73a0 100644 --- a/src/SpatialLite.Osm/NodeInfo.cs +++ b/src/SpatialLite.Osm/NodeInfo.cs @@ -2,76 +2,83 @@ using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Represents information about node. /// - public class NodeInfo : IEntityInfo { + public class NodeInfo : IEntityInfo + { - /// - /// Initializes a new instance of the NodeInfo class with specified ID, latitude, longitude, collection of tags and optionally EntityMetadata. - /// - /// The id of the node. - /// The latitude of the node. - /// The longitude of the node. - /// The collection of thag associated with the node. - /// The EntityMetadata structure with additinal properties. Default value is null. - public NodeInfo(long id, double latitude, double longitude, TagsCollection tags, EntityMetadata additionalInfo = null) { - this.ID = id; - this.Latitude = latitude; - this.Longitude = longitude; - this.Tags = tags; - this.Metadata = additionalInfo; - } + /// + /// Initializes a new instance of the NodeInfo class with specified ID, latitude, longitude, collection of tags and optionally EntityMetadata. + /// + /// The id of the node. + /// The latitude of the node. + /// The longitude of the node. + /// The collection of thag associated with the node. + /// The EntityMetadata structure with additinal properties. Default value is null. + public NodeInfo(long id, double latitude, double longitude, TagsCollection tags, EntityMetadata additionalInfo = null) + { + this.ID = id; + this.Latitude = latitude; + this.Longitude = longitude; + this.Tags = tags; + this.Metadata = additionalInfo; + } - /// - /// Initializes a new instance of the NodeInfo class with data from Node. - /// - /// The Node obejct to take data from. - public NodeInfo(Node node) { - if (node == null) { - throw new ArgumentNullException("Node parameter cannot be null", "node"); - } + /// + /// Initializes a new instance of the NodeInfo class with data from Node. + /// + /// The Node obejct to take data from. + public NodeInfo(Node node) + { + if (node == null) + { + throw new ArgumentNullException(nameof(node), "Node parameter cannot be null"); + } - this.ID = node.ID; - this.Longitude = node.Position.X; - this.Latitude = node.Position.Y; - this.Tags = node.Tags; - this.Metadata = node.Metadata; - } + this.ID = node.ID; + this.Longitude = node.Position.X; + this.Latitude = node.Position.Y; + this.Tags = node.Tags; + this.Metadata = node.Metadata; + } - /// - /// Gets type of the object that is represented by this IOsmGeometryInfo. - /// - public EntityType EntityType { - get { - return EntityType.Node; - } - } + /// + /// Gets type of the object that is represented by this IOsmGeometryInfo. + /// + public EntityType EntityType + { + get + { + return EntityType.Node; + } + } - /// - /// Gets ID of the object. - /// - public long ID { get; set; } + /// + /// Gets ID of the object. + /// + public long ID { get; set; } - /// - /// Gets the collection of tags associated with this node. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets the collection of tags associated with this node. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets the latitude of the node. - /// - public double Latitude { get; set; } + /// + /// Gets the latitude of the node. + /// + public double Latitude { get; set; } - /// - /// Gets the longitude of the node. - /// - public double Longitude { get; set; } + /// + /// Gets the longitude of the node. + /// + public double Longitude { get; set; } - /// - /// Gets or sets metadata of this Node. - /// - public EntityMetadata Metadata { get; set; } - } + /// + /// Gets or sets metadata of this Node. + /// + public EntityMetadata Metadata { get; set; } + } } diff --git a/src/SpatialLite.Osm/OsmDatabase.cs b/src/SpatialLite.Osm/OsmDatabase.cs index ced2f3e..293394c 100644 --- a/src/SpatialLite.Osm/OsmDatabase.cs +++ b/src/SpatialLite.Osm/OsmDatabase.cs @@ -2,7 +2,8 @@ using System.Collections.Generic; using SpatialLite.Osm.IO; -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Represents in-memory database of OSM entities. /// @@ -10,220 +11,256 @@ namespace SpatialLite.Osm { /// The type of Nodes /// The type of Ways /// The type of Relations - public class OsmDatabase : IEntityCollection where T : IOsmEntity where N : T where W : T where R : T { - - /// - /// Initializes a new instance of the OsmDatabase class that is empty. - /// - internal OsmDatabase() { - this.Nodes = new EntityCollection(); - this.Ways = new EntityCollection(); - this.Relations = new EntityCollection(); - } - - /// - /// Initializes a new instance of the OsmDatabase class with specific entities. - /// - /// Entities to add to the database. - internal OsmDatabase(IEnumerable entities) - : this() { - foreach (var entity in entities) { - this.Add(entity); - } - } - - /// - /// Gets collection of nodes in the database. - /// - public ITypedEntityCollection Nodes { get; private set; } - - /// - /// Gets collection of ways in the database. - /// - public ITypedEntityCollection Ways { get; private set; } - - /// - /// Gets collection of relations in the database. - /// - public ITypedEntityCollection Relations { get; private set; } - - /// - /// Gets the number of entities in the collection. - /// - public int Count { - get { - return this.Nodes.Count + this.Ways.Count + this.Relations.Count; - } - } - - /// - /// Gets a value indicating whether the collection is read-only. - /// - public bool IsReadOnly { - get { - return false; - } - } - - /// - /// Gets an entity with specific ID from the collection. - /// - /// The ID of the entity to get. + public class OsmDatabase : IEntityCollection where T : IOsmEntity where N : T where W : T where R : T + { + + /// + /// Initializes a new instance of the OsmDatabase class that is empty. + /// + internal OsmDatabase() + { + this.Nodes = new EntityCollection(); + this.Ways = new EntityCollection(); + this.Relations = new EntityCollection(); + } + + /// + /// Initializes a new instance of the OsmDatabase class with specific entities. + /// + /// Entities to add to the database. + internal OsmDatabase(IEnumerable entities) + : this() + { + foreach (var entity in entities) + { + this.Add(entity); + } + } + + /// + /// Gets collection of nodes in the database. + /// + public ITypedEntityCollection Nodes { get; private set; } + + /// + /// Gets collection of ways in the database. + /// + public ITypedEntityCollection Ways { get; private set; } + + /// + /// Gets collection of relations in the database. + /// + public ITypedEntityCollection Relations { get; private set; } + + /// + /// Gets the number of entities in the collection. + /// + public int Count + { + get + { + return this.Nodes.Count + this.Ways.Count + this.Relations.Count; + } + } + + /// + /// Gets a value indicating whether the collection is read-only. + /// + public bool IsReadOnly + { + get + { + return false; + } + } + + /// + /// Gets an entity with specific ID from the collection. + /// + /// The ID of the entity to get. /// The type of the entity to get. - /// entity with the specific ID or null if such entity is not present in the collection. - public T this[long id, EntityType type] { - get { - if (type == EntityType.Node && this.Nodes.Contains(id)) { - return (T)this.Nodes[id]; - } - - if (type == EntityType.Way && this.Ways.Contains(id)) { - return (T)this.Ways[id]; - } - - if (type == EntityType.Relation && this.Relations.Contains(id)) { - return (T)this.Relations[id]; - } - - return default(T); - } - } - - /// - /// When overridden in derived class, saves entities from the database to specific writer. - /// - /// IOsmWriter to save entities to. - public virtual void Save(IOsmWriter writer) { - } - - /// - /// Removes an entity with the specific ID from the collection. - /// - /// The ID of the entity to remove from the collection. + /// entity with the specific ID or null if such entity is not present in the collection. + public T this[long id, EntityType type] + { + get + { + if (type == EntityType.Node && this.Nodes.Contains(id)) + { + return (T)this.Nodes[id]; + } + + if (type == EntityType.Way && this.Ways.Contains(id)) + { + return (T)this.Ways[id]; + } + + if (type == EntityType.Relation && this.Relations.Contains(id)) + { + return (T)this.Relations[id]; + } + + return default(T); + } + } + + /// + /// When overridden in derived class, saves entities from the database to specific writer. + /// + /// IOsmWriter to save entities to. + public virtual void Save(IOsmWriter writer) + { + } + + /// + /// Removes an entity with the specific ID from the collection. + /// + /// The ID of the entity to remove from the collection. /// The type of the entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(long id, EntityType type) { - if (this.Nodes.Contains(id)) { - return this.Nodes.Remove(id); - } - - if (this.Ways.Contains(id)) { - return this.Ways.Remove(id); - } - - if (this.Relations.Contains(id)) { - return this.Relations.Remove(id); - } - - return false; - } - - /// - /// Determines whether the EntityICollection contains an entity with specific ID. - /// - /// The ID of the entity to locate in the EntityCollection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(long id, EntityType type) + { + if (this.Nodes.Contains(id)) + { + return this.Nodes.Remove(id); + } + + if (this.Ways.Contains(id)) + { + return this.Ways.Remove(id); + } + + if (this.Relations.Contains(id)) + { + return this.Relations.Remove(id); + } + + return false; + } + + /// + /// Determines whether the EntityICollection contains an entity with specific ID. + /// + /// The ID of the entity to locate in the EntityCollection. /// The type of the entity to locate in the EntityCollection - /// true if entity is found in the collection, otherwise false. - public bool Contains(long id, EntityType type) { - switch (type) { + /// true if entity is found in the collection, otherwise false. + public bool Contains(long id, EntityType type) + { + switch (type) + { case EntityType.Node: return this.Nodes.Contains(id); case EntityType.Way: return this.Ways.Contains(id); case EntityType.Relation: return this.Relations.Contains(id); } throw new NotImplementedException(); - } - - /// - /// Adds specified entity to the collection. - /// - /// The entity to add to the collection. - public void Add(T entity) { - if (entity == null) { - throw new ArgumentNullException("entity", "Cannot add null to EntityCollection"); - } - - if (this.Contains(entity.ID, entity.EntityType)) { - throw new ArgumentException("An entity with the same ID has already been added."); - } - - switch (entity.EntityType) { - case EntityType.Node: this.Nodes.Add((N)entity); break; - case EntityType.Way: this.Ways.Add((W)entity); break; - case EntityType.Relation: this.Relations.Add((R)entity); break; - } - } - - /// - /// Removes all entities form the collection. - /// - public void Clear() { - this.Nodes.Clear(); - this.Ways.Clear(); - this.Relations.Clear(); - } - - /// - /// Determines whether the EntityICollection contains a specific entity. - /// - /// The entity to locate in the EntityCollection. - /// true if entity is found in the collection, otherwise false. - public bool Contains(T item) { - if (item == null) { - return false; - } - - return this.Contains(item.ID, item.EntityType); - } - - /// - /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. - /// The zero-based index in array at which copying begins. - public void CopyTo(T[] array, int arrayIndex) { - foreach (var entity in this) { - array[arrayIndex++] = entity; - } - } - - /// - /// Removes the specific entity from the collection. - /// - /// The entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(T entity) { - if (entity == null) { - return false; - } - - return this.Remove(entity.ID, entity.EntityType); - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator<T> that can be used to iterate through the collection. - public IEnumerator GetEnumerator() { - foreach (var node in this.Nodes) { - yield return node; - } - - foreach (var way in this.Ways) { - yield return way; - } - - foreach (var relation in this.Relations) { - yield return relation; - } - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return this.GetEnumerator(); - } + } + + /// + /// Adds specified entity to the collection. + /// + /// The entity to add to the collection. + public void Add(T entity) + { + if (entity == null) + { + throw new ArgumentNullException(nameof(entity), "Cannot add null to EntityCollection"); + } + + if (this.Contains(entity.ID, entity.EntityType)) + { + throw new ArgumentException("An entity with the same ID has already been added."); + } + + switch (entity.EntityType) + { + case EntityType.Node: this.Nodes.Add((N)entity); break; + case EntityType.Way: this.Ways.Add((W)entity); break; + case EntityType.Relation: this.Relations.Add((R)entity); break; + } + } + + /// + /// Removes all entities form the collection. + /// + public void Clear() + { + this.Nodes.Clear(); + this.Ways.Clear(); + this.Relations.Clear(); + } + + /// + /// Determines whether the EntityICollection contains a specific entity. + /// + /// The entity to locate in the EntityCollection. + /// true if entity is found in the collection, otherwise false. + public bool Contains(T item) + { + if (item == null) + { + return false; + } + + return this.Contains(item.ID, item.EntityType); + } + + /// + /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. + /// + /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. + /// The zero-based index in array at which copying begins. + public void CopyTo(T[] array, int arrayIndex) + { + foreach (var entity in this) + { + array[arrayIndex++] = entity; + } + } + + /// + /// Removes the specific entity from the collection. + /// + /// The entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(T entity) + { + if (entity == null) + { + return false; + } + + return this.Remove(entity.ID, entity.EntityType); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator<T> that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + foreach (var node in this.Nodes) + { + yield return node; + } + + foreach (var way in this.Ways) + { + yield return way; + } + + foreach (var relation in this.Relations) + { + yield return relation; + } + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } } } diff --git a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs index 7e0843a..c08d158 100644 --- a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs +++ b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs @@ -1,56 +1,65 @@ -using System.Collections.Generic; - -using SpatialLite.Osm.IO; - -namespace SpatialLite.Osm { - /// - /// Represents in-memory OSM entities database that contains entities as IEntityInfo objects. - /// - public class OsmEntityInfoDatabase : OsmDatabase { - - /// - /// Initializes a new instance of the OsmEntityInfoDatabase class that is empty. - /// - public OsmEntityInfoDatabase() - : base() { - } - - /// - /// Initializes a new instance of the OsmEntityInfoDatabase class with specific entities. - /// - /// Entities to add to the database. - public OsmEntityInfoDatabase(IEnumerable entities) - : base(entities) { - } - - /// - /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. - /// - /// The IOsmReader to read data from. - /// New instance of the OsmDAtabase class with data loaded from specified reader. - public static OsmEntityInfoDatabase Load(IOsmReader reader) { - OsmEntityInfoDatabase db = new OsmEntityInfoDatabase(); - - IEntityInfo entityInfo = null; - while ((entityInfo = reader.Read()) != null) { - switch (entityInfo.EntityType) { - case EntityType.Node: db.Nodes.Add((NodeInfo)entityInfo); break; - case EntityType.Way: db.Ways.Add((WayInfo)entityInfo); break; - case EntityType.Relation: db.Relations.Add((RelationInfo)entityInfo); break; - } - } - - return db; - } - - /// - /// Saves entities from the database to specific writer. - /// - /// IOsmWriter to save entities to. - public override void Save(IOsmWriter writer) { - foreach (var entity in this) { - writer.Write(entity); - } - } - } -} +using System.Collections.Generic; + +using SpatialLite.Osm.IO; + +namespace SpatialLite.Osm +{ + /// + /// Represents in-memory OSM entities database that contains entities as IEntityInfo objects. + /// + public class OsmEntityInfoDatabase : OsmDatabase + { + + /// + /// Initializes a new instance of the OsmEntityInfoDatabase class that is empty. + /// + public OsmEntityInfoDatabase() + : base() + { + } + + /// + /// Initializes a new instance of the OsmEntityInfoDatabase class with specific entities. + /// + /// Entities to add to the database. + public OsmEntityInfoDatabase(IEnumerable entities) + : base(entities) + { + } + + /// + /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. + /// + /// The IOsmReader to read data from. + /// New instance of the OsmDAtabase class with data loaded from specified reader. + public static OsmEntityInfoDatabase Load(IOsmReader reader) + { + OsmEntityInfoDatabase db = new OsmEntityInfoDatabase(); + + IEntityInfo entityInfo = null; + while ((entityInfo = reader.Read()) != null) + { + switch (entityInfo.EntityType) + { + case EntityType.Node: db.Nodes.Add((NodeInfo)entityInfo); break; + case EntityType.Way: db.Ways.Add((WayInfo)entityInfo); break; + case EntityType.Relation: db.Relations.Add((RelationInfo)entityInfo); break; + } + } + + return db; + } + + /// + /// Saves entities from the database to specific writer. + /// + /// IOsmWriter to save entities to. + public override void Save(IOsmWriter writer) + { + foreach (var entity in this) + { + writer.Write(entity); + } + } + } +} diff --git a/src/SpatialLite.Osm/Properties/AssemblyInfo.cs b/src/SpatialLite.Osm/Properties/AssemblyInfo.cs index 2912abd..2cb1564 100644 --- a/src/SpatialLite.Osm/Properties/AssemblyInfo.cs +++ b/src/SpatialLite.Osm/Properties/AssemblyInfo.cs @@ -18,4 +18,4 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("81094df5-f2b1-49e1-b545-e6f0528de92b")] -[assembly: InternalsVisibleTo("Tests.SpatialLite.Osm")] \ No newline at end of file +[assembly: InternalsVisibleTo("Tests.SpatialLite.Osm")] diff --git a/src/SpatialLite.Osm/RelationInfo.cs b/src/SpatialLite.Osm/RelationInfo.cs index c79f754..89f9ec0 100644 --- a/src/SpatialLite.Osm/RelationInfo.cs +++ b/src/SpatialLite.Osm/RelationInfo.cs @@ -2,72 +2,80 @@ using System.Collections.Generic; using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Represents information about relation. /// - public class RelationInfo : IEntityInfo { + public class RelationInfo : IEntityInfo + { - /// - /// Initializes a new instance of the RelationInfo class with specified ID, Tags, Member and optionally EntityMetadata. - /// - /// The id of the relation. - /// The collection of tags associated with the relation. - /// The members of the relation. - /// The EntityMetadata structure with additinal properties. Default value is null. - public RelationInfo(long id, TagsCollection tags, IList members, EntityMetadata additionalInfo = null) { - this.ID = id; - this.Tags = tags; - this.Members = members; - this.Metadata = additionalInfo; - } + /// + /// Initializes a new instance of the RelationInfo class with specified ID, Tags, Member and optionally EntityMetadata. + /// + /// The id of the relation. + /// The collection of tags associated with the relation. + /// The members of the relation. + /// The EntityMetadata structure with additinal properties. Default value is null. + public RelationInfo(long id, TagsCollection tags, IList members, EntityMetadata additionalInfo = null) + { + this.ID = id; + this.Tags = tags; + this.Members = members; + this.Metadata = additionalInfo; + } - /// - /// Initializes a new instance of the RelationInfo class with data from specific Relation. - /// - /// The Relation object to copy data from. - public RelationInfo(Relation source) { - if (source == null) { - throw new ArgumentNullException("Source relation cannot be null", "source"); - } + /// + /// Initializes a new instance of the RelationInfo class with data from specific Relation. + /// + /// The Relation object to copy data from. + public RelationInfo(Relation source) + { + if (source == null) + { + throw new ArgumentNullException(nameof(source), "Source relation cannot be null"); + } - this.ID = source.ID; - this.Tags = source.Tags; - this.Metadata = source.Metadata; + this.ID = source.ID; + this.Tags = source.Tags; + this.Metadata = source.Metadata; - this.Members = new List(source.Geometries.Count); - foreach (var member in source.Geometries) { - this.Members.Add(new RelationMemberInfo(member)); - } - } + this.Members = new List(source.Geometries.Count); + foreach (var member in source.Geometries) + { + this.Members.Add(new RelationMemberInfo(member)); + } + } - /// - /// Gets type of the object that is represented by this IOsmGeometryInfo. - /// - public EntityType EntityType { - get { - return EntityType.Relation; - } - } + /// + /// Gets type of the object that is represented by this IOsmGeometryInfo. + /// + public EntityType EntityType + { + get + { + return EntityType.Relation; + } + } - /// - /// Gets ID of the relation. - /// - public long ID { get; set; } + /// + /// Gets ID of the relation. + /// + public long ID { get; set; } - /// - /// Gets the collection of tags associated with the relation. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets the collection of tags associated with the relation. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets list of members of the relation. - /// - public IList Members { get; set; } + /// + /// Gets list of members of the relation. + /// + public IList Members { get; set; } - /// - /// Gets additional information about this RelationInfo. - /// - public EntityMetadata Metadata { get; set; } - } + /// + /// Gets additional information about this RelationInfo. + /// + public EntityMetadata Metadata { get; set; } + } } diff --git a/src/SpatialLite.Osm/RelationMemberInfo.cs b/src/SpatialLite.Osm/RelationMemberInfo.cs index 2451771..c4e818b 100644 --- a/src/SpatialLite.Osm/RelationMemberInfo.cs +++ b/src/SpatialLite.Osm/RelationMemberInfo.cs @@ -1,35 +1,38 @@ using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Represents information about relation member. /// - public struct RelationMemberInfo { + public struct RelationMemberInfo + { - /// - /// The type of the member (node, way, relation) - /// - public EntityType MemberType; + /// + /// The type of the member (node, way, relation) + /// + public EntityType MemberType; - /// - /// The role of the member in relation - /// - public string Role; + /// + /// The role of the member in relation + /// + public string Role; - /// - /// The ID of the member entity - /// - public long Reference; + /// + /// The ID of the member entity + /// + public long Reference; - /// - /// Initializes a new instance of the RelationMemberInfo structure with values from specific RelationMember. - /// - /// The RelationMember object to copy valyes from. - public RelationMemberInfo(RelationMember source) { - this.Reference = source.Member.ID; - this.MemberType = source.MemberType; - this.Role = source.Role; - } + /// + /// Initializes a new instance of the RelationMemberInfo structure with values from specific RelationMember. + /// + /// The RelationMember object to copy valyes from. + public RelationMemberInfo(RelationMember source) + { + this.Reference = source.Member.ID; + this.MemberType = source.MemberType; + this.Role = source.Role; + } - } + } } diff --git a/src/SpatialLite.Osm/Tag.cs b/src/SpatialLite.Osm/Tag.cs index 8fe782f..47c185c 100644 --- a/src/SpatialLite.Osm/Tag.cs +++ b/src/SpatialLite.Osm/Tag.cs @@ -1,92 +1,109 @@ -using System; - -namespace SpatialLite.Osm { - /// - /// Represents OSM tag and it's value. - /// - public class Tag { - - private string _key; - private string _value; - - /// - /// Initializes a new instance of the Tag class with specified key and value. - /// - /// The key of the Tag. - /// The value of the Tag. - public Tag(string key, string value) { - if (key == null) { - throw new ArgumentNullException("Parameter 'key' can't be null."); - } - - if (key == string.Empty) { - throw new ArgumentException("Parameter 'key' can't be empty string."); - } - - if (value == null) { - throw new ArgumentNullException("Parameter 'value' can't be null."); - } - - _key = key; - _value = value; - } - - /// - /// Gets the key of the tag. - /// - public string Key { - get { - return _key; - } - } - - /// - /// Gets the value of the tag. - /// - public string Value { - get { - return _value; - } - } - - /// - /// Compares the current Tag object with the specified object for equivalence. - /// - /// The object to test for equivalence with the current Tag object. - /// true if the objects are equal, otherwise returns false. - public override bool Equals(object obj) { - if (obj == null) { - return false; - } - - Tag other = obj as Tag; - if (other != null) { - return Equals(other); - } - else { - return false; - } - } - - /// - /// Compares the current Tag object with the specified Tag. - /// - /// The Tag to test for equivalence with the current Tag object. - /// true if the objects are equal, otherwise returns false. - public bool Equals(Tag other) { - if (other == null) { - return false; - } - - return _key.Equals(other._key) && _value.Equals(other._value); - } - - /// - /// Returns the hash code for the current object. - /// - /// An integer hash code. - public override int GetHashCode() { - return unchecked(_key.GetHashCode() * 83 + _value.GetHashCode()); - } - } -} +using System; + +namespace SpatialLite.Osm +{ + /// + /// Represents OSM tag and it's value. + /// + public class Tag + { + + private string _key; + private string _value; + + /// + /// Initializes a new instance of the Tag class with specified key and value. + /// + /// The key of the Tag. + /// The value of the Tag. + public Tag(string key, string value) + { + if (key == null) + { + throw new ArgumentNullException("Parameter 'key' can't be null."); + } + + if (key == string.Empty) + { + throw new ArgumentException("Parameter 'key' can't be empty string."); + } + + if (value == null) + { + throw new ArgumentNullException("Parameter 'value' can't be null."); + } + + _key = key; + _value = value; + } + + /// + /// Gets the key of the tag. + /// + public string Key + { + get + { + return _key; + } + } + + /// + /// Gets the value of the tag. + /// + public string Value + { + get + { + return _value; + } + } + + /// + /// Compares the current Tag object with the specified object for equivalence. + /// + /// The object to test for equivalence with the current Tag object. + /// true if the objects are equal, otherwise returns false. + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + + Tag other = obj as Tag; + if (other != null) + { + return Equals(other); + } + else + { + return false; + } + } + + /// + /// Compares the current Tag object with the specified Tag. + /// + /// The Tag to test for equivalence with the current Tag object. + /// true if the objects are equal, otherwise returns false. + public bool Equals(Tag other) + { + if (other == null) + { + return false; + } + + return _key.Equals(other._key) && _value.Equals(other._value); + } + + /// + /// Returns the hash code for the current object. + /// + /// An integer hash code. + public override int GetHashCode() + { + return unchecked(_key.GetHashCode() * 83 + _value.GetHashCode()); + } + } +} diff --git a/src/SpatialLite.Osm/TagsCollection.cs b/src/SpatialLite.Osm/TagsCollection.cs index 206d47e..f7e9eb6 100644 --- a/src/SpatialLite.Osm/TagsCollection.cs +++ b/src/SpatialLite.Osm/TagsCollection.cs @@ -1,222 +1,266 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace SpatialLite.Osm { - /// - /// Represents collection of Tags that are accesible by their key. - /// - public class TagsCollection : ICollection { - - private List _tags; - - /// - /// Initializes a new instance of the TagsCollection class. - /// - public TagsCollection() { - } - - /// - /// Initializes a new instance of the TagsCollection class with specified tags. - /// - /// Collection of tags. - public TagsCollection(IEnumerable tags) { - _tags = new List(tags.Count()); - - foreach (var tag in tags) { - this.Add(tag); - } - } - - /// - /// Gets the number of Tags in the TagsCollection. - /// - public int Count { - get { - if (_tags == null) { - return 0; - } - else { - return _tags.Count; - } - } - } - - /// - /// Gets a value indicating whether the TagsCollection is read-only. - /// - public bool IsReadOnly { - get { return false; } - } - - /// - /// Gets or sets value of the Tag with given key. - /// - /// The string key of Tag. - /// The value of the Tag or null if Tag isn't found. - public string this[string key] { - get { - Tag tag = this.GetTag(key); - return tag.Value; - } - set { - if (this.Contains(key)) { - this.Remove(key); - this.Add(new Tag(key, value)); - } - else { - this.Add(new Tag(key, value)); - } - } - } - - /// - /// Adds Tag to the TagsCollection. - /// - /// The Tag to add to the TagsCollection. - public void Add(Tag tag) { - if (_tags == null) { - _tags = new List(); - } - - if (this.Contains(tag.Key)) { - throw new ArgumentException(string.Format("Tag with key '{0}' is already present in the collection.", tag.Key)); - } - - _tags.Add(tag); - } - - /// - /// Removes all items from the TagsCollection. - /// - public void Clear() { - if (_tags != null) { - _tags.Clear(); - } - } - - /// - /// Determines whether the TagsCollection contains a specific value. - /// - /// The Tag to locate in the TagsCollection. - /// true if item is found in the TagsCollection; otherwise, false. - public bool Contains(Tag item) { - if (_tags == null) { - return false; - } - - return _tags.Contains(item); - } - - /// - /// Determines whether the TagsCollection contains a Tag with specified key. - /// - /// The key of a Tag to locate in the TagsCollection. - /// true if item is found in the TagsCollection; otherwise, false. - public bool Contains(string key) { - if (_tags == null) { - return false; - } - - for (int i = 0; i < _tags.Count; i++) { - if (_tags[i].Key == key) { - return true; - } - } - - return false; - } - - /// - /// opies the entire TagCollection to a compatible one-dimensional Array, starting at the specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from TagCollection. - /// The zero-based index in array at which copying begins. - public void CopyTo(Tag[] array, int arrayIndex) { - if (_tags != null) { - _tags.CopyTo(array, arrayIndex); - } - } - - /// - /// Gets Tag with the specified key from the collection. - /// - /// The key of the Tag. - /// Tag with specified Key or null, if the Tag is not found in the TagsCollection. - public Tag GetTag(string key) { - if (_tags == null) { - throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); - } - - for (int i = 0; i < _tags.Count; i++) { - if (_tags[i].Key == key) { - return _tags[i]; - } - } - - throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); - } - - /// - /// Removes the specific Tag from the TagsCollection. - /// - /// The Tag to remove from the TagsCollection. - /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. - public bool Remove(Tag item) { - if (_tags == null) { - return false; - } - - return _tags.Remove(item); - } - - /// - /// Removes the Tag with specified key from the TagsCollection. - /// - /// The Key of the Tag to remove from the TagsCollection. - /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. - public bool Remove(string key) { - if (this.Contains(key)) { - Tag tag = this.GetTag(key); - return this.Remove(tag); - } - else { - return false; - } - } - - /// - /// Returns an generic enumerator that iterates through a collection. - /// - /// An generic IEnumerator object that can be used to iterate through the collection. - public IEnumerator GetEnumerator() { - if (_tags == null) { - return this.GetEmptyEnumerator(); - } - else { - return _tags.GetEnumerator(); - } - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// An IEnumerator object that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - if (_tags == null) { - return this.GetEmptyEnumerator(); - } - else { - return _tags.GetEnumerator(); - } - } - - /// - /// Returns Enumerator for empty collection. - /// - /// Enumerator that returns no items. - private IEnumerator GetEmptyEnumerator() { - yield break; - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; + +namespace SpatialLite.Osm +{ + /// + /// Represents collection of Tags that are accesible by their key. + /// + public class TagsCollection : ICollection + { + + private List _tags; + + /// + /// Initializes a new instance of the TagsCollection class. + /// + public TagsCollection() + { + } + + /// + /// Initializes a new instance of the TagsCollection class with specified tags. + /// + /// Collection of tags. + public TagsCollection(IEnumerable tags) + { + _tags = new List(tags.Count()); + + foreach (var tag in tags) + { + this.Add(tag); + } + } + + /// + /// Gets the number of Tags in the TagsCollection. + /// + public int Count + { + get + { + if (_tags == null) + { + return 0; + } + else + { + return _tags.Count; + } + } + } + + /// + /// Gets a value indicating whether the TagsCollection is read-only. + /// + public bool IsReadOnly + { + get { return false; } + } + + /// + /// Gets or sets value of the Tag with given key. + /// + /// The string key of Tag. + /// The value of the Tag or null if Tag isn't found. + public string this[string key] + { + get + { + Tag tag = this.GetTag(key); + return tag.Value; + } + set + { + if (this.Contains(key)) + { + this.Remove(key); + this.Add(new Tag(key, value)); + } + else + { + this.Add(new Tag(key, value)); + } + } + } + + /// + /// Adds Tag to the TagsCollection. + /// + /// The Tag to add to the TagsCollection. + public void Add(Tag tag) + { + if (_tags == null) + { + _tags = new List(); + } + + if (this.Contains(tag.Key)) + { + throw new ArgumentException(string.Format("Tag with key '{0}' is already present in the collection.", tag.Key)); + } + + _tags.Add(tag); + } + + /// + /// Removes all items from the TagsCollection. + /// + public void Clear() + { + if (_tags != null) + { + _tags.Clear(); + } + } + + /// + /// Determines whether the TagsCollection contains a specific value. + /// + /// The Tag to locate in the TagsCollection. + /// true if item is found in the TagsCollection; otherwise, false. + public bool Contains(Tag item) + { + if (_tags == null) + { + return false; + } + + return _tags.Contains(item); + } + + /// + /// Determines whether the TagsCollection contains a Tag with specified key. + /// + /// The key of a Tag to locate in the TagsCollection. + /// true if item is found in the TagsCollection; otherwise, false. + public bool Contains(string key) + { + if (_tags == null) + { + return false; + } + + for (int i = 0; i < _tags.Count; i++) + { + if (_tags[i].Key == key) + { + return true; + } + } + + return false; + } + + /// + /// opies the entire TagCollection to a compatible one-dimensional Array, starting at the specified index of the target array. + /// + /// The one-dimensional Array that is the destination of the elements copied from TagCollection. + /// The zero-based index in array at which copying begins. + public void CopyTo(Tag[] array, int arrayIndex) + { + if (_tags != null) + { + _tags.CopyTo(array, arrayIndex); + } + } + + /// + /// Gets Tag with the specified key from the collection. + /// + /// The key of the Tag. + /// Tag with specified Key or null, if the Tag is not found in the TagsCollection. + public Tag GetTag(string key) + { + if (_tags == null) + { + throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); + } + + for (int i = 0; i < _tags.Count; i++) + { + if (_tags[i].Key == key) + { + return _tags[i]; + } + } + + throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); + } + + /// + /// Removes the specific Tag from the TagsCollection. + /// + /// The Tag to remove from the TagsCollection. + /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. + public bool Remove(Tag item) + { + if (_tags == null) + { + return false; + } + + return _tags.Remove(item); + } + + /// + /// Removes the Tag with specified key from the TagsCollection. + /// + /// The Key of the Tag to remove from the TagsCollection. + /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. + public bool Remove(string key) + { + if (this.Contains(key)) + { + Tag tag = this.GetTag(key); + return this.Remove(tag); + } + else + { + return false; + } + } + + /// + /// Returns an generic enumerator that iterates through a collection. + /// + /// An generic IEnumerator object that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + if (_tags == null) + { + return this.GetEmptyEnumerator(); + } + else + { + return _tags.GetEnumerator(); + } + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// An IEnumerator object that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + if (_tags == null) + { + return this.GetEmptyEnumerator(); + } + else + { + return _tags.GetEnumerator(); + } + } + + /// + /// Returns Enumerator for empty collection. + /// + /// Enumerator that returns no items. + private IEnumerator GetEmptyEnumerator() + { + yield break; + } + } +} diff --git a/src/SpatialLite.Osm/WayInfo.cs b/src/SpatialLite.Osm/WayInfo.cs index aa44c25..375cc7d 100644 --- a/src/SpatialLite.Osm/WayInfo.cs +++ b/src/SpatialLite.Osm/WayInfo.cs @@ -3,75 +3,83 @@ using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm { +namespace SpatialLite.Osm +{ /// /// Represents information about way. /// /// /// Nodes are represented with their id's only. /// - public class WayInfo : IEntityInfo { + public class WayInfo : IEntityInfo + { - /// - /// Initializes a new instance of the WayInfo class with specified ID, Nodes, collection of tags and optionaly EntityMetadata. - /// - /// The Id of the way. - /// The collection of tags associated with the way. - /// The nodes of the way. - /// The EntityMetadata structure with additinal properties. Default value is null. - public WayInfo(long id, TagsCollection tags, IList nodes, EntityMetadata additionalInfo = null) { - this.ID = id; - this.Tags = tags; - this.Nodes = nodes; - this.Metadata = additionalInfo; - } + /// + /// Initializes a new instance of the WayInfo class with specified ID, Nodes, collection of tags and optionaly EntityMetadata. + /// + /// The Id of the way. + /// The collection of tags associated with the way. + /// The nodes of the way. + /// The EntityMetadata structure with additinal properties. Default value is null. + public WayInfo(long id, TagsCollection tags, IList nodes, EntityMetadata additionalInfo = null) + { + this.ID = id; + this.Tags = tags; + this.Nodes = nodes; + this.Metadata = additionalInfo; + } /// /// Initializes a new instance of the WayInfo class with data from specific Way /// /// The way to get data from - public WayInfo(Way way) { - if (way == null) { - throw new ArgumentNullException("Way parameter cannot be null", "way"); - } + public WayInfo(Way way) + { + if (way == null) + { + throw new ArgumentNullException(nameof(way), "Way parameter cannot be null"); + } - this.ID = way.ID; - this.Tags = way.Tags; - this.Metadata = way.Metadata; + this.ID = way.ID; + this.Tags = way.Tags; + this.Metadata = way.Metadata; - this.Nodes = new List(way.Nodes.Count); - foreach (var node in way.Nodes) { - this.Nodes.Add(node.ID); - } - } + this.Nodes = new List(way.Nodes.Count); + foreach (var node in way.Nodes) + { + this.Nodes.Add(node.ID); + } + } - /// - /// Gets type of the object that is represented by this WayInfo. - /// - public EntityType EntityType { - get { - return EntityType.Way; - } - } + /// + /// Gets type of the object that is represented by this WayInfo. + /// + public EntityType EntityType + { + get + { + return EntityType.Way; + } + } - /// - /// Gets ID of the object. - /// - public long ID { get; set; } + /// + /// Gets ID of the object. + /// + public long ID { get; set; } - /// - /// Gets the collection of tags associated with this WayInfo. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets the collection of tags associated with this WayInfo. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets the list of id's of this way nodes. - /// - public IList Nodes { get; private set; } + /// + /// Gets the list of id's of this way nodes. + /// + public IList Nodes { get; private set; } - /// - /// Gets additional information about this IOsmGeometryInfo. - /// - public EntityMetadata Metadata { get; set; } - } + /// + /// Gets additional information about this IOsmGeometryInfo. + /// + public EntityMetadata Metadata { get; set; } + } } diff --git a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs index 947e936..1a8a68b 100644 --- a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs +++ b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs @@ -1,196 +1,220 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; - -namespace Tests.SpatialLite.Core.API { - public class CoordinateTests { - double xCoordinate = 3.5; - double yCoordinate = 4.2; - double zCoordinate = 10.5; - double mValue = 100.4; - - [Fact] - public void Constructor_XY_SetsXYValuesAndZMNaN() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); - - Assert.Equal(xCoordinate, target.X); - Assert.Equal(yCoordinate, target.Y); - Assert.Equal(double.NaN, target.Z); - Assert.Equal(double.NaN, target.M); - } - - [Fact] - public void Constructor_XYZ_SetsXYZValuesAndMNaN() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); - - Assert.Equal(xCoordinate, target.X); - Assert.Equal(yCoordinate, target.Y); - Assert.Equal(zCoordinate, target.Z); - Assert.Equal(double.NaN, target.M); - } - - [Fact] - public void Constructor_XYZM_SetsXYZMValues() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.Equal(xCoordinate, target.X); - Assert.Equal(yCoordinate, target.Y); - Assert.Equal(zCoordinate, target.Z); - Assert.Equal(mValue, target.M); - } - - [Fact] - public void Is3D_ReturnsFalseForNaNZCoordinate() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); - - Assert.False(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsTrueFor3D() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); - - Assert.True(target.Is3D); - } - - [Fact] - public void IsMeasured_ReturnsFalseForNaNMCoordinate() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredCoordinate() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target.IsMeasured); - } - - [Fact] - public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsTrueForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.True(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForNull() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - object other = null; - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForOtherObjectType() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - object other = "string"; - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target.Equals2D(other)); - } - - [Fact] - public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); - - Assert.True(target.Equals2D(other)); - } - - [Fact] - public void Equals2D_ReturnsTrueForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.True(target.Equals2D(other)); - } - - [Fact] - public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); - - Assert.False(target.Equals2D(other)); - } - - [Fact] - public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target == other); - } - - [Fact] - public void EqualsOperator_ReturnsTrueForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.True(target == other); - } - - [Fact] - public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); - - Assert.False(target == other); - } - - [Fact] - public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.False(target != other); - } - - [Fact] - public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.False(target != other); - } - - [Fact] - public void NotEqualsOperator_ReturnsTrueForCoordinateWithDifferentOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); - - Assert.True(target != other); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; +using Xunit.Extensions; + +using SpatialLite.Core.API; + +namespace Tests.SpatialLite.Core.API +{ + public class CoordinateTests + { + double xCoordinate = 3.5; + double yCoordinate = 4.2; + double zCoordinate = 10.5; + double mValue = 100.4; + + [Fact] + public void Constructor_XY_SetsXYValuesAndZMNaN() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate); + + Assert.Equal(xCoordinate, target.X); + Assert.Equal(yCoordinate, target.Y); + Assert.Equal(double.NaN, target.Z); + Assert.Equal(double.NaN, target.M); + } + + [Fact] + public void Constructor_XYZ_SetsXYZValuesAndMNaN() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); + + Assert.Equal(xCoordinate, target.X); + Assert.Equal(yCoordinate, target.Y); + Assert.Equal(zCoordinate, target.Z); + Assert.Equal(double.NaN, target.M); + } + + [Fact] + public void Constructor_XYZM_SetsXYZMValues() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.Equal(xCoordinate, target.X); + Assert.Equal(yCoordinate, target.Y); + Assert.Equal(zCoordinate, target.Z); + Assert.Equal(mValue, target.M); + } + + [Fact] + public void Is3D_ReturnsFalseForNaNZCoordinate() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate); + + Assert.False(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsTrueFor3D() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); + + Assert.True(target.Is3D); + } + + [Fact] + public void IsMeasured_ReturnsFalseForNaNMCoordinate() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredCoordinate() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target.IsMeasured); + } + + [Fact] + public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsTrueForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.True(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForNull() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + object other = null; + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForOtherObjectType() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + object other = "string"; + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target.Equals2D(other)); + } + + [Fact] + public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); + + Assert.True(target.Equals2D(other)); + } + + [Fact] + public void Equals2D_ReturnsTrueForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.True(target.Equals2D(other)); + } + + [Fact] + public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); + + Assert.False(target.Equals2D(other)); + } + + [Fact] + public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target == other); + } + + [Fact] + public void EqualsOperator_ReturnsTrueForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.True(target == other); + } + + [Fact] + public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + + Assert.False(target == other); + } + + [Fact] + public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.False(target != other); + } + + [Fact] + public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.False(target != other); + } + + [Fact] + public void NotEqualsOperator_ReturnsTrueForCoordinateWithDifferentOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + + Assert.True(target != other); + } + } +} diff --git a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs index ea04057..889e97f 100644 --- a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs +++ b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs @@ -1,237 +1,262 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace Tests.SpatialLite.Core.API { - public class EnvelopeTests { - - Coordinate[] _coordinates = new Coordinate[] { - new Coordinate(1, 10, 100, 1000), - new Coordinate(0, 0, 0, 0), - new Coordinate(-1, -10, -100, -1000) - }; - - Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); - Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); - Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); - - double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; - - static public IEnumerable _XYZEnvelopeDifferentBounds { - get { - yield return new object[] { new Coordinate[] { new Coordinate(1 + 1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000)} }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2 + 1, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100 + 1, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000 + 1), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5 + 1, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6 + 1, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200 + 1, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000 + 1) } }; - } - } - - internal void CheckBoundaries(Envelope target, double minX, double maxX, double minY, double maxY, double minZ, double maxZ, double minM, double maxM) { - Assert.Equal(minX, target.MinX); - Assert.Equal(maxX, target.MaxX); - Assert.Equal(minY, target.MinY); - Assert.Equal(maxY, target.MaxY); - Assert.Equal(minZ, target.MinZ); - Assert.Equal(maxZ, target.MaxZ); - Assert.Equal(minM, target.MinM); - Assert.Equal(maxM, target.MaxM); - } - - [Fact] - public void Constructor__InitializesBoundsToNaNValues() { - Envelope target = new Envelope(); - - Assert.Equal(double.NaN, target.MinX); - Assert.Equal(double.NaN, target.MaxX); - Assert.Equal(double.NaN, target.MinY); - Assert.Equal(double.NaN, target.MaxY); - Assert.Equal(double.NaN, target.MinZ); - Assert.Equal(double.NaN, target.MaxZ); - Assert.Equal(double.NaN, target.MinM); - Assert.Equal(double.NaN, target.MaxM); - } - - [Fact] - public void Constructor_Coordinate_InitializesXYZProperties() { - Envelope target = new Envelope(_coordinates[0]); - - CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); - } - - [Fact] - public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() { - Envelope source = new Envelope(_coordinates); - - Envelope target = new Envelope(source); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Constructor_Envelope_CopiesMinMaxValues() { - Envelope source = new Envelope(_coordinates); - - Envelope target = new Envelope(source); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new Envelope(); - target.Extend(_coordinates[0]); - - CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, - _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); - } - - [Fact] - public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() { - Envelope target = new Envelope(_coordinates); - - target.Extend(Coordinate.Empty); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() { - Envelope target = new Envelope(_coordinates); - - target.Extend(_lowerValues); - - CheckBoundaries(target, _lowerValues.X, _expectedBounds[1], _lowerValues.Y, _expectedBounds[3], _lowerValues.Z, _expectedBounds[5], _lowerValues.M, _expectedBounds[7]); - } - - [Fact] - public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() { - Envelope target = new Envelope(_coordinates); - - target.Extend(_higherValues); - - CheckBoundaries(target, _expectedBounds[0], _higherValues.X, _expectedBounds[2], _higherValues.Y, _expectedBounds[4], _higherValues.Z, _expectedBounds[6], _higherValues.M); - } - - [Fact] - public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() { - Envelope target = new Envelope(_coordinates); - - target.Extend(_insideCoordinate); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new Envelope(); - - target.Extend(_coordinates); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() { - Envelope target = new Envelope(_coordinates); - - target.Extend(new Coordinate[] {}); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Extend_IEnumerableCoordinate_ExtendsEnvelope() { - Envelope target = new Envelope(_coordinates); - - target.Extend(new Coordinate[] {_lowerValues, _higherValues }); - - CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); - } - - [Fact] - public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new Envelope(); - - target.Extend(new Envelope(_coordinates)); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() { - Envelope target = new Envelope(_coordinates); - - target.Extend(new Envelope(_coordinates[1])); - - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } - - [Fact] - public void Extend_Envelope_ExtendsEnvelope() { - Envelope target = new Envelope(_coordinates); - - target.Extend(new Envelope(new Coordinate[] {_lowerValues, _higherValues})); - - CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); - } - - [Fact] - public void Equals_ReturnsTrueForSameObjectInstance() { - Envelope target = new Envelope(_coordinates); - - Assert.True(target.Equals(target)); - } - - [Fact] - public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() { - Envelope target = new Envelope(_coordinates); - Envelope other = new Envelope(target); - - Assert.True(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForNull() { - Envelope target = new Envelope(_coordinates); - object other = null; - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForOtherObjectType() { - Envelope target = new Envelope(_coordinates); - object other = "string"; - - Assert.False(target.Equals(other)); - } - - [Theory] - [MemberData(nameof(_XYZEnvelopeDifferentBounds))] - public void Equals_ReturnsFalseForTheEnvelopeWithDifferentBounds(Coordinate[] corners) { - Envelope target = new Envelope(_coordinates); - Envelope other = new Envelope(corners); - - Assert.False(target.Equals(other)); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; +using Xunit.Extensions; + +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace Tests.SpatialLite.Core.API +{ + public class EnvelopeTests + { + + Coordinate[] _coordinates = new Coordinate[] { + new Coordinate(1, 10, 100, 1000), + new Coordinate(0, 0, 0, 0), + new Coordinate(-1, -10, -100, -1000) + }; + + Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); + Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); + Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); + + double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; + + static public IEnumerable _XYZEnvelopeDifferentBounds + { + get + { + yield return new object[] { new Coordinate[] { new Coordinate(1 + 1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2 + 1, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100 + 1, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000 + 1), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5 + 1, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6 + 1, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200 + 1, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000 + 1) } }; + } + } + + internal void CheckBoundaries(Envelope target, double minX, double maxX, double minY, double maxY, double minZ, double maxZ, double minM, double maxM) + { + Assert.Equal(minX, target.MinX); + Assert.Equal(maxX, target.MaxX); + Assert.Equal(minY, target.MinY); + Assert.Equal(maxY, target.MaxY); + Assert.Equal(minZ, target.MinZ); + Assert.Equal(maxZ, target.MaxZ); + Assert.Equal(minM, target.MinM); + Assert.Equal(maxM, target.MaxM); + } + + [Fact] + public void Constructor__InitializesBoundsToNaNValues() + { + Envelope target = new Envelope(); + + Assert.Equal(double.NaN, target.MinX); + Assert.Equal(double.NaN, target.MaxX); + Assert.Equal(double.NaN, target.MinY); + Assert.Equal(double.NaN, target.MaxY); + Assert.Equal(double.NaN, target.MinZ); + Assert.Equal(double.NaN, target.MaxZ); + Assert.Equal(double.NaN, target.MinM); + Assert.Equal(double.NaN, target.MaxM); + } + + [Fact] + public void Constructor_Coordinate_InitializesXYZProperties() + { + Envelope target = new Envelope(_coordinates[0]); + + CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); + } + + [Fact] + public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() + { + Envelope source = new Envelope(_coordinates); + + Envelope target = new Envelope(source); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Constructor_Envelope_CopiesMinMaxValues() + { + Envelope source = new Envelope(_coordinates); + + Envelope target = new Envelope(source); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() + { + Envelope target = new Envelope(); + target.Extend(_coordinates[0]); + + CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, + _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); + } + + [Fact] + public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(Coordinate.Empty); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(_lowerValues); + + CheckBoundaries(target, _lowerValues.X, _expectedBounds[1], _lowerValues.Y, _expectedBounds[3], _lowerValues.Z, _expectedBounds[5], _lowerValues.M, _expectedBounds[7]); + } + + [Fact] + public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(_higherValues); + + CheckBoundaries(target, _expectedBounds[0], _higherValues.X, _expectedBounds[2], _higherValues.Y, _expectedBounds[4], _higherValues.Z, _expectedBounds[6], _higherValues.M); + } + + [Fact] + public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(_insideCoordinate); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() + { + Envelope target = new Envelope(); + + target.Extend(_coordinates); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(new Coordinate[] { }); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Extend_IEnumerableCoordinate_ExtendsEnvelope() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(new Coordinate[] { _lowerValues, _higherValues }); + + CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); + } + + [Fact] + public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() + { + Envelope target = new Envelope(); + + target.Extend(new Envelope(_coordinates)); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(new Envelope(_coordinates[1])); + + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } + + [Fact] + public void Extend_Envelope_ExtendsEnvelope() + { + Envelope target = new Envelope(_coordinates); + + target.Extend(new Envelope(new Coordinate[] { _lowerValues, _higherValues })); + + CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); + } + + [Fact] + public void Equals_ReturnsTrueForSameObjectInstance() + { + Envelope target = new Envelope(_coordinates); + + Assert.True(target.Equals(target)); + } + + [Fact] + public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() + { + Envelope target = new Envelope(_coordinates); + Envelope other = new Envelope(target); + + Assert.True(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForNull() + { + Envelope target = new Envelope(_coordinates); + object other = null; + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForOtherObjectType() + { + Envelope target = new Envelope(_coordinates); + object other = "string"; + + Assert.False(target.Equals(other)); + } + + [Theory] + [MemberData(nameof(_XYZEnvelopeDifferentBounds))] + public void Equals_ReturnsFalseForTheEnvelopeWithDifferentBounds(Coordinate[] corners) + { + Envelope target = new Envelope(_coordinates); + Envelope other = new Envelope(corners); + + Assert.False(target.Equals(other)); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs index b73a5af..972adf4 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs @@ -1,232 +1,260 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Xunit.Extensions; -using Moq; - -using SpatialLite.Core.API; -using SpatialLite.Core.Algorithms; - -namespace Tests.SpatialLite.Core.Algorithms { - public class Euclidean2DCalculatorTests { - public static IEnumerable CoordinatesSameXYOrdinates { - get { - yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2) }; - yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1) }; - yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1, 1) }; - } - } - - [Theory] - [MemberData(nameof(CoordinatesSameXYOrdinates))] - public void ComputeDistance_CoordinateCoordinate_ReturnsZeroForPointsWithSameXYCoordinates(Coordinate c1, Coordinate c2) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c1, c2); - - Assert.Equal(0, distance); - } - - public static IEnumerable CoordinatesDistanceTestData { - get { - yield return new object[] { new Coordinate(-1, 0), new Coordinate(1, 0), 2 }; - yield return new object[] { new Coordinate(0, -1), new Coordinate(0, 1), 2 }; - yield return new object[] { new Coordinate(2, 1), new Coordinate(-1, -3), 5 }; - } - } - - [Theory] - [MemberData(nameof(CoordinatesDistanceTestData))] - public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinates(Coordinate c1, Coordinate c2, double expectedDistance) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c1, c2); - - Assert.Equal(expectedDistance, distance); - } - - [Fact] - public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() { - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(new Coordinate(-1, 0, 100), new Coordinate(1, 0, -100)); - - Assert.Equal(2, distance); - } - - [Fact] - public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsDistanceToEndPointsIfPointsProjectionLiesOutsideSegment() { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(-1, -1); - Coordinate c1 = new Coordinate(1,2); - Coordinate c2 = new Coordinate(-1,-2); - - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distanceC1 = target.CalculateDistance(c1, A, B, LineMode.LineSegment); - Assert.Equal(1, distanceC1); - - double distanceC2 = target.CalculateDistance(c2, A, B, LineMode.LineSegment); - Assert.Equal(1, distanceC2); - } - - public static IEnumerable LineSegmentDistanceTestData { - get { - yield return new object[] { new Coordinate(0.5, 1), new Coordinate(-1, 0), new Coordinate(1, 0), 1 }; - yield return new object[] { new Coordinate(1, 0.5), new Coordinate(0, -1), new Coordinate(0, 1), 1 }; - yield return new object[] { new Coordinate(-1, 1), new Coordinate(-5, -5), new Coordinate(5,5), Math.Sqrt(2) }; - } - } - - [Theory] - [MemberData(nameof(LineSegmentDistanceTestData))] - public void ComputeDistance_CoordinateLineLineSegmentMode_ComputesPerpendicularDistanceToLineIfPointsProjectionLiesInside(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); - Assert.Equal(expectedDistance, distance); - } - - public static IEnumerable LineSegmentDistanceZeroDistanceTestData { - get { - yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, 0), new Coordinate(1, 0) }; - yield return new object[] { new Coordinate(0, -1), new Coordinate(0, -1), new Coordinate(0, 1) }; - yield return new object[] { new Coordinate(0, 0), new Coordinate(0, -1), new Coordinate(0, 1) }; - } - } - - [Theory] - [MemberData(nameof(LineSegmentDistanceZeroDistanceTestData))] - public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLiesOnLineSegment(Coordinate c, Coordinate A, Coordinate B) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); - Assert.Equal(0, distance); - } - - [Fact] - public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIfABAreEquals() { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(1, 1); - Coordinate c = new Coordinate(1, 2); - - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); - Assert.Equal(1, distance); - } - - [Fact] - public void ComputeDistance_CoordinateLineLineMode_ReturnsPointDistanceIfABAreEquals() { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(1, 1); - Coordinate c = new Coordinate(1, 2); - - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c, A, B, LineMode.Line); - Assert.Equal(1, distance); - } - - public static IEnumerable LineDistanceZeroDistanceTestData { - get { - yield return new object[] { new Coordinate(-2, -2), new Coordinate(-1, -1), new Coordinate(1, 1) }; - yield return new object[] { new Coordinate(2, 2), new Coordinate(-1, -1), new Coordinate(1, 1) }; - yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, -1), new Coordinate(1, 1) }; - } - } - - [Theory] - [MemberData(nameof(LineDistanceZeroDistanceTestData))] - public void ComputeDistance_CoordinateLineLineMode_ReturnsZeroIfPointLiesOnLine(Coordinate c, Coordinate A, Coordinate B) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c, A, B, LineMode.Line); - Assert.Equal(0, distance); - } - - public static IEnumerable LineDistanceTestData { - get { - yield return new object[] { new Coordinate(-3, -1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; - yield return new object[] { new Coordinate(-1, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; - yield return new object[] { new Coordinate(3, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; - } - } - - [Theory] - [MemberData(nameof(LineDistanceTestData))] - public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistanceToLine(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double distance = target.CalculateDistance(c, A, B, LineMode.Line); - Assert.Equal(expectedDistance, distance); - } - - [Fact] - public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() { - Mock listM = new Mock(); - listM.SetupGet(l => l.Count).Returns(2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - Assert.Throws(() => target.CalculateArea(listM.Object)); - } - - [Fact] - public void ComputeArea_ReturnsAreaOfConvexPolygon() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; - double expectedArea = 2.5; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(5); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[3]); - listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.Equal(expectedArea, area); - } - - [Fact] - public void ComputeArea_ReturnsAreaOfConcavePolygon() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; - double expectedArea = 1.5; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(5); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[3]); - listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.Equal(expectedArea, area); - } - - [Fact] - public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2), new Coordinate(1, 1) }; - double expectedArea = 2.5; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(6); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[3]); - listM.Setup(list => list[4]).Returns(coordinates[4]); - listM.Setup(list => list[5]).Returns(coordinates[5]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.Equal(expectedArea, area); - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; +using Xunit.Extensions; +using Moq; + +using SpatialLite.Core.API; +using SpatialLite.Core.Algorithms; + +namespace Tests.SpatialLite.Core.Algorithms +{ + public class Euclidean2DCalculatorTests + { + public static IEnumerable CoordinatesSameXYOrdinates + { + get + { + yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2) }; + yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1) }; + yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1, 1) }; + } + } + + [Theory] + [MemberData(nameof(CoordinatesSameXYOrdinates))] + public void ComputeDistance_CoordinateCoordinate_ReturnsZeroForPointsWithSameXYCoordinates(Coordinate c1, Coordinate c2) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c1, c2); + + Assert.Equal(0, distance); + } + + public static IEnumerable CoordinatesDistanceTestData + { + get + { + yield return new object[] { new Coordinate(-1, 0), new Coordinate(1, 0), 2 }; + yield return new object[] { new Coordinate(0, -1), new Coordinate(0, 1), 2 }; + yield return new object[] { new Coordinate(2, 1), new Coordinate(-1, -3), 5 }; + } + } + + [Theory] + [MemberData(nameof(CoordinatesDistanceTestData))] + public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinates(Coordinate c1, Coordinate c2, double expectedDistance) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c1, c2); + + Assert.Equal(expectedDistance, distance); + } + + [Fact] + public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(new Coordinate(-1, 0, 100), new Coordinate(1, 0, -100)); + + Assert.Equal(2, distance); + } + + [Fact] + public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsDistanceToEndPointsIfPointsProjectionLiesOutsideSegment() + { + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(-1, -1); + Coordinate c1 = new Coordinate(1, 2); + Coordinate c2 = new Coordinate(-1, -2); + + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distanceC1 = target.CalculateDistance(c1, A, B, LineMode.LineSegment); + Assert.Equal(1, distanceC1); + + double distanceC2 = target.CalculateDistance(c2, A, B, LineMode.LineSegment); + Assert.Equal(1, distanceC2); + } + + public static IEnumerable LineSegmentDistanceTestData + { + get + { + yield return new object[] { new Coordinate(0.5, 1), new Coordinate(-1, 0), new Coordinate(1, 0), 1 }; + yield return new object[] { new Coordinate(1, 0.5), new Coordinate(0, -1), new Coordinate(0, 1), 1 }; + yield return new object[] { new Coordinate(-1, 1), new Coordinate(-5, -5), new Coordinate(5, 5), Math.Sqrt(2) }; + } + } + + [Theory] + [MemberData(nameof(LineSegmentDistanceTestData))] + public void ComputeDistance_CoordinateLineLineSegmentMode_ComputesPerpendicularDistanceToLineIfPointsProjectionLiesInside(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); + Assert.Equal(expectedDistance, distance); + } + + public static IEnumerable LineSegmentDistanceZeroDistanceTestData + { + get + { + yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, 0), new Coordinate(1, 0) }; + yield return new object[] { new Coordinate(0, -1), new Coordinate(0, -1), new Coordinate(0, 1) }; + yield return new object[] { new Coordinate(0, 0), new Coordinate(0, -1), new Coordinate(0, 1) }; + } + } + + [Theory] + [MemberData(nameof(LineSegmentDistanceZeroDistanceTestData))] + public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLiesOnLineSegment(Coordinate c, Coordinate A, Coordinate B) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); + Assert.Equal(0, distance); + } + + [Fact] + public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIfABAreEquals() + { + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(1, 1); + Coordinate c = new Coordinate(1, 2); + + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); + Assert.Equal(1, distance); + } + + [Fact] + public void ComputeDistance_CoordinateLineLineMode_ReturnsPointDistanceIfABAreEquals() + { + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(1, 1); + Coordinate c = new Coordinate(1, 2); + + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c, A, B, LineMode.Line); + Assert.Equal(1, distance); + } + + public static IEnumerable LineDistanceZeroDistanceTestData + { + get + { + yield return new object[] { new Coordinate(-2, -2), new Coordinate(-1, -1), new Coordinate(1, 1) }; + yield return new object[] { new Coordinate(2, 2), new Coordinate(-1, -1), new Coordinate(1, 1) }; + yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, -1), new Coordinate(1, 1) }; + } + } + + [Theory] + [MemberData(nameof(LineDistanceZeroDistanceTestData))] + public void ComputeDistance_CoordinateLineLineMode_ReturnsZeroIfPointLiesOnLine(Coordinate c, Coordinate A, Coordinate B) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c, A, B, LineMode.Line); + Assert.Equal(0, distance); + } + + public static IEnumerable LineDistanceTestData + { + get + { + yield return new object[] { new Coordinate(-3, -1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; + yield return new object[] { new Coordinate(-1, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; + yield return new object[] { new Coordinate(3, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; + } + } + + [Theory] + [MemberData(nameof(LineDistanceTestData))] + public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistanceToLine(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double distance = target.CalculateDistance(c, A, B, LineMode.Line); + Assert.Equal(expectedDistance, distance); + } + + [Fact] + public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() + { + Mock listM = new Mock(); + listM.SetupGet(l => l.Count).Returns(2); + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + Assert.Throws(() => target.CalculateArea(listM.Object)); + } + + [Fact] + public void ComputeArea_ReturnsAreaOfConvexPolygon() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; + double expectedArea = 2.5; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(5); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[3]); + listM.Setup(list => list[4]).Returns(coordinates[4]); + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.Equal(expectedArea, area); + } + + [Fact] + public void ComputeArea_ReturnsAreaOfConcavePolygon() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; + double expectedArea = 1.5; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(5); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[3]); + listM.Setup(list => list[4]).Returns(coordinates[4]); + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.Equal(expectedArea, area); + } + + [Fact] + public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2), new Coordinate(1, 1) }; + double expectedArea = 2.5; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(6); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[3]); + listM.Setup(list => list[4]).Returns(coordinates[4]); + listM.Setup(list => list[5]).Returns(coordinates[5]); + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.Equal(expectedArea, area); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs index 3f39061..fc39ccc 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs @@ -1,271 +1,300 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; -using SpatialLite.Core.Algorithms; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.IO; - -namespace Tests.SpatialLite.Core.Algorithms { - public class Euclidean2DLocatorTests { - - [Fact] - public void IsOnLine_ReturnsTrueIfPointIsOnAorB() { - Coordinate a = new Coordinate(-10, 0); - Coordinate b = new Coordinate(3, 2); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.IsOnLine(a, a, b, LineMode.Line)); - Assert.True(target.IsOnLine(b, a, b, LineMode.Line)); - } - - public static IEnumerable PointsBetweenAB { - get { - yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; - } - } - - [Theory] - [MemberData(nameof(PointsBetweenAB))] - public void IsOnLine_ReturnsTrueIfPointLiesBetweenAAndB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.IsOnLine(c, a, b, mode)); - } - - public static IEnumerable PointsOnAB { - get { - yield return new object[] { new Coordinate(-11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; - yield return new object[] { new Coordinate(11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; - } - } - - [Theory] - [MemberData(nameof(PointsOnAB))] - public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coordinate a, Coordinate b) { - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.IsOnLine(c, a, b, LineMode.Line)); - } - - [Theory] - [MemberData(nameof(PointsOnAB))] - public void IsOnLine_ReturnsFalseIfPointLiesOnABAndModeIsLineSegment(Coordinate c, Coordinate a, Coordinate b) { - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.IsOnLine(c, a, b, LineMode.LineSegment)); - } - - public static IEnumerable PointsNotOnAB { - get { - yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; - yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; - yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; - yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; - yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; - yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; - } - } - - [Theory] - [MemberData(nameof(PointsNotOnAB))] - public void IsOnLine_ReturnsFalseIfPointDoEsNotLieOnAB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.IsOnLine(c, a, b, mode)); - } - - [Fact] - public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() { - Coordinate c = new Coordinate(0, 0); - CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0) }); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.Throws(() => target.IsInRing(c, ring)); - } - - [Fact] - public void IsInRing_ThrowsArgumentExceptionIfCoordinateListDoesNotRepresentRing() { - Coordinate c = new Coordinate(0, 0); - CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 2) }); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.Throws(() => target.IsInRing(c, ring)); - } - - [Fact] - public void IsInRing_ReturnsTrueIfPointIsInSimpleRing() { - string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); - - Coordinate c = new Coordinate(0.5, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.IsInRing(c, ring.Coordinates)); - } - - [Fact] - public void IsInRing_ReturnsTrueIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() { - string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); - - Coordinate c = new Coordinate(0.5, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.IsInRing(c, ring.Coordinates)); - } - - [Fact] - public void IsInRing_ReturnsTrueIfPointIsInConcaveRing() { - string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; - LineString ring = WktReader.Parse(wktRing); - - Coordinate c = new Coordinate(1, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.IsInRing(c, ring.Coordinates)); - } - - [Fact] - public void IsInRing_ReturnsFalseIfPointIsOutsideSimpleRing() { - string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); - - Coordinate c = new Coordinate(2, 2); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.IsInRing(c, ring.Coordinates)); - } - - [Fact] - public void IsInRing_ReturnsFalseIfPointIsOutsideRing() { - string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; - LineString ring = WktReader.Parse(wktRing); - - Coordinate c = new Coordinate(3, 0); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.IsInRing(c, ring.Coordinates)); - } - - [Fact] - public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() { - string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); - - Coordinate c = new Coordinate(-2, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.IsInRing(c, ring.Coordinates)); - } - - - - [Fact] - public void Intersects_ReturnsFalseForParallelLines() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 2.0); - - Coordinate A2 = new Coordinate(2.0, 1.0); - Coordinate B2 = new Coordinate(3.0, 2.0); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); - } - - [Fact] - public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); - - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); - } - - [Fact] - public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment1() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); - - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.Line)); - } - - [Fact] - public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment2() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); - - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 0.5); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.LineSegment)); - } - - [Fact] - public void Intersects_ReturnsFalseForNonIntersectingLineSegments() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); - - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); - } - - [Fact] - public void Intersects_ReturnsTrueForIntersectingLineSegments() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(3.0, 1.0); - - Coordinate A2 = new Coordinate(1.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 2.0); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); - } - - [Fact] - public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(2.0, 0.0), new Coordinate(2.0, -1.0) }); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.False(target.Intersects(line1, line2)); - } - - [Fact] - public void Intersects_LineLine_ReturnsaTrueForIntersectingLines() { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(1.5, 2.0), new Coordinate(2.0, -1.0) }); - - Euclidean2DLocator target = new Euclidean2DLocator(); - - Assert.True(target.Intersects(line1, line2)); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; +using Xunit.Extensions; + +using SpatialLite.Core.API; +using SpatialLite.Core.Algorithms; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.IO; + +namespace Tests.SpatialLite.Core.Algorithms +{ + public class Euclidean2DLocatorTests + { + + [Fact] + public void IsOnLine_ReturnsTrueIfPointIsOnAorB() + { + Coordinate a = new Coordinate(-10, 0); + Coordinate b = new Coordinate(3, 2); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.IsOnLine(a, a, b, LineMode.Line)); + Assert.True(target.IsOnLine(b, a, b, LineMode.Line)); + } + + public static IEnumerable PointsBetweenAB + { + get + { + yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; + } + } + + [Theory] + [MemberData(nameof(PointsBetweenAB))] + public void IsOnLine_ReturnsTrueIfPointLiesBetweenAAndB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.IsOnLine(c, a, b, mode)); + } + + public static IEnumerable PointsOnAB + { + get + { + yield return new object[] { new Coordinate(-11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; + yield return new object[] { new Coordinate(11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; + } + } + + [Theory] + [MemberData(nameof(PointsOnAB))] + public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coordinate a, Coordinate b) + { + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.IsOnLine(c, a, b, LineMode.Line)); + } + + [Theory] + [MemberData(nameof(PointsOnAB))] + public void IsOnLine_ReturnsFalseIfPointLiesOnABAndModeIsLineSegment(Coordinate c, Coordinate a, Coordinate b) + { + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.IsOnLine(c, a, b, LineMode.LineSegment)); + } + + public static IEnumerable PointsNotOnAB + { + get + { + yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; + yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; + yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; + yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; + yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; + yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; + } + } + + [Theory] + [MemberData(nameof(PointsNotOnAB))] + public void IsOnLine_ReturnsFalseIfPointDoEsNotLieOnAB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + Euclidean2DLocator target = new Euclidean2DLocator(); + Assert.False(target.IsOnLine(c, a, b, mode)); + } + + [Fact] + public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() + { + Coordinate c = new Coordinate(0, 0); + CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0) }); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.Throws(() => target.IsInRing(c, ring)); + } + + [Fact] + public void IsInRing_ThrowsArgumentExceptionIfCoordinateListDoesNotRepresentRing() + { + Coordinate c = new Coordinate(0, 0); + CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 2) }); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.Throws(() => target.IsInRing(c, ring)); + } + + [Fact] + public void IsInRing_ReturnsTrueIfPointIsInSimpleRing() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); + + Coordinate c = new Coordinate(0.5, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.IsInRing(c, ring.Coordinates)); + } + + [Fact] + public void IsInRing_ReturnsTrueIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); + + Coordinate c = new Coordinate(0.5, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.IsInRing(c, ring.Coordinates)); + } + + [Fact] + public void IsInRing_ReturnsTrueIfPointIsInConcaveRing() + { + string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; + LineString ring = WktReader.Parse(wktRing); + + Coordinate c = new Coordinate(1, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.IsInRing(c, ring.Coordinates)); + } + + [Fact] + public void IsInRing_ReturnsFalseIfPointIsOutsideSimpleRing() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); + + Coordinate c = new Coordinate(2, 2); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.IsInRing(c, ring.Coordinates)); + } + + [Fact] + public void IsInRing_ReturnsFalseIfPointIsOutsideRing() + { + string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; + LineString ring = WktReader.Parse(wktRing); + + Coordinate c = new Coordinate(3, 0); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.IsInRing(c, ring.Coordinates)); + } + + [Fact] + public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); + + Coordinate c = new Coordinate(-2, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.IsInRing(c, ring.Coordinates)); + } + + + + [Fact] + public void Intersects_ReturnsFalseForParallelLines() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 2.0); + + Coordinate A2 = new Coordinate(2.0, 1.0); + Coordinate B2 = new Coordinate(3.0, 2.0); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); + } + + [Fact] + public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); + + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); + } + + [Fact] + public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment1() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); + + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.Line)); + } + + [Fact] + public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment2() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); + + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 0.5); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.LineSegment)); + } + + [Fact] + public void Intersects_ReturnsFalseForNonIntersectingLineSegments() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); + + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); + } + + [Fact] + public void Intersects_ReturnsTrueForIntersectingLineSegments() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(3.0, 1.0); + + Coordinate A2 = new Coordinate(1.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 2.0); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); + } + + [Fact] + public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() + { + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(2.0, 0.0), new Coordinate(2.0, -1.0) }); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.False(target.Intersects(line1, line2)); + } + + [Fact] + public void Intersects_LineLine_ReturnsaTrueForIntersectingLines() + { + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(1.5, 2.0), new Coordinate(2.0, -1.0) }); + + Euclidean2DLocator target = new Euclidean2DLocator(); + + Assert.True(target.Intersects(line1, line2)); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs index c260b54..84e107b 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs @@ -1,155 +1,167 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using SpatialLite.Core.API; -using SpatialLite.Core.Algorithms; - -using Xunit; -using Moq; - -namespace Tests.SpatialLite.Core.Algorithms { - public class Sphere2DCalculatorTests { - - [Fact] - public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() { - Coordinate c = new Coordinate(10.1, 100.2); - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c, c); - - Assert.Equal(0, distance); - } - - //TODO more test cases - [Fact] - public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() { - Coordinate c1 = new Coordinate(0, 0); - Coordinate c2 = new Coordinate(0, 90); - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c1, c2); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; - - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } - - [Fact] - public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegBoundary() { - Coordinate c1 = new Coordinate(-45, 0); - Coordinate c2 = new Coordinate(45, 0); - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c1, c2); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; - - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } - - [Fact] - public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180DegBoundary() { - Coordinate c1 = new Coordinate(-135, 0); - Coordinate c2 = new Coordinate(135, 0); - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c1, c2); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; - - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } - - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(120, 45); - - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c, a, b, LineMode.Line); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; - - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } - - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(45, 45); - - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; - - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } - - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(95, 45); - - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); - double expectedDistance = target.CalculateDistance(b, c); - - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } - - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment2() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(5, 45); - - Sphere2DCalculator target = new Sphere2DCalculator(); - - double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); - double expectedDistance = target.CalculateDistance(a, c); - - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } - - [Fact] - public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(3); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - - double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - - Sphere2DCalculator target = new Sphere2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); - } - - [Fact] - public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(4); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[0]); - - double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - - Sphere2DCalculator target = new Sphere2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using SpatialLite.Core.API; +using SpatialLite.Core.Algorithms; + +using Xunit; +using Moq; + +namespace Tests.SpatialLite.Core.Algorithms +{ + public class Sphere2DCalculatorTests + { + + [Fact] + public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() + { + Coordinate c = new Coordinate(10.1, 100.2); + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c, c); + + Assert.Equal(0, distance); + } + + //TODO more test cases + [Fact] + public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() + { + Coordinate c1 = new Coordinate(0, 0); + Coordinate c2 = new Coordinate(0, 90); + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c1, c2); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; + + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } + + [Fact] + public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegBoundary() + { + Coordinate c1 = new Coordinate(-45, 0); + Coordinate c2 = new Coordinate(45, 0); + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c1, c2); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; + + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } + + [Fact] + public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180DegBoundary() + { + Coordinate c1 = new Coordinate(-135, 0); + Coordinate c2 = new Coordinate(135, 0); + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c1, c2); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; + + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } + + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(120, 45); + + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c, a, b, LineMode.Line); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; + + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } + + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(45, 45); + + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; + + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } + + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(95, 45); + + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); + double expectedDistance = target.CalculateDistance(b, c); + + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } + + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment2() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(5, 45); + + Sphere2DCalculator target = new Sphere2DCalculator(); + + double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); + double expectedDistance = target.CalculateDistance(a, c); + + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } + + [Fact] + public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(3); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + + double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; + + Sphere2DCalculator target = new Sphere2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); + } + + [Fact] + public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(4); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[0]); + + double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; + + Sphere2DCalculator target = new Sphere2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Data/TestDataReader.cs b/src/Tests.SpatialLite.Core/Data/TestDataReader.cs index 70f6c86..4357cb0 100644 --- a/src/Tests.SpatialLite.Core/Data/TestDataReader.cs +++ b/src/Tests.SpatialLite.Core/Data/TestDataReader.cs @@ -1,24 +1,28 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; - -namespace Tests.SpatialLite.Core.Data { - public static class TestDataReader { - public static Stream Open(string name) { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name); - } - - public static byte[] Read(string name) { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - - var stream = new MemoryStream(); - assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name).CopyTo(stream); - - return stream.ToArray(); - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; + +namespace Tests.SpatialLite.Core.Data +{ + public static class TestDataReader + { + public static Stream Open(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name); + } + + public static byte[] Read(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + + var stream = new MemoryStream(); + assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name).CopyTo(stream); + + return stream.ToArray(); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs index 7c8aba7..f01e42e 100644 --- a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs @@ -1,149 +1,168 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace Tests.SpatialLite.Core.Geometries { - public class CoordinateListTests { - - Coordinate _coordinate = new Coordinate(-10, -20, -200); - - Coordinate[] _coordinates = new Coordinate[] { - new Coordinate(12,10,100), - new Coordinate(22,20,200), - new Coordinate(32,30,300) - }; - - [Fact] - public void Constructor__CreatesEmptyList() { - CoordinateList target = new CoordinateList(); - - Assert.Empty(target); - } - - [Fact] - public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() { - CoordinateList target = new CoordinateList(_coordinates); - - for (int i = 0; i < _coordinates.Length; i++) { - Assert.Equal(_coordinates[i], target[i]); - } - } - - [Fact] - public void Indexer_GetsAndSetsValues() { - CoordinateList target = new CoordinateList(_coordinates); - - Assert.Equal(_coordinates[1], target[1]); - - target[1] = _coordinate; - Assert.Equal(_coordinate, target[1]); - } - - [Fact] - public void Count_Returns0ForEmptyList() { - CoordinateList target = new CoordinateList(); - - Assert.Equal(0, target.Count); - } - - [Fact] - public void Count_ReturnsNumberOfCoordinates() { - CoordinateList target = new CoordinateList(_coordinates); - - Assert.Equal(_coordinates.Length, target.Count); - } - - [Fact] - public void Add_AppendsCoordinateToTheEndOfList() { - CoordinateList target = new CoordinateList(_coordinates); - target.Add(_coordinate); - - Assert.Equal(_coordinate, target.Last()); - } - - [Fact] - public void Add_IncresesCount() { - CoordinateList target = new CoordinateList(_coordinates); - target.Add(_coordinate); - - Assert.Equal(_coordinates.Length + 1, target.Count); - } - - [Fact] - public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() { - CoordinateList target = new CoordinateList(new Coordinate[] {_coordinate}); - target.Add(_coordinates); - - for (int i = 0; i < _coordinates.Length; i++) { - Assert.Equal(_coordinates[i], target[i + 1]); - } - } - - [Fact] - public void Add_IncresesCount2() { - CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); - target.Add(_coordinates); - - Assert.Equal(_coordinates.Length + 1, target.Count); - } - - [Fact] - public void Insert_InsertsCoordinateToSpecifiedIndex() { - int index = 1; - CoordinateList target = new CoordinateList(_coordinates); - target.Insert(index, _coordinate); - - Assert.Equal(_coordinate, target[index]); - } - - [Fact] - public void Insert_IncresesCount() { - int index = 1; - CoordinateList target = new CoordinateList(_coordinates); - target.Insert(index, _coordinate); - - Assert.Equal(_coordinates.Length + 1, target.Count); - } - - [Fact] - public void Insert_AppendsCoordinateToListIfIndexEqulasCount() { - CoordinateList target = new CoordinateList(_coordinates); - target.Insert(target.Count, _coordinate); - - Assert.Equal(_coordinate, target.Last()); - Assert.Equal(_coordinates.Length + 1, target.Count); - } - - [Fact] - public void RemoveAt_RemovesCoordinateAtIndex() { - CoordinateList target = new CoordinateList(_coordinates); - target.RemoveAt(1); - - Assert.Equal(_coordinates[0], target[0]); - Assert.Equal(_coordinates[2], target[1]); - } - - [Fact] - public void RemoveAt_DecreasesCount() { - CoordinateList target = new CoordinateList(_coordinates); - target.RemoveAt(1); - - Assert.Equal(_coordinates.Length - 1, target.Count); - } - - [Fact] - public void Clear_RemovesAllCoordinatesFromList() { - CoordinateList target = new CoordinateList(_coordinates); - target.Clear(); - - Assert.Empty(target.ToArray()); - Assert.Equal(0, target.Count); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class CoordinateListTests + { + + Coordinate _coordinate = new Coordinate(-10, -20, -200); + + Coordinate[] _coordinates = new Coordinate[] { + new Coordinate(12,10,100), + new Coordinate(22,20,200), + new Coordinate(32,30,300) + }; + + [Fact] + public void Constructor__CreatesEmptyList() + { + CoordinateList target = new CoordinateList(); + + Assert.Empty(target); + } + + [Fact] + public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() + { + CoordinateList target = new CoordinateList(_coordinates); + + for (int i = 0; i < _coordinates.Length; i++) + { + Assert.Equal(_coordinates[i], target[i]); + } + } + + [Fact] + public void Indexer_GetsAndSetsValues() + { + CoordinateList target = new CoordinateList(_coordinates); + + Assert.Equal(_coordinates[1], target[1]); + + target[1] = _coordinate; + Assert.Equal(_coordinate, target[1]); + } + + [Fact] + public void Count_Returns0ForEmptyList() + { + CoordinateList target = new CoordinateList(); + + Assert.Equal(0, target.Count); + } + + [Fact] + public void Count_ReturnsNumberOfCoordinates() + { + CoordinateList target = new CoordinateList(_coordinates); + + Assert.Equal(_coordinates.Length, target.Count); + } + + [Fact] + public void Add_AppendsCoordinateToTheEndOfList() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Add(_coordinate); + + Assert.Equal(_coordinate, target.Last()); + } + + [Fact] + public void Add_IncresesCount() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Add(_coordinate); + + Assert.Equal(_coordinates.Length + 1, target.Count); + } + + [Fact] + public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() + { + CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); + target.Add(_coordinates); + + for (int i = 0; i < _coordinates.Length; i++) + { + Assert.Equal(_coordinates[i], target[i + 1]); + } + } + + [Fact] + public void Add_IncresesCount2() + { + CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); + target.Add(_coordinates); + + Assert.Equal(_coordinates.Length + 1, target.Count); + } + + [Fact] + public void Insert_InsertsCoordinateToSpecifiedIndex() + { + int index = 1; + CoordinateList target = new CoordinateList(_coordinates); + target.Insert(index, _coordinate); + + Assert.Equal(_coordinate, target[index]); + } + + [Fact] + public void Insert_IncresesCount() + { + int index = 1; + CoordinateList target = new CoordinateList(_coordinates); + target.Insert(index, _coordinate); + + Assert.Equal(_coordinates.Length + 1, target.Count); + } + + [Fact] + public void Insert_AppendsCoordinateToListIfIndexEqulasCount() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Insert(target.Count, _coordinate); + + Assert.Equal(_coordinate, target.Last()); + Assert.Equal(_coordinates.Length + 1, target.Count); + } + + [Fact] + public void RemoveAt_RemovesCoordinateAtIndex() + { + CoordinateList target = new CoordinateList(_coordinates); + target.RemoveAt(1); + + Assert.Equal(_coordinates[0], target[0]); + Assert.Equal(_coordinates[2], target[1]); + } + + [Fact] + public void RemoveAt_DecreasesCount() + { + CoordinateList target = new CoordinateList(_coordinates); + target.RemoveAt(1); + + Assert.Equal(_coordinates.Length - 1, target.Count); + } + + [Fact] + public void Clear_RemovesAllCoordinatesFromList() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Clear(); + + Assert.Empty(target.ToArray()); + Assert.Equal(0, target.Count); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs index b6aa419..c7db366 100644 --- a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs @@ -1,112 +1,127 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace Tests.SpatialLite.Core.Geometries { - public class GeometryCollectionTests { - - Point[] _geometries; - - Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(12,10,100, 1000), - new Coordinate(22,20,200, 2000), - new Coordinate(32,30,300, 3000) - }; - - public GeometryCollectionTests() { - _geometries = new Point[3]; - _geometries[0] = new Point(1, 2, 3); - _geometries[1] = new Point(1.1, 2.1, 3.1); - _geometries[2] = new Point(1.2, 2.2, 3.2); - } - - private void CheckGeometries(GeometryCollection target, Geometry[] geometries) { - Assert.Equal(geometries.Length, target.Geometries.Count); - - for (int i = 0; i < geometries.Length; i++) { - Assert.Same(geometries[i], target.Geometries[i]); - } - } - - [Fact] - public void Constructor__CreatesNewEmptyCollection() { - GeometryCollection target = new GeometryCollection(); - - Assert.NotNull(target.Geometries); - Assert.Empty(target.Geometries); - } - - [Fact] - public void Constructor_IEnumerable_CreateNewCollectionWithData() { - GeometryCollection target = new GeometryCollection(_geometries); - - CheckGeometries(target, _geometries); - } - - [Fact] - public void Is3D_ReturnsFalseForEmptyCollection() { - GeometryCollection target = new GeometryCollection(); - - Assert.False(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsFalseForCollectionOf2DObjects() { - var members2d = new Geometry[] { new Point(1, 2), new Point(2, 3) }; - GeometryCollection target = new GeometryCollection(members2d); - - Assert.False(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() { - GeometryCollection target = new GeometryCollection(_geometries); - - Assert.True(target.Is3D); - } - - [Fact] - public void IsMeasured_ReturnsFalseForEmptyCollection() { - GeometryCollection target = new GeometryCollection(); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() { - GeometryCollection target = new GeometryCollection(_geometries); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() { - var members = new Geometry[] { new Point(1, 2), new Point(2, 3, 4, 5) }; - GeometryCollection target = new GeometryCollection(members); - - Assert.True(target.IsMeasured); - } - - [Fact] - public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() { - GeometryCollection target = new GeometryCollection(); - - Assert.Equal(Envelope.Empty, target.GetEnvelope()); - } - - [Fact] - public void GetEnvelopeReturnsUnionOfMembersEnvelopes() { - GeometryCollection target = new GeometryCollection(_geometries); - Envelope expected = new Envelope(new Coordinate[] {_geometries[0].Position, _geometries[1].Position, _geometries[2].Position}); - - Assert.Equal(expected, target.GetEnvelope()); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class GeometryCollectionTests + { + + Point[] _geometries; + + Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(12,10,100, 1000), + new Coordinate(22,20,200, 2000), + new Coordinate(32,30,300, 3000) + }; + + public GeometryCollectionTests() + { + _geometries = new Point[3]; + _geometries[0] = new Point(1, 2, 3); + _geometries[1] = new Point(1.1, 2.1, 3.1); + _geometries[2] = new Point(1.2, 2.2, 3.2); + } + + private void CheckGeometries(GeometryCollection target, Geometry[] geometries) + { + Assert.Equal(geometries.Length, target.Geometries.Count); + + for (int i = 0; i < geometries.Length; i++) + { + Assert.Same(geometries[i], target.Geometries[i]); + } + } + + [Fact] + public void Constructor__CreatesNewEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); + + Assert.NotNull(target.Geometries); + Assert.Empty(target.Geometries); + } + + [Fact] + public void Constructor_IEnumerable_CreateNewCollectionWithData() + { + GeometryCollection target = new GeometryCollection(_geometries); + + CheckGeometries(target, _geometries); + } + + [Fact] + public void Is3D_ReturnsFalseForEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); + + Assert.False(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsFalseForCollectionOf2DObjects() + { + var members2d = new Geometry[] { new Point(1, 2), new Point(2, 3) }; + GeometryCollection target = new GeometryCollection(members2d); + + Assert.False(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() + { + GeometryCollection target = new GeometryCollection(_geometries); + + Assert.True(target.Is3D); + } + + [Fact] + public void IsMeasured_ReturnsFalseForEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() + { + GeometryCollection target = new GeometryCollection(_geometries); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() + { + var members = new Geometry[] { new Point(1, 2), new Point(2, 3, 4, 5) }; + GeometryCollection target = new GeometryCollection(members); + + Assert.True(target.IsMeasured); + } + + [Fact] + public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); + + Assert.Equal(Envelope.Empty, target.GetEnvelope()); + } + + [Fact] + public void GetEnvelopeReturnsUnionOfMembersEnvelopes() + { + GeometryCollection target = new GeometryCollection(_geometries); + Envelope expected = new Envelope(new Coordinate[] { _geometries[0].Position, _geometries[1].Position, _geometries[2].Position }); + + Assert.Equal(expected, target.GetEnvelope()); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs index ac58604..4f208ed 100644 --- a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs @@ -1,164 +1,185 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace Tests.SpatialLite.Core.Geometries { - public class LineStringTests { - - Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(12,10), - new Coordinate(22,20), - new Coordinate(32,30) - }; - - Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(12,10,100), - new Coordinate(22,20,200), - new Coordinate(32,30,300) - }; - - Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(12,10,100, 1000), - new Coordinate(22,20,200, 2000), - new Coordinate(32,30,300, 3000) - }; - - - private void CheckCoordinates(LineString target, Coordinate[] expectedPoints) { - Assert.Equal(expectedPoints.Length, target.Coordinates.Count); - - for (int i = 0; i < expectedPoints.Length; i++) { - Assert.Equal(expectedPoints[i], target.Coordinates[i]); - } - } - - [Fact] - public void Constructor__CreatesEmptyLineString() { - LineString target = new LineString(); - - Assert.Equal(0, target.Coordinates.Count); - } - - [Fact] - public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() { - LineString target = new LineString(_coordinatesXYZ); - - CheckCoordinates(target, _coordinatesXYZ); - } - - [Fact] - public void Is3D_ReturnsFalseForEmptyLineString() { - LineString target = new LineString(); - - Assert.False(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsFalseForAll2DCoords() { - LineString target = new LineString(_coordinatesXY); - - Assert.False(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsTrueForAll3DCoords() { - LineString target = new LineString(_coordinatesXYZ); - - Assert.True(target.Is3D); - } - - [Fact] - public void IsMeasured_ReturnsFalseForEmptyLineString() { - LineString target = new LineString(); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsFalseForNonMeasuredCoords() { - LineString target = new LineString(_coordinatesXYZ); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredCoords() { - LineString target = new LineString(_coordinatesXYZM); - - Assert.True(target.IsMeasured); - } - - [Fact] - public void Start_ReturnsEmptyCoordinateForEmptyLineString() { - LineString target = new LineString(); - - Assert.Equal(Coordinate.Empty, target.Start); - } - - [Fact] - public void Start_ReturnsFirstCoordinate() { - LineString target = new LineString(_coordinatesXYZ); - - Assert.Equal(_coordinatesXYZ.First(), target.Start); - } - - [Fact] - public void End_ReturnsEmptyCoordinateForEmptyLineString() { - LineString target = new LineString(); - - Assert.Equal(Coordinate.Empty, target.End); - } - - [Fact] - public void End_ReturnsLastCoordinate() { - LineString target = new LineString(_coordinatesXYZ); - - Assert.Equal(_coordinatesXYZ.Last(), target.End); - } - - [Fact] - public void IsClosed_ReturnsTrueForClosedLineString() { - LineString target = new LineString(_coordinatesXYZ); - target.Coordinates.Add(target.Coordinates[0]); - - Assert.True(target.IsClosed); - } - - [Fact] - public void IsClosed_ReturnsFalseForOpenLineString() { - LineString target = new LineString(_coordinatesXYZ); - - Assert.False(target.IsClosed); - } - - [Fact] - public void IsClosed_ReturnsFalseForEmptyLineString() { - LineString target = new LineString(); - - Assert.False(target.IsClosed); - } - - [Fact] - public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() { - LineString target = new LineString(); - Envelope envelope = target.GetEnvelope(); - - Assert.Equal(Envelope.Empty, envelope); - } - - [Fact] - public void GetEnvelope_ReturnsEnvelopeOfLineString() { - LineString target = new LineString(_coordinatesXYZ); - Envelope expected = new Envelope(_coordinatesXYZ); - - Assert.Equal(expected, target.GetEnvelope()); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class LineStringTests + { + + Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(12,10), + new Coordinate(22,20), + new Coordinate(32,30) + }; + + Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(12,10,100), + new Coordinate(22,20,200), + new Coordinate(32,30,300) + }; + + Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(12,10,100, 1000), + new Coordinate(22,20,200, 2000), + new Coordinate(32,30,300, 3000) + }; + + + private void CheckCoordinates(LineString target, Coordinate[] expectedPoints) + { + Assert.Equal(expectedPoints.Length, target.Coordinates.Count); + + for (int i = 0; i < expectedPoints.Length; i++) + { + Assert.Equal(expectedPoints[i], target.Coordinates[i]); + } + } + + [Fact] + public void Constructor__CreatesEmptyLineString() + { + LineString target = new LineString(); + + Assert.Equal(0, target.Coordinates.Count); + } + + [Fact] + public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() + { + LineString target = new LineString(_coordinatesXYZ); + + CheckCoordinates(target, _coordinatesXYZ); + } + + [Fact] + public void Is3D_ReturnsFalseForEmptyLineString() + { + LineString target = new LineString(); + + Assert.False(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsFalseForAll2DCoords() + { + LineString target = new LineString(_coordinatesXY); + + Assert.False(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsTrueForAll3DCoords() + { + LineString target = new LineString(_coordinatesXYZ); + + Assert.True(target.Is3D); + } + + [Fact] + public void IsMeasured_ReturnsFalseForEmptyLineString() + { + LineString target = new LineString(); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsFalseForNonMeasuredCoords() + { + LineString target = new LineString(_coordinatesXYZ); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredCoords() + { + LineString target = new LineString(_coordinatesXYZM); + + Assert.True(target.IsMeasured); + } + + [Fact] + public void Start_ReturnsEmptyCoordinateForEmptyLineString() + { + LineString target = new LineString(); + + Assert.Equal(Coordinate.Empty, target.Start); + } + + [Fact] + public void Start_ReturnsFirstCoordinate() + { + LineString target = new LineString(_coordinatesXYZ); + + Assert.Equal(_coordinatesXYZ.First(), target.Start); + } + + [Fact] + public void End_ReturnsEmptyCoordinateForEmptyLineString() + { + LineString target = new LineString(); + + Assert.Equal(Coordinate.Empty, target.End); + } + + [Fact] + public void End_ReturnsLastCoordinate() + { + LineString target = new LineString(_coordinatesXYZ); + + Assert.Equal(_coordinatesXYZ.Last(), target.End); + } + + [Fact] + public void IsClosed_ReturnsTrueForClosedLineString() + { + LineString target = new LineString(_coordinatesXYZ); + target.Coordinates.Add(target.Coordinates[0]); + + Assert.True(target.IsClosed); + } + + [Fact] + public void IsClosed_ReturnsFalseForOpenLineString() + { + LineString target = new LineString(_coordinatesXYZ); + + Assert.False(target.IsClosed); + } + + [Fact] + public void IsClosed_ReturnsFalseForEmptyLineString() + { + LineString target = new LineString(); + + Assert.False(target.IsClosed); + } + + [Fact] + public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() + { + LineString target = new LineString(); + Envelope envelope = target.GetEnvelope(); + + Assert.Equal(Envelope.Empty, envelope); + } + + [Fact] + public void GetEnvelope_ReturnsEnvelopeOfLineString() + { + LineString target = new LineString(_coordinatesXYZ); + Envelope expected = new Envelope(_coordinatesXYZ); + + Assert.Equal(expected, target.GetEnvelope()); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs index e501782..2bc4d0c 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs @@ -1,10 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tests.SpatialLite.Core.Geometries { - public class MultiLineStringTests { - //The current implementation of MultiLineString just calls parents constructors, so nothing worth testing - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class MultiLineStringTests + { + //The current implementation of MultiLineString just calls parents constructors, so nothing worth testing + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs index 1c42c4c..0810afa 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs @@ -1,10 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tests.SpatialLite.Core.Geometries { - public class MultiPointTests { - //The current implementation of MultiPoint just calls parent constructors, so nothing worth testing - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class MultiPointTests + { + //The current implementation of MultiPoint just calls parent constructors, so nothing worth testing + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs index 08a3083..f8b1285 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs @@ -1,10 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tests.SpatialLite.Core.Geometries { - public class MultiPolygonTests { - //The current implementation of MultiPolygon just calls parents constructors, so nothing worth testing - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class MultiPolygonTests + { + //The current implementation of MultiPolygon just calls parents constructors, so nothing worth testing + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs index 4100b11..38cd3fe 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs @@ -1,125 +1,140 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace Tests.SpatialLite.Core.Geometries { - public class PointTests { - - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - double _mValue = 100.4; - - Coordinate _coordinate; - public PointTests() { - _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); - } - - private void ChenckPosition(Point target, double x, double y, double z, double m) { - Assert.Equal(x, target.Position.X); - Assert.Equal(y, target.Position.Y); - Assert.Equal(z, target.Position.Z); - Assert.Equal(m, target.Position.M); - } - - [Fact] - public void Constructor__CreatesPointWithEmptyPosition() { - Point target = new Point(); - - Assert.Equal(Coordinate.Empty, target.Position); - } - - [Fact] - public void Constructor_XY_SetsCoordinates() { - Point target = new Point(_xOrdinate, _yOrdinate); - - ChenckPosition(target, _xOrdinate, _yOrdinate, double.NaN, double.NaN); - } - - [Fact] - public void Constructor_XYZ_SetsCoordinates() { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); - - ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, double.NaN); - } - - [Fact] - public void Constructor_XYZM_SetsCoordinates() { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); - - ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, _mValue); - } - - [Fact] - public void Constructor_Coordinate_SetsCoordinates() { - Point target = new Point(_coordinate); - - Assert.Equal(_coordinate, target.Position); - } - - [Fact] - public void Is3D_ReturnsTrueFor3DPoint() { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); - - Assert.True(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsFalseFor2DPoint() { - Point target = new Point(_xOrdinate, _yOrdinate); - - Assert.False(target.Is3D); - } - - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredPoint() { - Point target = new Point(_xOrdinate, _yOrdinate, double.NaN, _mValue); - - Assert.True(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsFalseForNonMeasuredPoint() { - Point target = new Point(_xOrdinate, _yOrdinate); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() { - Point target = new Point(); - Envelope envelope = target.GetEnvelope(); - - Assert.Equal(double.NaN, envelope.MinX); - Assert.Equal(double.NaN, envelope.MaxX); - Assert.Equal(double.NaN, envelope.MinY); - Assert.Equal(double.NaN, envelope.MaxY); - Assert.Equal(double.NaN, envelope.MinZ); - Assert.Equal(double.NaN, envelope.MaxZ); - Assert.Equal(double.NaN, envelope.MinM); - Assert.Equal(double.NaN, envelope.MaxM); - } - - [Fact] - public void GetEnvelope_ReturnsEnvelopeThatCoversOnePoint() { - Point target = new Point(_coordinate); - Envelope envelope = target.GetEnvelope(); - - Assert.Equal(_coordinate.X, envelope.MinX); - Assert.Equal(_coordinate.X, envelope.MaxX); - Assert.Equal(_coordinate.Y, envelope.MinY); - Assert.Equal(_coordinate.Y, envelope.MaxY); - Assert.Equal(_coordinate.Z, envelope.MinZ); - Assert.Equal(_coordinate.Z, envelope.MaxZ); - Assert.Equal(_coordinate.M, envelope.MinM); - Assert.Equal(_coordinate.M, envelope.MaxM); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class PointTests + { + + double _xOrdinate = 3.5; + double _yOrdinate = 4.2; + double _zOrdinate = 10.5; + double _mValue = 100.4; + + Coordinate _coordinate; + public PointTests() + { + _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); + } + + private void ChenckPosition(Point target, double x, double y, double z, double m) + { + Assert.Equal(x, target.Position.X); + Assert.Equal(y, target.Position.Y); + Assert.Equal(z, target.Position.Z); + Assert.Equal(m, target.Position.M); + } + + [Fact] + public void Constructor__CreatesPointWithEmptyPosition() + { + Point target = new Point(); + + Assert.Equal(Coordinate.Empty, target.Position); + } + + [Fact] + public void Constructor_XY_SetsCoordinates() + { + Point target = new Point(_xOrdinate, _yOrdinate); + + ChenckPosition(target, _xOrdinate, _yOrdinate, double.NaN, double.NaN); + } + + [Fact] + public void Constructor_XYZ_SetsCoordinates() + { + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); + + ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, double.NaN); + } + + [Fact] + public void Constructor_XYZM_SetsCoordinates() + { + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); + + ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, _mValue); + } + + [Fact] + public void Constructor_Coordinate_SetsCoordinates() + { + Point target = new Point(_coordinate); + + Assert.Equal(_coordinate, target.Position); + } + + [Fact] + public void Is3D_ReturnsTrueFor3DPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); + + Assert.True(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsFalseFor2DPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate); + + Assert.False(target.Is3D); + } + + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate, double.NaN, _mValue); + + Assert.True(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsFalseForNonMeasuredPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() + { + Point target = new Point(); + Envelope envelope = target.GetEnvelope(); + + Assert.Equal(double.NaN, envelope.MinX); + Assert.Equal(double.NaN, envelope.MaxX); + Assert.Equal(double.NaN, envelope.MinY); + Assert.Equal(double.NaN, envelope.MaxY); + Assert.Equal(double.NaN, envelope.MinZ); + Assert.Equal(double.NaN, envelope.MaxZ); + Assert.Equal(double.NaN, envelope.MinM); + Assert.Equal(double.NaN, envelope.MaxM); + } + + [Fact] + public void GetEnvelope_ReturnsEnvelopeThatCoversOnePoint() + { + Point target = new Point(_coordinate); + Envelope envelope = target.GetEnvelope(); + + Assert.Equal(_coordinate.X, envelope.MinX); + Assert.Equal(_coordinate.X, envelope.MaxX); + Assert.Equal(_coordinate.Y, envelope.MinY); + Assert.Equal(_coordinate.Y, envelope.MaxY); + Assert.Equal(_coordinate.Z, envelope.MinZ); + Assert.Equal(_coordinate.Z, envelope.MaxZ); + Assert.Equal(_coordinate.M, envelope.MinM); + Assert.Equal(_coordinate.M, envelope.MaxM); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs index 2f584b6..fe92ad3 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs @@ -1,126 +1,141 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - -namespace Tests.SpatialLite.Core.Geometries { - public class PolygonTests { - - Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(1, 2), new Coordinate(1.1, 2.1), new Coordinate(1.2, 2.2), new Coordinate(1.3, 2.3) - }; - - Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(1, 2, 3), new Coordinate(1.1, 2.1, 3.1), new Coordinate(1.2, 2.2, 3.2), new Coordinate(1.3, 2.3, 3.3) - }; - - Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(1, 2, 3, 10), new Coordinate(1.1, 2.1, 3.1, 20), new Coordinate(1.2, 2.2, 3.2, 30), new Coordinate(1.3, 2.3, 3.3, 40) - }; - - CoordinateList _exteriorRing3D; - CoordinateList[] _interiorRings3D; - - public PolygonTests() { - _exteriorRing3D = new CoordinateList(_coordinatesXYZ); - - _interiorRings3D = new CoordinateList[2]; - _interiorRings3D[0] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[0], _coordinatesXYZ[1], _coordinatesXYZ[0] }); - _interiorRings3D[1] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[1], _coordinatesXYZ[2], _coordinatesXYZ[1] }); - } - - private void CheckInteriorRings(Polygon target, CoordinateList[] expected) { - Assert.Equal(expected.Length, target.InteriorRings.Count); - for (int i = 0; i < expected.Length; i++) { - Assert.Same(expected[i], target.InteriorRings[i]); - } - } - - [Fact] - public void Constructor__CreatesEmptyPolygonAndInitializesProperties() { - Polygon target = new Polygon(); - - Assert.NotNull(target.ExteriorRing); - Assert.Empty(target.ExteriorRing); - - Assert.NotNull(target.InteriorRings); - Assert.Empty(target.InteriorRings); - } - - [Fact] - public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() { - Polygon target = new Polygon(_exteriorRing3D); - - Assert.Same(_exteriorRing3D, target.ExteriorRing); - - Assert.NotNull(target.InteriorRings); - Assert.Empty(target.InteriorRings); - } - - [Fact] - public void Is3D_ReturnsTrueFor3DExteriorRing() { - Polygon target = new Polygon(_exteriorRing3D); - - Assert.True(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsFalseForEmptyPolygon() { - Polygon target = new Polygon(); - - Assert.False(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsFalseFor2DExteriorRing() { - Polygon target = new Polygon(new CoordinateList(_coordinatesXY)); - - Assert.False(target.Is3D); - } - - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() { - Polygon target = new Polygon(new CoordinateList(_coordinatesXYZM)); - - Assert.True(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsFalseForEmptyPolygon() { - Polygon target = new Polygon(); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() { - Polygon target = new Polygon(new CoordinateList(_coordinatesXYZ)); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() { - Polygon target = new Polygon(); - Envelope envelope = target.GetEnvelope(); - - Assert.Equal(Envelope.Empty, envelope); - } - - [Fact] - public void GetEnvelopeReturnsEnvelopeOfLineString() { - Envelope expectedEnvelope = new Envelope(_coordinatesXYZ); - - Polygon target = new Polygon(_exteriorRing3D); - Envelope envelope = target.GetEnvelope(); - - Assert.Equal(expectedEnvelope, envelope); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class PolygonTests + { + + Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(1, 2), new Coordinate(1.1, 2.1), new Coordinate(1.2, 2.2), new Coordinate(1.3, 2.3) + }; + + Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(1, 2, 3), new Coordinate(1.1, 2.1, 3.1), new Coordinate(1.2, 2.2, 3.2), new Coordinate(1.3, 2.3, 3.3) + }; + + Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(1, 2, 3, 10), new Coordinate(1.1, 2.1, 3.1, 20), new Coordinate(1.2, 2.2, 3.2, 30), new Coordinate(1.3, 2.3, 3.3, 40) + }; + + CoordinateList _exteriorRing3D; + CoordinateList[] _interiorRings3D; + + public PolygonTests() + { + _exteriorRing3D = new CoordinateList(_coordinatesXYZ); + + _interiorRings3D = new CoordinateList[2]; + _interiorRings3D[0] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[0], _coordinatesXYZ[1], _coordinatesXYZ[0] }); + _interiorRings3D[1] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[1], _coordinatesXYZ[2], _coordinatesXYZ[1] }); + } + + private void CheckInteriorRings(Polygon target, CoordinateList[] expected) + { + Assert.Equal(expected.Length, target.InteriorRings.Count); + for (int i = 0; i < expected.Length; i++) + { + Assert.Same(expected[i], target.InteriorRings[i]); + } + } + + [Fact] + public void Constructor__CreatesEmptyPolygonAndInitializesProperties() + { + Polygon target = new Polygon(); + + Assert.NotNull(target.ExteriorRing); + Assert.Empty(target.ExteriorRing); + + Assert.NotNull(target.InteriorRings); + Assert.Empty(target.InteriorRings); + } + + [Fact] + public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() + { + Polygon target = new Polygon(_exteriorRing3D); + + Assert.Same(_exteriorRing3D, target.ExteriorRing); + + Assert.NotNull(target.InteriorRings); + Assert.Empty(target.InteriorRings); + } + + [Fact] + public void Is3D_ReturnsTrueFor3DExteriorRing() + { + Polygon target = new Polygon(_exteriorRing3D); + + Assert.True(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsFalseForEmptyPolygon() + { + Polygon target = new Polygon(); + + Assert.False(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsFalseFor2DExteriorRing() + { + Polygon target = new Polygon(new CoordinateList(_coordinatesXY)); + + Assert.False(target.Is3D); + } + + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() + { + Polygon target = new Polygon(new CoordinateList(_coordinatesXYZM)); + + Assert.True(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsFalseForEmptyPolygon() + { + Polygon target = new Polygon(); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() + { + Polygon target = new Polygon(new CoordinateList(_coordinatesXYZ)); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() + { + Polygon target = new Polygon(); + Envelope envelope = target.GetEnvelope(); + + Assert.Equal(Envelope.Empty, envelope); + } + + [Fact] + public void GetEnvelopeReturnsEnvelopeOfLineString() + { + Envelope expectedEnvelope = new Envelope(_coordinatesXYZ); + + Polygon target = new Polygon(_exteriorRing3D); + Envelope envelope = target.GetEnvelope(); + + Assert.Equal(expectedEnvelope, envelope); + } + } +} diff --git a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs index 0a26188..9faeb47 100644 --- a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs @@ -1,84 +1,96 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core.Geometries; -using SpatialLite.Core.API; - -namespace Tests.SpatialLite.Core.Geometries { - public class ReadOnlyCoordinateListTests { - List _points = new List(new Point[] { - new Point(5, 1.1, 2.2), - new Point(6, 10.1, -20.2), - new Point(7, -30.1, 40.2) }); - - - [Fact] - public void Constructor_Source_SetsSource() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Same(_points, target.Source); - } - - [Fact] - public void Indexer_Get_ReturnsCoordinatesFromSourceList() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - for (int i = 0; i < _points.Count; i++) { - Assert.Equal(_points[i].Position, target[i]); - } - } - - [Fact] - public void Indexer_Set_ThrowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); - } - - [Fact] - public void Count_GetsNumberOfItemsInSourceCollection() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Equal(_points.Count, target.Count); - } - - [Fact] - public void Add_Coordinate_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Throws(() => target.Add(Coordinate.Empty)); - } - - [Fact] - public void Add_Coordinates_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); - } - - [Fact] - public void Insert_Index_Coordinate_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Throws(() => target.Insert(0, Coordinate.Empty)); - } - - [Fact] - public void RemoveAt_Index_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Throws(() => target.RemoveAt(0)); - } - - [Fact] - public void Clear_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - - Assert.Throws(() => target.Clear()); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core.Geometries; +using SpatialLite.Core.API; + +namespace Tests.SpatialLite.Core.Geometries +{ + public class ReadOnlyCoordinateListTests + { + List _points = new List(new Point[] { + new Point(5, 1.1, 2.2), + new Point(6, 10.1, -20.2), + new Point(7, -30.1, 40.2) }); + + + [Fact] + public void Constructor_Source_SetsSource() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Same(_points, target.Source); + } + + [Fact] + public void Indexer_Get_ReturnsCoordinatesFromSourceList() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + for (int i = 0; i < _points.Count; i++) + { + Assert.Equal(_points[i].Position, target[i]); + } + } + + [Fact] + public void Indexer_Set_ThrowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); + } + + [Fact] + public void Count_GetsNumberOfItemsInSourceCollection() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Equal(_points.Count, target.Count); + } + + [Fact] + public void Add_Coordinate_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Throws(() => target.Add(Coordinate.Empty)); + } + + [Fact] + public void Add_Coordinates_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); + } + + [Fact] + public void Insert_Index_Coordinate_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Throws(() => target.Insert(0, Coordinate.Empty)); + } + + [Fact] + public void RemoveAt_Index_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Throws(() => target.RemoveAt(0)); + } + + [Fact] + public void Clear_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + + Assert.Throws(() => target.Clear()); + } + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs index 4503ba9..e314a51 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs @@ -1,614 +1,696 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; - -using Xunit; -using Tests.SpatialLite.Core.Data; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.IO; - -namespace Tests.SpatialLite.Core.IO { - public class WkbReaderTests { - [Fact] - public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() { - Stream stream = null; - Assert.Throws(() => new WkbReader(stream)); - } - - [Fact] - public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() { - Assert.Throws(() => new WkbReader("non-existing-file.wkb")); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = "../../../Data/IO/point-3DM.wkb"; - - WkbReader target = new WkbReader(filename); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() { - var stream = TestDataReader.Open("point-3DM.wkb"); - - WkbReader target = new WkbReader(stream); - target.Dispose(); - - Assert.False(stream.CanRead); - } - - [Fact] - public void Read_ReturnsNullIfStreamIsEmpty() { - MemoryStream stream = new MemoryStream(); - - WkbReader target = new WkbReader(stream); - Geometry read = target.Read(); - - Assert.Null(read); - } - - [Fact] - public void Read_ReadsGeometry() { - Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - Point parsed = (Point)target.Read(); - - this.ComparePoints(parsed, expected); - } - - [Fact] - public void Read_ReadsMultipleGeometries() { - Point expected1 = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - Point expected2 = (Point)this.ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); - - WkbReader target = new WkbReader(TestDataReader.Open("two-points-3DM.wkb")); - - Point parsed1 = (Point)target.Read(); - this.ComparePoints(parsed1, expected1); - - Point parsed2 = (Point)target.Read(); - this.ComparePoints(parsed2, expected2); - } - - [Fact] - public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - - target.Read(); - Geometry parsed = target.Read(); - - Assert.Null(parsed); - } - - [Fact] - public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { - byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new MemoryStream(wkb)) { - WkbReader target = new WkbReader(ms); - - Assert.Throws(() => target.Read()); - } - } - - [Fact] - public void ReadT_ReturnsNullIfStreamIsEmpty() { - MemoryStream stream = new MemoryStream(); - - WkbReader target = new WkbReader(stream); - Geometry read = target.Read(); - - Assert.Null(read); - } - - [Fact] - public void ReadT_ReadsGeometry() { - Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - Point parsed = target.Read(); - - this.ComparePoints(parsed, expected); - } - - [Fact] - public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - - target.Read(); - Geometry parsed = target.Read(); - - Assert.Null(parsed); - } - - [Fact] - public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { - byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new MemoryStream(wkb)) { - WkbReader target = new WkbReader(ms); - - Assert.Throws(() => target.Read()); - } - } - - [Fact] - public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiecGeometryType() { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Parse_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { - byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - - Assert.Throws(() => WkbReader.Parse(wkb)); - } - - [Fact] - public void Parse_ReturnsNullForEmptyInput() { - byte[] wkb = new byte[0]; - - Assert.Null(WkbReader.Parse(wkb)); - } - - [Fact] - public void Parse_ThrowsArgumentNullExceptionIfDataIsNull() { - Assert.Throws(() => WkbReader.Parse(null)); - } - - [Fact] - public void Parse_ReturnsParsedGeometry() { - string wkt = "point m (-10.1 15.5 1000.5)"; - Point expected = (Point)this.ParseWKT(wkt); - Point parsed = (Point)WkbReader.Parse(TestDataReader.Read("point-2DM.wkb")); - - this.ComparePoints(parsed, expected); - } - - [Fact] - public void ParseT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiedType() { - byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); - - Assert.Throws(() => WkbReader.Parse(wkb)); - } - - [Fact] - public void ParseT_ReturnsNullForEmptyInput() { - byte[] wkb = new byte[0]; - - Assert.Null(WkbReader.Parse(wkb)); - } - - [Fact] - public void ParseT_ThrowsArgumentNullExceptionIfDataIsNull() { - Assert.Throws(() => WkbReader.Parse(null)); - } - - [Fact] - public void ParsePoint_Parses2DPoint() { - string wkt = "point (-10.1 15.5)"; - byte[] wkb = TestDataReader.Read("point-2D.wkb"); - - this.TestParsePoint(wkb, wkt); - } - - [Fact] - public void ParsePoint_Parses2DMeasuredPoint() { - string wkt = "point m (-10.1 15.5 1000.5)"; - byte[] wkb = TestDataReader.Read("point-2DM.wkb"); - - this.TestParsePoint(wkb, wkt); - } - - [Fact] - public void ParsePoint_Parses3DPoint() { - string wkt = "point z (-10.1 15.5 100.5)"; - byte[] wkb = TestDataReader.Read("point-3D.wkb"); - - this.TestParsePoint(wkb, wkt); - } - - [Fact] - public void ParsePoint_Parses3DMeasuredPoint() { - string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; - byte[] wkb = TestDataReader.Read("point-3DM.wkb"); - - this.TestParsePoint(wkb, wkt); - } - - [Fact] - public void Parse_ParsesEmptyLineString() { - string wkt = "linestring empty"; - byte[] wkb = TestDataReader.Read("linestring-empty.wkb"); - - this.TestParseLineString(wkb, wkt); - } - - [Fact] - public void Parse_Parses2DLineString() { - string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; - byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); - - this.TestParseLineString(wkb, wkt); - } - - [Fact] - public void Parse_Parses2DMeasuredLineString() { - string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; - byte[] wkb = TestDataReader.Read("linestring-2DM.wkb"); - - this.TestParseLineString(wkb, wkt); - } - - [Fact] - public void Parse_Parses3DLineString() { - string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; - byte[] wkb = TestDataReader.Read("linestring-3D.wkb"); - this.TestParseLineString(wkb, wkt); - } - - [Fact] - public void Parse_Parses3DMeasuredLineString() { - string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; - byte[] wkb = TestDataReader.Read("linestring-3DM.wkb"); - - this.TestParseLineString(wkb, wkt); - } - - [Fact] - public void Parse_ParsesEmptyPolygon() { - string wkt = "polygon empty"; - byte[] wkb = TestDataReader.Read("polygon-empty.wkb"); - - this.TestParsePolygon(wkb, wkt); - } - - [Fact] - public void Parse_Parses2DPolygonOnlyExteriorRing() { - string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-2D.wkb"); - - this.TestParsePolygon(wkb, wkt); - } - - [Fact] - public void Parse_Parses2DMeasuredPolygonOnlyExteriorRing() { - string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-2DM.wkb"); - - this.TestParsePolygon(wkb, wkt); - } - - [Fact] - public void Parse_Parses3DPolygonOnlyExteriorRing() { - string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-3D.wkb"); - - this.TestParsePolygon(wkb, wkt); - } - - [Fact] - public void Parse_Parses3DMeasuredPolygonOnlyExteriorRing() { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-3DM.wkb"); - - this.TestParsePolygon(wkb, wkt); - } - - [Fact] - public void Parse_Parses3DMeasuredPolygon() { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - byte[] wkb = TestDataReader.Read("polygon-3DM.wkb"); - - this.TestParsePolygon(wkb, wkt); - } - - [Fact] - public void ParseMultiPoint_ParsesEmptyMultipoint() { - string wkt = "multipoint empty"; - byte[] wkb = TestDataReader.Read("multipoint-empty.wkb"); - - this.TestParseMultiPoint(wkb, wkt); - } - - [Fact] - public void ParseMultiPoint_Parses2DMultiPoint() { - string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; - byte[] wkb = TestDataReader.Read("multipoint-2D.wkb"); - - this.TestParseMultiPoint(wkb, wkt); - } - - [Fact] - public void ParseMultiPoint_Parses2DMeasuredMultiPoint() { - string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; - byte[] wkb = TestDataReader.Read("multipoint-2DM.wkb"); - - this.TestParseMultiPoint(wkb, wkt); - } - - [Fact] - public void ParseMultiPoint_Parses3DMultiPoint() { - string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; - byte[] wkb = TestDataReader.Read("multipoint-3D.wkb"); - - this.TestParseMultiPoint(wkb, wkt); - } - - [Fact] - public void ParseMultiPoint_Parses3DMeasuredMultiPoint() { - string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; - byte[] wkb = TestDataReader.Read("multipoint-3DM.wkb"); - - this.TestParseMultiPoint(wkb, wkt); - } - - [Fact] - public void ParseMultiLineString_ParsesEmptyMultiLineString() { - string wkt = "multilinestring empty"; - byte[] wkb = TestDataReader.Read("multilinestring-empty.wkb"); - - this.TestParseMultiLineString(wkb, wkt); - } - - [Fact] - public void ParseMultiLineString_Parses2DMultiLineString() { - string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-2D.wkb"); - - this.TestParseMultiLineString(wkb, wkt); - } - - [Fact] - public void ParseMultiLineString_Parses2DMeasuredMultiLineString() { - string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-2DM.wkb"); - - this.TestParseMultiLineString(wkb, wkt); - } - - [Fact] - public void ParseMultiLineString_Parses3DMultiLineString() { - string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-3D.wkb"); - - this.TestParseMultiLineString(wkb, wkt); - } - - [Fact] - public void ParseMultiLineString_Parses3DMeasuredMultiLineString() { - string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-3DM.wkb"); - - this.TestParseMultiLineString(wkb, wkt); - } - - [Fact] - public void ParseMultiPolygon_ParsesEmptyMultiPolygon() { - string wkt = "multipolygon empty"; - byte[] wkb = TestDataReader.Read("multipolygon-empty.wkb"); - - this.TestParseMultiPolygon(wkb, wkt); - } - - [Fact] - public void ParseMultiPolygon_Parses2DMultiPolygon() { - string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-2D.wkb"); - - this.TestParseMultiPolygon(wkb, wkt); - } - - [Fact] - public void ParseMultiPolygon_Parses2DMeasuredMultiPolygon() { - string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-2DM.wkb"); - - this.TestParseMultiPolygon(wkb, wkt); - } - - [Fact] - public void ParseMultiPolygon_Parses3DMultiPolygon() { - string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-3D.wkb"); - - this.TestParseMultiPolygon(wkb, wkt); - } - - [Fact] - public void ParseMultiPolygon_Parses3DMeasuredMultiPolygon() { - string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-3DM.wkb"); - - this.TestParseMultiPolygon(wkb, wkt); - } - - [Fact] - public void ParseGeometryCollection_ParsesEmptyGeometryCollection() { - string wkt = "geometrycollection empty"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-empty.wkb")); - - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void ParseGeometryCollection_Parses2DGeometryCollection() { - string wkt = "geometrycollection (point (-10.1 15.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2D.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } - - [Fact] - public void ParseGeometryCollection_Parses2DMeasuredGeometryCollection() { - string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2DM.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } - - [Fact] - public void ParseGeometryCollection_Parses3DGeometryCollection() { - string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3D.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } - - [Fact] - public void ParseGeometryCollection_Parses3DMeasuredGeometryCollection() { - string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3DM.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } - - [Fact] - public void ParseGeometryCollection_ParsesCollectionWithPointLineStringAndPolygon() { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-pt-ls-poly.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - this.CompareLineStrings((LineString)parsed.Geometries[1], (LineString)expected.Geometries[1]); - this.ComparePolygons((Polygon)parsed.Geometries[2], (Polygon)expected.Geometries[2]); - } - - [Fact] - public void ParseGeometryCollection_ParsesCollectionWithMultiGeometries() { - string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-multi.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.CompareMultiPoints((MultiPoint)parsed.Geometries[0], (MultiPoint)expected.Geometries[0]); - this.CompareMultiLineStrings((MultiLineString)parsed.Geometries[1], (MultiLineString)expected.Geometries[1]); - this.CompareMultiPolygons((MultiPolygon)parsed.Geometries[2], (MultiPolygon)expected.Geometries[2]); - } - - [Fact] - public void ParseGeometryCollection_ParsesNestedCollection() { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-nested.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - Assert.Equal(((GeometryCollection)expected.Geometries[0]).Geometries.Count, ((GeometryCollection)parsed.Geometries[0]).Geometries.Count); - this.ComparePoints((Point)((GeometryCollection)parsed.Geometries[0]).Geometries[0], (Point)((GeometryCollection)expected.Geometries[0]).Geometries[0]); - } - - private void TestParsePoint(byte[] wkb, string expectedAsWkt) { - Point expected = (Point)this.ParseWKT(expectedAsWkt); - Point parsed = WkbReader.Parse(wkb); - - this.ComparePoints(parsed, expected); - } - - private void TestParseLineString(byte[] wkb, string expectedAsWkt) { - LineString expected = (LineString)this.ParseWKT(expectedAsWkt); - LineString parsed = WkbReader.Parse(wkb); - - this.CompareLineStrings(parsed, expected); - } - - private void TestParsePolygon(byte[] wkb, string expectedAsWkt) { - Polygon expected = (Polygon)this.ParseWKT(expectedAsWkt); - Polygon parsed = WkbReader.Parse(wkb); - - this.ComparePolygons(parsed, expected); - } - - private void TestParseMultiPoint(byte[] wkb, string expectedAsWkt) { - MultiPoint expected = (MultiPoint)this.ParseWKT(expectedAsWkt); - MultiPoint parsed = WkbReader.Parse(wkb); - - this.CompareMultiPoints(parsed, expected); - } - - private void TestParseMultiLineString(byte[] wkb, string expectedAsWkt) { - MultiLineString expected = (MultiLineString)this.ParseWKT(expectedAsWkt); - MultiLineString parsed = WkbReader.Parse(wkb); - - this.CompareMultiLineStrings(parsed, expected); - } - - private void TestParseMultiPolygon(byte[] wkb, string expectedAsWkt) { - MultiPolygon expected = (MultiPolygon)this.ParseWKT(expectedAsWkt); - MultiPolygon parsed = WkbReader.Parse(wkb); - - this.CompareMultiPolygons(parsed, expected); - } - - private void ComparePoints(Point point, Point expected) { - Assert.Equal(expected.Position, point.Position); - } - - private void CompareCoordinateLists(ICoordinateList list, ICoordinateList expected) { - Assert.Equal(expected.Count, list.Count); - for (int i = 0; i < expected.Count; i++) { - Assert.Equal(expected[i], list[i]); - } - } - - private void CompareLineStrings(LineString linestring, LineString expected) { - this.CompareCoordinateLists(linestring.Coordinates, expected.Coordinates); - } - - private void ComparePolygons(Polygon polygon, Polygon expected) { - this.CompareCoordinateLists(polygon.ExteriorRing, expected.ExteriorRing); - - Assert.Equal(expected.InteriorRings.Count, polygon.InteriorRings.Count); - for (int i = 0; i < expected.InteriorRings.Count; i++) { - this.CompareCoordinateLists(polygon.InteriorRings[i], expected.InteriorRings[i]); - } - } - - private void CompareMultiPoints(MultiPoint multipoint, MultiPoint expected) { - Assert.Equal(expected.Geometries.Count, multipoint.Geometries.Count); - - for (int i = 0; i < expected.Geometries.Count; i++) { - this.ComparePoints(multipoint.Geometries[i], expected.Geometries[i]); - } - } - - private void CompareMultiLineStrings(MultiLineString multilinestring, MultiLineString expected) { - Assert.Equal(expected.Geometries.Count, multilinestring.Geometries.Count); - - for (int i = 0; i < expected.Geometries.Count; i++) { - this.CompareLineStrings(multilinestring.Geometries[i], expected.Geometries[i]); - } - } - - private void CompareMultiPolygons(MultiPolygon multipolygon, MultiPolygon expected) { - Assert.Equal(expected.Geometries.Count, multipolygon.Geometries.Count); - - for (int i = 0; i < expected.Geometries.Count; i++) { - this.ComparePolygons(multipolygon.Geometries[i], expected.Geometries[i]); - } - } - - - private Geometry ParseWKT(string wkt) { - return WktReader.Parse(wkt); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + +using Xunit; +using Tests.SpatialLite.Core.Data; + +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.IO; + +namespace Tests.SpatialLite.Core.IO +{ + public class WkbReaderTests + { + [Fact] + public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() + { + Stream stream = null; + Assert.Throws(() => new WkbReader(stream)); + } + + [Fact] + public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() + { + Assert.Throws(() => new WkbReader("non-existing-file.wkb")); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/IO/point-3DM.wkb"; + + WkbReader target = new WkbReader(filename); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + var stream = TestDataReader.Open("point-3DM.wkb"); + + WkbReader target = new WkbReader(stream); + target.Dispose(); + + Assert.False(stream.CanRead); + } + + [Fact] + public void Read_ReturnsNullIfStreamIsEmpty() + { + MemoryStream stream = new MemoryStream(); + + WkbReader target = new WkbReader(stream); + Geometry read = target.Read(); + + Assert.Null(read); + } + + [Fact] + public void Read_ReadsGeometry() + { + Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + Point parsed = (Point)target.Read(); + + this.ComparePoints(parsed, expected); + } + + [Fact] + public void Read_ReadsMultipleGeometries() + { + Point expected1 = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + Point expected2 = (Point)this.ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); + + WkbReader target = new WkbReader(TestDataReader.Open("two-points-3DM.wkb")); + + Point parsed1 = (Point)target.Read(); + this.ComparePoints(parsed1, expected1); + + Point parsed2 = (Point)target.Read(); + this.ComparePoints(parsed2, expected2); + } + + [Fact] + public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() + { + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + + target.Read(); + Geometry parsed = target.Read(); + + Assert.Null(parsed); + } + + [Fact] + public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + { + byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; + using (MemoryStream ms = new MemoryStream(wkb)) + { + WkbReader target = new WkbReader(ms); + + Assert.Throws(() => target.Read()); + } + } + + [Fact] + public void ReadT_ReturnsNullIfStreamIsEmpty() + { + MemoryStream stream = new MemoryStream(); + + WkbReader target = new WkbReader(stream); + Geometry read = target.Read(); + + Assert.Null(read); + } + + [Fact] + public void ReadT_ReadsGeometry() + { + Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + Point parsed = target.Read(); + + this.ComparePoints(parsed, expected); + } + + [Fact] + public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() + { + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + + target.Read(); + Geometry parsed = target.Read(); + + Assert.Null(parsed); + } + + [Fact] + public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + { + byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; + using (MemoryStream ms = new MemoryStream(wkb)) + { + WkbReader target = new WkbReader(ms); + + Assert.Throws(() => target.Read()); + } + } + + [Fact] + public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiecGeometryType() + { + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Parse_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + { + byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; + + Assert.Throws(() => WkbReader.Parse(wkb)); + } + + [Fact] + public void Parse_ReturnsNullForEmptyInput() + { + byte[] wkb = new byte[0]; + + Assert.Null(WkbReader.Parse(wkb)); + } + + [Fact] + public void Parse_ThrowsArgumentNullExceptionIfDataIsNull() + { + Assert.Throws(() => WkbReader.Parse(null)); + } + + [Fact] + public void Parse_ReturnsParsedGeometry() + { + string wkt = "point m (-10.1 15.5 1000.5)"; + Point expected = (Point)this.ParseWKT(wkt); + Point parsed = (Point)WkbReader.Parse(TestDataReader.Read("point-2DM.wkb")); + + this.ComparePoints(parsed, expected); + } + + [Fact] + public void ParseT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiedType() + { + byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); + + Assert.Throws(() => WkbReader.Parse(wkb)); + } + + [Fact] + public void ParseT_ReturnsNullForEmptyInput() + { + byte[] wkb = new byte[0]; + + Assert.Null(WkbReader.Parse(wkb)); + } + + [Fact] + public void ParseT_ThrowsArgumentNullExceptionIfDataIsNull() + { + Assert.Throws(() => WkbReader.Parse(null)); + } + + [Fact] + public void ParsePoint_Parses2DPoint() + { + string wkt = "point (-10.1 15.5)"; + byte[] wkb = TestDataReader.Read("point-2D.wkb"); + + this.TestParsePoint(wkb, wkt); + } + + [Fact] + public void ParsePoint_Parses2DMeasuredPoint() + { + string wkt = "point m (-10.1 15.5 1000.5)"; + byte[] wkb = TestDataReader.Read("point-2DM.wkb"); + + this.TestParsePoint(wkb, wkt); + } + + [Fact] + public void ParsePoint_Parses3DPoint() + { + string wkt = "point z (-10.1 15.5 100.5)"; + byte[] wkb = TestDataReader.Read("point-3D.wkb"); + + this.TestParsePoint(wkb, wkt); + } + + [Fact] + public void ParsePoint_Parses3DMeasuredPoint() + { + string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; + byte[] wkb = TestDataReader.Read("point-3DM.wkb"); + + this.TestParsePoint(wkb, wkt); + } + + [Fact] + public void Parse_ParsesEmptyLineString() + { + string wkt = "linestring empty"; + byte[] wkb = TestDataReader.Read("linestring-empty.wkb"); + + this.TestParseLineString(wkb, wkt); + } + + [Fact] + public void Parse_Parses2DLineString() + { + string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; + byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); + + this.TestParseLineString(wkb, wkt); + } + + [Fact] + public void Parse_Parses2DMeasuredLineString() + { + string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; + byte[] wkb = TestDataReader.Read("linestring-2DM.wkb"); + + this.TestParseLineString(wkb, wkt); + } + + [Fact] + public void Parse_Parses3DLineString() + { + string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; + byte[] wkb = TestDataReader.Read("linestring-3D.wkb"); + this.TestParseLineString(wkb, wkt); + } + + [Fact] + public void Parse_Parses3DMeasuredLineString() + { + string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; + byte[] wkb = TestDataReader.Read("linestring-3DM.wkb"); + + this.TestParseLineString(wkb, wkt); + } + + [Fact] + public void Parse_ParsesEmptyPolygon() + { + string wkt = "polygon empty"; + byte[] wkb = TestDataReader.Read("polygon-empty.wkb"); + + this.TestParsePolygon(wkb, wkt); + } + + [Fact] + public void Parse_Parses2DPolygonOnlyExteriorRing() + { + string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-2D.wkb"); + + this.TestParsePolygon(wkb, wkt); + } + + [Fact] + public void Parse_Parses2DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-2DM.wkb"); + + this.TestParsePolygon(wkb, wkt); + } + + [Fact] + public void Parse_Parses3DPolygonOnlyExteriorRing() + { + string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-3D.wkb"); + + this.TestParsePolygon(wkb, wkt); + } + + [Fact] + public void Parse_Parses3DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-3DM.wkb"); + + this.TestParsePolygon(wkb, wkt); + } + + [Fact] + public void Parse_Parses3DMeasuredPolygon() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + byte[] wkb = TestDataReader.Read("polygon-3DM.wkb"); + + this.TestParsePolygon(wkb, wkt); + } + + [Fact] + public void ParseMultiPoint_ParsesEmptyMultipoint() + { + string wkt = "multipoint empty"; + byte[] wkb = TestDataReader.Read("multipoint-empty.wkb"); + + this.TestParseMultiPoint(wkb, wkt); + } + + [Fact] + public void ParseMultiPoint_Parses2DMultiPoint() + { + string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; + byte[] wkb = TestDataReader.Read("multipoint-2D.wkb"); + + this.TestParseMultiPoint(wkb, wkt); + } + + [Fact] + public void ParseMultiPoint_Parses2DMeasuredMultiPoint() + { + string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; + byte[] wkb = TestDataReader.Read("multipoint-2DM.wkb"); + + this.TestParseMultiPoint(wkb, wkt); + } + + [Fact] + public void ParseMultiPoint_Parses3DMultiPoint() + { + string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; + byte[] wkb = TestDataReader.Read("multipoint-3D.wkb"); + + this.TestParseMultiPoint(wkb, wkt); + } + + [Fact] + public void ParseMultiPoint_Parses3DMeasuredMultiPoint() + { + string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; + byte[] wkb = TestDataReader.Read("multipoint-3DM.wkb"); + + this.TestParseMultiPoint(wkb, wkt); + } + + [Fact] + public void ParseMultiLineString_ParsesEmptyMultiLineString() + { + string wkt = "multilinestring empty"; + byte[] wkb = TestDataReader.Read("multilinestring-empty.wkb"); + + this.TestParseMultiLineString(wkb, wkt); + } + + [Fact] + public void ParseMultiLineString_Parses2DMultiLineString() + { + string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-2D.wkb"); + + this.TestParseMultiLineString(wkb, wkt); + } + + [Fact] + public void ParseMultiLineString_Parses2DMeasuredMultiLineString() + { + string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-2DM.wkb"); + + this.TestParseMultiLineString(wkb, wkt); + } + + [Fact] + public void ParseMultiLineString_Parses3DMultiLineString() + { + string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-3D.wkb"); + + this.TestParseMultiLineString(wkb, wkt); + } + + [Fact] + public void ParseMultiLineString_Parses3DMeasuredMultiLineString() + { + string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-3DM.wkb"); + + this.TestParseMultiLineString(wkb, wkt); + } + + [Fact] + public void ParseMultiPolygon_ParsesEmptyMultiPolygon() + { + string wkt = "multipolygon empty"; + byte[] wkb = TestDataReader.Read("multipolygon-empty.wkb"); + + this.TestParseMultiPolygon(wkb, wkt); + } + + [Fact] + public void ParseMultiPolygon_Parses2DMultiPolygon() + { + string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-2D.wkb"); + + this.TestParseMultiPolygon(wkb, wkt); + } + + [Fact] + public void ParseMultiPolygon_Parses2DMeasuredMultiPolygon() + { + string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-2DM.wkb"); + + this.TestParseMultiPolygon(wkb, wkt); + } + + [Fact] + public void ParseMultiPolygon_Parses3DMultiPolygon() + { + string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-3D.wkb"); + + this.TestParseMultiPolygon(wkb, wkt); + } + + [Fact] + public void ParseMultiPolygon_Parses3DMeasuredMultiPolygon() + { + string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-3DM.wkb"); + + this.TestParseMultiPolygon(wkb, wkt); + } + + [Fact] + public void ParseGeometryCollection_ParsesEmptyGeometryCollection() + { + string wkt = "geometrycollection empty"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-empty.wkb")); + + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void ParseGeometryCollection_Parses2DGeometryCollection() + { + string wkt = "geometrycollection (point (-10.1 15.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2D.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } + + [Fact] + public void ParseGeometryCollection_Parses2DMeasuredGeometryCollection() + { + string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2DM.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } + + [Fact] + public void ParseGeometryCollection_Parses3DGeometryCollection() + { + string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3D.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } + + [Fact] + public void ParseGeometryCollection_Parses3DMeasuredGeometryCollection() + { + string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3DM.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } + + [Fact] + public void ParseGeometryCollection_ParsesCollectionWithPointLineStringAndPolygon() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-pt-ls-poly.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + this.CompareLineStrings((LineString)parsed.Geometries[1], (LineString)expected.Geometries[1]); + this.ComparePolygons((Polygon)parsed.Geometries[2], (Polygon)expected.Geometries[2]); + } + + [Fact] + public void ParseGeometryCollection_ParsesCollectionWithMultiGeometries() + { + string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-multi.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.CompareMultiPoints((MultiPoint)parsed.Geometries[0], (MultiPoint)expected.Geometries[0]); + this.CompareMultiLineStrings((MultiLineString)parsed.Geometries[1], (MultiLineString)expected.Geometries[1]); + this.CompareMultiPolygons((MultiPolygon)parsed.Geometries[2], (MultiPolygon)expected.Geometries[2]); + } + + [Fact] + public void ParseGeometryCollection_ParsesNestedCollection() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-nested.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + Assert.Equal(((GeometryCollection)expected.Geometries[0]).Geometries.Count, ((GeometryCollection)parsed.Geometries[0]).Geometries.Count); + this.ComparePoints((Point)((GeometryCollection)parsed.Geometries[0]).Geometries[0], (Point)((GeometryCollection)expected.Geometries[0]).Geometries[0]); + } + + private void TestParsePoint(byte[] wkb, string expectedAsWkt) + { + Point expected = (Point)this.ParseWKT(expectedAsWkt); + Point parsed = WkbReader.Parse(wkb); + + this.ComparePoints(parsed, expected); + } + + private void TestParseLineString(byte[] wkb, string expectedAsWkt) + { + LineString expected = (LineString)this.ParseWKT(expectedAsWkt); + LineString parsed = WkbReader.Parse(wkb); + + this.CompareLineStrings(parsed, expected); + } + + private void TestParsePolygon(byte[] wkb, string expectedAsWkt) + { + Polygon expected = (Polygon)this.ParseWKT(expectedAsWkt); + Polygon parsed = WkbReader.Parse(wkb); + + this.ComparePolygons(parsed, expected); + } + + private void TestParseMultiPoint(byte[] wkb, string expectedAsWkt) + { + MultiPoint expected = (MultiPoint)this.ParseWKT(expectedAsWkt); + MultiPoint parsed = WkbReader.Parse(wkb); + + this.CompareMultiPoints(parsed, expected); + } + + private void TestParseMultiLineString(byte[] wkb, string expectedAsWkt) + { + MultiLineString expected = (MultiLineString)this.ParseWKT(expectedAsWkt); + MultiLineString parsed = WkbReader.Parse(wkb); + + this.CompareMultiLineStrings(parsed, expected); + } + + private void TestParseMultiPolygon(byte[] wkb, string expectedAsWkt) + { + MultiPolygon expected = (MultiPolygon)this.ParseWKT(expectedAsWkt); + MultiPolygon parsed = WkbReader.Parse(wkb); + + this.CompareMultiPolygons(parsed, expected); + } + + private void ComparePoints(Point point, Point expected) + { + Assert.Equal(expected.Position, point.Position); + } + + private void CompareCoordinateLists(ICoordinateList list, ICoordinateList expected) + { + Assert.Equal(expected.Count, list.Count); + for (int i = 0; i < expected.Count; i++) + { + Assert.Equal(expected[i], list[i]); + } + } + + private void CompareLineStrings(LineString linestring, LineString expected) + { + this.CompareCoordinateLists(linestring.Coordinates, expected.Coordinates); + } + + private void ComparePolygons(Polygon polygon, Polygon expected) + { + this.CompareCoordinateLists(polygon.ExteriorRing, expected.ExteriorRing); + + Assert.Equal(expected.InteriorRings.Count, polygon.InteriorRings.Count); + for (int i = 0; i < expected.InteriorRings.Count; i++) + { + this.CompareCoordinateLists(polygon.InteriorRings[i], expected.InteriorRings[i]); + } + } + + private void CompareMultiPoints(MultiPoint multipoint, MultiPoint expected) + { + Assert.Equal(expected.Geometries.Count, multipoint.Geometries.Count); + + for (int i = 0; i < expected.Geometries.Count; i++) + { + this.ComparePoints(multipoint.Geometries[i], expected.Geometries[i]); + } + } + + private void CompareMultiLineStrings(MultiLineString multilinestring, MultiLineString expected) + { + Assert.Equal(expected.Geometries.Count, multilinestring.Geometries.Count); + + for (int i = 0; i < expected.Geometries.Count; i++) + { + this.CompareLineStrings(multilinestring.Geometries[i], expected.Geometries[i]); + } + } + + private void CompareMultiPolygons(MultiPolygon multipolygon, MultiPolygon expected) + { + Assert.Equal(expected.Geometries.Count, multipolygon.Geometries.Count); + + for (int i = 0; i < expected.Geometries.Count; i++) + { + this.ComparePolygons(multipolygon.Geometries[i], expected.Geometries[i]); + } + } + + + private Geometry ParseWKT(string wkt) + { + return WktReader.Parse(wkt); + } + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs index d248108..d221292 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs @@ -1,28 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core.IO; - -namespace Tests.SpatialLite.Core.IO { - public class WkbWriterSettingsTests { - - [Fact] - public void Constructor__SetsDefaultValues() { - WkbWriterSettings target = new WkbWriterSettings(); - - Assert.Equal(BinaryEncoding.LittleEndian, target.Encoding); - } - - [Fact] - public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - WkbWriterSettings target = new WkbWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.Encoding = BinaryEncoding.BigEndian); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core.IO; + +namespace Tests.SpatialLite.Core.IO +{ + public class WkbWriterSettingsTests + { + + [Fact] + public void Constructor__SetsDefaultValues() + { + WkbWriterSettings target = new WkbWriterSettings(); + + Assert.Equal(BinaryEncoding.LittleEndian, target.Encoding); + } + + [Fact] + public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + WkbWriterSettings target = new WkbWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.Encoding = BinaryEncoding.BigEndian); + } + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs index bb582d5..5e33e3c 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs @@ -1,659 +1,762 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; - -using Xunit; -using Xunit.Extensions; - -using Tests.SpatialLite.Core.Data; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.IO; - - -namespace Tests.SpatialLite.Core.IO { - public class WkbWriterTests { - - [Fact] - public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() { - Stream stream = null; - Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings())); - } - - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() { - Assert.Throws(() => new WkbWriter(new MemoryStream(), null)); - } - - [Fact] - public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() { - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_PathSettings_CreatesOutputFile() { - string filename = PathHelper.GetTempFilePath("wkbwriter-constructor-creates-output-test.bin"); - - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(filename, settings)) { - ; - } - - Assert.True(File.Exists(filename)); - } - - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() { - string path = null; - Assert.Throws(() => new WkbWriter(path, new WkbWriterSettings())); - } - - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() { - string path = PathHelper.GetTempFilePath("wkbwriter-constructor-test.bin"); - - Assert.Throws(() => new WkbWriter(path, null)); - } - - [Fact] - public void Constructor_ThrowsExceptionIfEncodingIsSetToBingEndian() { - MemoryStream stream = new MemoryStream(); - Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.BigEndian })); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = PathHelper.GetTempFilePath("wkbwriter-closes-output-filestream-test.bin"); - - WkbWriterSettings settings = new WkbWriterSettings(); - WkbWriter target = new WkbWriter(filename, settings); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new MemoryStream(); - - WkbWriter target = new WkbWriter(stream, new WkbWriterSettings()); - target.Dispose(); - - Assert.False(stream.CanRead); - } - - [Fact] - public void WkbWriter_Write_WritesLittleEndianEncodingByte() { - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) { - target.Write(new Point()); - - CompareBytes(stream.ToArray(), 0, new byte[] { (byte)BinaryEncoding.LittleEndian }); - } - } - - [Fact] - public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() { - string wkt = "point empty"; - Point point = (Point)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(point); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); - } - } - - [Fact] - public void Write_Writes2DPoint() { - string wkt = "point (-10.1 15.5)"; - Point point = (Point)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(point); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2D.wkb")); - } - } - - [Fact] - public void Write_Writes2DMeasuredPoint() { - string wkt = "point m (-10.1 15.5 1000.5)"; - Point point = (Point)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(point); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DPoint() { - string wkt = "point z (-10.1 15.5 100.5)"; - Point point = (Point)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(point); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3D.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredPoint() { - string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; - Point point = (Point)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(point); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3DM.wkb")); - } - } - - [Fact] - public void Write_WritesEmptyLineString() { - string wkt = "linestring empty"; - LineString linestring = (LineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(linestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-empty.wkb")); - } - } - - [Fact] - public void Write_Writes2DLineString() { - string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(linestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2D.wkb")); - } - } - - [Fact] - public void Write_Writes2DMeasuredLineString() { - string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(linestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DLineString() { - string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(linestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3D.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredLineString() { - string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(linestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3DM.wkb")); - } - } - - [Fact] - public void Write_WritesEmptyPolygon() { - string wkt = "polygon empty"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(polygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-empty.wkb")); - } - } - - [Fact] - public void Write_Writes2DPolygonOnlyExteriorRing() { - string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(polygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2D.wkb")); - } - } - - [Fact] - public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() { - string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(polygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DPolygonOnlyExteriorRing() { - string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(polygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3D.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(polygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredPolygon() { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(polygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-3DM.wkb")); - } - } - - [Fact] - public void Write_WritesEmptyMultipoint() { - string wkt = "multipoint empty"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipoint); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-empty.wkb")); - } - } - - [Fact] - public void Write_Writes2DMultiPoint() { - string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipoint); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2D.wkb")); - } - } - - [Fact] - public void Write_Writes2DMeasuredMultiPoint() { - string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipoint); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DMultiPoint() { - string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipoint); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3D.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredMultiPoint() { - string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipoint); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3DM.wkb")); - } - } - - [Fact] - public void Write_WritesEmptyMultiLineString() { - string wkt = "multilinestring empty"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multilinestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-empty.wkb")); - } - } - - [Fact] - public void Write_Writes2DMultiLineString() { - string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multilinestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2D.wkb")); - } - } - - [Fact] - public void Write_Writes2DMeasuredMultiLineString() { - string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multilinestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DMultiLineString() { - string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multilinestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3D.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredMultiLineString() { - string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multilinestring); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3DM.wkb")); - } - } - - [Fact] - public void Write_WritesEmptyMultiPolygon() { - string wkt = "multipolygon empty"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipolygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-empty.wkb")); - } - } - - [Fact] - public void Write_Writes2DMultiPolygon() { - string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipolygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2D.wkb")); - } - } - - [Fact] - public void Write_Writes2DMeasuredMultiPolygon() { - string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipolygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DMultiPolygon() { - string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipolygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3D.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredMultiPolygon() { - string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(multipolygon); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3DM.wkb")); - } - } - - [Fact] - public void Write_WritesEmptyGeometryCollection() { - string wkt = "geometrycollection empty"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); - } - } - - [Fact] - public void Write_Writes2DGeometryCollection() { - string wkt = "geometrycollection (point (-10.1 15.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2D.wkb")); - } - } - - [Fact] - public void Write_Writes2DMeasuredGeometryCollection() { - string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2DM.wkb")); - } - } - - [Fact] - public void Write_Writes3DGeometryCollection() { - string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3D.wkb")); - } - } - - [Fact] - public void Write_Writes3DMeasuredGeometryCollection() { - string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3DM.wkb")); - } - } - - [Fact] - public void Write_WritesCollectionWithPointLineStringAndPolygon() { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-pt-ls-poly.wkb")); - } - } - - [Fact] - public void Write_WritesCollectionWithMultiGeometries() { - string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-multi.wkb")); - } - } - - [Fact] - public void Write_WritesNestedCollection() { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - target.Write(collection); - - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-nested.wkb")); - } - } - - public static IEnumerable WriteToArrayTestData { - get { - yield return new object[] { "point zm (-10.1 15.5 100.5 1000.5)", TestDataReader.Read("point-3DM.wkb") }; - yield return new object[] { "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)", TestDataReader.Read("linestring-3DM.wkb") }; - yield return new object[] { "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))", TestDataReader.Read("polygon-3DM.wkb") }; - yield return new object[] { "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))", TestDataReader.Read("multipoint-3DM.wkb") }; - yield return new object[] { "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))", TestDataReader.Read("multilinestring-3DM.wkb") }; - yield return new object[] { "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))", TestDataReader.Read("multipolygon-3DM.wkb") }; - yield return new object[] { "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))", TestDataReader.Read("collection-3DM.wkb") }; - - } - } - - [Theory] - [MemberData(nameof(WriteToArrayTestData))] - public void WriteToArray_WritesAllGeometryTypes(string wkt, byte[] expectedWkb) { - IGeometry geometry = this.ParseWKT(wkt); - - byte[] wkb = WkbWriter.WriteToArray(geometry); - this.CompareBytes(wkb, expectedWkb); - } - - private void CompareBytes(byte[] array, byte[] expected) { - Assert.Equal(array.Length, expected.Length); - - for (int i = 0; i < expected.Length; i++) { - Assert.Equal(expected[i], array[i]); - } - } - - private void CompareBytes(byte[] array, int offset, byte[] expected) { - for (int i = 0; i < expected.Length; i++) { - Assert.Equal(expected[i], array[i + offset]); - } - } - - private Geometry ParseWKT(string wkt) { - return WktReader.Parse(wkt); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + +using Xunit; +using Xunit.Extensions; + +using Tests.SpatialLite.Core.Data; + +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.IO; + + +namespace Tests.SpatialLite.Core.IO +{ + public class WkbWriterTests + { + + [Fact] + public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + { + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + Stream stream = null; + Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings())); + } + + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + Assert.Throws(() => new WkbWriter(new MemoryStream(), null)); + } + + [Fact] + public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() + { + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_PathSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("wkbwriter-constructor-creates-output-test.bin"); + + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(filename, settings)) + { + ; + } + + Assert.True(File.Exists(filename)); + } + + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + string path = null; + Assert.Throws(() => new WkbWriter(path, new WkbWriterSettings())); + } + + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + string path = PathHelper.GetTempFilePath("wkbwriter-constructor-test.bin"); + + Assert.Throws(() => new WkbWriter(path, null)); + } + + [Fact] + public void Constructor_ThrowsExceptionIfEncodingIsSetToBingEndian() + { + MemoryStream stream = new MemoryStream(); + Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.BigEndian })); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = PathHelper.GetTempFilePath("wkbwriter-closes-output-filestream-test.bin"); + + WkbWriterSettings settings = new WkbWriterSettings(); + WkbWriter target = new WkbWriter(filename, settings); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + MemoryStream stream = new MemoryStream(); + + WkbWriter target = new WkbWriter(stream, new WkbWriterSettings()); + target.Dispose(); + + Assert.False(stream.CanRead); + } + + [Fact] + public void WkbWriter_Write_WritesLittleEndianEncodingByte() + { + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) + { + target.Write(new Point()); + + CompareBytes(stream.ToArray(), 0, new byte[] { (byte)BinaryEncoding.LittleEndian }); + } + } + + [Fact] + public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() + { + string wkt = "point empty"; + Point point = (Point)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); + } + } + + [Fact] + public void Write_Writes2DPoint() + { + string wkt = "point (-10.1 15.5)"; + Point point = (Point)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2D.wkb")); + } + } + + [Fact] + public void Write_Writes2DMeasuredPoint() + { + string wkt = "point m (-10.1 15.5 1000.5)"; + Point point = (Point)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DPoint() + { + string wkt = "point z (-10.1 15.5 100.5)"; + Point point = (Point)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3D.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredPoint() + { + string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; + Point point = (Point)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3DM.wkb")); + } + } + + [Fact] + public void Write_WritesEmptyLineString() + { + string wkt = "linestring empty"; + LineString linestring = (LineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-empty.wkb")); + } + } + + [Fact] + public void Write_Writes2DLineString() + { + string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2D.wkb")); + } + } + + [Fact] + public void Write_Writes2DMeasuredLineString() + { + string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DLineString() + { + string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3D.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredLineString() + { + string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3DM.wkb")); + } + } + + [Fact] + public void Write_WritesEmptyPolygon() + { + string wkt = "polygon empty"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-empty.wkb")); + } + } + + [Fact] + public void Write_Writes2DPolygonOnlyExteriorRing() + { + string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2D.wkb")); + } + } + + [Fact] + public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DPolygonOnlyExteriorRing() + { + string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3D.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredPolygon() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-3DM.wkb")); + } + } + + [Fact] + public void Write_WritesEmptyMultipoint() + { + string wkt = "multipoint empty"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-empty.wkb")); + } + } + + [Fact] + public void Write_Writes2DMultiPoint() + { + string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2D.wkb")); + } + } + + [Fact] + public void Write_Writes2DMeasuredMultiPoint() + { + string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DMultiPoint() + { + string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3D.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredMultiPoint() + { + string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3DM.wkb")); + } + } + + [Fact] + public void Write_WritesEmptyMultiLineString() + { + string wkt = "multilinestring empty"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-empty.wkb")); + } + } + + [Fact] + public void Write_Writes2DMultiLineString() + { + string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2D.wkb")); + } + } + + [Fact] + public void Write_Writes2DMeasuredMultiLineString() + { + string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DMultiLineString() + { + string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3D.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredMultiLineString() + { + string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3DM.wkb")); + } + } + + [Fact] + public void Write_WritesEmptyMultiPolygon() + { + string wkt = "multipolygon empty"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-empty.wkb")); + } + } + + [Fact] + public void Write_Writes2DMultiPolygon() + { + string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2D.wkb")); + } + } + + [Fact] + public void Write_Writes2DMeasuredMultiPolygon() + { + string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DMultiPolygon() + { + string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3D.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredMultiPolygon() + { + string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3DM.wkb")); + } + } + + [Fact] + public void Write_WritesEmptyGeometryCollection() + { + string wkt = "geometrycollection empty"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); + } + } + + [Fact] + public void Write_Writes2DGeometryCollection() + { + string wkt = "geometrycollection (point (-10.1 15.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2D.wkb")); + } + } + + [Fact] + public void Write_Writes2DMeasuredGeometryCollection() + { + string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2DM.wkb")); + } + } + + [Fact] + public void Write_Writes3DGeometryCollection() + { + string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3D.wkb")); + } + } + + [Fact] + public void Write_Writes3DMeasuredGeometryCollection() + { + string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3DM.wkb")); + } + } + + [Fact] + public void Write_WritesCollectionWithPointLineStringAndPolygon() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-pt-ls-poly.wkb")); + } + } + + [Fact] + public void Write_WritesCollectionWithMultiGeometries() + { + string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-multi.wkb")); + } + } + + [Fact] + public void Write_WritesNestedCollection() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); + + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-nested.wkb")); + } + } + + public static IEnumerable WriteToArrayTestData + { + get + { + yield return new object[] { "point zm (-10.1 15.5 100.5 1000.5)", TestDataReader.Read("point-3DM.wkb") }; + yield return new object[] { "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)", TestDataReader.Read("linestring-3DM.wkb") }; + yield return new object[] { "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))", TestDataReader.Read("polygon-3DM.wkb") }; + yield return new object[] { "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))", TestDataReader.Read("multipoint-3DM.wkb") }; + yield return new object[] { "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))", TestDataReader.Read("multilinestring-3DM.wkb") }; + yield return new object[] { "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))", TestDataReader.Read("multipolygon-3DM.wkb") }; + yield return new object[] { "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))", TestDataReader.Read("collection-3DM.wkb") }; + + } + } + + [Theory] + [MemberData(nameof(WriteToArrayTestData))] + public void WriteToArray_WritesAllGeometryTypes(string wkt, byte[] expectedWkb) + { + IGeometry geometry = this.ParseWKT(wkt); + + byte[] wkb = WkbWriter.WriteToArray(geometry); + this.CompareBytes(wkb, expectedWkb); + } + + private void CompareBytes(byte[] array, byte[] expected) + { + Assert.Equal(array.Length, expected.Length); + + for (int i = 0; i < expected.Length; i++) + { + Assert.Equal(expected[i], array[i]); + } + } + + private void CompareBytes(byte[] array, int offset, byte[] expected) + { + for (int i = 0; i < expected.Length; i++) + { + Assert.Equal(expected[i], array[i + offset]); + } + } + + private Geometry ParseWKT(string wkt) + { + return WktReader.Parse(wkt); + } + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs index 6e140f9..1e0f9cc 100644 --- a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs @@ -1,729 +1,809 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; - -using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.IO; -using Tests.SpatialLite.Core.Data; - -namespace Tests.SpatialLite.Core.IO { - - public class WktReaderTests { - - private Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) - }; - - private Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) - }; - - private Coordinate[] _coordinatesXYM = new Coordinate[] { - new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) - }; - - private Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) - }; - - private Coordinate[] _coordinates2XYZM = new Coordinate[] { - new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) - }; - - [Fact] - public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() { - Stream stream = null; - Assert.Throws(() => new WktReader(stream)); - } - - [Fact] - public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() { - Assert.Throws(() => new WktReader("non-existing-file.wkb")); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = "../../../Data/IO/wkt-point-3DM.wkt"; - - WktReader target = new WktReader(filename); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() { - var stream = TestDataReader.Open("wkt-point-3DM.wkt"); - - WktReader target = new WktReader(stream); - target.Dispose(); - - Assert.False(stream.CanRead); - } - public static IEnumerable Read_ReadsAllGeometryTypesTestData { - get { - yield return new object[] { TestDataReader.Read("wkt-point-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-linestring-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-polygon-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-multipoint-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-multilinestring-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-multipolygon-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-geometry-collection-3DM.wkt") }; - } - } - - [Theory] - [MemberData(nameof(Read_ReadsAllGeometryTypesTestData))] - public void Read_ReadsAllGeometryTypes(byte[] data) { - using (WktReader target = new WktReader(new MemoryStream(data))) { - IGeometry readGeometry = target.Read(); - Assert.NotNull(readGeometry); - } - } - - [Fact] - public void Read_ReturnsNullIfStreamIsEmpty() { - using (WktReader target = new WktReader(new MemoryStream())) { - IGeometry readGeometry = target.Read(); - - Assert.Null(readGeometry); - } - } - - [Fact] - public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { - target.Read(); - IGeometry readGeometry = target.Read(); - - Assert.Null(readGeometry); - } - } - - [Fact] - public void Read_ReadsMultipleGeometries() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) { - IGeometry readGeometry = target.Read(); - Assert.True(readGeometry is Point); - - readGeometry = target.Read(); - Assert.True(readGeometry is LineString); - } - } - - [Fact] - public void ReadT_ReadsGeometry() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { - Point read = target.Read(); - Assert.NotNull(read); - } - } - - [Fact] - public void ReadT_ReturnsNullIfStreamIsEmpty() { - using (WktReader target = new WktReader(new MemoryStream())) { - IGeometry readGeometry = target.Read(); - - Assert.Null(readGeometry); - } - } - - [Fact] - public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { - Assert.Throws(() => target.Read()); - } - } - - [Fact] - public void Parse_ParsesPoint() { - string wkt = "point empty"; - - Point parsed = (Point)WktReader.Parse(wkt); - this.CompareCoordinate(Coordinate.Empty, parsed.Position); - } - - [Fact] - public void Parse_ParsesLineString() { - string wkt = "linestring empty"; - - LineString parsed = (LineString)WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Coordinates); - } - - [Fact] - public void Parse_ParsesPolygon() { - string wkt = "polygon empty"; - - Polygon parsed = (Polygon)WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.ExteriorRing); - } - - [Fact] - public void Parse_ParsesGeometryCollection() { - string wkt = "geometrycollection empty"; - - GeometryCollection parsed = (GeometryCollection)WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_ParsesMultiPoint() { - string wkt = "multipoint empty"; - - MultiPoint parsed = (MultiPoint)WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_ParsesMultiLineString() { - string wkt = "multilinestring empty"; - - MultiLineString parsed = (MultiLineString)WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_ParsesMultiPolygon() { - string wkt = "multipolygon empty"; - - MultiPolygon parsed = (MultiPolygon)WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometry() { - string wkt = "invalid string"; - - Assert.Throws(() => WktReader.Parse(wkt)); - } - - [Theory] - [InlineData("point zm \t(-10.1 15.5 100.5 \n1000.5)")] - [InlineData("\n\rlinestring (-10.1 15.5, 20.2 -25.5, \t30.3 35.5)")] - [InlineData("polygon\n\r m\t ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))")] - [InlineData("multipoint\t\r z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))")] - [InlineData("\nmultilinestring \tempty")] - [InlineData("multipolygon\n\r (((-10.1\t 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))")] - [InlineData("geometrycollection \t\n\r(point (-10.1 15.5))")] - public void Parse_ParsesGeometriesWithMultipleWhitespacesInsteadOneSpace(string wkt) { - WktReader.Parse(wkt); - } - - [Theory] - [InlineData("point zm ( -10.1 15.5 100.5 1000.5 )")] - [InlineData("linestring ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 )")] - [InlineData("polygon m ( ( -10.1 15.5 1000.5 , 20.2 -25.5 2000.5, 30.3 35.5 -3000.5 ) )")] - [InlineData("multipoint z ( ( -10.1 15.5 100.5 ) , ( 20.2 -25.5 200.5 ) )")] - [InlineData("multilinestring ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) , ( -10.1 15.5, 20.2 -25.5, 30.3 35.5 ) ) ")] - [InlineData("multipolygon ( ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) , ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) )")] - [InlineData("geometrycollection ( point ( -10.1 15.5 ) )")] - public void Parse_ParsesGeometriesWithWhitespacesAtPlacesWhereTheyAreNotExpected(string wkt) { - WktReader.Parse(wkt); - } - - [Fact] - public void Parse_ParsesEmptyPoint() { - string wkt = "point empty"; - - Point parsed = WktReader.Parse(wkt); - - this.CompareCoordinate(Coordinate.Empty, parsed.Position); - } - - [Fact] - public void Parse_Parses2DPoint() { - string wkt = "point (-10.1 15.5)"; - - Point parsed = WktReader.Parse(wkt); - - Assert.False(parsed.Is3D); - Assert.False(parsed.IsMeasured); - this.CompareCoordinate(_coordinatesXY[0], parsed.Position); - } - - [Fact] - public void Parse_Parses2DMeasuredPoint() { - string wkt = "point m (-10.1 15.5 1000.5)"; - - Point parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.False(parsed.Is3D); - this.CompareCoordinate(_coordinatesXYM[0], parsed.Position); - } - - [Fact] - public void Parse_Parses3DPoint() { - string wkt = "point z (-10.1 15.5 100.5)"; - - Point parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.False(parsed.IsMeasured); - this.CompareCoordinate(_coordinatesXYZ[0], parsed.Position); - } - - [Fact] - public void Parse_Parses3DMeasuredPoint() { - string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; - - Point parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinate(_coordinatesXYZM[0], parsed.Position); - } - - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentPoint() { - string wkt = "linestring empty"; - - Assert.Throws(() => WktReader.Parse(wkt)); - } - - [Fact] - public void Parse_ParsesEmptyLineString() { - string wkt = "linestring empty"; - - LineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Coordinates); - } - - [Fact] - public void Parse_Parses2DLineString() { - string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; - - LineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXY, parsed.Coordinates); - } - - [Fact] - public void Parse_Parses2DMeasuredLineString() { - string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; - - LineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYM, parsed.Coordinates); - } - - [Fact] - public void Parse_Parses3DLineString() { - string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; - - LineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZ, parsed.Coordinates); - } - - [Fact] - public void Parse_Parses3DMeasuredLineString() { - string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; - - LineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.Coordinates); - } - - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentLineString() { - string wkt = "point empty"; - - Assert.Throws(() => WktReader.Parse(wkt)); - } - - [Fact] - public void ParsePolygon_ParsesEmptyPolygon() { - string wkt = "polygon empty"; - - Polygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } - - [Fact] - public void ParsePolygon_Parses2DPolygonOnlyExteriorRing() { - string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - - Polygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXY, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } - - [Fact] - public void ParsePolygon_Parses3DPolygonOnlyExteriorRing() { - string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - - Polygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZ, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } - - [Fact] - public void ParsePolygon_Parses2DMeauredPolygonOnlyExteriorRing() { - string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - - Polygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYM, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } - - [Fact] - public void ParsePolygon_Parses3DMeasuredPolygonOnlyExteriorRing() { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - - Polygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } - - [Fact] - public void ParsePolygon_Parses3DMeasuredPolygonWithInteriorRings() { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - - Polygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); - Assert.Equal(2, parsed.InteriorRings.Count); - this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[0]); - this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[1]); - } - - [Fact] - public void ParsePolygong_ThrowsExceptionIfWktDoNotRepresentPolygon() { - string wkt = "point empty"; - - Assert.Throws(() => WktReader.Parse(wkt)); - } - - [Fact] - public void Parse_ParsesEmptyMultiPoint() { - string wkt = "multipoint empty"; - - MultiPoint parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_Parses2DMultiPoint() { - string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; - - MultiPoint parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXY[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXY[1], parsed.Geometries[1].Position); - } - - [Fact] - public void Parse_Parses2DMeasuredMultiPoint() { - string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; - - MultiPoint parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYM[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYM[1], parsed.Geometries[1].Position); - } - - [Fact] - public void Parse_Parses3DMultiPoint() { - string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; - - MultiPoint parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYZ[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYZ[1], parsed.Geometries[1].Position); - } - - [Fact] - public void Parse_Parses3DMeasuredMultiPoint() { - string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; - - MultiPoint parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYZM[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYZM[1], parsed.Geometries[1].Position); - } - - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPoint() { - string wkt = "point empty"; - - Assert.Throws(() => WktReader.Parse(wkt)); - } - - [Fact] - public void Parse_ParsesEmptyMultiLineString() { - string wkt = "multilinestring empty"; - - MultiLineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_Parses2DMultiLineString() { - string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - - MultiLineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].Coordinates); - } - - [Fact] - public void Parse_Parses2DMeasuredMultiLineString() { - string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - - MultiLineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].Coordinates); - } - - [Fact] - public void Parse_Parses3DMultiLineString() { - string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - - MultiLineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].Coordinates); - } - - [Fact] - public void Parse_Parses3DMeasuredMultiLineString() { - string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - - MultiLineString parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].Coordinates); - } - - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiLineString() { - string wkt = "point empty"; - - Assert.Throws(() => WktReader.Parse(wkt)); - } - - [Fact] - public void Parse_ParsesEmptyMultiPolygon() { - string wkt = "multipolygon empty"; - - MultiPolygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_Parses2DMultiPolygon() { - string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - - MultiPolygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].ExteriorRing); - } - - [Fact] - public void Parse_Parses2DMeasuredMultiPolygon() { - string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; - - MultiPolygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].ExteriorRing); - } - - [Fact] - public void Parse_Parses3DMultiPolygon() { - string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; - - MultiPolygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].ExteriorRing); - } - - [Fact] - public void Parse_Parses3DMeasuredMultiPolygon() { - string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; - - MultiPolygon parsed = WktReader.Parse(wkt); - - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].ExteriorRing); - } - - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPolygon() { - string wkt = "point empty"; - - Assert.Throws(() => WktReader.Parse(wkt)); - } - - [Fact] - public void Parse_ParsesEmptyGeometryCollection() { - string wkt = "geometrycollection empty"; - - GeometryCollection parsed = WktReader.Parse>(wkt); - - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } - - [Fact] - public void Parse_Parses2DGeometryCollectionWithPoint() { - string wkt = "geometrycollection (point (-10.1 15.5))"; - - GeometryCollection parsed = WktReader.Parse>(wkt); - - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); - } - - [Fact] - public void Parse_Parses2DMeasuredGeometryCollectionWithPoint() { - string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - - GeometryCollection parsed = WktReader.Parse>(wkt); - - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYM[0], ((Point)parsed.Geometries[0]).Position); - } - - [Fact] - public void Parse_Parses3DGeometryCollectionWithPoint() { - string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - - GeometryCollection parsed = WktReader.Parse>(wkt); - - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYZ[0], ((Point)parsed.Geometries[0]).Position); - } - - [Fact] - public void Parse_Parses3DMeasuredGeometryCollectionWithPoint() { - string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - - GeometryCollection parsed = WktReader.Parse>(wkt); - - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYZM[0], ((Point)parsed.Geometries[0]).Position); - } - - [Fact] - public void Parse_ParsesCollectionWithPointLineStringAndPolygon() { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - - GeometryCollection parsed = WktReader.Parse>(wkt); - - Assert.NotNull(parsed); - Assert.Equal(3, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); - this.CompareCoordinates(_coordinatesXY, ((LineString)parsed.Geometries[1]).Coordinates); - this.CompareCoordinates(_coordinatesXY, ((Polygon)parsed.Geometries[2]).ExteriorRing); - } - - [Fact] - public void Parse_ParsesNestedCollections() { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - - GeometryCollection parsed = WktReader.Parse>(wkt); - - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - GeometryCollection nested = (GeometryCollection)parsed.Geometries[0]; - this.CompareCoordinate(_coordinatesXY[0], ((Point)nested.Geometries[0]).Position); - } - - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometryCollection() { - string wkt = "point empty"; - - Assert.Throws(() => WktReader.Parse>(wkt)); - } - - private void CompareCoordinate(Coordinate expected, Coordinate actual) { - Assert.Equal(expected, actual); - } - - private void CompareCoordinates(Coordinate[] expected, ICoordinateList actual) { - Assert.Equal(expected.Length, actual.Count); - - for (int i = 0; i < expected.Length; i++) { - Assert.Equal(expected[i], actual[i]); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + +using Xunit; +using Xunit.Extensions; + +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.IO; +using Tests.SpatialLite.Core.Data; + +namespace Tests.SpatialLite.Core.IO +{ + + public class WktReaderTests + { + + private Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) + }; + + private Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) + }; + + private Coordinate[] _coordinatesXYM = new Coordinate[] { + new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) + }; + + private Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) + }; + + private Coordinate[] _coordinates2XYZM = new Coordinate[] { + new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) + }; + + [Fact] + public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() + { + Stream stream = null; + Assert.Throws(() => new WktReader(stream)); + } + + [Fact] + public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() + { + Assert.Throws(() => new WktReader("non-existing-file.wkb")); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/IO/wkt-point-3DM.wkt"; + + WktReader target = new WktReader(filename); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + var stream = TestDataReader.Open("wkt-point-3DM.wkt"); + + WktReader target = new WktReader(stream); + target.Dispose(); + + Assert.False(stream.CanRead); + } + public static IEnumerable Read_ReadsAllGeometryTypesTestData + { + get + { + yield return new object[] { TestDataReader.Read("wkt-point-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-linestring-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-polygon-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-multipoint-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-multilinestring-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-multipolygon-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-geometry-collection-3DM.wkt") }; + } + } + + [Theory] + [MemberData(nameof(Read_ReadsAllGeometryTypesTestData))] + public void Read_ReadsAllGeometryTypes(byte[] data) + { + using (WktReader target = new WktReader(new MemoryStream(data))) + { + IGeometry readGeometry = target.Read(); + Assert.NotNull(readGeometry); + } + } + + [Fact] + public void Read_ReturnsNullIfStreamIsEmpty() + { + using (WktReader target = new WktReader(new MemoryStream())) + { + IGeometry readGeometry = target.Read(); + + Assert.Null(readGeometry); + } + } + + [Fact] + public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) + { + target.Read(); + IGeometry readGeometry = target.Read(); + + Assert.Null(readGeometry); + } + } + + [Fact] + public void Read_ReadsMultipleGeometries() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) + { + IGeometry readGeometry = target.Read(); + Assert.True(readGeometry is Point); + + readGeometry = target.Read(); + Assert.True(readGeometry is LineString); + } + } + + [Fact] + public void ReadT_ReadsGeometry() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) + { + Point read = target.Read(); + Assert.NotNull(read); + } + } + + [Fact] + public void ReadT_ReturnsNullIfStreamIsEmpty() + { + using (WktReader target = new WktReader(new MemoryStream())) + { + IGeometry readGeometry = target.Read(); + + Assert.Null(readGeometry); + } + } + + [Fact] + public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) + { + Assert.Throws(() => target.Read()); + } + } + + [Fact] + public void Parse_ParsesPoint() + { + string wkt = "point empty"; + + Point parsed = (Point)WktReader.Parse(wkt); + this.CompareCoordinate(Coordinate.Empty, parsed.Position); + } + + [Fact] + public void Parse_ParsesLineString() + { + string wkt = "linestring empty"; + + LineString parsed = (LineString)WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Coordinates); + } + + [Fact] + public void Parse_ParsesPolygon() + { + string wkt = "polygon empty"; + + Polygon parsed = (Polygon)WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.ExteriorRing); + } + + [Fact] + public void Parse_ParsesGeometryCollection() + { + string wkt = "geometrycollection empty"; + + GeometryCollection parsed = (GeometryCollection)WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_ParsesMultiPoint() + { + string wkt = "multipoint empty"; + + MultiPoint parsed = (MultiPoint)WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_ParsesMultiLineString() + { + string wkt = "multilinestring empty"; + + MultiLineString parsed = (MultiLineString)WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_ParsesMultiPolygon() + { + string wkt = "multipolygon empty"; + + MultiPolygon parsed = (MultiPolygon)WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometry() + { + string wkt = "invalid string"; + + Assert.Throws(() => WktReader.Parse(wkt)); + } + + [Theory] + [InlineData("point zm \t(-10.1 15.5 100.5 \n1000.5)")] + [InlineData("\n\rlinestring (-10.1 15.5, 20.2 -25.5, \t30.3 35.5)")] + [InlineData("polygon\n\r m\t ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))")] + [InlineData("multipoint\t\r z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))")] + [InlineData("\nmultilinestring \tempty")] + [InlineData("multipolygon\n\r (((-10.1\t 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))")] + [InlineData("geometrycollection \t\n\r(point (-10.1 15.5))")] + public void Parse_ParsesGeometriesWithMultipleWhitespacesInsteadOneSpace(string wkt) + { + WktReader.Parse(wkt); + } + + [Theory] + [InlineData("point zm ( -10.1 15.5 100.5 1000.5 )")] + [InlineData("linestring ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 )")] + [InlineData("polygon m ( ( -10.1 15.5 1000.5 , 20.2 -25.5 2000.5, 30.3 35.5 -3000.5 ) )")] + [InlineData("multipoint z ( ( -10.1 15.5 100.5 ) , ( 20.2 -25.5 200.5 ) )")] + [InlineData("multilinestring ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) , ( -10.1 15.5, 20.2 -25.5, 30.3 35.5 ) ) ")] + [InlineData("multipolygon ( ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) , ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) )")] + [InlineData("geometrycollection ( point ( -10.1 15.5 ) )")] + public void Parse_ParsesGeometriesWithWhitespacesAtPlacesWhereTheyAreNotExpected(string wkt) + { + WktReader.Parse(wkt); + } + + [Fact] + public void Parse_ParsesEmptyPoint() + { + string wkt = "point empty"; + + Point parsed = WktReader.Parse(wkt); + + this.CompareCoordinate(Coordinate.Empty, parsed.Position); + } + + [Fact] + public void Parse_Parses2DPoint() + { + string wkt = "point (-10.1 15.5)"; + + Point parsed = WktReader.Parse(wkt); + + Assert.False(parsed.Is3D); + Assert.False(parsed.IsMeasured); + this.CompareCoordinate(_coordinatesXY[0], parsed.Position); + } + + [Fact] + public void Parse_Parses2DMeasuredPoint() + { + string wkt = "point m (-10.1 15.5 1000.5)"; + + Point parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.False(parsed.Is3D); + this.CompareCoordinate(_coordinatesXYM[0], parsed.Position); + } + + [Fact] + public void Parse_Parses3DPoint() + { + string wkt = "point z (-10.1 15.5 100.5)"; + + Point parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.False(parsed.IsMeasured); + this.CompareCoordinate(_coordinatesXYZ[0], parsed.Position); + } + + [Fact] + public void Parse_Parses3DMeasuredPoint() + { + string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; + + Point parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinate(_coordinatesXYZM[0], parsed.Position); + } + + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentPoint() + { + string wkt = "linestring empty"; + + Assert.Throws(() => WktReader.Parse(wkt)); + } + + [Fact] + public void Parse_ParsesEmptyLineString() + { + string wkt = "linestring empty"; + + LineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Coordinates); + } + + [Fact] + public void Parse_Parses2DLineString() + { + string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; + + LineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXY, parsed.Coordinates); + } + + [Fact] + public void Parse_Parses2DMeasuredLineString() + { + string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; + + LineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYM, parsed.Coordinates); + } + + [Fact] + public void Parse_Parses3DLineString() + { + string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; + + LineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZ, parsed.Coordinates); + } + + [Fact] + public void Parse_Parses3DMeasuredLineString() + { + string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; + + LineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZM, parsed.Coordinates); + } + + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentLineString() + { + string wkt = "point empty"; + + Assert.Throws(() => WktReader.Parse(wkt)); + } + + [Fact] + public void ParsePolygon_ParsesEmptyPolygon() + { + string wkt = "polygon empty"; + + Polygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } + + [Fact] + public void ParsePolygon_Parses2DPolygonOnlyExteriorRing() + { + string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + + Polygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXY, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } + + [Fact] + public void ParsePolygon_Parses3DPolygonOnlyExteriorRing() + { + string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + + Polygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZ, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } + + [Fact] + public void ParsePolygon_Parses2DMeauredPolygonOnlyExteriorRing() + { + string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + + Polygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYM, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } + + [Fact] + public void ParsePolygon_Parses3DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + + Polygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } + + [Fact] + public void ParsePolygon_Parses3DMeasuredPolygonWithInteriorRings() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + + Polygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); + Assert.Equal(2, parsed.InteriorRings.Count); + this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[0]); + this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[1]); + } + + [Fact] + public void ParsePolygong_ThrowsExceptionIfWktDoNotRepresentPolygon() + { + string wkt = "point empty"; + + Assert.Throws(() => WktReader.Parse(wkt)); + } + + [Fact] + public void Parse_ParsesEmptyMultiPoint() + { + string wkt = "multipoint empty"; + + MultiPoint parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_Parses2DMultiPoint() + { + string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; + + MultiPoint parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXY[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXY[1], parsed.Geometries[1].Position); + } + + [Fact] + public void Parse_Parses2DMeasuredMultiPoint() + { + string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; + + MultiPoint parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXYM[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXYM[1], parsed.Geometries[1].Position); + } + + [Fact] + public void Parse_Parses3DMultiPoint() + { + string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; + + MultiPoint parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXYZ[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXYZ[1], parsed.Geometries[1].Position); + } + + [Fact] + public void Parse_Parses3DMeasuredMultiPoint() + { + string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; + + MultiPoint parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXYZM[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXYZM[1], parsed.Geometries[1].Position); + } + + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPoint() + { + string wkt = "point empty"; + + Assert.Throws(() => WktReader.Parse(wkt)); + } + + [Fact] + public void Parse_ParsesEmptyMultiLineString() + { + string wkt = "multilinestring empty"; + + MultiLineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_Parses2DMultiLineString() + { + string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + + MultiLineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].Coordinates); + } + + [Fact] + public void Parse_Parses2DMeasuredMultiLineString() + { + string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + + MultiLineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].Coordinates); + } + + [Fact] + public void Parse_Parses3DMultiLineString() + { + string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + + MultiLineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].Coordinates); + } + + [Fact] + public void Parse_Parses3DMeasuredMultiLineString() + { + string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + + MultiLineString parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].Coordinates); + } + + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiLineString() + { + string wkt = "point empty"; + + Assert.Throws(() => WktReader.Parse(wkt)); + } + + [Fact] + public void Parse_ParsesEmptyMultiPolygon() + { + string wkt = "multipolygon empty"; + + MultiPolygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_Parses2DMultiPolygon() + { + string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + + MultiPolygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].ExteriorRing); + } + + [Fact] + public void Parse_Parses2DMeasuredMultiPolygon() + { + string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; + + MultiPolygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].ExteriorRing); + } + + [Fact] + public void Parse_Parses3DMultiPolygon() + { + string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; + + MultiPolygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].ExteriorRing); + } + + [Fact] + public void Parse_Parses3DMeasuredMultiPolygon() + { + string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; + + MultiPolygon parsed = WktReader.Parse(wkt); + + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].ExteriorRing); + } + + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPolygon() + { + string wkt = "point empty"; + + Assert.Throws(() => WktReader.Parse(wkt)); + } + + [Fact] + public void Parse_ParsesEmptyGeometryCollection() + { + string wkt = "geometrycollection empty"; + + GeometryCollection parsed = WktReader.Parse>(wkt); + + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } + + [Fact] + public void Parse_Parses2DGeometryCollectionWithPoint() + { + string wkt = "geometrycollection (point (-10.1 15.5))"; + + GeometryCollection parsed = WktReader.Parse>(wkt); + + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); + } + + [Fact] + public void Parse_Parses2DMeasuredGeometryCollectionWithPoint() + { + string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; + + GeometryCollection parsed = WktReader.Parse>(wkt); + + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXYM[0], ((Point)parsed.Geometries[0]).Position); + } + + [Fact] + public void Parse_Parses3DGeometryCollectionWithPoint() + { + string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; + + GeometryCollection parsed = WktReader.Parse>(wkt); + + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXYZ[0], ((Point)parsed.Geometries[0]).Position); + } + + [Fact] + public void Parse_Parses3DMeasuredGeometryCollectionWithPoint() + { + string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; + + GeometryCollection parsed = WktReader.Parse>(wkt); + + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXYZM[0], ((Point)parsed.Geometries[0]).Position); + } + + [Fact] + public void Parse_ParsesCollectionWithPointLineStringAndPolygon() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + + GeometryCollection parsed = WktReader.Parse>(wkt); + + Assert.NotNull(parsed); + Assert.Equal(3, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); + this.CompareCoordinates(_coordinatesXY, ((LineString)parsed.Geometries[1]).Coordinates); + this.CompareCoordinates(_coordinatesXY, ((Polygon)parsed.Geometries[2]).ExteriorRing); + } + + [Fact] + public void Parse_ParsesNestedCollections() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + + GeometryCollection parsed = WktReader.Parse>(wkt); + + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + GeometryCollection nested = (GeometryCollection)parsed.Geometries[0]; + this.CompareCoordinate(_coordinatesXY[0], ((Point)nested.Geometries[0]).Position); + } + + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometryCollection() + { + string wkt = "point empty"; + + Assert.Throws(() => WktReader.Parse>(wkt)); + } + + private void CompareCoordinate(Coordinate expected, Coordinate actual) + { + Assert.Equal(expected, actual); + } + + private void CompareCoordinates(Coordinate[] expected, ICoordinateList actual) + { + Assert.Equal(expected.Length, actual.Count); + + for (int i = 0; i < expected.Length; i++) + { + Assert.Equal(expected[i], actual[i]); + } + } + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs index 6852962..0b4bd9d 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs @@ -1,136 +1,142 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.IO; -using System.IO; - -namespace Tests.SpatialLite.Core.IO { - public class WktTokenizerTests { - - [Fact] - void Tokenize_String_ReturnsEmptyTokenForEmptyString() { - string data = string.Empty; - var tokens = WktTokenizer.Tokenize(data); - - Assert.Empty(tokens); - } - - [Theory] - [InlineData("stringTOOKEN", TokenType.STRING)] - [InlineData(" ", TokenType.WHITESPACE)] - [InlineData("\t", TokenType.WHITESPACE)] - [InlineData("\n", TokenType.WHITESPACE)] - [InlineData("\r", TokenType.WHITESPACE)] - [InlineData("(", TokenType.LEFT_PARENTHESIS)] - [InlineData(")", TokenType.RIGHT_PARENTHESIS)] - [InlineData(",", TokenType.COMMA)] - [InlineData("-123456780.9", TokenType.NUMBER)] - void Tokenize_String_CorrectlyRecognizesTokenTypes(string str, TokenType expectedType) { - var tokens = WktTokenizer.Tokenize(str).ToArray(); - - Assert.Single(tokens); - - WktToken t = tokens.First(); - Assert.Equal(expectedType, t.Type); - Assert.Equal(str, t.Value); - } - - [Fact] - void Tokenize_String_ProcessesComplexText() { - string data = "point z (-10 -15 -100.1)"; - var tokens =WktTokenizer.Tokenize(data).ToArray(); - - Assert.Equal(11, tokens.Length); - - WktToken t = tokens[0]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("point", t.Value); - - t = tokens[1]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[2]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("z", t.Value); - - t = tokens[3]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[4]; - Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); - - t = tokens[5]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-10", t.Value); - - t = tokens[6]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[7]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-15", t.Value); - - t = tokens[8]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[9]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-100.1", t.Value); - - t = tokens[10]; - Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); - } - - [Fact] - void Tokenize_TextReader_ProcessesComplexText() { - StringReader reader = new StringReader("point z (-10 -15 -100.1)"); - - var tokens = WktTokenizer.Tokenize(reader).ToArray(); - - Assert.Equal(11, tokens.Length); - - WktToken t = tokens[0]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("point", t.Value); - - t = tokens[1]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[2]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("z", t.Value); - - t = tokens[3]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[4]; - Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); - - t = tokens[5]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-10", t.Value); - - t = tokens[6]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[7]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-15", t.Value); - - t = tokens[8]; - Assert.Equal(TokenType.WHITESPACE, t.Type); - - t = tokens[9]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-100.1", t.Value); - - t = tokens[10]; - Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; +using Xunit.Extensions; + +using SpatialLite.Core.IO; +using System.IO; + +namespace Tests.SpatialLite.Core.IO +{ + public class WktTokenizerTests + { + + [Fact] + void Tokenize_String_ReturnsEmptyTokenForEmptyString() + { + string data = string.Empty; + var tokens = WktTokenizer.Tokenize(data); + + Assert.Empty(tokens); + } + + [Theory] + [InlineData("stringTOOKEN", TokenType.STRING)] + [InlineData(" ", TokenType.WHITESPACE)] + [InlineData("\t", TokenType.WHITESPACE)] + [InlineData("\n", TokenType.WHITESPACE)] + [InlineData("\r", TokenType.WHITESPACE)] + [InlineData("(", TokenType.LEFT_PARENTHESIS)] + [InlineData(")", TokenType.RIGHT_PARENTHESIS)] + [InlineData(",", TokenType.COMMA)] + [InlineData("-123456780.9", TokenType.NUMBER)] + void Tokenize_String_CorrectlyRecognizesTokenTypes(string str, TokenType expectedType) + { + var tokens = WktTokenizer.Tokenize(str).ToArray(); + + Assert.Single(tokens); + + WktToken t = tokens.First(); + Assert.Equal(expectedType, t.Type); + Assert.Equal(str, t.Value); + } + + [Fact] + void Tokenize_String_ProcessesComplexText() + { + string data = "point z (-10 -15 -100.1)"; + var tokens = WktTokenizer.Tokenize(data).ToArray(); + + Assert.Equal(11, tokens.Length); + + WktToken t = tokens[0]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("point", t.Value); + + t = tokens[1]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[2]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("z", t.Value); + + t = tokens[3]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[4]; + Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); + + t = tokens[5]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-10", t.Value); + + t = tokens[6]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[7]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-15", t.Value); + + t = tokens[8]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[9]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-100.1", t.Value); + + t = tokens[10]; + Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); + } + + [Fact] + void Tokenize_TextReader_ProcessesComplexText() + { + StringReader reader = new StringReader("point z (-10 -15 -100.1)"); + + var tokens = WktTokenizer.Tokenize(reader).ToArray(); + + Assert.Equal(11, tokens.Length); + + WktToken t = tokens[0]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("point", t.Value); + + t = tokens[1]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[2]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("z", t.Value); + + t = tokens[3]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[4]; + Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); + + t = tokens[5]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-10", t.Value); + + t = tokens[6]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[7]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-15", t.Value); + + t = tokens[8]; + Assert.Equal(TokenType.WHITESPACE, t.Type); + + t = tokens[9]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-100.1", t.Value); + + t = tokens[10]; + Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); + } + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs index 0692dbd..7b88fff 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs @@ -1,185 +1,205 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core.IO; - -namespace Tests.SpatialLite.Core.IO { - public class WktTokensBufferTests { - WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, - new WktToken() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; - - [Fact] - public void Constructor__CreatesEmptyBuffer() { - WktTokensBuffer target = new WktTokensBuffer(); - - Assert.Empty(target); - } - - [Fact] - public void Constructor_TextReader_CreatesBufferWithSpecificTokens() { - WktTokensBuffer target = new WktTokensBuffer(_testData); - - Assert.Equal(_testData.Length, target.Count()); - for (int i = 0; i < _testData.Length; i++) { - Assert.Equal(_testData[i], target.ToArray()[i]); - } - } - - [Fact] - public void Count_GetsNumberOfItemsInBufffer() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData); - - Assert.Equal(_testData.Length, target.Count); - } - - [Fact] - public void Add_WktToken_AddsItemToTheCollection() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData[0]); - - Assert.Single(target); - Assert.Contains(_testData[0], target); - } - - [Fact] - public void Add_IEnumerable_AddsItemsToTheCollection() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData); - - Assert.Equal(_testData.Length, target.Count()); - for (int i = 0; i < _testData.Length; i++) { - Assert.Equal(_testData[i], target.ToArray()[i]); - } - } - - [Fact] - public void Clear_RemovesAllItemsFromCollection() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData); - - target.Clear(); - - Assert.Empty(target); - } - - [Fact] - public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData[0]); - - var result = target.Peek(false); - - Assert.Equal(_testData[0], result); - Assert.Contains(_testData[0], target); - } - - [Fact] - public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(_testData[0]); - - var result = target.Peek(true); - - Assert.Equal(_testData[0], result); - Assert.Equal(3, target.Count); - } - - [Fact] - public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); - target.Add(_testData[0]); - - var result = target.Peek(false); - - Assert.Equal(whitespaceToken, result); - Assert.Equal(2, target.Count); - } - - [Fact] - public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() { - WktTokensBuffer target = new WktTokensBuffer(); - - var result = target.Peek(false); - - Assert.Equal(WktToken.EndOfDataToken, result); - } - - [Fact] - public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); - - var result = target.Peek(true); - - Assert.Equal(WktToken.EndOfDataToken, result); - } - - [Fact] - public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData[0]); - - var result = target.GetToken(false); - - Assert.Equal(_testData[0], result); - Assert.DoesNotContain(_testData[0], target); - } - - [Fact] - public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(_testData[0]); - - var result = target.GetToken(true); - - Assert.Equal(_testData[0], result); - Assert.Equal(0, target.Count); - } - - [Fact] - public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); - target.Add(_testData[0]); - - var result = target.GetToken(false); - - Assert.Equal(whitespaceToken, result); - Assert.Equal(1, target.Count); - } - - [Fact] - public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() { - WktTokensBuffer target = new WktTokensBuffer(); - - var result = target.GetToken(false); - - Assert.Equal(WktToken.EndOfDataToken, result); - } - - [Fact] - public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); - - var result = target.GetToken(true); - - Assert.Equal(WktToken.EndOfDataToken, result); - Assert.Empty(target); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core.IO; + +namespace Tests.SpatialLite.Core.IO +{ + public class WktTokensBufferTests + { + WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, + new WktToken() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; + + [Fact] + public void Constructor__CreatesEmptyBuffer() + { + WktTokensBuffer target = new WktTokensBuffer(); + + Assert.Empty(target); + } + + [Fact] + public void Constructor_TextReader_CreatesBufferWithSpecificTokens() + { + WktTokensBuffer target = new WktTokensBuffer(_testData); + + Assert.Equal(_testData.Length, target.Count()); + for (int i = 0; i < _testData.Length; i++) + { + Assert.Equal(_testData[i], target.ToArray()[i]); + } + } + + [Fact] + public void Count_GetsNumberOfItemsInBufffer() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData); + + Assert.Equal(_testData.Length, target.Count); + } + + [Fact] + public void Add_WktToken_AddsItemToTheCollection() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData[0]); + + Assert.Single(target); + Assert.Contains(_testData[0], target); + } + + [Fact] + public void Add_IEnumerable_AddsItemsToTheCollection() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData); + + Assert.Equal(_testData.Length, target.Count()); + for (int i = 0; i < _testData.Length; i++) + { + Assert.Equal(_testData[i], target.ToArray()[i]); + } + } + + [Fact] + public void Clear_RemovesAllItemsFromCollection() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData); + + target.Clear(); + + Assert.Empty(target); + } + + [Fact] + public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData[0]); + + var result = target.Peek(false); + + Assert.Equal(_testData[0], result); + Assert.Contains(_testData[0], target); + } + + [Fact] + public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(_testData[0]); + + var result = target.Peek(true); + + Assert.Equal(_testData[0], result); + Assert.Equal(3, target.Count); + } + + [Fact] + public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); + target.Add(_testData[0]); + + var result = target.Peek(false); + + Assert.Equal(whitespaceToken, result); + Assert.Equal(2, target.Count); + } + + [Fact] + public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() + { + WktTokensBuffer target = new WktTokensBuffer(); + + var result = target.Peek(false); + + Assert.Equal(WktToken.EndOfDataToken, result); + } + + [Fact] + public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); + + var result = target.Peek(true); + + Assert.Equal(WktToken.EndOfDataToken, result); + } + + [Fact] + public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData[0]); + + var result = target.GetToken(false); + + Assert.Equal(_testData[0], result); + Assert.DoesNotContain(_testData[0], target); + } + + [Fact] + public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(_testData[0]); + + var result = target.GetToken(true); + + Assert.Equal(_testData[0], result); + Assert.Equal(0, target.Count); + } + + [Fact] + public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); + target.Add(_testData[0]); + + var result = target.GetToken(false); + + Assert.Equal(whitespaceToken, result); + Assert.Equal(1, target.Count); + } + + [Fact] + public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() + { + WktTokensBuffer target = new WktTokensBuffer(); + + var result = target.GetToken(false); + + Assert.Equal(WktToken.EndOfDataToken, result); + } + + [Fact] + public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); + + var result = target.GetToken(true); + + Assert.Equal(WktToken.EndOfDataToken, result); + Assert.Empty(target); + } + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs index f6c7841..d5d846d 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs @@ -1,21 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core.IO; - -namespace Tests.SpatialLite.Core.IO { - public class WktWriterSettingsTests { - - [Fact] - public void Constructor__SetsDefaultValues() { - WktWriterSettings target = new WktWriterSettings(); - - Assert.False(target.IsReadOnly); - } - - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; + +using SpatialLite.Core.IO; + +namespace Tests.SpatialLite.Core.IO +{ + public class WktWriterSettingsTests + { + + [Fact] + public void Constructor__SetsDefaultValues() + { + WktWriterSettings target = new WktWriterSettings(); + + Assert.False(target.IsReadOnly); + } + + } +} diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs index 81aa6ab..a1d1938 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs @@ -1,302 +1,346 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.IO; - -namespace Tests.SpatialLite.Core.IO { - public class WktWriterTests { - - - private static Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) - }; - - private static Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) - }; - - private static Coordinate[] _coordinatesXYM = new Coordinate[] { - new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) - }; - - private static Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) - }; - - private static Coordinate[] _coordinates2XYZM = new Coordinate[] { - new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) - }; - - [Fact] - public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(new MemoryStream(), settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() { - Stream stream = null; - Assert.Throws(() => new WktWriter(stream, new WktWriterSettings())); - } - - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() { - Assert.Throws(() => new WktWriter(new MemoryStream(), null)); - } - - [Fact] - public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() { - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(new MemoryStream(), settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_PathSettings_CreatesOutputFile() { - string filename = PathHelper.GetTempFilePath("wktwriter-constructor-creates-output-test.wkt"); - File.Delete(filename); - - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(filename, settings)) { - ; - } - - Assert.True(File.Exists(filename)); - } - - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() { - string path = null; - Assert.Throws(() => new WktWriter(path, new WktWriterSettings())); - } - - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() { - string path = PathHelper.GetTempFilePath("WktWriter-constructor-test.bin"); - - Assert.Throws(() => new WktWriter(path, null)); - } - - public static IEnumerable WriteToStringTestData { - get { - yield return new object[] { new Point(), "point empty" }; - yield return new object[] { new LineString(), "linestring empty" }; - yield return new object[] { new Polygon(), "polygon empty" }; - yield return new object[] { new MultiPoint(), "multipoint empty" }; - yield return new object[] { new MultiLineString(), "multilinestring empty" }; - yield return new object[] { new MultiPolygon(), "multipolygon empty" }; - yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; - - } - } - - [Theory] - [MemberData(nameof(WriteToStringTestData))] - public void WriteToString_WritesAllGeometryTypes(Geometry toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = PathHelper.GetTempFilePath("wktwriter-closes-output-filestream-test.wkt"); - - WktWriterSettings settings = new WktWriterSettings(); - WktWriter target = new WktWriter(filename, settings); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new MemoryStream(); - - WktWriter target = new WktWriter(stream, new WktWriterSettings()); - target.Dispose(); - - Assert.False(stream.CanRead); - } - - public static IEnumerable Write_WritesPointsOfAllDimensionsTestData { - get { - yield return new object[] { new Point(), "point empty" }; - yield return new object[] { new Point(_coordinatesXY[0]), "point (-10.1 15.5)" }; - yield return new object[] { new Point(_coordinatesXYM[0]), "point m (-10.1 15.5 1000.5)" }; - yield return new object[] { new Point(_coordinatesXYZ[0]), "point z (-10.1 15.5 100.5)" }; - yield return new object[] { new Point(_coordinatesXYZM[0]), "point zm (-10.1 15.5 100.5 1000.5)" }; - } - } - - [Theory] - [MemberData(nameof(Write_WritesPointsOfAllDimensionsTestData))] - public void Write_WritesPointsOfAllDimensions(Point toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - public static IEnumerable Write_WritesLinestringOfAllDimensionsTestData { - get { - yield return new object[] { new LineString(), "linestring empty" }; - yield return new object[] { new LineString(_coordinatesXY), "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)" }; - yield return new object[] { new LineString(_coordinatesXYM), "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)" }; - yield return new object[] { new LineString(_coordinatesXYZ), "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)" }; - yield return new object[] { new LineString(_coordinatesXYZM), "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)" }; - } - } - - [Theory] - [MemberData(nameof(Write_WritesLinestringOfAllDimensionsTestData))] - public void Write_WritesLinestringsOfAllDimensions(LineString toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - public static IEnumerable Write_WritesPolygonsOfAllDimensionsTestData { - get { - yield return new object[] { new Polygon(), "polygon empty" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXY)), "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYM)), "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZ)), "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZM)), "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; - } - } - - [Theory] - [MemberData(nameof(Write_WritesPolygonsOfAllDimensionsTestData))] - public void Write_WritesPolygonsOfAllDimensions(Polygon toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - [Fact] - public void Write_WritesComplexPolygonWitOuterAndInnerRings() { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon polygon = new Polygon(new CoordinateList(_coordinatesXYZM)); - polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); - polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); - - this.TestWriteGeometry(polygon, wkt); - } - - public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestData { - get { - yield return new object[] { new MultiPoint(), "multipoint empty" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXY[0]), new Point(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYM[0]), new Point(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZ[0]), new Point(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZM[0]), new Point(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; - } - } - - [Theory] - [MemberData(nameof(Write_WritesMultiPoinsOfAllDimensionsTestData))] - public void Write_WritesMultiPointsOfAllDimensions(MultiPoint toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsTestData { - get { - yield return new object[] { new MultiLineString(), "multilinestring empty" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXY), new LineString(_coordinatesXY) }), - "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYM), new LineString(_coordinatesXYM) }), - "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZ), new LineString(_coordinatesXYZ) }), - "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZM), new LineString(_coordinatesXYZM) }), - "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; - } - } - - [Theory] - [MemberData(nameof(Write_WritesMultiLineStringsOfAllDimensionsTestData))] - public void Write_WritesMultiLineStringsOfAllDimensions(MultiLineString toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTestData { - get { - yield return new object[] { new MultiPolygon(), "multipolygon empty" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXY)), new Polygon(new CoordinateList(_coordinatesXY)) }), - "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYM)), new Polygon(new CoordinateList(_coordinatesXYM)) }), - "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZ)), new Polygon(new CoordinateList(_coordinatesXYZ)) }), - "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZM)), new Polygon(new CoordinateList(_coordinatesXYZM)) }), - "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))" }; - } - } - - [Theory] - [MemberData(nameof(Write_WritesMultiPolygonsOfAllDimensionsTestData))] - public void Write_WritesMultiPolygonsOfAllDimensions(MultiPolygon toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - public static IEnumerable Write_WritesGeometryCollectionOfAllDimensionsTestData { - get { - yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXY[0]) }), "geometrycollection (point (-10.1 15.5))" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYM[0]) }), "geometrycollection m (point m (-10.1 15.5 1000.5))" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZ[0]) }), "geometrycollection z (point z (-10.1 15.5 100.5))" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZM[0]) }), "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))" }; - } - } - - [Theory] - [MemberData(nameof(Write_WritesGeometryCollectionOfAllDimensionsTestData))] - public void Write_WritesGeometryCollectionOfAllDimensions(GeometryCollection toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); - } - - [Fact] - public void Write_WritesCollectionWithAllGeometryTypes() { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection collection = new GeometryCollection(); - collection.Geometries.Add(new Point(_coordinatesXY[0])); - collection.Geometries.Add(new LineString(_coordinatesXY)); - collection.Geometries.Add(new Polygon(new CoordinateList(_coordinatesXY))); - collection.Geometries.Add(new MultiPoint()); - collection.Geometries.Add(new MultiLineString()); - collection.Geometries.Add(new MultiPolygon()); - - this.TestWriteGeometry(collection, wkt); - } - - [Fact] - public void Write_WritesNestedCollection() { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection collection = new GeometryCollection(); - GeometryCollection nested = new GeometryCollection(); - nested.Geometries.Add(new Point(_coordinatesXY[0])); - collection.Geometries.Add(nested); - - this.TestWriteGeometry(collection, wkt); - } - - private void TestWriteGeometry(IGeometry geometry, string expectedWkt) { - MemoryStream stream = new MemoryStream(); - using (WktWriter writer = new WktWriter(stream, new WktWriterSettings())) { - writer.Write(geometry); - } - - using (TextReader tr = new StreamReader(new MemoryStream(stream.ToArray()))) { - string wkt = tr.ReadToEnd(); - Assert.Equal(expectedWkt, wkt, StringComparer.OrdinalIgnoreCase); - } - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +using Xunit; +using Xunit.Extensions; + +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.IO; + +namespace Tests.SpatialLite.Core.IO +{ + public class WktWriterTests + { + + + private static Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) + }; + + private static Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) + }; + + private static Coordinate[] _coordinatesXYM = new Coordinate[] { + new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) + }; + + private static Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) + }; + + private static Coordinate[] _coordinates2XYZM = new Coordinate[] { + new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) + }; + + [Fact] + public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + { + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(new MemoryStream(), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + Stream stream = null; + Assert.Throws(() => new WktWriter(stream, new WktWriterSettings())); + } + + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + Assert.Throws(() => new WktWriter(new MemoryStream(), null)); + } + + [Fact] + public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() + { + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(new MemoryStream(), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_PathSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("wktwriter-constructor-creates-output-test.wkt"); + File.Delete(filename); + + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(filename, settings)) + { + ; + } + + Assert.True(File.Exists(filename)); + } + + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + string path = null; + Assert.Throws(() => new WktWriter(path, new WktWriterSettings())); + } + + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + string path = PathHelper.GetTempFilePath("WktWriter-constructor-test.bin"); + + Assert.Throws(() => new WktWriter(path, null)); + } + + public static IEnumerable WriteToStringTestData + { + get + { + yield return new object[] { new Point(), "point empty" }; + yield return new object[] { new LineString(), "linestring empty" }; + yield return new object[] { new Polygon(), "polygon empty" }; + yield return new object[] { new MultiPoint(), "multipoint empty" }; + yield return new object[] { new MultiLineString(), "multilinestring empty" }; + yield return new object[] { new MultiPolygon(), "multipolygon empty" }; + yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; + + } + } + + [Theory] + [MemberData(nameof(WriteToStringTestData))] + public void WriteToString_WritesAllGeometryTypes(Geometry toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = PathHelper.GetTempFilePath("wktwriter-closes-output-filestream-test.wkt"); + + WktWriterSettings settings = new WktWriterSettings(); + WktWriter target = new WktWriter(filename, settings); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + MemoryStream stream = new MemoryStream(); + + WktWriter target = new WktWriter(stream, new WktWriterSettings()); + target.Dispose(); + + Assert.False(stream.CanRead); + } + + public static IEnumerable Write_WritesPointsOfAllDimensionsTestData + { + get + { + yield return new object[] { new Point(), "point empty" }; + yield return new object[] { new Point(_coordinatesXY[0]), "point (-10.1 15.5)" }; + yield return new object[] { new Point(_coordinatesXYM[0]), "point m (-10.1 15.5 1000.5)" }; + yield return new object[] { new Point(_coordinatesXYZ[0]), "point z (-10.1 15.5 100.5)" }; + yield return new object[] { new Point(_coordinatesXYZM[0]), "point zm (-10.1 15.5 100.5 1000.5)" }; + } + } + + [Theory] + [MemberData(nameof(Write_WritesPointsOfAllDimensionsTestData))] + public void Write_WritesPointsOfAllDimensions(Point toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + public static IEnumerable Write_WritesLinestringOfAllDimensionsTestData + { + get + { + yield return new object[] { new LineString(), "linestring empty" }; + yield return new object[] { new LineString(_coordinatesXY), "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)" }; + yield return new object[] { new LineString(_coordinatesXYM), "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)" }; + yield return new object[] { new LineString(_coordinatesXYZ), "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)" }; + yield return new object[] { new LineString(_coordinatesXYZM), "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)" }; + } + } + + [Theory] + [MemberData(nameof(Write_WritesLinestringOfAllDimensionsTestData))] + public void Write_WritesLinestringsOfAllDimensions(LineString toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + public static IEnumerable Write_WritesPolygonsOfAllDimensionsTestData + { + get + { + yield return new object[] { new Polygon(), "polygon empty" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXY)), "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYM)), "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZ)), "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZM)), "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; + } + } + + [Theory] + [MemberData(nameof(Write_WritesPolygonsOfAllDimensionsTestData))] + public void Write_WritesPolygonsOfAllDimensions(Polygon toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + [Fact] + public void Write_WritesComplexPolygonWitOuterAndInnerRings() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + Polygon polygon = new Polygon(new CoordinateList(_coordinatesXYZM)); + polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); + polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); + + this.TestWriteGeometry(polygon, wkt); + } + + public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestData + { + get + { + yield return new object[] { new MultiPoint(), "multipoint empty" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXY[0]), new Point(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYM[0]), new Point(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZ[0]), new Point(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZM[0]), new Point(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; + } + } + + [Theory] + [MemberData(nameof(Write_WritesMultiPoinsOfAllDimensionsTestData))] + public void Write_WritesMultiPointsOfAllDimensions(MultiPoint toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsTestData + { + get + { + yield return new object[] { new MultiLineString(), "multilinestring empty" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXY), new LineString(_coordinatesXY) }), + "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYM), new LineString(_coordinatesXYM) }), + "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZ), new LineString(_coordinatesXYZ) }), + "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZM), new LineString(_coordinatesXYZM) }), + "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; + } + } + + [Theory] + [MemberData(nameof(Write_WritesMultiLineStringsOfAllDimensionsTestData))] + public void Write_WritesMultiLineStringsOfAllDimensions(MultiLineString toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTestData + { + get + { + yield return new object[] { new MultiPolygon(), "multipolygon empty" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXY)), new Polygon(new CoordinateList(_coordinatesXY)) }), + "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYM)), new Polygon(new CoordinateList(_coordinatesXYM)) }), + "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZ)), new Polygon(new CoordinateList(_coordinatesXYZ)) }), + "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZM)), new Polygon(new CoordinateList(_coordinatesXYZM)) }), + "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))" }; + } + } + + [Theory] + [MemberData(nameof(Write_WritesMultiPolygonsOfAllDimensionsTestData))] + public void Write_WritesMultiPolygonsOfAllDimensions(MultiPolygon toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + public static IEnumerable Write_WritesGeometryCollectionOfAllDimensionsTestData + { + get + { + yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXY[0]) }), "geometrycollection (point (-10.1 15.5))" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYM[0]) }), "geometrycollection m (point m (-10.1 15.5 1000.5))" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZ[0]) }), "geometrycollection z (point z (-10.1 15.5 100.5))" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZM[0]) }), "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))" }; + } + } + + [Theory] + [MemberData(nameof(Write_WritesGeometryCollectionOfAllDimensionsTestData))] + public void Write_WritesGeometryCollectionOfAllDimensions(GeometryCollection toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } + + [Fact] + public void Write_WritesCollectionWithAllGeometryTypes() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),multipoint empty,multilinestring empty,multipolygon empty)"; + GeometryCollection collection = new GeometryCollection(); + collection.Geometries.Add(new Point(_coordinatesXY[0])); + collection.Geometries.Add(new LineString(_coordinatesXY)); + collection.Geometries.Add(new Polygon(new CoordinateList(_coordinatesXY))); + collection.Geometries.Add(new MultiPoint()); + collection.Geometries.Add(new MultiLineString()); + collection.Geometries.Add(new MultiPolygon()); + + this.TestWriteGeometry(collection, wkt); + } + + [Fact] + public void Write_WritesNestedCollection() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + GeometryCollection collection = new GeometryCollection(); + GeometryCollection nested = new GeometryCollection(); + nested.Geometries.Add(new Point(_coordinatesXY[0])); + collection.Geometries.Add(nested); + + this.TestWriteGeometry(collection, wkt); + } + + private void TestWriteGeometry(IGeometry geometry, string expectedWkt) + { + MemoryStream stream = new MemoryStream(); + using (WktWriter writer = new WktWriter(stream, new WktWriterSettings())) + { + writer.Write(geometry); + } + + using (TextReader tr = new StreamReader(new MemoryStream(stream.ToArray()))) + { + string wkt = tr.ReadToEnd(); + Assert.Equal(expectedWkt, wkt, StringComparer.OrdinalIgnoreCase); + } + } + } +} diff --git a/src/Tests.SpatialLite.Core/MeasurementsTests.cs b/src/Tests.SpatialLite.Core/MeasurementsTests.cs index 424dd01..c7fb079 100644 --- a/src/Tests.SpatialLite.Core/MeasurementsTests.cs +++ b/src/Tests.SpatialLite.Core/MeasurementsTests.cs @@ -1,274 +1,296 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Moq; - -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.Algorithms; - -namespace Tests.SpatialLite.Core { - public class MeasurementsTests { - - [Fact] - public void Euclidean2D_GetsInstanceOfMeasuremntsWithTheEuclidean2DCalculator() { - Assert.IsType(Measurements.Euclidean2D.DimensionsCalculator); - } - - [Fact] - public void Sphere2D_GetsInstanceOfMeasuremntsWithTheSphere2DCalculator() { - Assert.IsType(Measurements.Sphere2D.DimensionsCalculator); - } - - [Fact] - public void Constructor_SetsCalculatorObject() { - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - - Assert.Same(calculatorM.Object, target.DimensionsCalculator); - } - - [Fact] - public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCorrectParameters() { - Coordinate c1 = new Coordinate(10.1, 20.1); - Coordinate c2 = new Coordinate(10.2, 20.2); - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(c1, c2); - - calculatorM.Verify(calc => calc.CalculateDistance(c1, c2), Times.Once()); - } - - [Fact] - public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() { - Point p1 = new Point(Coordinate.Empty); - Point p2 = new Point(new Coordinate(10.2, 20.2)); - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(p1, p2); - - Assert.True(double.IsNaN(distance)); - } - - [Fact] - public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() { - Point p1 = new Point(new Coordinate(10.1, 20.1)); - Point p2 = new Point(Coordinate.Empty); - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(p1, p2); - - Assert.True(double.IsNaN(distance)); - } - - [Fact] - public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParameters() { - Point p1 = new Point(new Coordinate(10.1, 20.1)); - Point p2 = new Point(new Coordinate(10.2, 20.2)); - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(p1, p2); - - calculatorM.Verify(calc => calc.CalculateDistance(p1.Position, p2.Position), Times.Once()); - } - - [Fact] - public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() { - Point point = new Point(new Coordinate(10.1, 20.1)); - LineString linestring = new LineString(); - - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, linestring); - - Assert.True(double.IsNaN(distance)); - } - - [Fact] - public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() { - Point point = new Point(Coordinate.Empty); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, linestring); - - Assert.True(double.IsNaN(distance)); - } - - [Fact] - public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEmpty() { - Point point = new Point(new Coordinate(10.1, 20.1)); - MultiLineString multilinestring = new MultiLineString(); - - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, multilinestring); - - Assert.True(double.IsNaN(distance)); - } - - [Fact] - public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() { - Point point = new Point(Coordinate.Empty); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); - - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, multilinestring); - - Assert.True(double.IsNaN(distance)); - } - - [Fact] - public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() { - LineString linestring = new LineString(); - - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); - - double length = target.ComputeLength(linestring); - - Assert.Equal(0, length); - } - - [Fact] - public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() { - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1) }); - - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); - - double length = target.ComputeLength(linestring); - - Assert.Equal(0, length); - } - - [Fact] - public void ComputeLength_LineString_RetursSumOfSegmentsLengths() { - Random generator = new Random(); - double segment1Length = generator.Next(100); - double segment2Length = generator.Next(100); - double sum = segment1Length + segment2Length; - - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - - Measurements target = new Measurements(calculatorM.Object); - double length = target.ComputeLength(linestring); - - Assert.Equal(sum, length); - } - - [Fact] - public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMembers() { - MultiLineString multilinestring = new MultiLineString(); - - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); - - double length = target.ComputeLength(multilinestring); - - Assert.Equal(0, length); - } - - [Fact] - public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() { - Random generator = new Random(); - double segment1Length = generator.Next(100); - double segment2Length = generator.Next(100); - double sum = 2 * (segment1Length + segment2Length); - - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); - - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - - Measurements target = new Measurements(calculatorM.Object); - double length = target.ComputeLength(multilinestring); - - Assert.Equal(sum, length); - } - - [Fact] - public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator() { - Polygon polygon = new Polygon(new CoordinateList()); - Random generator = new Random(); - double expectedArea = generator.Next(100); - - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea); - Measurements target = new Measurements(calculatorM.Object); - - double area = target.ComputeArea(polygon); - - Assert.Equal(expectedArea, area); - } - - [Fact] - public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator() { - // Create polygon with interior ring - Polygon polygon = new Polygon(new CoordinateList()); - polygon.InteriorRings.Add(new CoordinateList()); - - // Fixed test values - double exteriorArea = 50; - double interiorArea = 10; - double expectedArea = exteriorArea - interiorArea; - - // Setup mock - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateArea(It.IsAny())) - .Returns(coords => { - if (coords == polygon.ExteriorRing) return exteriorArea; - if (coords == polygon.InteriorRings[0]) return interiorArea; - return 0; - }); - - // Create the object being tested - Measurements target = new Measurements(calculatorM.Object); - - // Execute the method being tested - double area = target.ComputeArea(polygon); - - // Verify the result - Assert.Equal(expectedArea, area); - } - - [Fact] - public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas() { - Random generator = new Random(); - - Polygon polygon = new Polygon(new CoordinateList()); - double polygonArea = generator.Next(100); - MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon }); - - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea); - - Measurements target = new Measurements(calculatorM.Object); - - double area = target.ComputeArea(multipolygon); - - Assert.Equal(2 * polygonArea, area); - } - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xunit; +using Moq; + +using SpatialLite.Core; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.Algorithms; + +namespace Tests.SpatialLite.Core +{ + public class MeasurementsTests + { + + [Fact] + public void Euclidean2D_GetsInstanceOfMeasuremntsWithTheEuclidean2DCalculator() + { + Assert.IsType(Measurements.Euclidean2D.DimensionsCalculator); + } + + [Fact] + public void Sphere2D_GetsInstanceOfMeasuremntsWithTheSphere2DCalculator() + { + Assert.IsType(Measurements.Sphere2D.DimensionsCalculator); + } + + [Fact] + public void Constructor_SetsCalculatorObject() + { + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + + Assert.Same(calculatorM.Object, target.DimensionsCalculator); + } + + [Fact] + public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCorrectParameters() + { + Coordinate c1 = new Coordinate(10.1, 20.1); + Coordinate c2 = new Coordinate(10.2, 20.2); + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(c1, c2); + + calculatorM.Verify(calc => calc.CalculateDistance(c1, c2), Times.Once()); + } + + [Fact] + public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() + { + Point p1 = new Point(Coordinate.Empty); + Point p2 = new Point(new Coordinate(10.2, 20.2)); + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(p1, p2); + + Assert.True(double.IsNaN(distance)); + } + + [Fact] + public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() + { + Point p1 = new Point(new Coordinate(10.1, 20.1)); + Point p2 = new Point(Coordinate.Empty); + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(p1, p2); + + Assert.True(double.IsNaN(distance)); + } + + [Fact] + public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParameters() + { + Point p1 = new Point(new Coordinate(10.1, 20.1)); + Point p2 = new Point(new Coordinate(10.2, 20.2)); + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(p1, p2); + + calculatorM.Verify(calc => calc.CalculateDistance(p1.Position, p2.Position), Times.Once()); + } + + [Fact] + public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() + { + Point point = new Point(new Coordinate(10.1, 20.1)); + LineString linestring = new LineString(); + + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, linestring); + + Assert.True(double.IsNaN(distance)); + } + + [Fact] + public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() + { + Point point = new Point(Coordinate.Empty); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, linestring); + + Assert.True(double.IsNaN(distance)); + } + + [Fact] + public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEmpty() + { + Point point = new Point(new Coordinate(10.1, 20.1)); + MultiLineString multilinestring = new MultiLineString(); + + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, multilinestring); + + Assert.True(double.IsNaN(distance)); + } + + [Fact] + public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() + { + Point point = new Point(Coordinate.Empty); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); + + Mock calculatorM = new Mock(); + + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, multilinestring); + + Assert.True(double.IsNaN(distance)); + } + + [Fact] + public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() + { + LineString linestring = new LineString(); + + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); + + double length = target.ComputeLength(linestring); + + Assert.Equal(0, length); + } + + [Fact] + public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() + { + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1) }); + + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); + + double length = target.ComputeLength(linestring); + + Assert.Equal(0, length); + } + + [Fact] + public void ComputeLength_LineString_RetursSumOfSegmentsLengths() + { + Random generator = new Random(); + double segment1Length = generator.Next(100); + double segment2Length = generator.Next(100); + double sum = segment1Length + segment2Length; + + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); + + Measurements target = new Measurements(calculatorM.Object); + double length = target.ComputeLength(linestring); + + Assert.Equal(sum, length); + } + + [Fact] + public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMembers() + { + MultiLineString multilinestring = new MultiLineString(); + + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); + + double length = target.ComputeLength(multilinestring); + + Assert.Equal(0, length); + } + + [Fact] + public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() + { + Random generator = new Random(); + double segment1Length = generator.Next(100); + double segment2Length = generator.Next(100); + double sum = 2 * (segment1Length + segment2Length); + + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); + + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); + + Measurements target = new Measurements(calculatorM.Object); + double length = target.ComputeLength(multilinestring); + + Assert.Equal(sum, length); + } + + [Fact] + public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator() + { + Polygon polygon = new Polygon(new CoordinateList()); + Random generator = new Random(); + double expectedArea = generator.Next(100); + + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea); + Measurements target = new Measurements(calculatorM.Object); + + double area = target.ComputeArea(polygon); + + Assert.Equal(expectedArea, area); + } + + [Fact] + public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator() + { + // Create polygon with interior ring + Polygon polygon = new Polygon(new CoordinateList()); + polygon.InteriorRings.Add(new CoordinateList()); + + // Fixed test values + double exteriorArea = 50; + double interiorArea = 10; + double expectedArea = exteriorArea - interiorArea; + + // Setup mock + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateArea(It.IsAny())) + .Returns(coords => + { + if (coords == polygon.ExteriorRing) return exteriorArea; + if (coords == polygon.InteriorRings[0]) return interiorArea; + return 0; + }); + + // Create the object being tested + Measurements target = new Measurements(calculatorM.Object); + + // Execute the method being tested + double area = target.ComputeArea(polygon); + + // Verify the result + Assert.Equal(expectedArea, area); + } + + [Fact] + public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas() + { + Random generator = new Random(); + + Polygon polygon = new Polygon(new CoordinateList()); + double polygonArea = generator.Next(100); + MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon }); + + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea); + + Measurements target = new Measurements(calculatorM.Object); + + double area = target.ComputeArea(multipolygon); + + Assert.Equal(2 * polygonArea, area); + } + } +} diff --git a/src/Tests.SpatialLite.Core/PathHelper.cs b/src/Tests.SpatialLite.Core/PathHelper.cs index ae77de6..b7c8d09 100644 --- a/src/Tests.SpatialLite.Core/PathHelper.cs +++ b/src/Tests.SpatialLite.Core/PathHelper.cs @@ -1,23 +1,28 @@ -using System.IO; - -namespace Tests.SpatialLite.Core { - static class PathHelper { - private const string TempDirectoryName = "Temp"; - - private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); - public static string RealGpxFilePath => _realGpxFilePath; - - public static string GetTempFilePath(string filename) { - if (!Directory.Exists(TempDirectoryName)) { - Directory.CreateDirectory(TempDirectoryName); - } - - string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); - if (File.Exists(pbfFile)) { - File.Delete(pbfFile); - } - - return pbfFile; - } - } -} +using System.IO; + +namespace Tests.SpatialLite.Core +{ + static class PathHelper + { + private const string TempDirectoryName = "Temp"; + + private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); + public static string RealGpxFilePath => _realGpxFilePath; + + public static string GetTempFilePath(string filename) + { + if (!Directory.Exists(TempDirectoryName)) + { + Directory.CreateDirectory(TempDirectoryName); + } + + string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); + if (File.Exists(pbfFile)) + { + File.Delete(pbfFile); + } + + return pbfFile; + } + } +} diff --git a/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs b/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs index dea17a6..1a0da6c 100644 --- a/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs +++ b/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs @@ -1,19 +1,19 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tests.SpatialLite.Core")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f22d4fd4-c5de-4e97-87aa-fa5b85507ee6")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tests.SpatialLite.Core")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f22d4fd4-c5de-4e97-87aa-fa5b85507ee6")] diff --git a/src/Tests.SpatialLite.Core/TopologyTests.cs b/src/Tests.SpatialLite.Core/TopologyTests.cs index 83cde37..49ddfd5 100644 --- a/src/Tests.SpatialLite.Core/TopologyTests.cs +++ b/src/Tests.SpatialLite.Core/TopologyTests.cs @@ -1,22 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Core.Algorithms; - -using Xunit; -using Moq; - -namespace Tests.SpatialLite.Core { - public class TopologyTests { - - [Fact] - public void Euclidean2D_GetTopologyInstanceWithEuclidean2DLocator() { - Assert.IsType(Topology.Euclidean2D.GeometryLocator); - } - - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using SpatialLite.Core; +using SpatialLite.Core.API; +using SpatialLite.Core.Algorithms; + +using Xunit; +using Moq; + +namespace Tests.SpatialLite.Core +{ + public class TopologyTests + { + + [Fact] + public void Euclidean2D_GetTopologyInstanceWithEuclidean2DLocator() + { + Assert.IsType(Topology.Euclidean2D.GeometryLocator); + } + + } +} diff --git a/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs b/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs index 33c3022..9c7ec58 100644 --- a/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs +++ b/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs @@ -1,20 +1,24 @@ -using System.IO; -using System.Reflection; - -namespace Tests.SpatialLite.Gps.Data { - public static class TestDataReader { - public static Stream Open(string name) { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name); - } - - public static byte[] Read(string name) { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - - var stream = new MemoryStream(); - assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name).CopyTo(stream); - - return stream.ToArray(); - } - } -} +using System.IO; +using System.Reflection; + +namespace Tests.SpatialLite.Gps.Data +{ + public static class TestDataReader + { + public static Stream Open(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name); + } + + public static byte[] Read(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + + var stream = new MemoryStream(); + assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name).CopyTo(stream); + + return stream.ToArray(); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs index 2e29553..d11e9fc 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs @@ -1,55 +1,62 @@ -using System; - -using Xunit; - -using SpatialLite.Gps.Geometries; -using SpatialLite.Core.API; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpsPointTests { - - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - - Coordinate _coordinate; - - public GpsPointTests() { - _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); - } - - [Fact] - public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() { - var target = new GpsPoint(); - - Assert.Equal(Coordinate.Empty, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() { - var target = new GpsPoint(_coordinate); - - Assert.Equal(_coordinate, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() { - var timestamp = DateTime.Now; - var target = new GpsPoint(_coordinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } - - [Fact] - public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() { - var timestamp = DateTime.Now; - var target = new GpsPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } - } -} +using System; + +using Xunit; + +using SpatialLite.Gps.Geometries; +using SpatialLite.Core.API; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpsPointTests + { + + double _xOrdinate = 3.5; + double _yOrdinate = 4.2; + double _zOrdinate = 10.5; + + Coordinate _coordinate; + + public GpsPointTests() + { + _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); + } + + [Fact] + public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() + { + var target = new GpsPoint(); + + Assert.Equal(Coordinate.Empty, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() + { + var target = new GpsPoint(_coordinate); + + Assert.Equal(_coordinate, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() + { + var timestamp = DateTime.Now; + var target = new GpsPoint(_coordinate, timestamp); + + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); + } + + [Fact] + public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() + { + var timestamp = DateTime.Now; + var target = new GpsPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); + + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs index 3fc778d..ec3735b 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs @@ -1,59 +1,69 @@ -using System; -using System.Collections.Generic; - -using Xunit; -using SpatialLite.Gps.Geometries; -using SpatialLite.Core.Geometries; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpsTrackBaseTests { - List _points; - - public GpsTrackBaseTests() { - _points = new List { - new GpsPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), - new GpsPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), - new GpsPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - - } - - [Fact] - public void Constructor__CreatesEmptyGpsTrack() { - GpsTrackBase target = new GpsTrackBase(); - - Assert.Equal(0 ,target.Coordinates.Count); - } - - [Fact] - public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() { - - GpsTrackBase target = new GpsTrackBase(_points); - - Assert.Equal(_points.Count, target.Points.Count); - for (int i = 0; i < target.Points.Count; i++) { - Assert.Same(_points[i], target.Points[i]); - } - } - - [Fact] - public void Coordinates_GetsPositionOfPoints() { - GpsTrackBase target = new GpsTrackBase(_points); - - Assert.Equal(_points.Count, target.Coordinates.Count); - for (int i = 0; i < _points.Count; i++) { - Assert.Equal(_points[i].Position, target.Coordinates[i]); - } - } - - [Fact] - public void Coordinates_GetsPositionOfPointsIfWayCastedToLineString() { - GpsTrackBase line = new GpsTrackBase(_points); - LineString target = (LineString)line; - - Assert.Equal(_points.Count, target.Coordinates.Count); - for (int i = 0; i < _points.Count; i++) { - Assert.Equal(_points[i].Position, target.Coordinates[i]); - } - } - } -} +using System; +using System.Collections.Generic; + +using Xunit; +using SpatialLite.Gps.Geometries; +using SpatialLite.Core.Geometries; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpsTrackBaseTests + { + List _points; + + public GpsTrackBaseTests() + { + _points = new List { + new GpsPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), + new GpsPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), + new GpsPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; + + } + + [Fact] + public void Constructor__CreatesEmptyGpsTrack() + { + GpsTrackBase target = new GpsTrackBase(); + + Assert.Equal(0, target.Coordinates.Count); + } + + [Fact] + public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() + { + + GpsTrackBase target = new GpsTrackBase(_points); + + Assert.Equal(_points.Count, target.Points.Count); + for (int i = 0; i < target.Points.Count; i++) + { + Assert.Same(_points[i], target.Points[i]); + } + } + + [Fact] + public void Coordinates_GetsPositionOfPoints() + { + GpsTrackBase target = new GpsTrackBase(_points); + + Assert.Equal(_points.Count, target.Coordinates.Count); + for (int i = 0; i < _points.Count; i++) + { + Assert.Equal(_points[i].Position, target.Coordinates[i]); + } + } + + [Fact] + public void Coordinates_GetsPositionOfPointsIfWayCastedToLineString() + { + GpsTrackBase line = new GpsTrackBase(_points); + LineString target = (LineString)line; + + Assert.Equal(_points.Count, target.Coordinates.Count); + for (int i = 0; i < _points.Count; i++) + { + Assert.Equal(_points[i].Position, target.Coordinates[i]); + } + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs index 0119d04..23584b3 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs @@ -1,41 +1,48 @@ -using System.Collections.Generic; -using SpatialLite.Gps.Geometries; -using Xunit; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpxFixHelperTests { - public static IEnumerable GpsFixes { - get { - yield return new object[] { GpsFix.Dgps, "dgps" }; - yield return new object[] { GpsFix.Fix2D, "2d" }; - yield return new object[] { GpsFix.Fix3D, "3d" }; - yield return new object[] { GpsFix.None, "none" }; - yield return new object[] { GpsFix.Pps, "pps" }; - } - } - - [Theory] - [MemberData(nameof(GpsFixes))] - public void ParseGpsFix_ValidGpsFixes_ParsesStringValue(GpsFix expectedValue, string s) { - GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(s); - - Assert.Equal(expectedValue, parsedValue); - } - - [Fact] - public void ParseGpsFix_InvalidValue_ReturnsNull() { - string invalidValue = "some other string"; - GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(invalidValue); - - Assert.Null(parsedValue); - } - - [Theory] - [MemberData(nameof(GpsFixes))] - public void GpsFixToString_GpsFixes_ConvertsToStringEquivalents(GpsFix fix, string expectedValue) { - string strValue = GpxFixHelper.GpsFixToString(fix); - - Assert.Equal(expectedValue, strValue); - } - } -} +using System.Collections.Generic; +using SpatialLite.Gps.Geometries; +using Xunit; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpxFixHelperTests + { + public static IEnumerable GpsFixes + { + get + { + yield return new object[] { GpsFix.Dgps, "dgps" }; + yield return new object[] { GpsFix.Fix2D, "2d" }; + yield return new object[] { GpsFix.Fix3D, "3d" }; + yield return new object[] { GpsFix.None, "none" }; + yield return new object[] { GpsFix.Pps, "pps" }; + } + } + + [Theory] + [MemberData(nameof(GpsFixes))] + public void ParseGpsFix_ValidGpsFixes_ParsesStringValue(GpsFix expectedValue, string s) + { + GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(s); + + Assert.Equal(expectedValue, parsedValue); + } + + [Fact] + public void ParseGpsFix_InvalidValue_ReturnsNull() + { + string invalidValue = "some other string"; + GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(invalidValue); + + Assert.Null(parsedValue); + } + + [Theory] + [MemberData(nameof(GpsFixes))] + public void GpsFixToString_GpsFixes_ConvertsToStringEquivalents(GpsFix fix, string expectedValue) + { + string strValue = GpxFixHelper.GpsFixToString(fix); + + Assert.Equal(expectedValue, strValue); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs index 9c59ed3..408cf53 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs @@ -1,17 +1,20 @@ -using System; -using Xunit; -using SpatialLite.Gps.Geometries; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpxLinkTests { - - [Fact] - public void Constructor_Url_SetsUrl() { - Uri url = new Uri("http://spatial.litesolutions.net"); - - GpxLink target = new GpxLink(url); - - Assert.Same(url, target.Url); - } - } -} +using System; +using Xunit; +using SpatialLite.Gps.Geometries; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpxLinkTests + { + + [Fact] + public void Constructor_Url_SetsUrl() + { + Uri url = new Uri("http://spatial.litesolutions.net"); + + GpxLink target = new GpxLink(url); + + Assert.Same(url, target.Url); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs index a17b544..23e0028 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs @@ -1,18 +1,22 @@ -using Xunit; - -using SpatialLite.Gps.Geometries; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpxMetadataTests { - - [Fact] - public void Constructor_CreatesMetadataWithEmptyCollectionOfLinks() { - GpxMetadata target = new GpxMetadataWrapper(); - - Assert.Empty(target.Links); - } - } - - public class GpxMetadataWrapper : GpxMetadata { - } -} +using Xunit; + +using SpatialLite.Gps.Geometries; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpxMetadataTests + { + + [Fact] + public void Constructor_CreatesMetadataWithEmptyCollectionOfLinks() + { + GpxMetadata target = new GpxMetadataWrapper(); + + Assert.Empty(target.Links); + } + } + + public class GpxMetadataWrapper : GpxMetadata + { + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs index ea8035f..608efd7 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs @@ -1,62 +1,70 @@ -using System; - -using Xunit; - -using SpatialLite.Gps.Geometries; -using SpatialLite.Core.API; -using SpatialLite.Gps; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpxPointTests { - - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - - Coordinate _coordinate; - public GpxPointTests() { - _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); - } - - [Fact] - public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() { - var target = new GpsPoint(); - - Assert.Equal(Coordinate.Empty, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() { - var target = new GpxPoint(_coordinate); - - Assert.Equal(_coordinate, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() { - var timestamp = DateTime.Now; - var target = new GpxPoint(_coordinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } - - [Fact] - public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() { - var timestamp = DateTime.Now; - var target = new GpxPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } - - [Fact] - public void GeometryType_ReturnsWaypoint() { - GpxPoint target = new GpxPoint(); - - Assert.Equal(GpxGeometryType.Waypoint, target.GeometryType); - } - } -} +using System; + +using Xunit; + +using SpatialLite.Gps.Geometries; +using SpatialLite.Core.API; +using SpatialLite.Gps; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpxPointTests + { + + double _xOrdinate = 3.5; + double _yOrdinate = 4.2; + double _zOrdinate = 10.5; + + Coordinate _coordinate; + public GpxPointTests() + { + _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); + } + + [Fact] + public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() + { + var target = new GpsPoint(); + + Assert.Equal(Coordinate.Empty, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() + { + var target = new GpxPoint(_coordinate); + + Assert.Equal(_coordinate, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() + { + var timestamp = DateTime.Now; + var target = new GpxPoint(_coordinate, timestamp); + + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); + } + + [Fact] + public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() + { + var timestamp = DateTime.Now; + var target = new GpxPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); + + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); + } + + [Fact] + public void GeometryType_ReturnsWaypoint() + { + GpxPoint target = new GpxPoint(); + + Assert.Equal(GpxGeometryType.Waypoint, target.GeometryType); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs index 2a26294..0f30eee 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs @@ -1,38 +1,44 @@ -using System; -using System.Collections.Generic; -using SpatialLite.Gps; -using SpatialLite.Gps.Geometries; -using Xunit; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpxRouteTests { - [Fact] - public void Constructor_Parameterless_CreatesEmptyRoute() { - GpxRoute target = new GpxRoute(); - - Assert.Empty(target.Points); - } - - [Fact] - public void Constructor_IEnumerablePoints_CreatesRouteWithPoints() { - List points = new List { - new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), - new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), - new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - - GpxRoute target = new GpxRoute(points); - - Assert.Equal(points.Count, target.Points.Count); - for (int i = 0; i < target.Points.Count; i++) { - Assert.Same(points[i], target.Points[i]); - } - } - - [Fact] - public void GeometryType_ReturnsRoute() { - GpxRoute target = new GpxRoute(); - - Assert.Equal(GpxGeometryType.Route, target.GeometryType); - } - } -} +using System; +using System.Collections.Generic; +using SpatialLite.Gps; +using SpatialLite.Gps.Geometries; +using Xunit; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpxRouteTests + { + [Fact] + public void Constructor_Parameterless_CreatesEmptyRoute() + { + GpxRoute target = new GpxRoute(); + + Assert.Empty(target.Points); + } + + [Fact] + public void Constructor_IEnumerablePoints_CreatesRouteWithPoints() + { + List points = new List { + new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), + new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), + new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; + + GpxRoute target = new GpxRoute(points); + + Assert.Equal(points.Count, target.Points.Count); + for (int i = 0; i < target.Points.Count; i++) + { + Assert.Same(points[i], target.Points[i]); + } + } + + [Fact] + public void GeometryType_ReturnsRoute() + { + GpxRoute target = new GpxRoute(); + + Assert.Equal(GpxGeometryType.Route, target.GeometryType); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs index a1413f0..54a661b 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs @@ -1,30 +1,35 @@ -using System; -using System.Collections.Generic; -using SpatialLite.Gps.Geometries; -using Xunit; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpxTrackSegmentTests { - [Fact] - public void Constructor_CreatesEmptyGpsTrack() { - GpxTrackSegment target = new GpxTrackSegment(); - - Assert.Empty(target.Points); - } - - [Fact] - public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() { - List points = new List { - new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), - new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), - new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - - GpxTrackSegment target = new GpxTrackSegment(points); - - Assert.Equal(points.Count, target.Points.Count); - for (int i = 0; i < target.Points.Count; i++) { - Assert.Same(points[i], target.Points[i]); - } - } - } -} +using System; +using System.Collections.Generic; +using SpatialLite.Gps.Geometries; +using Xunit; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpxTrackSegmentTests + { + [Fact] + public void Constructor_CreatesEmptyGpsTrack() + { + GpxTrackSegment target = new GpxTrackSegment(); + + Assert.Empty(target.Points); + } + + [Fact] + public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() + { + List points = new List { + new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), + new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), + new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; + + GpxTrackSegment target = new GpxTrackSegment(points); + + Assert.Equal(points.Count, target.Points.Count); + for (int i = 0; i < target.Points.Count; i++) + { + Assert.Same(points[i], target.Points[i]); + } + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs index 47d9cf3..23bbbb5 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs @@ -1,33 +1,39 @@ -using SpatialLite.Gps; -using SpatialLite.Gps.Geometries; -using Xunit; - -namespace Tests.SpatialLite.Gps.Geometries { - public class GpxTrackTests { - [Fact] - public void Constructor_Parameterless_CreateEmptyGpxTrack() { - GpxTrack target = new GpxTrack(); - - Assert.Empty(target.Geometries); - } - - [Fact] - public void Constructor_Segments_CreateGpxTrackWithSegments() { - GpxTrackSegment[] segments = new GpxTrackSegment[] { new GpxTrackSegment(), new GpxTrackSegment(), new GpxTrackSegment() }; - - GpxTrack target = new GpxTrack(segments); - - Assert.Equal(segments.Length, target.Geometries.Count); - for (int i = 0; i < target.Geometries.Count; i++) { - Assert.Same(segments[i], target.Geometries[i]); - } - } - - [Fact] - public void GeometryType_ReturnsTrack() { - GpxTrack target = new GpxTrack(); - - Assert.Equal(GpxGeometryType.Track, target.GeometryType); - } - } -} +using SpatialLite.Gps; +using SpatialLite.Gps.Geometries; +using Xunit; + +namespace Tests.SpatialLite.Gps.Geometries +{ + public class GpxTrackTests + { + [Fact] + public void Constructor_Parameterless_CreateEmptyGpxTrack() + { + GpxTrack target = new GpxTrack(); + + Assert.Empty(target.Geometries); + } + + [Fact] + public void Constructor_Segments_CreateGpxTrackWithSegments() + { + GpxTrackSegment[] segments = new GpxTrackSegment[] { new GpxTrackSegment(), new GpxTrackSegment(), new GpxTrackSegment() }; + + GpxTrack target = new GpxTrack(segments); + + Assert.Equal(segments.Length, target.Geometries.Count); + for (int i = 0; i < target.Geometries.Count; i++) + { + Assert.Same(segments[i], target.Geometries[i]); + } + } + + [Fact] + public void GeometryType_ReturnsTrack() + { + GpxTrack target = new GpxTrack(); + + Assert.Equal(GpxGeometryType.Track, target.GeometryType); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs index 9760fd8..debfa2d 100644 --- a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs +++ b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs @@ -1,153 +1,170 @@ -using System; -using System.Collections.Generic; - -using Xunit; - -using SpatialLite.Gps.IO; -using SpatialLite.Gps; -using SpatialLite.Gps.Geometries; -using System.IO; -using System.Xml.Linq; -using Moq; -using Tests.SpatialLite.Gps.Data; - -namespace Tests.SpatialLite.Gps { - public class GpxDocumentTests { - [Fact] - public void Constructor_CreatesEmptyDocument() { - var target = new GpxDocument(); - - Assert.Empty(target.Waypoints); - Assert.Empty(target.Routes); - Assert.Empty(target.Tracks); - } - - [Fact] - public void Constructor_WaypointsRoutesTracks_CreatesDocumentWithGpxEntities() { - IEnumerable waypoints = new[] { new GpxPoint() }; - IEnumerable routes = new[] { new GpxRoute() }; - IEnumerable tracks = new[] { new GpxTrack() }; - - var target = new GpxDocument(waypoints, routes, tracks); - - Assert.Equal(waypoints, target.Waypoints); - Assert.Equal(routes, target.Routes); - Assert.Equal(tracks, target.Tracks); - } - - [Fact] - public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfWaypointsIsNull() { - IEnumerable routes = new[] { new GpxRoute() }; - IEnumerable tracks = new[] { new GpxTrack() }; - - Assert.Throws(() => new GpxDocument(null, routes, tracks)); - } - - [Fact] - public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfRoutesIsNull() { - IEnumerable waypoints = new[] { new GpxPoint() }; - IEnumerable tracks = new[] { new GpxTrack() }; - - Assert.Throws(() => new GpxDocument(waypoints, null, tracks)); - } - - [Fact] - public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfTracksIsNull() { - IEnumerable waypoints = new[] { new GpxPoint() }; - IEnumerable routes = new[] { new GpxRoute() }; - - Assert.Throws(() => new GpxDocument(waypoints, routes, null)); - } - - [Fact] - public void Load_IGpxReader_ThrowsExceptionIfReaderIsNull() { - IGpxReader reader = null; - - Assert.Throws(() => GpxDocument.Load(reader)); - } - - [Fact] - public void Load_IGpxReader_LoadsEntitiesFromReader() { - using (var reader = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), new GpxReaderSettings() { ReadMetadata = true })) { - var target = GpxDocument.Load(reader); - - Assert.Equal(3, target.Waypoints.Count); - Assert.Equal(2, target.Routes.Count); - Assert.Single(target.Tracks); - } - } - - [Fact] - public void Load_string_ThrowsExceptionIfPathIsNull() { - string path = null; - - Assert.Throws(() => GpxDocument.Load(path)); - } - - [Fact] - public void Load_string_ThrowsExceptionIfFileDoesntExists() { - string path = "non-existing-file.gpx"; - - Assert.Throws(() => GpxDocument.Load(path)); - } - - [Fact] - public void Load_LoadsGpxEntitiesFromFile() { - string path = "../../../Data/Gpx/gpx-real-file.gpx"; - - var target = GpxDocument.Load(path); - - Assert.Equal(3, target.Waypoints.Count); - Assert.Equal(2, target.Routes.Count); - Assert.Single(target.Tracks); - } - - [Fact] - public void Save_IGpxWriter_ThrowsExceptionIfWriterIsNull() { - IGpxWriter writer = null; - - var target = new GpxDocument(); - Assert.Throws(() => target.Save(writer)); - } - - [Fact] - public void Save_IGpxWriter_WritesDataToWriter() { - var waypoint = new GpxPoint(); - var route = new GpxRoute(); - var track = new GpxTrack(); - - Mock writerM = new Mock(); - writerM.Setup(w => w.Write(waypoint)).Verifiable(); - writerM.Setup(w => w.Write(route)).Verifiable(); - writerM.Setup(w => w.Write(track)).Verifiable(); - - var target = new GpxDocument(new[] { waypoint }, new[] { route }, new[] { track }); - target.Save(writerM.Object); - - writerM.Verify(w => w.Write(waypoint), Times.Once()); - writerM.Verify(w => w.Write(route), Times.Once()); - writerM.Verify(w => w.Write(track), Times.Once()); - } - - [Fact] - public void Save_ThrowsExceptionIfPathIsNull() { - string path = null; - var target = new GpxDocument(); - - Assert.Throws(() => target.Save(path)); - } - - [Fact] - public void Save_SavesDataToFile() { - string path = PathHelper.GetTempFilePath("gpxdocument-save-test.gpx"); - - var target = GpxDocument.Load(PathHelper.RealGpxFilePath); - target.Save(path); - - var original = XDocument.Load(PathHelper.RealGpxFilePath); - var saved = XDocument.Load(path); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(original, saved)); - } - } -} +using System; +using System.Collections.Generic; + +using Xunit; + +using SpatialLite.Gps.IO; +using SpatialLite.Gps; +using SpatialLite.Gps.Geometries; +using System.IO; +using System.Xml.Linq; +using Moq; +using Tests.SpatialLite.Gps.Data; + +namespace Tests.SpatialLite.Gps +{ + public class GpxDocumentTests + { + [Fact] + public void Constructor_CreatesEmptyDocument() + { + var target = new GpxDocument(); + + Assert.Empty(target.Waypoints); + Assert.Empty(target.Routes); + Assert.Empty(target.Tracks); + } + + [Fact] + public void Constructor_WaypointsRoutesTracks_CreatesDocumentWithGpxEntities() + { + IEnumerable waypoints = new[] { new GpxPoint() }; + IEnumerable routes = new[] { new GpxRoute() }; + IEnumerable tracks = new[] { new GpxTrack() }; + + var target = new GpxDocument(waypoints, routes, tracks); + + Assert.Equal(waypoints, target.Waypoints); + Assert.Equal(routes, target.Routes); + Assert.Equal(tracks, target.Tracks); + } + + [Fact] + public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfWaypointsIsNull() + { + IEnumerable routes = new[] { new GpxRoute() }; + IEnumerable tracks = new[] { new GpxTrack() }; + + Assert.Throws(() => new GpxDocument(null, routes, tracks)); + } + + [Fact] + public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfRoutesIsNull() + { + IEnumerable waypoints = new[] { new GpxPoint() }; + IEnumerable tracks = new[] { new GpxTrack() }; + + Assert.Throws(() => new GpxDocument(waypoints, null, tracks)); + } + + [Fact] + public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfTracksIsNull() + { + IEnumerable waypoints = new[] { new GpxPoint() }; + IEnumerable routes = new[] { new GpxRoute() }; + + Assert.Throws(() => new GpxDocument(waypoints, routes, null)); + } + + [Fact] + public void Load_IGpxReader_ThrowsExceptionIfReaderIsNull() + { + IGpxReader reader = null; + + Assert.Throws(() => GpxDocument.Load(reader)); + } + + [Fact] + public void Load_IGpxReader_LoadsEntitiesFromReader() + { + using (var reader = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), new GpxReaderSettings() { ReadMetadata = true })) + { + var target = GpxDocument.Load(reader); + + Assert.Equal(3, target.Waypoints.Count); + Assert.Equal(2, target.Routes.Count); + Assert.Single(target.Tracks); + } + } + + [Fact] + public void Load_string_ThrowsExceptionIfPathIsNull() + { + string path = null; + + Assert.Throws(() => GpxDocument.Load(path)); + } + + [Fact] + public void Load_string_ThrowsExceptionIfFileDoesntExists() + { + string path = "non-existing-file.gpx"; + + Assert.Throws(() => GpxDocument.Load(path)); + } + + [Fact] + public void Load_LoadsGpxEntitiesFromFile() + { + string path = "../../../Data/Gpx/gpx-real-file.gpx"; + + var target = GpxDocument.Load(path); + + Assert.Equal(3, target.Waypoints.Count); + Assert.Equal(2, target.Routes.Count); + Assert.Single(target.Tracks); + } + + [Fact] + public void Save_IGpxWriter_ThrowsExceptionIfWriterIsNull() + { + IGpxWriter writer = null; + + var target = new GpxDocument(); + Assert.Throws(() => target.Save(writer)); + } + + [Fact] + public void Save_IGpxWriter_WritesDataToWriter() + { + var waypoint = new GpxPoint(); + var route = new GpxRoute(); + var track = new GpxTrack(); + + Mock writerM = new Mock(); + writerM.Setup(w => w.Write(waypoint)).Verifiable(); + writerM.Setup(w => w.Write(route)).Verifiable(); + writerM.Setup(w => w.Write(track)).Verifiable(); + + var target = new GpxDocument(new[] { waypoint }, new[] { route }, new[] { track }); + target.Save(writerM.Object); + + writerM.Verify(w => w.Write(waypoint), Times.Once()); + writerM.Verify(w => w.Write(route), Times.Once()); + writerM.Verify(w => w.Write(track), Times.Once()); + } + + [Fact] + public void Save_ThrowsExceptionIfPathIsNull() + { + string path = null; + var target = new GpxDocument(); + + Assert.Throws(() => target.Save(path)); + } + + [Fact] + public void Save_SavesDataToFile() + { + string path = PathHelper.GetTempFilePath("gpxdocument-save-test.gpx"); + + var target = GpxDocument.Load(PathHelper.RealGpxFilePath); + target.Save(path); + + var original = XDocument.Load(PathHelper.RealGpxFilePath); + var saved = XDocument.Load(path); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(original, saved)); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs index 67065ea..ee9c418 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs @@ -1,23 +1,27 @@ -using System; -using SpatialLite.Gps.IO; -using Xunit; - -namespace Tests.SpatialLite.Gps.IO { - public class GpxReaderSettingsTests { - - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() { - var target = new GpxReaderSettings(); - - Assert.True(target.ReadMetadata); - } - - [Fact] - public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - var target = new GpxReaderSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.ReadMetadata = true); - } - } -} +using System; +using SpatialLite.Gps.IO; +using Xunit; + +namespace Tests.SpatialLite.Gps.IO +{ + public class GpxReaderSettingsTests + { + + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() + { + var target = new GpxReaderSettings(); + + Assert.True(target.ReadMetadata); + } + + [Fact] + public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + var target = new GpxReaderSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.ReadMetadata = true); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs index 50e6717..3dd0284 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs @@ -1,409 +1,445 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using SpatialLite.Core.API; -using SpatialLite.Gps; -using SpatialLite.Gps.Geometries; -using SpatialLite.Gps.IO; -using Xunit; -using Tests.SpatialLite.Gps.Data; - -namespace Tests.SpatialLite.Gps.IO { - public class GpxReaderTests { - - [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() { - Assert.Throws(delegate { new GpxReader("non-existing-file.gpx", new GpxReaderSettings() { ReadMetadata = false }); }); - } - - [Fact] - public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() { - string path = "../../../Data/Gpx/gpx-real-file.gpx"; - var settings = new GpxReaderSettings() { ReadMetadata = false }; - using (var target = new GpxReader(path, settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() { - var settings = new GpxReaderSettings() { ReadMetadata = false }; - using (var target = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_StreamSettings_ThrowsExceptionIfVersionIsnt10or11() { - Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-version-2_0.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); - } - - [Fact] - public void Constructor_StreamSettings_ThrowsExceptionXmlContainsInvalidRootElement() { - Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-invalid-root-element.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); - } - - [Fact] - public void Read_ThrowsExceptionIfWaypointHasntLat() { - GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lat.gpx"), new GpxReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ThrowsExceptionIfWaypointHasntLon() { - GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lon.gpx"), new GpxReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_SetsMetadataIfReadMetadataIsTrue() { - var data = TestDataReader.Open("gpx-waypoint-simple.gpx"); - var expectedCoordinate = new Coordinate(-71.119277, 42.438878); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxPoint; - - Assert.NotNull(result.Metadata); - } - - [Fact] - public void Read_DoesntSetMetadataIfReadMetadataIsFalse() { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - var expectedCoordinate = new Coordinate(-71.119277, 42.438878); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxPoint; - - Assert.Null(result.Metadata); - } - - [Fact] - public void Read_ParsesWaypointWithLatLonElevationAndTime() { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); - DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxPoint; - - Assert.Equal(result.Position, expectedCoordinate); - Assert.Equal(result.Timestamp, expectedTime); - } - - [Fact] - public void Read_ParsesWaypointWithExtensions() { - var data = TestDataReader.Open("gpx-waypoint-extensions.gpx"); - Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); - DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxPoint; - - Assert.Equal(result.Position, expectedCoordinate); - Assert.Equal(result.Timestamp, expectedTime); - } - - [Fact] - public void Read_ParsesMultipleWaypoints() { - var data = TestDataReader.Open("gpx-waypoint-multiple.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - GpxPoint result = null; - - int count = 0; - while ((result = target.Read() as GpxPoint) != null) { - count++; - } - - Assert.Equal(3, count); - } - - [Fact] - public void Read_ReadsWaypointMetadata() { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxPoint; - - Assert.Equal(0.98, result.Metadata.MagVar); - Assert.Equal(12.5, result.Metadata.GeoidHeight); - Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); - Assert.Equal(8, result.Metadata.SatellitesCount); - Assert.Equal(5.1, result.Metadata.Hdop); - Assert.Equal(8.1, result.Metadata.Vdop); - Assert.Equal(10.8, result.Metadata.Pdop); - Assert.Equal(45, result.Metadata.AgeOfDgpsData); - Assert.Equal(124, result.Metadata.DgpsId); - - Assert.Equal("WPT Comment", result.Metadata.Comment); - Assert.Equal("WPT Description", result.Metadata.Description); - Assert.Equal("WPT Name", result.Metadata.Name); - Assert.Equal("WPT Source", result.Metadata.Source); - - Assert.Equal(1, result.Metadata.Links.Count); - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } - - [Fact] - public void Read_ReadsWaypointUnsortedMetadataAndExtension() { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxPoint; - - Assert.Equal(0.98, result.Metadata.MagVar); - Assert.Equal(12.5, result.Metadata.GeoidHeight); - Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); - Assert.Equal(8, result.Metadata.SatellitesCount); - Assert.Equal(5.1, result.Metadata.Hdop); - Assert.Equal(8.1, result.Metadata.Vdop); - Assert.Equal(10.8, result.Metadata.Pdop); - Assert.Equal(45, result.Metadata.AgeOfDgpsData); - Assert.Equal(124, result.Metadata.DgpsId); - - Assert.Equal("WPT Comment", result.Metadata.Comment); - Assert.Equal("WPT Description", result.Metadata.Description); - Assert.Equal("WPT Name", result.Metadata.Name); - Assert.Equal("WPT Source", result.Metadata.Source); - - Assert.Equal(1, result.Metadata.Links.Count); - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } - - [Fact] - public void Read_ParsesTrackWithSingleSegment() { - var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; - - Assert.Single(result.Geometries); - - GpxTrackSegment segment = result.Geometries[0]; - Assert.Equal(new Coordinate(-76.638178825, 39.449270368), segment.Points[0].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), segment.Points[0].Timestamp); - Assert.Equal(new Coordinate(-76.638012528, 39.449130893), segment.Points[1].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), segment.Points[1].Timestamp); - Assert.Equal(new Coordinate(-76.637980342, 39.449098706), segment.Points[2].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), segment.Points[2].Timestamp); - } - - [Fact] - public void Read_ParsesTrackWithSingleSegmentAndExtensions() { - var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; - - Assert.Single(result.Geometries); - - GpxTrackSegment segment = result.Geometries[0]; - } - - [Fact] - public void Read_ParsesTrackWithMultipleSegments() { - var data = TestDataReader.Open("gpx-track-2-track-segments.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; - - //segments - Assert.Equal(2, result.Geometries.Count); - //points in segments - Assert.Equal(3, result.Geometries[0].Points.Count); - Assert.Equal(2, result.Geometries[1].Points.Count); - } - - [Fact] - public void Read_ParsesMultipleTracks() { - var data = TestDataReader.Open("gpx-track-multiple-tracks.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result1 = target.Read() as GpxTrack; - var result2 = target.Read() as GpxTrack; - - //segments - first track - Assert.Equal(2, result1.Geometries.Count); - //points in segments - first track - Assert.Equal(3, result1.Geometries[0].Points.Count); - Assert.Equal(2, result1.Geometries[1].Points.Count); - - //segments - second track - Assert.Single(result2.Geometries); - //points in segments - second track - Assert.Equal(2, result2.Geometries[0].Points.Count); - } - - [Fact] - public void Read_ParsesEmptyTrack() { - var data = TestDataReader.Open("gpx-track-empty.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; - - Assert.Empty(result.Geometries); - } - - [Fact] - public void Read_ParsesTrackWithEmptySegment() { - var data = TestDataReader.Open("gpx-track-empty-track-segment.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; - - Assert.Single(result.Geometries); - Assert.Empty(result.Geometries[0].Points); - } - - [Fact] - public void Read_ParsesTrackMetadata() { - var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxTrack; - - Assert.Equal("TRK Comment", result.Metadata.Comment); - Assert.Equal("TRK Description", result.Metadata.Description); - Assert.Equal("TRK Name", result.Metadata.Name); - Assert.Equal("TRK Source", result.Metadata.Source); - Assert.Equal("TRK Type", result.Metadata.Type); - - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } - - [Fact] - public void Read_SetsTrackMetadataToNullIfReadMetadataIsFalse() { - var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; - - Assert.Null(result.Metadata); - } - - [Fact] - public void Read_ParsesEmptyRoute() { - var data = TestDataReader.Open("gpx-route-empty.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() {ReadMetadata = false}); - - var result = target.Read() as GpxRoute; - - Assert.Empty(result.Points); - } - - [Fact] - public void Read_ParsesSingleRoute() { - var data = TestDataReader.Open("gpx-route-single-route.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - - var result = target.Read() as GpxRoute; - - Assert.Equal(new Coordinate(-76.638178825, 39.449270368), result.Points[0].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), result.Points[0].Timestamp); - Assert.Equal(new Coordinate(-76.638012528, 39.449130893), result.Points[1].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), result.Points[1].Timestamp); - Assert.Equal(new Coordinate(-76.637980342, 39.449098706), result.Points[2].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), result.Points[2].Timestamp); - } - - [Fact] - public void Read_ParsesSingleRouteWithExtensions() { - var data = TestDataReader.Open("gpx-route-with-metadata-and-extensions.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - - var result = target.Read() as GpxRoute; - - Assert.Equal(3, result.Points.Count); - } - - [Fact] - public void Read_ParsesMultipleRoutes() { - var data = TestDataReader.Open("gpx-route-multiple-routes.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - - var result1 = target.Read() as GpxRoute; - var result2 = target.Read() as GpxRoute; - - Assert.Equal(3, result1.Points.Count); - Assert.Equal(2, result2.Points.Count); - } - - [Fact] - public void Read_ParsesRouteWithMetadata() { - var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - - var result = target.Read() as GpxRoute; - - Assert.Equal("RTE Comment", result.Metadata.Comment); - Assert.Equal("RTE Description", result.Metadata.Description); - Assert.Equal("RTE Name", result.Metadata.Name); - Assert.Equal("RTE Source", result.Metadata.Source); - Assert.Equal("RTE Type", result.Metadata.Type); - - Assert.Equal(1, result.Metadata.Links.Count); - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } - - [Fact] - public void Read_SetsRouteMetadataToNullIfReadMetadataIsFalse() { - var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - - var result = target.Read() as GpxRoute; - - Assert.Null(result.Metadata); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = "../../../Data/Gpx/gpx-real-file.gpx"; - - var target = new GpxReader(filename, new GpxReaderSettings() { ReadMetadata = false }); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } - - [Fact] - public void Read_ReadsAllEntitiesFromRealGpxFile() { - var data = TestDataReader.Open("gpx-real-file.gpx"); - List parsed = new List(); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - - IGpxGeometry geometry = null; - while ((geometry = target.Read()) != null) { - parsed.Add(geometry); - } - - // waypoints - Assert.Equal(3, parsed.Where(g => g.GeometryType == GpxGeometryType.Waypoint).Count()); - - // routes - Assert.Equal(2, parsed.Where(g => g.GeometryType == GpxGeometryType.Route).Count()); - - // tracks - Assert.Single(parsed.Where(g => g.GeometryType == GpxGeometryType.Track)); - } - } -} +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using SpatialLite.Core.API; +using SpatialLite.Gps; +using SpatialLite.Gps.Geometries; +using SpatialLite.Gps.IO; +using Xunit; +using Tests.SpatialLite.Gps.Data; + +namespace Tests.SpatialLite.Gps.IO +{ + public class GpxReaderTests + { + + [Fact] + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() + { + Assert.Throws(delegate { new GpxReader("non-existing-file.gpx", new GpxReaderSettings() { ReadMetadata = false }); }); + } + + [Fact] + public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() + { + string path = "../../../Data/Gpx/gpx-real-file.gpx"; + var settings = new GpxReaderSettings() { ReadMetadata = false }; + using (var target = new GpxReader(path, settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() + { + var settings = new GpxReaderSettings() { ReadMetadata = false }; + using (var target = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_StreamSettings_ThrowsExceptionIfVersionIsnt10or11() + { + Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-version-2_0.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); + } + + [Fact] + public void Constructor_StreamSettings_ThrowsExceptionXmlContainsInvalidRootElement() + { + Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-invalid-root-element.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); + } + + [Fact] + public void Read_ThrowsExceptionIfWaypointHasntLat() + { + GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lat.gpx"), new GpxReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ThrowsExceptionIfWaypointHasntLon() + { + GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lon.gpx"), new GpxReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_SetsMetadataIfReadMetadataIsTrue() + { + var data = TestDataReader.Open("gpx-waypoint-simple.gpx"); + var expectedCoordinate = new Coordinate(-71.119277, 42.438878); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxPoint; + + Assert.NotNull(result.Metadata); + } + + [Fact] + public void Read_DoesntSetMetadataIfReadMetadataIsFalse() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + var expectedCoordinate = new Coordinate(-71.119277, 42.438878); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxPoint; + + Assert.Null(result.Metadata); + } + + [Fact] + public void Read_ParsesWaypointWithLatLonElevationAndTime() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); + DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxPoint; + + Assert.Equal(result.Position, expectedCoordinate); + Assert.Equal(result.Timestamp, expectedTime); + } + + [Fact] + public void Read_ParsesWaypointWithExtensions() + { + var data = TestDataReader.Open("gpx-waypoint-extensions.gpx"); + Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); + DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxPoint; + + Assert.Equal(result.Position, expectedCoordinate); + Assert.Equal(result.Timestamp, expectedTime); + } + + [Fact] + public void Read_ParsesMultipleWaypoints() + { + var data = TestDataReader.Open("gpx-waypoint-multiple.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxPoint result = null; + + int count = 0; + while ((result = target.Read() as GpxPoint) != null) + { + count++; + } + + Assert.Equal(3, count); + } + + [Fact] + public void Read_ReadsWaypointMetadata() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxPoint; + + Assert.Equal(0.98, result.Metadata.MagVar); + Assert.Equal(12.5, result.Metadata.GeoidHeight); + Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); + Assert.Equal(8, result.Metadata.SatellitesCount); + Assert.Equal(5.1, result.Metadata.Hdop); + Assert.Equal(8.1, result.Metadata.Vdop); + Assert.Equal(10.8, result.Metadata.Pdop); + Assert.Equal(45, result.Metadata.AgeOfDgpsData); + Assert.Equal(124, result.Metadata.DgpsId); + + Assert.Equal("WPT Comment", result.Metadata.Comment); + Assert.Equal("WPT Description", result.Metadata.Description); + Assert.Equal("WPT Name", result.Metadata.Name); + Assert.Equal("WPT Source", result.Metadata.Source); + + Assert.Equal(1, result.Metadata.Links.Count); + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } + + [Fact] + public void Read_ReadsWaypointUnsortedMetadataAndExtension() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxPoint; + + Assert.Equal(0.98, result.Metadata.MagVar); + Assert.Equal(12.5, result.Metadata.GeoidHeight); + Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); + Assert.Equal(8, result.Metadata.SatellitesCount); + Assert.Equal(5.1, result.Metadata.Hdop); + Assert.Equal(8.1, result.Metadata.Vdop); + Assert.Equal(10.8, result.Metadata.Pdop); + Assert.Equal(45, result.Metadata.AgeOfDgpsData); + Assert.Equal(124, result.Metadata.DgpsId); + + Assert.Equal("WPT Comment", result.Metadata.Comment); + Assert.Equal("WPT Description", result.Metadata.Description); + Assert.Equal("WPT Name", result.Metadata.Name); + Assert.Equal("WPT Source", result.Metadata.Source); + + Assert.Equal(1, result.Metadata.Links.Count); + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } + + [Fact] + public void Read_ParsesTrackWithSingleSegment() + { + var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; + + Assert.Single(result.Geometries); + + GpxTrackSegment segment = result.Geometries[0]; + Assert.Equal(new Coordinate(-76.638178825, 39.449270368), segment.Points[0].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), segment.Points[0].Timestamp); + Assert.Equal(new Coordinate(-76.638012528, 39.449130893), segment.Points[1].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), segment.Points[1].Timestamp); + Assert.Equal(new Coordinate(-76.637980342, 39.449098706), segment.Points[2].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), segment.Points[2].Timestamp); + } + + [Fact] + public void Read_ParsesTrackWithSingleSegmentAndExtensions() + { + var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; + + Assert.Single(result.Geometries); + + GpxTrackSegment segment = result.Geometries[0]; + } + + [Fact] + public void Read_ParsesTrackWithMultipleSegments() + { + var data = TestDataReader.Open("gpx-track-2-track-segments.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; + + //segments + Assert.Equal(2, result.Geometries.Count); + //points in segments + Assert.Equal(3, result.Geometries[0].Points.Count); + Assert.Equal(2, result.Geometries[1].Points.Count); + } + + [Fact] + public void Read_ParsesMultipleTracks() + { + var data = TestDataReader.Open("gpx-track-multiple-tracks.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result1 = target.Read() as GpxTrack; + var result2 = target.Read() as GpxTrack; + + //segments - first track + Assert.Equal(2, result1.Geometries.Count); + //points in segments - first track + Assert.Equal(3, result1.Geometries[0].Points.Count); + Assert.Equal(2, result1.Geometries[1].Points.Count); + + //segments - second track + Assert.Single(result2.Geometries); + //points in segments - second track + Assert.Equal(2, result2.Geometries[0].Points.Count); + } + + [Fact] + public void Read_ParsesEmptyTrack() + { + var data = TestDataReader.Open("gpx-track-empty.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; + + Assert.Empty(result.Geometries); + } + + [Fact] + public void Read_ParsesTrackWithEmptySegment() + { + var data = TestDataReader.Open("gpx-track-empty-track-segment.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; + + Assert.Single(result.Geometries); + Assert.Empty(result.Geometries[0].Points); + } + + [Fact] + public void Read_ParsesTrackMetadata() + { + var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxTrack; + + Assert.Equal("TRK Comment", result.Metadata.Comment); + Assert.Equal("TRK Description", result.Metadata.Description); + Assert.Equal("TRK Name", result.Metadata.Name); + Assert.Equal("TRK Source", result.Metadata.Source); + Assert.Equal("TRK Type", result.Metadata.Type); + + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } + + [Fact] + public void Read_SetsTrackMetadataToNullIfReadMetadataIsFalse() + { + var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; + + Assert.Null(result.Metadata); + } + + [Fact] + public void Read_ParsesEmptyRoute() + { + var data = TestDataReader.Open("gpx-route-empty.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + + var result = target.Read() as GpxRoute; + + Assert.Empty(result.Points); + } + + [Fact] + public void Read_ParsesSingleRoute() + { + var data = TestDataReader.Open("gpx-route-single-route.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + + var result = target.Read() as GpxRoute; + + Assert.Equal(new Coordinate(-76.638178825, 39.449270368), result.Points[0].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), result.Points[0].Timestamp); + Assert.Equal(new Coordinate(-76.638012528, 39.449130893), result.Points[1].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), result.Points[1].Timestamp); + Assert.Equal(new Coordinate(-76.637980342, 39.449098706), result.Points[2].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), result.Points[2].Timestamp); + } + + [Fact] + public void Read_ParsesSingleRouteWithExtensions() + { + var data = TestDataReader.Open("gpx-route-with-metadata-and-extensions.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + + var result = target.Read() as GpxRoute; + + Assert.Equal(3, result.Points.Count); + } + + [Fact] + public void Read_ParsesMultipleRoutes() + { + var data = TestDataReader.Open("gpx-route-multiple-routes.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + + var result1 = target.Read() as GpxRoute; + var result2 = target.Read() as GpxRoute; + + Assert.Equal(3, result1.Points.Count); + Assert.Equal(2, result2.Points.Count); + } + + [Fact] + public void Read_ParsesRouteWithMetadata() + { + var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + + var result = target.Read() as GpxRoute; + + Assert.Equal("RTE Comment", result.Metadata.Comment); + Assert.Equal("RTE Description", result.Metadata.Description); + Assert.Equal("RTE Name", result.Metadata.Name); + Assert.Equal("RTE Source", result.Metadata.Source); + Assert.Equal("RTE Type", result.Metadata.Type); + + Assert.Equal(1, result.Metadata.Links.Count); + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } + + [Fact] + public void Read_SetsRouteMetadataToNullIfReadMetadataIsFalse() + { + var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + + var result = target.Read() as GpxRoute; + + Assert.Null(result.Metadata); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/Gpx/gpx-real-file.gpx"; + + var target = new GpxReader(filename, new GpxReaderSettings() { ReadMetadata = false }); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } + + [Fact] + public void Read_ReadsAllEntitiesFromRealGpxFile() + { + var data = TestDataReader.Open("gpx-real-file.gpx"); + List parsed = new List(); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + + IGpxGeometry geometry = null; + while ((geometry = target.Read()) != null) + { + parsed.Add(geometry); + } + + // waypoints + Assert.Equal(3, parsed.Where(g => g.GeometryType == GpxGeometryType.Waypoint).Count()); + + // routes + Assert.Equal(2, parsed.Where(g => g.GeometryType == GpxGeometryType.Route).Count()); + + // tracks + Assert.Single(parsed.Where(g => g.GeometryType == GpxGeometryType.Track)); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs index 614ebcf..044a6fa 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs @@ -1,31 +1,36 @@ -using System; -using SpatialLite.Gps.IO; -using Xunit; - -namespace Tests.SpatialLite.Gps.IO { - public class GpxWriterSettingsTests { - - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() { - var target = new GpxWriterSettings(); - - Assert.True(target.WriteMetadata); - } - - [Fact] - public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - var target = new GpxWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.WriteMetadata = true); - } - - [Fact] - public void GeneratorNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - var target = new GpxWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.GeneratorName = "TEST"); - } - } -} +using System; +using SpatialLite.Gps.IO; +using Xunit; + +namespace Tests.SpatialLite.Gps.IO +{ + public class GpxWriterSettingsTests + { + + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() + { + var target = new GpxWriterSettings(); + + Assert.True(target.WriteMetadata); + } + + [Fact] + public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + var target = new GpxWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.WriteMetadata = true); + } + + [Fact] + public void GeneratorNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + var target = new GpxWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.GeneratorName = "TEST"); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs index 2c07157..c89dd25 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs @@ -1,335 +1,374 @@ -using System; - -using Xunit; - -using SpatialLite.Gps.Geometries; -using SpatialLite.Gps.IO; -using System.IO; -using System.Xml.Linq; -using SpatialLite.Core.API; -using Tests.SpatialLite.Gps.Data; - -namespace Tests.SpatialLite.Gps.IO { - public class GpxWriterTests { - GpxPoint _waypoint = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); - GpxPoint _waypointWithMetadata = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); - GpxPointMetadata _pointMetadata; - - GpxRoute _route = new GpxRoute(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) - }); - GpxRoute _routeWithMetadata = new GpxRoute(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) - }); - GpxTrackMetadata _routeMetadata; - - GpxTrackSegment _segment = new GpxTrackSegment(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) - }); - GpxTrackMetadata _trackMetadata; - GpxTrack _track; - GpxTrack _trackWithMetadata; - public GpxWriterTests() { - _pointMetadata = new GpxPointMetadata(); - _pointMetadata.AgeOfDgpsData = 45; - _pointMetadata.DgpsId = 124; - _pointMetadata.Fix = GpsFix.Fix3D; - _pointMetadata.GeoidHeight = 12.5; - _pointMetadata.Hdop = 5.1; - _pointMetadata.MagVar = 0.98; - _pointMetadata.Pdop = 10.8; - _pointMetadata.SatellitesCount = 8; - _pointMetadata.Symbol = "WPT Symbol"; - _pointMetadata.Vdop = 8.1; - - _pointMetadata.Comment = "WPT Comment"; - _pointMetadata.Description = "WPT Description"; - _pointMetadata.Name = "WPT Name"; - _pointMetadata.Source = "WPT Source"; - _pointMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); - _waypointWithMetadata.Metadata = _pointMetadata; - - _routeMetadata = new GpxTrackMetadata(); - _routeMetadata.Comment = "RTE Comment"; - _routeMetadata.Description = "RTE Description"; - _routeMetadata.Name = "RTE Name"; - _routeMetadata.Source = "RTE Source"; - _routeMetadata.Type = "RTE Type"; - _routeMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); - _routeWithMetadata.Metadata = _routeMetadata; - - _trackMetadata = new GpxTrackMetadata(); - _trackMetadata.Comment = "TRK Comment"; - _trackMetadata.Description = "TRK Description"; - _trackMetadata.Name = "TRK Name"; - _trackMetadata.Source = "TRK Source"; - _trackMetadata.Type = "TRK Type"; - _trackMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); - - _track = new GpxTrack(new GpxTrackSegment[] { _segment }); - _trackWithMetadata = new GpxTrack(new GpxTrackSegment[] { _segment }); - _trackWithMetadata.Metadata = _trackMetadata; - } - - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMarkSettingsAsReadOnly() { - var stream = new MemoryStream(); - var settings = new GpxWriterSettings(); - using (var target = new GpxWriter(stream, settings)) { - Assert.Same(settings, target.Settings); - Assert.True(target.Settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_StreamSettings_CreatesGpxFileWithRootElement() { - string generatorName = "SpatialLite"; - var stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) { - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() { - string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-1.gpx"); - - var settings = new GpxWriterSettings(); - using (var target = new GpxWriter(path, settings)) { - Assert.Same(settings, target.Settings); - Assert.True(target.Settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_PathSettings_CreatesOutputFile() { - string filename = PathHelper.GetTempFilePath("gpxwriter-constructor-creates-output-test.gpx"); - - var settings = new GpxWriterSettings(); - using (var target = new GpxWriter(filename, settings)) { - ; - } - - Assert.True(File.Exists(filename)); - } - - [Fact] - public void Constructor_PathSettings_CreatesGpxFileWithRootElement() { - string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-2.gpx"); - string generatorName = "SpatialLite"; - - using (GpxWriter target = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) { - } - - XDocument written = XDocument.Load(path); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesWaypointWithoutMetadataIfMetadataIsNull() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - target.Write(_waypoint); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesWaypointWithoutMetadataIfWriteMetadataIsFalse() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - target.Write(_waypointWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesWaypointWithMetadata() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - target.Write(_waypointWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesWaypointWithoutUnnecessaryElements() { - _waypointWithMetadata.Metadata.SatellitesCount = null; - _waypointWithMetadata.Metadata.Name = null; - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - target.Write(_waypointWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata-selection.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesRouteWith3Points() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - target.Write(_route); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesRouteWithMetadata() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - target.Write(_routeWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesRouteWithoutMetadataIfWriteMetadataIsFalse() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - target.Write(_routeWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesRouteWithoutUnnecessaryElements() { - _routeWithMetadata.Metadata.Source = null; - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - target.Write(_routeWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata-selection.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesTrack() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - target.Write(_track); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_WritesTrackWithMetadata() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - target.Write(_trackWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_DoesntWriteTrackMetadataIfWriteMetadataIsFalse() { - MemoryStream stream = new MemoryStream(); - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - target.Write(_trackWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Write_TrackWithEntityDetailsButNullValues_WritesTrackWithoutUnnecessaryElements() { - MemoryStream stream = new MemoryStream(); - _trackWithMetadata.Metadata.Source = null; - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - target.Write(_trackWithMetadata); - } - - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata-selection.gpx")); - - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string path = PathHelper.GetTempFilePath("gpxwriter-closes-output-filestream-test.osm"); - - var target = new GpxWriter(path, new GpxWriterSettings()); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new MemoryStream(); - - var target = new GpxWriter(stream, new GpxWriterSettings()); - target.Dispose(); - - Assert.False(stream.CanRead); - } - } -} +using System; + +using Xunit; + +using SpatialLite.Gps.Geometries; +using SpatialLite.Gps.IO; +using System.IO; +using System.Xml.Linq; +using SpatialLite.Core.API; +using Tests.SpatialLite.Gps.Data; + +namespace Tests.SpatialLite.Gps.IO +{ + public class GpxWriterTests + { + GpxPoint _waypoint = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + GpxPoint _waypointWithMetadata = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + GpxPointMetadata _pointMetadata; + + GpxRoute _route = new GpxRoute(new GpxPoint[] { + new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + }); + GpxRoute _routeWithMetadata = new GpxRoute(new GpxPoint[] { + new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + }); + GpxTrackMetadata _routeMetadata; + + GpxTrackSegment _segment = new GpxTrackSegment(new GpxPoint[] { + new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + }); + GpxTrackMetadata _trackMetadata; + GpxTrack _track; + GpxTrack _trackWithMetadata; + public GpxWriterTests() + { + _pointMetadata = new GpxPointMetadata(); + _pointMetadata.AgeOfDgpsData = 45; + _pointMetadata.DgpsId = 124; + _pointMetadata.Fix = GpsFix.Fix3D; + _pointMetadata.GeoidHeight = 12.5; + _pointMetadata.Hdop = 5.1; + _pointMetadata.MagVar = 0.98; + _pointMetadata.Pdop = 10.8; + _pointMetadata.SatellitesCount = 8; + _pointMetadata.Symbol = "WPT Symbol"; + _pointMetadata.Vdop = 8.1; + + _pointMetadata.Comment = "WPT Comment"; + _pointMetadata.Description = "WPT Description"; + _pointMetadata.Name = "WPT Name"; + _pointMetadata.Source = "WPT Source"; + _pointMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); + _waypointWithMetadata.Metadata = _pointMetadata; + + _routeMetadata = new GpxTrackMetadata(); + _routeMetadata.Comment = "RTE Comment"; + _routeMetadata.Description = "RTE Description"; + _routeMetadata.Name = "RTE Name"; + _routeMetadata.Source = "RTE Source"; + _routeMetadata.Type = "RTE Type"; + _routeMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); + _routeWithMetadata.Metadata = _routeMetadata; + + _trackMetadata = new GpxTrackMetadata(); + _trackMetadata.Comment = "TRK Comment"; + _trackMetadata.Description = "TRK Description"; + _trackMetadata.Name = "TRK Name"; + _trackMetadata.Source = "TRK Source"; + _trackMetadata.Type = "TRK Type"; + _trackMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); + + _track = new GpxTrack(new GpxTrackSegment[] { _segment }); + _trackWithMetadata = new GpxTrack(new GpxTrackSegment[] { _segment }); + _trackWithMetadata.Metadata = _trackMetadata; + } + + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMarkSettingsAsReadOnly() + { + var stream = new MemoryStream(); + var settings = new GpxWriterSettings(); + using (var target = new GpxWriter(stream, settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(target.Settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_StreamSettings_CreatesGpxFileWithRootElement() + { + string generatorName = "SpatialLite"; + var stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) + { + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() + { + string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-1.gpx"); + + var settings = new GpxWriterSettings(); + using (var target = new GpxWriter(path, settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(target.Settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_PathSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("gpxwriter-constructor-creates-output-test.gpx"); + + var settings = new GpxWriterSettings(); + using (var target = new GpxWriter(filename, settings)) + { + ; + } + + Assert.True(File.Exists(filename)); + } + + [Fact] + public void Constructor_PathSettings_CreatesGpxFileWithRootElement() + { + string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-2.gpx"); + string generatorName = "SpatialLite"; + + using (GpxWriter target = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) + { + } + + XDocument written = XDocument.Load(path); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesWaypointWithoutMetadataIfMetadataIsNull() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + { + target.Write(_waypoint); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesWaypointWithoutMetadataIfWriteMetadataIsFalse() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + { + target.Write(_waypointWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesWaypointWithMetadata() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + { + target.Write(_waypointWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesWaypointWithoutUnnecessaryElements() + { + _waypointWithMetadata.Metadata.SatellitesCount = null; + _waypointWithMetadata.Metadata.Name = null; + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + { + target.Write(_waypointWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata-selection.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesRouteWith3Points() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + { + target.Write(_route); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesRouteWithMetadata() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + { + target.Write(_routeWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesRouteWithoutMetadataIfWriteMetadataIsFalse() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + { + target.Write(_routeWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesRouteWithoutUnnecessaryElements() + { + _routeWithMetadata.Metadata.Source = null; + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + { + target.Write(_routeWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata-selection.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesTrack() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + { + target.Write(_track); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_WritesTrackWithMetadata() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + { + target.Write(_trackWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_DoesntWriteTrackMetadataIfWriteMetadataIsFalse() + { + MemoryStream stream = new MemoryStream(); + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + { + target.Write(_trackWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Write_TrackWithEntityDetailsButNullValues_WritesTrackWithoutUnnecessaryElements() + { + MemoryStream stream = new MemoryStream(); + _trackWithMetadata.Metadata.Source = null; + + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + { + target.Write(_trackWithMetadata); + } + + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata-selection.gpx")); + + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string path = PathHelper.GetTempFilePath("gpxwriter-closes-output-filestream-test.osm"); + + var target = new GpxWriter(path, new GpxWriterSettings()); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + MemoryStream stream = new MemoryStream(); + + var target = new GpxWriter(stream, new GpxWriterSettings()); + target.Dispose(); + + Assert.False(stream.CanRead); + } + } +} diff --git a/src/Tests.SpatialLite.Gps/PathHelper.cs b/src/Tests.SpatialLite.Gps/PathHelper.cs index a903e6f..e5d7362 100644 --- a/src/Tests.SpatialLite.Gps/PathHelper.cs +++ b/src/Tests.SpatialLite.Gps/PathHelper.cs @@ -1,23 +1,28 @@ -using System.IO; - -namespace Tests.SpatialLite.Gps { - static class PathHelper { - private const string TempDirectoryName = "Temp"; - - private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); - public static string RealGpxFilePath => _realGpxFilePath; - - public static string GetTempFilePath(string filename) { - if (!Directory.Exists(TempDirectoryName)) { - Directory.CreateDirectory(TempDirectoryName); - } - - string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); - if (File.Exists(pbfFile)) { - File.Delete(pbfFile); - } - - return pbfFile; - } - } -} +using System.IO; + +namespace Tests.SpatialLite.Gps +{ + static class PathHelper + { + private const string TempDirectoryName = "Temp"; + + private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); + public static string RealGpxFilePath => _realGpxFilePath; + + public static string GetTempFilePath(string filename) + { + if (!Directory.Exists(TempDirectoryName)) + { + Directory.CreateDirectory(TempDirectoryName); + } + + string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); + if (File.Exists(pbfFile)) + { + File.Delete(pbfFile); + } + + return pbfFile; + } + } +} diff --git a/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs b/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs index ebbc34a..68138f3 100644 --- a/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs +++ b/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs @@ -1,19 +1,19 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tests.SpatialLite.Gps")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c4a5dbc7-deca-4b13-8fa9-c5f98fd4e666")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tests.SpatialLite.Gps")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c4a5dbc7-deca-4b13-8fa9-c5f98fd4e666")] diff --git a/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs b/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs index abfe039..6ee386b 100644 --- a/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs +++ b/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs @@ -1,43 +1,55 @@ -using System.Linq; -using System.Xml.Linq; - -namespace Tests.SpatialLite.Gps { - /// - /// Extends XDocument with correct DeepEquals function - /// - public static class XDocumentExtensions { - public static bool DeepEqualsWithNormalization(XDocument doc1, XDocument doc2) { - return XMLCompare(doc1.Root, doc2.Root); - } - - public static bool XMLCompare(XElement ele1, XElement ele2) { - if (ele1.HasAttributes) { - if (ele1.Attributes().Count() != ele2.Attributes().Count()) { - return false; - } - - foreach (XAttribute attr in ele1.Attributes()) { - if (ele2.Attribute(attr.Name.LocalName) == null) { - return false; - } - if (attr.Value.ToLower() != ele2.Attribute(attr.Name.LocalName).Value.ToLower()) { - return false; - } - } - } - - if (ele1.HasElements) { - if (ele1.Elements().Count() != ele2.Elements().Count()) { - return false; - } - - for (var i = 0; i <= ele1.Elements().Count() - 1; i++) { - if (XMLCompare(ele1.Elements().ElementAt(i), ele2.Elements().ElementAt(i)) == false) - return false; - } - } - - return true; - } - } -} +using System.Linq; +using System.Xml.Linq; + +namespace Tests.SpatialLite.Gps +{ + /// + /// Extends XDocument with correct DeepEquals function + /// + public static class XDocumentExtensions + { + public static bool DeepEqualsWithNormalization(XDocument doc1, XDocument doc2) + { + return XMLCompare(doc1.Root, doc2.Root); + } + + public static bool XMLCompare(XElement ele1, XElement ele2) + { + if (ele1.HasAttributes) + { + if (ele1.Attributes().Count() != ele2.Attributes().Count()) + { + return false; + } + + foreach (XAttribute attr in ele1.Attributes()) + { + if (ele2.Attribute(attr.Name.LocalName) == null) + { + return false; + } + if (attr.Value.ToLower() != ele2.Attribute(attr.Name.LocalName).Value.ToLower()) + { + return false; + } + } + } + + if (ele1.HasElements) + { + if (ele1.Elements().Count() != ele2.Elements().Count()) + { + return false; + } + + for (var i = 0; i <= ele1.Elements().Count() - 1; i++) + { + if (XMLCompare(ele1.Elements().ElementAt(i), ele2.Elements().ElementAt(i)) == false) + return false; + } + } + + return true; + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs b/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs index 7091126..eb09eeb 100644 --- a/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs +++ b/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs @@ -1,21 +1,26 @@ -using System.IO; -using System.Reflection; - -namespace Tests.SpatialLite.Osm.Data { - public static class TestDataReader { - public static Stream OpenXml(string name) { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Xml." + name); - } - - public static Stream OpenPbf(string name) { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Pbf." + name); - } - - public static Stream OpenOsmDB(string name) { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.OsmDatabase." + name); - } - } -} +using System.IO; +using System.Reflection; + +namespace Tests.SpatialLite.Osm.Data +{ + public static class TestDataReader + { + public static Stream OpenXml(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Xml." + name); + } + + public static Stream OpenPbf(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Pbf." + name); + } + + public static Stream OpenOsmDB(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.OsmDatabase." + name); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs index 03f5a47..97f146c 100644 --- a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs @@ -1,201 +1,227 @@ -using System; -using System.Linq; - -using Xunit; -using Moq; - -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; - -namespace Tests.SpatialLite.Osm { - public class EntityCollectionTests { - IOsmGeometry[] _data; - - public EntityCollectionTests() { - _data = new IOsmGeometry[3]; - _data[0] = new Node(1); - _data[1] = new Node(2); - _data[2] = new Node(3); - } - - [Fact] - public void Constructor__CreatesEmptyCollection() { - EntityCollection target = new EntityCollection(); - - Assert.Empty(target); - } - - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - EntityCollection target = new EntityCollection(_data); - - for (int i = 0; i < _data.Length; i++) { - Assert.Contains(_data[i], target); - } - } - - [Fact] - public void Count_ReturnsNumberOfElements() { - EntityCollection target = new EntityCollection(_data); - Mock entityM = new Mock(); - - Assert.Equal(_data.Length, target.Count); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseForEmptyCollection() { - EntityCollection target = new EntityCollection(); - - Assert.DoesNotContain(_data[0], target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseForNull() { - EntityCollection target = new EntityCollection(); - - Assert.DoesNotContain(null, target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainEntity() { - EntityCollection target = new EntityCollection(_data.Skip(1)); - - Assert.DoesNotContain(_data[0], target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsEntity() { - EntityCollection target = new EntityCollection(_data); - - Assert.Contains(_data[0], target); - } - - [Fact] - public void Contains_ID_ReturnsFalseForEmptyCollection() { - EntityCollection target = new EntityCollection(); - - Assert.False(target.Contains(_data[0].ID)); - } - - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainEntity() { - EntityCollection target = new EntityCollection(_data.Skip(1)); - - Assert.False(target.Contains(_data[0].ID)); - } - - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsEntity() { - EntityCollection target = new EntityCollection(_data); - - Assert.True(target.Contains(_data[0].ID)); - } - - [Fact] - public void Clear_RemovesAllItemsFromCollection() { - EntityCollection target = new EntityCollection(_data); - target.Clear(); - - Assert.Empty(target); - } - - [Fact] - public void Add_AddsEntityToCollection() { - EntityCollection target = new EntityCollection(); - target.Add(_data[0]); - - Assert.Contains(_data[0], target); - } - - [Fact] - public void Add_ThrowsArgumentNullExceptionIfItemIsNull() { - EntityCollection target = new EntityCollection(); - - Assert.Throws(() => target.Add(null)); - } - - [Fact] - public void Add_ThrowsExceptionWhenAddingDuplicateID() { - EntityCollection target = new EntityCollection(_data); - - Assert.Throws(() => target.Add(_data[0])); - } - - [Fact] - public void IsReadOnly_ReturnsFalse() { - EntityCollection target = new EntityCollection(); - - Assert.False(target.IsReadOnly); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() { - EntityCollection target = new EntityCollection(_data.Skip(1)); - - bool callResult = target.Remove(_data[0]); - - Assert.False(callResult); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() { - EntityCollection target = new EntityCollection(_data); - - bool callResult = target.Remove(null); - - Assert.False(callResult); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesItemFromCollection() { - EntityCollection target = new EntityCollection(_data); - - bool callResult = target.Remove(_data[0]); - - Assert.True(callResult); - Assert.DoesNotContain(_data[0], target); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } - - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() { - EntityCollection target = new EntityCollection(_data.Skip(1)); - - bool callResult = target.Remove(_data[0].ID); - - Assert.False(callResult); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } - - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesItemFromCollection() { - EntityCollection target = new EntityCollection(_data); - - bool callResult = target.Remove(_data[0].ID); - - Assert.True(callResult); - Assert.DoesNotContain(_data[0], target); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } - - [Fact] - public void Item_ReturnsNullIfIDIsNotpResentInCollection() { - EntityCollection target = new EntityCollection(_data); - - Assert.Null(target[1000]); - } - - [Fact] - public void Item_ReturnsEntityWitSpecificID() { - EntityCollection target = new EntityCollection(_data); - IOsmGeometry entity = target[1]; - - Assert.Equal(1, entity.ID); - } - } -} +using System; +using System.Linq; + +using Xunit; +using Moq; + +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; + +namespace Tests.SpatialLite.Osm +{ + public class EntityCollectionTests + { + IOsmGeometry[] _data; + + public EntityCollectionTests() + { + _data = new IOsmGeometry[3]; + _data[0] = new Node(1); + _data[1] = new Node(2); + _data[2] = new Node(3); + } + + [Fact] + public void Constructor__CreatesEmptyCollection() + { + EntityCollection target = new EntityCollection(); + + Assert.Empty(target); + } + + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + EntityCollection target = new EntityCollection(_data); + + for (int i = 0; i < _data.Length; i++) + { + Assert.Contains(_data[i], target); + } + } + + [Fact] + public void Count_ReturnsNumberOfElements() + { + EntityCollection target = new EntityCollection(_data); + Mock entityM = new Mock(); + + Assert.Equal(_data.Length, target.Count); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseForEmptyCollection() + { + EntityCollection target = new EntityCollection(); + + Assert.DoesNotContain(_data[0], target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseForNull() + { + EntityCollection target = new EntityCollection(); + + Assert.DoesNotContain(null, target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainEntity() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); + + Assert.DoesNotContain(_data[0], target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsEntity() + { + EntityCollection target = new EntityCollection(_data); + + Assert.Contains(_data[0], target); + } + + [Fact] + public void Contains_ID_ReturnsFalseForEmptyCollection() + { + EntityCollection target = new EntityCollection(); + + Assert.False(target.Contains(_data[0].ID)); + } + + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainEntity() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); + + Assert.False(target.Contains(_data[0].ID)); + } + + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsEntity() + { + EntityCollection target = new EntityCollection(_data); + + Assert.True(target.Contains(_data[0].ID)); + } + + [Fact] + public void Clear_RemovesAllItemsFromCollection() + { + EntityCollection target = new EntityCollection(_data); + target.Clear(); + + Assert.Empty(target); + } + + [Fact] + public void Add_AddsEntityToCollection() + { + EntityCollection target = new EntityCollection(); + target.Add(_data[0]); + + Assert.Contains(_data[0], target); + } + + [Fact] + public void Add_ThrowsArgumentNullExceptionIfItemIsNull() + { + EntityCollection target = new EntityCollection(); + + Assert.Throws(() => target.Add(null)); + } + + [Fact] + public void Add_ThrowsExceptionWhenAddingDuplicateID() + { + EntityCollection target = new EntityCollection(_data); + + Assert.Throws(() => target.Add(_data[0])); + } + + [Fact] + public void IsReadOnly_ReturnsFalse() + { + EntityCollection target = new EntityCollection(); + + Assert.False(target.IsReadOnly); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); + + bool callResult = target.Remove(_data[0]); + + Assert.False(callResult); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() + { + EntityCollection target = new EntityCollection(_data); + + bool callResult = target.Remove(null); + + Assert.False(callResult); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesItemFromCollection() + { + EntityCollection target = new EntityCollection(_data); + + bool callResult = target.Remove(_data[0]); + + Assert.True(callResult); + Assert.DoesNotContain(_data[0], target); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } + + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); + + bool callResult = target.Remove(_data[0].ID); + + Assert.False(callResult); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } + + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesItemFromCollection() + { + EntityCollection target = new EntityCollection(_data); + + bool callResult = target.Remove(_data[0].ID); + + Assert.True(callResult); + Assert.DoesNotContain(_data[0], target); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } + + [Fact] + public void Item_ReturnsNullIfIDIsNotpResentInCollection() + { + EntityCollection target = new EntityCollection(_data); + + Assert.Null(target[1000]); + } + + [Fact] + public void Item_ReturnsEntityWitSpecificID() + { + EntityCollection target = new EntityCollection(_data); + IOsmGeometry entity = target[1]; + + Assert.Equal(1, entity.ID); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs index ab01fdc..36d4ed2 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs @@ -1,96 +1,105 @@ -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; - -namespace Tests.SpatialLite.Osm.Geometry { - public class NodeTests { - - [Fact] - public void Constructor_int_CreatesNodeAndInitializeProperties() { - int id = 11; - Node target = new Node(id); - - Assert.Equal(Coordinate.Empty, target.Position); - Assert.Equal(id, target.ID); - Assert.NotNull(target.Tags); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_int_double_double_CreatesNodeAndInitializeProperties() { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - Node target = new Node(id, coord.X, coord.Y); - - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.Equal(id, target.ID); - Assert.NotNull(target.Tags); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_int_double_double_Tags_CreatesNodeAndInitializesProperties() { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - TagsCollection tags = new TagsCollection(); - - Node target = new Node(id, coord.X, coord.Y, tags); - - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_int_Coordinate_CreatesNodeAndInitializeProperties() { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - Node target = new Node(id, coord); - - Assert.Equal(id, target.ID); - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.NotNull(target.Tags); - } - - [Fact] - public void Constructor_int_Coordinate_Tags_CreatesNodeAndInitializeProperties() { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - TagsCollection tags = new TagsCollection(); - - Node target = new Node(id, coord, tags); - - Assert.Equal(id, target.ID); - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.Same(tags, target.Tags); - } - - [Fact] - public void Constructor_NodeInfo_CreatesNodeFromNodeInfo() { - NodeInfo info = new NodeInfo(1, 15.6, 20.4, new TagsCollection(), new EntityMetadata()); - - Node target = Node.FromNodeInfo(info); - - Assert.Equal(info.ID, target.ID); - Assert.Equal(info.Longitude, target.Position.X); - Assert.Equal(info.Latitude, target.Position.Y); - Assert.Same(info.Tags, target.Tags); - Assert.Same(info.Metadata, target.Metadata); - } - - [Fact] - public void EntityType_Returns_Node() { - Node target = new Node(1); - - Assert.Equal(EntityType.Node, target.EntityType); - } - } -} +using Xunit; + +using SpatialLite.Core; +using SpatialLite.Core.API; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; + +namespace Tests.SpatialLite.Osm.Geometry +{ + public class NodeTests + { + + [Fact] + public void Constructor_int_CreatesNodeAndInitializeProperties() + { + int id = 11; + Node target = new Node(id); + + Assert.Equal(Coordinate.Empty, target.Position); + Assert.Equal(id, target.ID); + Assert.NotNull(target.Tags); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_int_double_double_CreatesNodeAndInitializeProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + Node target = new Node(id, coord.X, coord.Y); + + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.Equal(id, target.ID); + Assert.NotNull(target.Tags); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_int_double_double_Tags_CreatesNodeAndInitializesProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + TagsCollection tags = new TagsCollection(); + + Node target = new Node(id, coord.X, coord.Y, tags); + + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_int_Coordinate_CreatesNodeAndInitializeProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + Node target = new Node(id, coord); + + Assert.Equal(id, target.ID); + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.NotNull(target.Tags); + } + + [Fact] + public void Constructor_int_Coordinate_Tags_CreatesNodeAndInitializeProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + TagsCollection tags = new TagsCollection(); + + Node target = new Node(id, coord, tags); + + Assert.Equal(id, target.ID); + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.Same(tags, target.Tags); + } + + [Fact] + public void Constructor_NodeInfo_CreatesNodeFromNodeInfo() + { + NodeInfo info = new NodeInfo(1, 15.6, 20.4, new TagsCollection(), new EntityMetadata()); + + Node target = Node.FromNodeInfo(info); + + Assert.Equal(info.ID, target.ID); + Assert.Equal(info.Longitude, target.Position.X); + Assert.Equal(info.Latitude, target.Position.Y); + Assert.Same(info.Tags, target.Tags); + Assert.Same(info.Metadata, target.Metadata); + } + + [Fact] + public void EntityType_Returns_Node() + { + Node target = new Node(1); + + Assert.Equal(EntityType.Node, target.EntityType); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs index 561df3a..b073604 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs @@ -1,161 +1,180 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.IO; - -using Xunit; -using Moq; -using SpatialLite.Osm.IO; -using SpatialLite.Osm.Geometries; -using Tests.SpatialLite.Osm.Data; - -namespace Tests.SpatialLite.Osm.Geometries { - public class OsmGeometryDatabaseTests { - Node[] _nodeData; - Way[] _wayData; - Relation[] _relationData; - IOsmGeometry[] _data; - public OsmGeometryDatabaseTests() { - _nodeData = new Node[3]; - _nodeData[0] = new Node(1); - _nodeData[1] = new Node(2); - _nodeData[2] = new Node(3); - - _wayData = new Way[2]; - _wayData[0] = new Way(10, _nodeData); - _wayData[1] = new Way(11, _nodeData.Skip(1)); - - _relationData = new Relation[2]; - _relationData[0] = new Relation(100, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); - _relationData[1] = new Relation(101, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); - - _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); - } - - [Fact] - public void Constructor__CreatesEmptyDatabase() { - OsmGeometryDatabase target = new OsmGeometryDatabase(); - - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } - - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); - - for (int i = 0; i < _data.Length; i++) { - Assert.Contains(_data[i], target); - } - } - - [Fact] - public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() { - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); - - for (int i = 0; i < _nodeData.Length; i++) { - Assert.Contains(_nodeData[i], target.Nodes); - } - - for (int i = 0; i < _wayData.Length; i++) { - Assert.Contains(_wayData[i], target.Ways); - } - - for (int i = 0; i < _relationData.Length; i++) { - Assert.Contains(_relationData[i], target.Relations); - } - } - - [Fact] - public void Load_LoadsNodes() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); - } - - [Fact] - public void Load_LoadsWay() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); - - Assert.Equal(1, target.Ways.Count); - Assert.True(target.Ways.Contains(10)); - } - - [Fact] - public void Load_LoadsRelation() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(1, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - - Assert.Equal(1, target.Relations.Count); - Assert.True(target.Relations.Contains(100)); - } - - [Fact] - public void Load_CanLoadRelationsWithReferenceToRelationsNotYetCreated() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-ref-other-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(2, target.Relations.Count); - Assert.True(target.Relations.Contains(100)); - Assert.True(target.Relations.Contains(101)); - - Assert.Equal(101, target.Relations[100].Geometries[0].Member.ID); - } - - [Fact] - public void Load_ThrowsExceptionIfAllRelationReferencesAreNotResolvedAtTheEndOfLoadingAndIgnoreMissingIsFalse() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - Assert.Throws(() => OsmGeometryDatabase.Load(reader, false)); - } - - [Fact] - public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndWaysNodeIsMissing() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = null; - target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(2, target.Nodes.Count); - Assert.Equal(0, target.Ways.Count); - } - - [Fact] - public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndRelationMemberIsMissing() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = null; - target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(1, target.Relations.Count); - } - - [Fact] - public void Save_CallsIOsmWriterWriteForAllEntities() { - List written = new List(); - Mock writerM = new Mock(); - - writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); - - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); - target.Save(writerM.Object); - - Assert.Equal(target.Count, written.Count); - foreach (var entity in target) { - Assert.Contains(entity, written); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.IO; + +using Xunit; +using Moq; +using SpatialLite.Osm.IO; +using SpatialLite.Osm.Geometries; +using Tests.SpatialLite.Osm.Data; + +namespace Tests.SpatialLite.Osm.Geometries +{ + public class OsmGeometryDatabaseTests + { + Node[] _nodeData; + Way[] _wayData; + Relation[] _relationData; + IOsmGeometry[] _data; + public OsmGeometryDatabaseTests() + { + _nodeData = new Node[3]; + _nodeData[0] = new Node(1); + _nodeData[1] = new Node(2); + _nodeData[2] = new Node(3); + + _wayData = new Way[2]; + _wayData[0] = new Way(10, _nodeData); + _wayData[1] = new Way(11, _nodeData.Skip(1)); + + _relationData = new Relation[2]; + _relationData[0] = new Relation(100, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); + _relationData[1] = new Relation(101, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); + + _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); + } + + [Fact] + public void Constructor__CreatesEmptyDatabase() + { + OsmGeometryDatabase target = new OsmGeometryDatabase(); + + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } + + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + + for (int i = 0; i < _data.Length; i++) + { + Assert.Contains(_data[i], target); + } + } + + [Fact] + public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() + { + OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + + for (int i = 0; i < _nodeData.Length; i++) + { + Assert.Contains(_nodeData[i], target.Nodes); + } + + for (int i = 0; i < _wayData.Length; i++) + { + Assert.Contains(_wayData[i], target.Ways); + } + + for (int i = 0; i < _relationData.Length; i++) + { + Assert.Contains(_relationData[i], target.Relations); + } + } + + [Fact] + public void Load_LoadsNodes() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); + } + + [Fact] + public void Load_LoadsWay() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); + + Assert.Equal(1, target.Ways.Count); + Assert.True(target.Ways.Contains(10)); + } + + [Fact] + public void Load_LoadsRelation() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(1, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + + Assert.Equal(1, target.Relations.Count); + Assert.True(target.Relations.Contains(100)); + } + + [Fact] + public void Load_CanLoadRelationsWithReferenceToRelationsNotYetCreated() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-ref-other-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(2, target.Relations.Count); + Assert.True(target.Relations.Contains(100)); + Assert.True(target.Relations.Contains(101)); + + Assert.Equal(101, target.Relations[100].Geometries[0].Member.ID); + } + + [Fact] + public void Load_ThrowsExceptionIfAllRelationReferencesAreNotResolvedAtTheEndOfLoadingAndIgnoreMissingIsFalse() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + Assert.Throws(() => OsmGeometryDatabase.Load(reader, false)); + } + + [Fact] + public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndWaysNodeIsMissing() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = null; + target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(2, target.Nodes.Count); + Assert.Equal(0, target.Ways.Count); + } + + [Fact] + public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndRelationMemberIsMissing() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = null; + target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(1, target.Relations.Count); + } + + [Fact] + public void Save_CallsIOsmWriterWriteForAllEntities() + { + List written = new List(); + Mock writerM = new Mock(); + + writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); + + OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + target.Save(writerM.Object); + + Assert.Equal(target.Count, written.Count); + foreach (var entity in target) + { + Assert.Contains(entity, written); + } + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs index 6f2bec5..53fd2f7 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs @@ -1,160 +1,180 @@ -using System; - -using Xunit; -using Moq; - -using SpatialLite.Osm.Geometries; -using SpatialLite.Core.API; -using SpatialLite.Osm; - -namespace Tests.SpatialLite.Osm.Geometries { - public class RelationMemberTests { - IEntityCollection _nodesEntityCollection; - - public RelationMemberTests() { - Mock> _nodesCollectionM = new Mock>(); - _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); - _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); - _nodesEntityCollection = _nodesCollectionM.Object; - } - - [Fact] - public void Constructor_Member_CreatesNewRelationMembeAndSetsMember() { - Node member = new Node(11); - RelationMember target = new RelationMember(member); - - Assert.Same(member, target.Member); - Assert.True(string.IsNullOrEmpty(target.Role)); - } - - [Fact] - public void Constructor_Member_ThrowsExceptionIfMemberIsNull() { - Assert.Throws(() => new RelationMember(null)); - } - - [Fact] - public void Constructor_Member_Role_CreatesRelationMemberAndSetsMemberAndRole() { - Node member = new Node(11); - string role = "role"; - RelationMember target = new RelationMember(member, role); - - Assert.Same(member, target.Member); - Assert.Equal(role, target.Role); - } - - [Fact] - public void Constructor_Member_Role_ThrowsExceptionIfMemberIsNull() { - Assert.Throws(() => new RelationMember(null)); - } - - [Fact] - public void FromRelationMemberInfo_ThrowExceptionIfTypeIsUnknown() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Unknown, Role = "role" }; - - Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); - } - - [Fact] - public void FromRelationMemberInfo_CreatesRelationMember() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node, Role = "role" }; - RelationMember target = RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true); - - Assert.Equal(info.Reference, target.Member.ID); - Assert.Equal(info.Role, target.Role); - Assert.Equal(info.MemberType, target.MemberType); - } - - [Fact] - public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityIsNotAvailable() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; - - Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); - } - - [Fact] - public void FromRelationMemberInfo_ReturnsNullIfReferencedEntityIsNotAvailableAndThrowOnMissingIsFalse() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; - - Assert.Null(RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, false)); - } - - [Fact] - public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityTypeDoesntMatchMemberType() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Way, Role = "role" }; - - Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); - } - - [Fact] - public void Is3D_GetsTrueFor3DMember() { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.Is3D).Returns(true); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.Is3D, target.Is3D); - } - - [Fact] - public void Is3D_GetsFalseFor2DMember() { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.Is3D).Returns(false); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.Is3D, target.Is3D); - } - - [Fact] - public void IsMeasured_GetsTrueForMeasuredMember() { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.IsMeasured).Returns(true); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); - } - - [Fact] - public void IsMeasured_GetFalseForNonMeasuredMember() { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.IsMeasured).Returns(false); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); - } - - [Fact] - public void MemberType_ReturnsCorrectValueForNode() { - RelationMember target = new RelationMember(new Node(11)); - - Assert.Equal(EntityType.Node, target.MemberType); - } - - [Fact] - public void MemberType_ReturnsCorrectValueForWay() { - RelationMember target = new RelationMember(new Way(11)); - - Assert.Equal(EntityType.Way, target.MemberType); - } - - [Fact] - public void MemberType_ReturnsCorrectValueForRelation() { - RelationMember target = new RelationMember(new Relation(11)); - - Assert.Equal(EntityType.Relation, target.MemberType); - } - - [Fact] - public void GetEnvelopeReturnsMembersEnvelope() { - Envelope expectedEnvelope = new Envelope(new Coordinate(1.1, 2.2)); - Mock member = new Mock(11); - member.Setup(function => function.GetEnvelope()).Returns(expectedEnvelope); - - RelationMember target = new RelationMember(member.Object); - - Assert.Same(expectedEnvelope, target.GetEnvelope()); - } - } -} +using System; + +using Xunit; +using Moq; + +using SpatialLite.Osm.Geometries; +using SpatialLite.Core.API; +using SpatialLite.Osm; + +namespace Tests.SpatialLite.Osm.Geometries +{ + public class RelationMemberTests + { + IEntityCollection _nodesEntityCollection; + + public RelationMemberTests() + { + Mock> _nodesCollectionM = new Mock>(); + _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); + _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); + _nodesEntityCollection = _nodesCollectionM.Object; + } + + [Fact] + public void Constructor_Member_CreatesNewRelationMembeAndSetsMember() + { + Node member = new Node(11); + RelationMember target = new RelationMember(member); + + Assert.Same(member, target.Member); + Assert.True(string.IsNullOrEmpty(target.Role)); + } + + [Fact] + public void Constructor_Member_ThrowsExceptionIfMemberIsNull() + { + Assert.Throws(() => new RelationMember(null)); + } + + [Fact] + public void Constructor_Member_Role_CreatesRelationMemberAndSetsMemberAndRole() + { + Node member = new Node(11); + string role = "role"; + RelationMember target = new RelationMember(member, role); + + Assert.Same(member, target.Member); + Assert.Equal(role, target.Role); + } + + [Fact] + public void Constructor_Member_Role_ThrowsExceptionIfMemberIsNull() + { + Assert.Throws(() => new RelationMember(null)); + } + + [Fact] + public void FromRelationMemberInfo_ThrowExceptionIfTypeIsUnknown() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Unknown, Role = "role" }; + + Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); + } + + [Fact] + public void FromRelationMemberInfo_CreatesRelationMember() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node, Role = "role" }; + RelationMember target = RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true); + + Assert.Equal(info.Reference, target.Member.ID); + Assert.Equal(info.Role, target.Role); + Assert.Equal(info.MemberType, target.MemberType); + } + + [Fact] + public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityIsNotAvailable() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; + + Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); + } + + [Fact] + public void FromRelationMemberInfo_ReturnsNullIfReferencedEntityIsNotAvailableAndThrowOnMissingIsFalse() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; + + Assert.Null(RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, false)); + } + + [Fact] + public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityTypeDoesntMatchMemberType() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Way, Role = "role" }; + + Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); + } + + [Fact] + public void Is3D_GetsTrueFor3DMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.Is3D).Returns(true); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.Is3D, target.Is3D); + } + + [Fact] + public void Is3D_GetsFalseFor2DMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.Is3D).Returns(false); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.Is3D, target.Is3D); + } + + [Fact] + public void IsMeasured_GetsTrueForMeasuredMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.IsMeasured).Returns(true); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); + } + + [Fact] + public void IsMeasured_GetFalseForNonMeasuredMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.IsMeasured).Returns(false); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); + } + + [Fact] + public void MemberType_ReturnsCorrectValueForNode() + { + RelationMember target = new RelationMember(new Node(11)); + + Assert.Equal(EntityType.Node, target.MemberType); + } + + [Fact] + public void MemberType_ReturnsCorrectValueForWay() + { + RelationMember target = new RelationMember(new Way(11)); + + Assert.Equal(EntityType.Way, target.MemberType); + } + + [Fact] + public void MemberType_ReturnsCorrectValueForRelation() + { + RelationMember target = new RelationMember(new Relation(11)); + + Assert.Equal(EntityType.Relation, target.MemberType); + } + + [Fact] + public void GetEnvelopeReturnsMembersEnvelope() + { + Envelope expectedEnvelope = new Envelope(new Coordinate(1.1, 2.2)); + Mock member = new Mock(11); + member.Setup(function => function.GetEnvelope()).Returns(expectedEnvelope); + + RelationMember target = new RelationMember(member.Object); + + Assert.Same(expectedEnvelope, target.GetEnvelope()); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs index a14cfd4..bea2080 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs @@ -1,105 +1,118 @@ -using System; -using System.Collections.Generic; - -using Xunit; -using Moq; - -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; - -namespace Tests.SpatialLite.Osm.Geometries { - public class RelationTests { - RelationInfo _relationEmptyInfo = new RelationInfo(100, new TagsCollection(), new List(), new EntityMetadata()); - RelationInfo _relationInfo = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); - - IEntityCollection _nodesEntityCollection; - - public RelationTests() { - Mock> _nodesCollectionM = new Mock>(); - _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); - _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); - - _nodesEntityCollection = _nodesCollectionM.Object; - } - - [Fact] - public void Constructor_int_CreatesNewRelationAndInitializesProperties() { - int id = 11; - Relation target = new Relation(id); - - Assert.Equal(id, target.ID); - Assert.Empty(target.Tags); - Assert.Empty(target.Geometries); - } - - [Fact] - public void Constructor_int_IEnumerable_CreatesRelationWithMembersAndInitializesProperties() { - int id = 11; - var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; - Relation target = new Relation(id, members); - - Assert.Equal(id, target.ID); - Assert.Equal(members.Length, target.Geometries.Count); - for (int i = 0; i < members.Length; i++) { - Assert.Same(members[i], target.Geometries[i]); - } - - Assert.Empty(target.Tags); - } - - [Fact] - public void Constructor_int_tags_CreatesRelationAndIntializesProperties() { - int id = 11; - var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; - TagsCollection tags = new TagsCollection(); - Relation target = new Relation(id, members, tags); - - Assert.Equal(id, target.ID); - Assert.Equal(members.Length, target.Geometries.Count); - for (int i = 0; i < members.Length; i++) { - Assert.Same(members[i], target.Geometries[i]); - } - - Assert.Same(tags, target.Tags); - } - - [Fact] - public void FromRelationInfo_SetsRelationProperties() { - Relation target = Relation.FromRelationInfo(_relationEmptyInfo, _nodesEntityCollection ,true); - - Assert.Equal(_relationEmptyInfo.ID, target.ID); - Assert.Same(_relationEmptyInfo.Tags, target.Tags); - Assert.Same(_relationEmptyInfo.Metadata, target.Metadata); - } - - [Fact] - public void FromRelationInfo_SetsRelationMembers() { - Relation target = Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true); - - Assert.Single(target.Geometries); - Assert.Equal(_relationInfo.Members[0].Reference, target.Geometries[0].Member.ID); - } - - [Fact] - public void FromRelationInfo_ThrowExceptionIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsTrue() { - _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; - - Assert.Throws(() => Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true)); - } - - [Fact] - public void FromRelationInfo_ReturnsNullIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsFalse() { - _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; - - Assert.Null(Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, false)); - } - - [Fact] - public void EntityType_Returns_Relation() { - Relation target = new Relation(100); - - Assert.Equal(EntityType.Relation, target.EntityType); - } - - } -} +using System; +using System.Collections.Generic; + +using Xunit; +using Moq; + +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm; + +namespace Tests.SpatialLite.Osm.Geometries +{ + public class RelationTests + { + RelationInfo _relationEmptyInfo = new RelationInfo(100, new TagsCollection(), new List(), new EntityMetadata()); + RelationInfo _relationInfo = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); + + IEntityCollection _nodesEntityCollection; + + public RelationTests() + { + Mock> _nodesCollectionM = new Mock>(); + _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); + _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); + + _nodesEntityCollection = _nodesCollectionM.Object; + } + + [Fact] + public void Constructor_int_CreatesNewRelationAndInitializesProperties() + { + int id = 11; + Relation target = new Relation(id); + + Assert.Equal(id, target.ID); + Assert.Empty(target.Tags); + Assert.Empty(target.Geometries); + } + + [Fact] + public void Constructor_int_IEnumerable_CreatesRelationWithMembersAndInitializesProperties() + { + int id = 11; + var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; + Relation target = new Relation(id, members); + + Assert.Equal(id, target.ID); + Assert.Equal(members.Length, target.Geometries.Count); + for (int i = 0; i < members.Length; i++) + { + Assert.Same(members[i], target.Geometries[i]); + } + + Assert.Empty(target.Tags); + } + + [Fact] + public void Constructor_int_tags_CreatesRelationAndIntializesProperties() + { + int id = 11; + var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; + TagsCollection tags = new TagsCollection(); + Relation target = new Relation(id, members, tags); + + Assert.Equal(id, target.ID); + Assert.Equal(members.Length, target.Geometries.Count); + for (int i = 0; i < members.Length; i++) + { + Assert.Same(members[i], target.Geometries[i]); + } + + Assert.Same(tags, target.Tags); + } + + [Fact] + public void FromRelationInfo_SetsRelationProperties() + { + Relation target = Relation.FromRelationInfo(_relationEmptyInfo, _nodesEntityCollection, true); + + Assert.Equal(_relationEmptyInfo.ID, target.ID); + Assert.Same(_relationEmptyInfo.Tags, target.Tags); + Assert.Same(_relationEmptyInfo.Metadata, target.Metadata); + } + + [Fact] + public void FromRelationInfo_SetsRelationMembers() + { + Relation target = Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true); + + Assert.Single(target.Geometries); + Assert.Equal(_relationInfo.Members[0].Reference, target.Geometries[0].Member.ID); + } + + [Fact] + public void FromRelationInfo_ThrowExceptionIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsTrue() + { + _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; + + Assert.Throws(() => Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true)); + } + + [Fact] + public void FromRelationInfo_ReturnsNullIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsFalse() + { + _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; + + Assert.Null(Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, false)); + } + + [Fact] + public void EntityType_Returns_Relation() + { + Relation target = new Relation(100); + + Assert.Equal(EntityType.Relation, target.EntityType); + } + + } +} diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs index 973d609..2d9e7e1 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs @@ -1,83 +1,95 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using Xunit; - -using SpatialLite.Core.API; -using SpatialLite.Osm.Geometries; - -namespace Tests.SpatialLite.Osm.Geometries { - public class WayCoordinateListTests { - List _nodes = new List(new Node[] { - new Node(5, 1.1, 2.2), - new Node(6, 10.1, -20.2), - new Node(7, -30.1, 40.2) }); - - - [Fact] - public void Constructor_Source_SetsSource() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Same(_nodes, target.Source); - } - - [Fact] - public void Indexer_Get_ReturnsCoordinatesFromSourceList() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - for (int i = 0; i < _nodes.Count; i++) { - Assert.Equal(_nodes[i].Position, target[i]); - } - } - - [Fact] - public void Indexer_Set_ThrowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); - } - - [Fact] - public void Count_GetsNumberOfItemsInSourceCollection() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Equal(_nodes.Count, target.Count); - } - - [Fact] - public void Add_Coordinate_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Throws(() => target.Add(Coordinate.Empty)); - } - - [Fact] - public void Add_Coordinates_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); - } - - [Fact] - public void Insert_Index_Coordinate_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Throws(() => target.Insert(0, Coordinate.Empty)); - } - - [Fact] - public void RemoveAt_Index_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Throws(() => target.RemoveAt(0)); - } - - [Fact] - public void Clear_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); - - Assert.Throws(() => target.Clear()); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; + +using Xunit; + +using SpatialLite.Core.API; +using SpatialLite.Osm.Geometries; + +namespace Tests.SpatialLite.Osm.Geometries +{ + public class WayCoordinateListTests + { + List _nodes = new List(new Node[] { + new Node(5, 1.1, 2.2), + new Node(6, 10.1, -20.2), + new Node(7, -30.1, 40.2) }); + + + [Fact] + public void Constructor_Source_SetsSource() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Same(_nodes, target.Source); + } + + [Fact] + public void Indexer_Get_ReturnsCoordinatesFromSourceList() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + for (int i = 0; i < _nodes.Count; i++) + { + Assert.Equal(_nodes[i].Position, target[i]); + } + } + + [Fact] + public void Indexer_Set_ThrowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); + } + + [Fact] + public void Count_GetsNumberOfItemsInSourceCollection() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Equal(_nodes.Count, target.Count); + } + + [Fact] + public void Add_Coordinate_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Throws(() => target.Add(Coordinate.Empty)); + } + + [Fact] + public void Add_Coordinates_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); + } + + [Fact] + public void Insert_Index_Coordinate_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Throws(() => target.Insert(0, Coordinate.Empty)); + } + + [Fact] + public void RemoveAt_Index_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Throws(() => target.RemoveAt(0)); + } + + [Fact] + public void Clear_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); + + Assert.Throws(() => target.Clear()); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs index 491cf72..62d6b6f 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs @@ -9,19 +9,22 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.Geometries { - public class WayTests { - List _nodes = new List(new Node[] { - new Node(1, 1.1, 2.2), - new Node(2, 10.1, -20.2), - new Node(3, -30.1, 40.2) }); +namespace Tests.SpatialLite.Osm.Geometries +{ + public class WayTests + { + List _nodes = new List(new Node[] { + new Node(1, 1.1, 2.2), + new Node(2, 10.1, -20.2), + new Node(3, -30.1, 40.2) }); WayInfo _wayEmptyInfo = new WayInfo(10, new TagsCollection(), new List(), new EntityMetadata()); WayInfo _wayInfo = new WayInfo(10, new TagsCollection(), new long[] { 1, 2, 3 }, new EntityMetadata()); IEntityCollection _nodesEntityCollection; - public WayTests() { + public WayTests() + { Mock> _nodesCollectionM = new Mock>(); _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(_nodes[0]); _nodesCollectionM.SetupGet(c => c[2, EntityType.Node]).Returns(_nodes[1]); @@ -30,7 +33,8 @@ public WayTests() { } [Fact] - public void Constructor_ID_CreatesNewEmptyWayAndInitializesProperties() { + public void Constructor_ID_CreatesNewEmptyWayAndInitializesProperties() + { int id = 11; Way target = new Way(id); @@ -42,13 +46,15 @@ public void Constructor_ID_CreatesNewEmptyWayAndInitializesProperties() { } [Fact] - public void Constructor_ID_Nodes_CreatesWayAddsNodesAndInitializesProperties() { + public void Constructor_ID_Nodes_CreatesWayAddsNodesAndInitializesProperties() + { int id = 11; Way target = new Way(id, _nodes); Assert.Equal(id, target.ID); Assert.Equal(_nodes.Count, target.Nodes.Count); - for (int i = 0; i < _nodes.Count; i++) { + for (int i = 0; i < _nodes.Count; i++) + { Assert.Same(_nodes[i], target.Nodes[i]); } @@ -57,7 +63,8 @@ public void Constructor_ID_Nodes_CreatesWayAddsNodesAndInitializesProperties() { } [Fact] - public void Constructor_ID_Nodes_Tags_CreatesWayAddsNodesAndInitializesProperties() { + public void Constructor_ID_Nodes_Tags_CreatesWayAddsNodesAndInitializesProperties() + { int id = 11; TagsCollection tags = new TagsCollection(); @@ -65,7 +72,8 @@ public void Constructor_ID_Nodes_Tags_CreatesWayAddsNodesAndInitializesPropertie Assert.Equal(id, target.ID); Assert.Equal(_nodes.Count, target.Nodes.Count); - for (int i = 0; i < _nodes.Count; i++) { + for (int i = 0; i < _nodes.Count; i++) + { Assert.Same(_nodes[i], target.Nodes[i]); } @@ -74,7 +82,8 @@ public void Constructor_ID_Nodes_Tags_CreatesWayAddsNodesAndInitializesPropertie } [Fact] - public void FromWayInfo_SetsProperties() { + public void FromWayInfo_SetsProperties() + { Way target = Way.FromWayInfo(_wayEmptyInfo, _nodesEntityCollection, true); Assert.Equal(_wayEmptyInfo.ID, target.ID); @@ -84,65 +93,75 @@ public void FromWayInfo_SetsProperties() { } [Fact] - public void FromWayInfo_SetsNodes() { + public void FromWayInfo_SetsNodes() + { Way target = Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true); Assert.Equal(_wayInfo.Nodes.Count, target.Nodes.Count); - for (int i = 0; i < _wayInfo.Nodes.Count; i++) { + for (int i = 0; i < _wayInfo.Nodes.Count; i++) + { Assert.Equal(_wayInfo.Nodes[i], target.Nodes[i].ID); } } [Fact] - public void FromWayInfo_ThrowsArgumentExceptionIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsTrue() { + public void FromWayInfo_ThrowsArgumentExceptionIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsTrue() + { _wayInfo.Nodes[0] = 10000; Assert.Throws(() => Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true)); } [Fact] - public void FromWayInfo_ReturnsNullIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsFalse() { + public void FromWayInfo_ReturnsNullIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsFalse() + { _wayInfo.Nodes[0] = 10000; Assert.Null(Way.FromWayInfo(_wayInfo, _nodesEntityCollection, false)); } - [Fact] - public void WhenWayIsInitializedFromWayInfo_CoordinatesReturnsNodesCoordinates() { - Way target = Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true); + [Fact] + public void WhenWayIsInitializedFromWayInfo_CoordinatesReturnsNodesCoordinates() + { + Way target = Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true); - Assert.Equal(_wayInfo.Nodes.Count, target.Nodes.Count); + Assert.Equal(_wayInfo.Nodes.Count, target.Nodes.Count); - Assert.Equal(_nodes[0].Position, target.Coordinates[0]); - Assert.Equal(_nodes[0].Position, target.Coordinates[0]); - Assert.Equal(_nodes[0].Position, target.Coordinates[0]); - } + Assert.Equal(_nodes[0].Position, target.Coordinates[0]); + Assert.Equal(_nodes[0].Position, target.Coordinates[0]); + Assert.Equal(_nodes[0].Position, target.Coordinates[0]); + } [Fact] - public void Coordinates_GetsPositionOfNodes() { + public void Coordinates_GetsPositionOfNodes() + { int id = 11; Way target = new Way(id, _nodes); Assert.Equal(_nodes.Count, target.Coordinates.Count); - for (int i = 0; i < _nodes.Count; i++) { + for (int i = 0; i < _nodes.Count; i++) + { Assert.Equal(_nodes[i].Position, target.Coordinates[i]); } } [Fact] - public void Coordinates_GetsPositionOfNodesIfWayCastedToLineString() { + public void Coordinates_GetsPositionOfNodesIfWayCastedToLineString() + { int id = 11; Way way = new Way(id, _nodes); LineString target = (LineString)way; Assert.Equal(_nodes.Count, target.Coordinates.Count); - for (int i = 0; i < _nodes.Count; i++) { + for (int i = 0; i < _nodes.Count; i++) + { Assert.Equal(_nodes[i].Position, target.Coordinates[i]); } } [Fact] - public void EntityType_Returns_Way() { + public void EntityType_Returns_Way() + { Way target = new Way(10); Assert.Equal(EntityType.Way, target.EntityType); diff --git a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs index bc5296b..6cf603f 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs @@ -1,24 +1,28 @@ -using System; - -using Xunit; - -using SpatialLite.Osm.IO; - -namespace Tests.SpatialLite.Osm.IO { - public class OsmReaderSettingsTests { - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() { - OsmReaderSettings target = new OsmReaderSettings(); - - Assert.True(target.ReadMetadata); - } - - [Fact] - public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - OsmReaderSettings target = new OsmReaderSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.ReadMetadata = true); - } - } -} +using System; + +using Xunit; + +using SpatialLite.Osm.IO; + +namespace Tests.SpatialLite.Osm.IO +{ + public class OsmReaderSettingsTests + { + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() + { + OsmReaderSettings target = new OsmReaderSettings(); + + Assert.True(target.ReadMetadata); + } + + [Fact] + public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + OsmReaderSettings target = new OsmReaderSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.ReadMetadata = true); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs index 0c31851..094ee8d 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs @@ -1,32 +1,37 @@ -using System; - -using Xunit; - -using SpatialLite.Osm.IO; - -namespace Tests.SpatialLite.Osm.IO { - public class OsmWriterSettingsTests { - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() { - OsmWriterSettings target = new OsmWriterSettings(); - - Assert.True(target.WriteMetadata); - } - - [Fact] - public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - OsmWriterSettings target = new OsmWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.WriteMetadata = true); - } - - [Fact] - public void ProgramNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - OsmWriterSettings target = new OsmWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.ProgramName = "TEST"); - } - } -} +using System; + +using Xunit; + +using SpatialLite.Osm.IO; + +namespace Tests.SpatialLite.Osm.IO +{ + public class OsmWriterSettingsTests + { + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() + { + OsmWriterSettings target = new OsmWriterSettings(); + + Assert.True(target.WriteMetadata); + } + + [Fact] + public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + OsmWriterSettings target = new OsmWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.WriteMetadata = true); + } + + [Fact] + public void ProgramNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + OsmWriterSettings target = new OsmWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.ProgramName = "TEST"); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs index 47568a3..a1fee68 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs @@ -8,353 +8,401 @@ using SpatialLite.Osm; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.IO { - public class OsmXmlReaderTests { - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationTags, _relationProperties, _relationWithoutMembers; - - public OsmXmlReaderTests() { - _details = new EntityMetadata() { - Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), - Uid = 127998, - User = "Luk@s", - Visible = true, - Version = 2, - Changeset = 6410629 - }; - - _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(2, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); - _nodeProperties = new NodeInfo(3, 50.4, 16.2, new TagsCollection(), _details); - - _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); - _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); - _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); - _relationTags = new RelationInfo( - 2, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); - _relationWithoutMembers = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { }); - } - - [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() { - Assert.Throws(delegate { new OsmXmlReader("non-existing-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false }); }); - } - - [Fact] - public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() { - string path = "../../../Data/Xml/osm-real-file.osm"; - OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; - using (OsmXmlReader target = new OsmXmlReader(path, settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() { - OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; - using (OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Read_SkipsUnknownElements() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-unknown-inner-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - IEntityInfo result = target.Read(); - - Assert.NotNull(result as NodeInfo); - } - - //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation - [Fact] - public void Read_ThrowsExceptionIfTagHasNotKey() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-key.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation - [Fact] - public void Read_ThrowsExceptionIfTagHasNotValue() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-value.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); - target.Read(); - } - - [Fact] - public void Read_ThrowsExceptionIfNodeHasNotID() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ThrowsExceptionIfNodeHasNotLat() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lat.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ThrowsExceptionIfNodeHasNotLon() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ReadsSimpleNode() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; - - this.CompareNodes(_node, readNode); - } - - [Fact] - public void Read_ReadsNodeWithUnknownElement() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tag-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; - - this.CompareNodes(_node, readNode); - - // nothing more left to read in the file - Assert.Null(target.Read()); - } - - [Fact] - public void Read_ReadsNodeWithTags() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; - - this.CompareNodes(_nodeTags, readNode); - } - - [Fact] - public void Read_ReadsNodeWithAllAttributes() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - NodeInfo readNode = target.Read() as NodeInfo; - - this.CompareNodes(_nodeProperties, readNode); - } - - [Fact] - public void Read_ThrowsExceptionIfWayHasNotID() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ThrowsExceptionIfWayNDHasNotRef() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ReadsWayWithoutNodes() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-without-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; - - this.CompareWays(_wayWithoutNodes, readWay); - } - - [Fact] - public void Read_ReadsSimpleWay() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; - - this.CompareWays(_way, readWay); - } - - [Fact] - public void Read_ReadsWayWithTags() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; - - this.CompareWays(_wayTags, readWay); - } - - [Fact] - public void Read_ReadsWayWithUnknownElement() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; - - this.CompareWays(_wayTags, readWay); - } - - [Fact] - public void Read_ReadsWayWithAllAttributes() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - WayInfo readWay = target.Read() as WayInfo; - - this.CompareWays(_wayProperties, readWay); - } - - [Fact] - public void Read_ThrowsExceptionIfRelationHasNotID() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ThrowsExceptionIfRelationMemberHasNotRef() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ThrowsExceptionIfRelationMemberHasNotType() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - - Assert.Throws(() => target.Read()); - } - - [Fact] - public void Read_ReadsRelationWithoutMembers() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-members.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; - - this.CompareRelation(_relationWithoutMembers, readRelation); - } - - [Fact] - public void Read_ReadsRelationWithNodeMember() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; - - this.CompareRelation(_relationNode, readRelation); - } - - [Fact] - public void Read_ReadsRelationWithWayMember() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; - - this.CompareRelation(_relationWay, readRelation); - } - - [Fact] - public void Read_ReadsRelationWithRelationMember() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; - - this.CompareRelation(_relationRelation, readRelation); - } - - [Fact] - public void Read_ReadsRelationWithTags() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; - - this.CompareRelation(_relationTags, readRelation); - } - - [Fact] - public void Read_ReadsRelationWithTagsAndUnknownElement() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; - - this.CompareRelation(_relationTags, readRelation); - } - - [Fact] - public void Read_ReadsRelationWithAllProperties() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - RelationInfo readRelation = target.Read() as RelationInfo; - - this.CompareRelation(_relationProperties, readRelation); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = "../../../Data/Xml/osm-real-file.osm"; - - OsmXmlReader target = new OsmXmlReader(filename, new OsmXmlReaderSettings() { ReadMetadata = false }); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } - - private void CompareNodes(NodeInfo expected, NodeInfo actual) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Longitude, actual.Longitude); - Assert.Equal(expected.Latitude, actual.Latitude); - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } - - private void CompareWays(WayInfo expected, WayInfo actual) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) { - Assert.Equal(expected.Nodes[i], actual.Nodes[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } - - private void CompareRelation(RelationInfo expected, RelationInfo actual) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) { - Assert.Equal(expected.Members[i], actual.Members[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } - - private void CompareTags(TagsCollection expected, TagsCollection actual) { - if (expected == null && actual == null) { - return; - } - - Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); - } - - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) { - if (expected == null && actual == null) { - return; - } - - Assert.Equal(expected.Timestamp, actual.Timestamp); - Assert.Equal(expected.Uid, actual.Uid); - Assert.Equal(expected.User, actual.User); - Assert.Equal(expected.Visible, actual.Visible); - Assert.Equal(expected.Version, actual.Version); - Assert.Equal(expected.Changeset, actual.Changeset); - } - } +namespace Tests.SpatialLite.Osm.IO +{ + public class OsmXmlReaderTests + { + private EntityMetadata _details; + private NodeInfo _node, _nodeTags, _nodeProperties; + private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private RelationInfo _relationNode, _relationWay, _relationRelation, _relationTags, _relationProperties, _relationWithoutMembers; + + public OsmXmlReaderTests() + { + _details = new EntityMetadata() + { + Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), + Uid = 127998, + User = "Luk@s", + Visible = true, + Version = 2, + Changeset = 6410629 + }; + + _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); + _nodeTags = new NodeInfo(2, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeProperties = new NodeInfo(3, 50.4, 16.2, new TagsCollection(), _details); + + _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); + _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); + + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationTags = new RelationInfo( + 2, + new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), + new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + _relationWithoutMembers = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { }); + } + + [Fact] + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() + { + Assert.Throws(delegate { new OsmXmlReader("non-existing-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false }); }); + } + + [Fact] + public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() + { + string path = "../../../Data/Xml/osm-real-file.osm"; + OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; + using (OsmXmlReader target = new OsmXmlReader(path, settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() + { + OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; + using (OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Read_SkipsUnknownElements() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-unknown-inner-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + IEntityInfo result = target.Read(); + + Assert.NotNull(result as NodeInfo); + } + + //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation + [Fact] + public void Read_ThrowsExceptionIfTagHasNotKey() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-key.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation + [Fact] + public void Read_ThrowsExceptionIfTagHasNotValue() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-value.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); + target.Read(); + } + + [Fact] + public void Read_ThrowsExceptionIfNodeHasNotID() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ThrowsExceptionIfNodeHasNotLat() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lat.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ThrowsExceptionIfNodeHasNotLon() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ReadsSimpleNode() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; + + this.CompareNodes(_node, readNode); + } + + [Fact] + public void Read_ReadsNodeWithUnknownElement() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tag-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; + + this.CompareNodes(_node, readNode); + + // nothing more left to read in the file + Assert.Null(target.Read()); + } + + [Fact] + public void Read_ReadsNodeWithTags() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; + + this.CompareNodes(_nodeTags, readNode); + } + + [Fact] + public void Read_ReadsNodeWithAllAttributes() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + NodeInfo readNode = target.Read() as NodeInfo; + + this.CompareNodes(_nodeProperties, readNode); + } + + [Fact] + public void Read_ThrowsExceptionIfWayHasNotID() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ThrowsExceptionIfWayNDHasNotRef() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ReadsWayWithoutNodes() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-without-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; + + this.CompareWays(_wayWithoutNodes, readWay); + } + + [Fact] + public void Read_ReadsSimpleWay() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; + + this.CompareWays(_way, readWay); + } + + [Fact] + public void Read_ReadsWayWithTags() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; + + this.CompareWays(_wayTags, readWay); + } + + [Fact] + public void Read_ReadsWayWithUnknownElement() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; + + this.CompareWays(_wayTags, readWay); + } + + [Fact] + public void Read_ReadsWayWithAllAttributes() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + WayInfo readWay = target.Read() as WayInfo; + + this.CompareWays(_wayProperties, readWay); + } + + [Fact] + public void Read_ThrowsExceptionIfRelationHasNotID() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ThrowsExceptionIfRelationMemberHasNotRef() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ThrowsExceptionIfRelationMemberHasNotType() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + + Assert.Throws(() => target.Read()); + } + + [Fact] + public void Read_ReadsRelationWithoutMembers() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-members.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; + + this.CompareRelation(_relationWithoutMembers, readRelation); + } + + [Fact] + public void Read_ReadsRelationWithNodeMember() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; + + this.CompareRelation(_relationNode, readRelation); + } + + [Fact] + public void Read_ReadsRelationWithWayMember() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; + + this.CompareRelation(_relationWay, readRelation); + } + + [Fact] + public void Read_ReadsRelationWithRelationMember() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; + + this.CompareRelation(_relationRelation, readRelation); + } + + [Fact] + public void Read_ReadsRelationWithTags() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; + + this.CompareRelation(_relationTags, readRelation); + } + + [Fact] + public void Read_ReadsRelationWithTagsAndUnknownElement() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; + + this.CompareRelation(_relationTags, readRelation); + } + + [Fact] + public void Read_ReadsRelationWithAllProperties() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + RelationInfo readRelation = target.Read() as RelationInfo; + + this.CompareRelation(_relationProperties, readRelation); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/Xml/osm-real-file.osm"; + + OsmXmlReader target = new OsmXmlReader(filename, new OsmXmlReaderSettings() { ReadMetadata = false }); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } + + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Longitude, actual.Longitude); + Assert.Equal(expected.Latitude, actual.Latitude); + + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareWays(WayInfo expected, WayInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); + for (int i = 0; i < expected.Nodes.Count; i++) + { + Assert.Equal(expected.Nodes[i], actual.Nodes[i]); + } + + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Members.Count, actual.Members.Count); + for (int i = 0; i < expected.Members.Count; i++) + { + Assert.Equal(expected.Members[i], actual.Members[i]); + } + + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { + return; + } + + Assert.Equal(expected.Count, actual.Count); + Assert.True(expected.All(tag => actual.Contains(tag))); + } + + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) + { + return; + } + + Assert.Equal(expected.Timestamp, actual.Timestamp); + Assert.Equal(expected.Uid, actual.Uid); + Assert.Equal(expected.User, actual.User); + Assert.Equal(expected.Visible, actual.Visible); + Assert.Equal(expected.Version, actual.Version); + Assert.Equal(expected.Changeset, actual.Changeset); + } + } } diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs index 461de99..17ed6f2 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs @@ -9,8 +9,10 @@ using SpatialLite.Osm.IO; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.IO { - public class OsmXmlWriterTests { +namespace Tests.SpatialLite.Osm.IO +{ + public class OsmXmlWriterTests + { //resolution for default granularity private const double _resolution = 1E-07; @@ -19,8 +21,10 @@ public class OsmXmlWriterTests { private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; - public OsmXmlWriterTests() { - _details = new EntityMetadata() { + public OsmXmlWriterTests() + { + _details = new EntityMetadata() + { Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), Uid = 127998, User = "Luk@s", @@ -49,32 +53,38 @@ public OsmXmlWriterTests() { } [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesThemReadOnly() { + public void Constructor_StreamSettings_SetsSettingsAndMakesThemReadOnly() + { MemoryStream stream = new MemoryStream(); OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, settings)) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, settings)) + { Assert.Same(settings, target.Settings); Assert.True(target.Settings.IsReadOnly); } } [Fact] - public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() { + public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() + { string path = PathHelper.GetTempFilePath("xmlwriter-constructor-test.osm"); OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(path, settings)) { + using (OsmXmlWriter target = new OsmXmlWriter(path, settings)) + { Assert.Same(settings, target.Settings); Assert.True(target.Settings.IsReadOnly); } } [Fact] - public void Constructor_PathSettings_CreatesOutputFile() { + public void Constructor_PathSettings_CreatesOutputFile() + { string filename = PathHelper.GetTempFilePath("osmwriter-constructor-creates-output-test.pbf"); OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(filename, settings)) { + using (OsmXmlWriter target = new OsmXmlWriter(filename, settings)) + { ; } @@ -82,7 +92,8 @@ public void Constructor_PathSettings_CreatesOutputFile() { } [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { string path = PathHelper.GetTempFilePath("xmlwriter-closes-output-filestream-test.osm"); OsmXmlWriter target = new OsmXmlWriter(path, new OsmWriterSettings()); @@ -94,29 +105,35 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { } [Fact] - public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() { + public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + { Assert.Throws(() => target.Write(_node)); } } [Fact] - public void Write_DoesNotThrowsExceptionIfMetadataContainsNullInsteadUsername() { + public void Write_DoesNotThrowsExceptionIfMetadataContainsNullInsteadUsername() + { MemoryStream stream = new MemoryStream(); _nodeProperties.Metadata.User = null; - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + { target.Write(_nodeProperties); } } [Fact] - public void Write_IEntityInfo_WritesNode() { + public void Write_IEntityInfo_WritesNode() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_node); } @@ -124,10 +141,12 @@ public void Write_IEntityInfo_WritesNode() { } [Fact] - public void Write_IEntityInfo_WritesNodeWithTags() { + public void Write_IEntityInfo_WritesNodeWithTags() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_nodeTags); } @@ -135,10 +154,12 @@ public void Write_IEntityInfo_WritesNodeWithTags() { } [Fact] - public void Write_IEntityInfo_WritesNodeWithMetadata() { + public void Write_IEntityInfo_WritesNodeWithMetadata() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + { target.Write(_nodeProperties); } @@ -146,28 +167,34 @@ public void Write_IEntityInfo_WritesNodeWithMetadata() { } [Fact] - public void Write_IEntityInfo_DoesntWriteNodeMetadataIfWriteMedataIsFalse() { + public void Write_IEntityInfo_DoesntWriteNodeMetadataIfWriteMedataIsFalse() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_nodeProperties); } stream = new MemoryStream(stream.ToArray()); - using (TextReader reader = new StreamReader(stream)) { + using (TextReader reader = new StreamReader(stream)) + { string line = null; - while ((line = reader.ReadLine()) != null) { + while ((line = reader.ReadLine()) != null) + { Assert.DoesNotContain("timestamp", line); } } } [Fact] - public void Write_IEntityInfo_WritesWay() { + public void Write_IEntityInfo_WritesWay() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_way); } @@ -175,10 +202,12 @@ public void Write_IEntityInfo_WritesWay() { } [Fact] - public void Write_IEntityInfo_WritesWayWithTags() { + public void Write_IEntityInfo_WritesWayWithTags() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_wayTags); } @@ -186,10 +215,12 @@ public void Write_IEntityInfo_WritesWayWithTags() { } [Fact] - public void Write_IEntityInfo_WritesWayWithMetadata() { + public void Write_IEntityInfo_WritesWayWithMetadata() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + { target.Write(_wayProperties); } @@ -197,28 +228,34 @@ public void Write_IEntityInfo_WritesWayWithMetadata() { } [Fact] - public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMedataIsFalse() { + public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMedataIsFalse() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_wayProperties); } stream = new MemoryStream(stream.ToArray()); - using (TextReader reader = new StreamReader(stream)) { + using (TextReader reader = new StreamReader(stream)) + { string line = null; - while ((line = reader.ReadLine()) != null) { + while ((line = reader.ReadLine()) != null) + { Assert.DoesNotContain("timestamp", line); } } } [Fact] - public void Write_IEntityInfo_WritesRelationWithNode() { + public void Write_IEntityInfo_WritesRelationWithNode() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_relationNode); } @@ -226,10 +263,12 @@ public void Write_IEntityInfo_WritesRelationWithNode() { } [Fact] - public void Write_IEntityInfo_WritesRelationWithWay() { + public void Write_IEntityInfo_WritesRelationWithWay() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_relationWay); } @@ -237,10 +276,12 @@ public void Write_IEntityInfo_WritesRelationWithWay() { } [Fact] - public void Write_IEntityInfo_WritesRelationWithRelation() { + public void Write_IEntityInfo_WritesRelationWithRelation() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_relationRelation); } @@ -248,10 +289,12 @@ public void Write_IEntityInfo_WritesRelationWithRelation() { } [Fact] - public void Write_IEntityInfo_WritesRelationWithTags() { + public void Write_IEntityInfo_WritesRelationWithTags() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_relationTags); } @@ -259,10 +302,12 @@ public void Write_IEntityInfo_WritesRelationWithTags() { } [Fact] - public void Write_IEntityInfo_WritesRelationWithMetadata() { + public void Write_IEntityInfo_WritesRelationWithMetadata() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + { target.Write(_relationNodeProperties); } @@ -270,30 +315,36 @@ public void Write_IEntityInfo_WritesRelationWithMetadata() { } [Fact] - public void Write_IEntityInfo_DoesntWriteRelationMetadataIfWriteMedataIsFalse() { + public void Write_IEntityInfo_DoesntWriteRelationMetadataIfWriteMedataIsFalse() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(_relationNodeProperties); } stream = new MemoryStream(stream.ToArray()); - using (TextReader reader = new StreamReader(stream)) { + using (TextReader reader = new StreamReader(stream)) + { string line = null; - while ((line = reader.ReadLine()) != null) { + while ((line = reader.ReadLine()) != null) + { Assert.DoesNotContain("timestamp", line); } } } [Fact] - public void Write_IOsmGeometry_WritesNode() { + public void Write_IOsmGeometry_WritesNode() + { Node node = new Node(1, 11.1, 12.1); MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(node); } @@ -301,12 +352,14 @@ public void Write_IOsmGeometry_WritesNode() { } [Fact] - public void Write_IOsmGeometry_WritesWay() { + public void Write_IOsmGeometry_WritesWay() + { Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(way); } @@ -314,12 +367,14 @@ public void Write_IOsmGeometry_WritesWay() { } [Fact] - public void Write_IOsmGeometry_WritesRelation() { + public void Write_IOsmGeometry_WritesRelation() + { Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { target.Write(relation); } @@ -327,33 +382,41 @@ public void Write_IOsmGeometry_WritesRelation() { } [Fact] - public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() { + public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() + { MemoryStream stream = new MemoryStream(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { IOsmGeometry entity = null; Assert.Throws(() => target.Write(entity)); } } - private void TestXmlOutput(MemoryStream xmlStream, IEntityInfo expected, bool readMetadata) { - if (xmlStream.CanSeek) { + private void TestXmlOutput(MemoryStream xmlStream, IEntityInfo expected, bool readMetadata) + { + if (xmlStream.CanSeek) + { xmlStream.Seek(0, SeekOrigin.Begin); - } else { + } + else + { xmlStream = new MemoryStream(xmlStream.ToArray()); } OsmXmlReader reader = new OsmXmlReader(xmlStream, new OsmXmlReaderSettings() { ReadMetadata = readMetadata }); IEntityInfo read = reader.Read(); - switch (expected.EntityType) { + switch (expected.EntityType) + { case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; } } - private void CompareNodes(NodeInfo expected, NodeInfo actual) { + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { Assert.Equal(expected.ID, actual.ID); Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); @@ -362,10 +425,12 @@ private void CompareNodes(NodeInfo expected, NodeInfo actual) { this.CompareEntityDetails(expected.Metadata, actual.Metadata); } - private void CompareWays(WayInfo expected, WayInfo actual) { + private void CompareWays(WayInfo expected, WayInfo actual) + { Assert.Equal(expected.ID, actual.ID); Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) { + for (int i = 0; i < expected.Nodes.Count; i++) + { Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } @@ -373,10 +438,12 @@ private void CompareWays(WayInfo expected, WayInfo actual) { this.CompareEntityDetails(expected.Metadata, actual.Metadata); } - private void CompareRelation(RelationInfo expected, RelationInfo actual) { + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { Assert.Equal(expected.ID, actual.ID); Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) { + for (int i = 0; i < expected.Members.Count; i++) + { Assert.Equal(expected.Members[i], actual.Members[i]); } @@ -384,8 +451,10 @@ private void CompareRelation(RelationInfo expected, RelationInfo actual) { this.CompareEntityDetails(expected.Metadata, actual.Metadata); } - private void CompareTags(TagsCollection expected, TagsCollection actual) { - if (expected == null && actual == null) { + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { return; } @@ -393,8 +462,10 @@ private void CompareTags(TagsCollection expected, TagsCollection actual) { Assert.True(expected.All(tag => actual.Contains(tag))); } - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) { - if (expected == null && actual == null) { + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) + { return; } @@ -408,7 +479,8 @@ private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual Assert.Equal(expected.Changeset, actual.Changeset); } - private void CheckNode(XElement element) { + private void CheckNode(XElement element) + { Assert.Equal("15", element.Attribute("id").Value); Assert.Equal("46.8", element.Attribute("lon").Value); Assert.Equal("-15.6", element.Attribute("lat").Value); @@ -418,7 +490,8 @@ private void CheckNode(XElement element) { Assert.Equal("survey", tagE.Attribute("v").Value); } - private void CheckWay(XElement element) { + private void CheckWay(XElement element) + { Assert.Equal("25", element.Attribute("id").Value); var nodesElement = element.Elements("nd"); @@ -432,7 +505,8 @@ private void CheckWay(XElement element) { Assert.Equal("survey", tagE.Attribute("v").Value); } - private void CheckRelation(XElement element) { + private void CheckRelation(XElement element) + { Assert.Equal("25", element.Attribute("id").Value); XElement tagE = element.Elements("tag").Single(); @@ -440,15 +514,19 @@ private void CheckRelation(XElement element) { Assert.Equal("survey", tagE.Attribute("v").Value); } - private void CheckOsmDetails(EntityMetadata details, XElement element) { - if (details == null) { + private void CheckOsmDetails(EntityMetadata details, XElement element) + { + if (details == null) + { Assert.Null(element.Attribute("version")); Assert.Null(element.Attribute("changeset")); Assert.Null(element.Attribute("uid")); Assert.Null(element.Attribute("user")); Assert.Null(element.Attribute("visible")); Assert.Null(element.Attribute("timestamp")); - } else { + } + else + { Assert.Equal("2", element.Attribute("version").Value); Assert.Equal("123", element.Attribute("changeset").Value); Assert.Equal("4587", element.Attribute("uid").Value); diff --git a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs index 5128540..4b060bb 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs @@ -8,8 +8,10 @@ using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.IO { - public class PbfReaderTests { +namespace Tests.SpatialLite.Osm.IO +{ + public class PbfReaderTests + { //resolution for default granularity private const double _resolution = 1E-07; @@ -18,8 +20,10 @@ public class PbfReaderTests { private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; private RelationInfo _relationNode, _relationWay, _relationRelation, _relationProperties, _relationTags; - public PbfReaderTests() { - _details = new EntityMetadata() { + public PbfReaderTests() + { + _details = new EntityMetadata() + { Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), Uid = 127998, User = "Luk@s", @@ -48,58 +52,68 @@ public PbfReaderTests() { } [Fact] - public void Constructor_StreamSettings_ThrowsExceptionIfStreamDoesntContainOSMHeaderBeforeOSMData() { + public void Constructor_StreamSettings_ThrowsExceptionIfStreamDoesntContainOSMHeaderBeforeOSMData() + { var dataStream = TestDataReader.OpenPbf("pbf-without-osm-header.pbf"); Assert.Throws(() => new PbfReader(dataStream, new OsmReaderSettings() { ReadMetadata = false })); } [Fact] - public void Constructor_StreamSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() { + public void Constructor_StreamSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() + { var dataStream = TestDataReader.OpenPbf("pbf-unsupported-required-feature.pbf"); Assert.Throws(() => new PbfReader(dataStream, new OsmReaderSettings() { ReadMetadata = false })); } [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesThemIsReadOnly() { + public void Constructor_StreamSettings_SetsSettingsAndMakesThemIsReadOnly() + { var dataStream = TestDataReader.OpenPbf("pbf-n-node.pbf"); OsmReaderSettings settings = new OsmReaderSettings(); - using (PbfReader target = new PbfReader(dataStream, settings)) { + using (PbfReader target = new PbfReader(dataStream, settings)) + { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); } } [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() { + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() + { Assert.Throws(delegate { new PbfReader("non-existing-file.pbf", new OsmReaderSettings() { ReadMetadata = false }); }); } [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesntContainOSMHeaderBeforeOSMData() { + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesntContainOSMHeaderBeforeOSMData() + { string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-without-osm-header.pbf"); Assert.Throws(() => new PbfReader(filename, new OsmReaderSettings() { ReadMetadata = false })); } [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() { + public void Constructor_StringSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() + { string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-unsupported-required-feature.pbf"); Assert.Throws(() => new PbfReader(filename, new OsmReaderSettings() { ReadMetadata = false })); } [Fact] - public void Constructor_StringSettings_SetsSettingsAndMakesThemIsReadOnly() { - string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); + public void Constructor_StringSettings_SetsSettingsAndMakesThemIsReadOnly() + { + string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); OsmReaderSettings settings = new OsmReaderSettings(); - using (PbfReader target = new PbfReader(filename, settings)) { + using (PbfReader target = new PbfReader(filename, settings)) + { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); } } [Fact] - public void Read_ReturnsNullIfAllEntitiesHaveBeenRead() { + public void Read_ReturnsNullIfAllEntitiesHaveBeenRead() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); //read only entity IEntityInfo read = target.Read(); @@ -110,17 +124,20 @@ public void Read_ReturnsNullIfAllEntitiesHaveBeenRead() { } [Fact] - public void Read_ThrowInvalidDataExceptionIfHeaderBlockSizeExceedesAllowdValue() { + public void Read_ThrowInvalidDataExceptionIfHeaderBlockSizeExceedesAllowdValue() + { Assert.Throws(() => new PbfReader(TestDataReader.OpenPbf("pbf-too-large-header-block.pbf"), new OsmReaderSettings() { ReadMetadata = false })); } [Fact] - public void Read_ThrowInvalidDataExceptionIfOsmDataBlockSizeExceedesAllowdValue() { + public void Read_ThrowInvalidDataExceptionIfOsmDataBlockSizeExceedesAllowdValue() + { Assert.Throws(() => new PbfReader(TestDataReader.OpenPbf("pbf-too-large-data-block.pbf"), new OsmReaderSettings() { ReadMetadata = false })); } [Fact] - public void Read_ReadsNode_DenseNoCompression() { + public void Read_ReadsNode_DenseNoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; @@ -128,7 +145,8 @@ public void Read_ReadsNode_DenseNoCompression() { } [Fact] - public void Read_ReadsNodeWithTags_DenseNoCompression() { + public void Read_ReadsNodeWithTags_DenseNoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; @@ -136,7 +154,8 @@ public void Read_ReadsNodeWithTags_DenseNoCompression() { } [Fact] - public void Read_ReadsNodeWithMetadata_DenseNoCompression() { + public void Read_ReadsNodeWithMetadata_DenseNoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); NodeInfo readNode = target.Read() as NodeInfo; @@ -144,7 +163,8 @@ public void Read_ReadsNodeWithMetadata_DenseNoCompression() { } [Fact] - public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_DenseNoCompression() { + public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_DenseNoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; @@ -152,7 +172,8 @@ public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_DenseNoCompression() } [Fact] - public void Read_ReadsNode_NoCompression() { + public void Read_ReadsNode_NoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; @@ -160,7 +181,8 @@ public void Read_ReadsNode_NoCompression() { } [Fact] - public void Read_ReadsNodeWithTags_NoCompression() { + public void Read_ReadsNodeWithTags_NoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; @@ -168,7 +190,8 @@ public void Read_ReadsNodeWithTags_NoCompression() { } [Fact] - public void Read_ReadsNodeWithMetadata_NoCompression() { + public void Read_ReadsNodeWithMetadata_NoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); NodeInfo readNode = target.Read() as NodeInfo; @@ -176,7 +199,8 @@ public void Read_ReadsNodeWithMetadata_NoCompression() { } [Fact] - public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression() { + public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; @@ -184,7 +208,8 @@ public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression() { } [Fact] - public void Read_ReadsWay_NoCompresion() { + public void Read_ReadsWay_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; @@ -192,7 +217,8 @@ public void Read_ReadsWay_NoCompresion() { } [Fact] - public void Read_ReadsWayWithTags_NoCompresion() { + public void Read_ReadsWayWithTags_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; @@ -200,7 +226,8 @@ public void Read_ReadsWayWithTags_NoCompresion() { } [Fact] - public void Read_ReadsWayWithMetadata_NoCompresion() { + public void Read_ReadsWayWithMetadata_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); WayInfo readWay = target.Read() as WayInfo; @@ -208,7 +235,8 @@ public void Read_ReadsWayWithMetadata_NoCompresion() { } [Fact] - public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion() { + public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; @@ -216,7 +244,8 @@ public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion() { } [Fact] - public void Read_ReadsWayWithoutNodes_NoCompresion() { + public void Read_ReadsWayWithoutNodes_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-without-nodes.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; @@ -224,7 +253,8 @@ public void Read_ReadsWayWithoutNodes_NoCompresion() { } [Fact] - public void Read_ReadsRelationWithNode_NoCompresion() { + public void Read_ReadsRelationWithNode_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; @@ -232,7 +262,8 @@ public void Read_ReadsRelationWithNode_NoCompresion() { } [Fact] - public void Read_ReadsRelationWithWay_NoCompresion() { + public void Read_ReadsRelationWithWay_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; @@ -240,7 +271,8 @@ public void Read_ReadsRelationWithWay_NoCompresion() { } [Fact] - public void Read_ReadsRelationWithRelation_NoCompresion() { + public void Read_ReadsRelationWithRelation_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-relation.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; @@ -248,7 +280,8 @@ public void Read_ReadsRelationWithRelation_NoCompresion() { } [Fact] - public void Read_ReadsRelationWithTags_NoCompresion() { + public void Read_ReadsRelationWithTags_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; @@ -256,7 +289,8 @@ public void Read_ReadsRelationWithTags_NoCompresion() { } [Fact] - public void Read_ReadsRelationWithAllProperties_NoCompresion() { + public void Read_ReadsRelationWithAllProperties_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); RelationInfo readRelation = target.Read() as RelationInfo; @@ -264,29 +298,32 @@ public void Read_ReadsRelationWithAllProperties_NoCompresion() { } [Fact] - public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion() { + public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion() + { PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; Assert.Null(readRelation.Metadata); } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; - - var aaa = Path.GetFullPath(filename); - PbfReader target = new PbfReader(filename, settings); - target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); + OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; + + var aaa = Path.GetFullPath(filename); + PbfReader target = new PbfReader(filename, settings); + target.Dispose(); + + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); } [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() { + public void Dispose_ClosesOutputStreamIfWritingToStream() + { var stream = TestDataReader.OpenPbf("pbf-n-node.pbf"); OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; @@ -296,7 +333,8 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() { Assert.False(stream.CanRead); } - private void CompareNodes(NodeInfo expected, NodeInfo actual) { + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { Assert.Equal(expected.ID, actual.ID); Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); @@ -305,10 +343,12 @@ private void CompareNodes(NodeInfo expected, NodeInfo actual) { this.CompareEntityDetails(expected.Metadata, actual.Metadata); } - private void CompareWays(WayInfo expected, WayInfo actual) { + private void CompareWays(WayInfo expected, WayInfo actual) + { Assert.Equal(expected.ID, actual.ID); Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) { + for (int i = 0; i < expected.Nodes.Count; i++) + { Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } @@ -316,10 +356,12 @@ private void CompareWays(WayInfo expected, WayInfo actual) { this.CompareEntityDetails(expected.Metadata, actual.Metadata); } - private void CompareRelation(RelationInfo expected, RelationInfo actual) { + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { Assert.Equal(expected.ID, actual.ID); Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) { + for (int i = 0; i < expected.Members.Count; i++) + { Assert.Equal(expected.Members[i], actual.Members[i]); } @@ -327,8 +369,10 @@ private void CompareRelation(RelationInfo expected, RelationInfo actual) { this.CompareEntityDetails(expected.Metadata, actual.Metadata); } - private void CompareTags(TagsCollection expected, TagsCollection actual) { - if (expected == null && actual == null) { + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { return; } @@ -336,8 +380,10 @@ private void CompareTags(TagsCollection expected, TagsCollection actual) { Assert.True(expected.All(tag => actual.Contains(tag))); } - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) { - if (expected == null && actual == null) { + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) + { return; } diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs index a39f987..a178ceb 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs @@ -1,34 +1,39 @@ -using System; - -using Xunit; - -using SpatialLite.Osm.IO; - -namespace Tests.SpatialLite.Osm.IO { - public class PbfWriterSettingsTests { - [Fact] - public void Constructor__SetsDefaultValues() { - PbfWriterSettings target = new PbfWriterSettings(); - - Assert.True(target.UseDenseFormat); - Assert.Equal(CompressionMode.ZlibDeflate, target.Compression); - Assert.True(target.WriteMetadata); - } - - [Fact] - public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - PbfWriterSettings target = new PbfWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.UseDenseFormat = false); - } - - [Fact] - public void ConpressionSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - PbfWriterSettings target = new PbfWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.Compression = CompressionMode.ZlibDeflate); - } - } -} +using System; + +using Xunit; + +using SpatialLite.Osm.IO; + +namespace Tests.SpatialLite.Osm.IO +{ + public class PbfWriterSettingsTests + { + [Fact] + public void Constructor__SetsDefaultValues() + { + PbfWriterSettings target = new PbfWriterSettings(); + + Assert.True(target.UseDenseFormat); + Assert.Equal(CompressionMode.ZlibDeflate, target.Compression); + Assert.True(target.WriteMetadata); + } + + [Fact] + public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + PbfWriterSettings target = new PbfWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.UseDenseFormat = false); + } + + [Fact] + public void ConpressionSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + PbfWriterSettings target = new PbfWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.Compression = CompressionMode.ZlibDeflate); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs index 53eb33f..4c6ecc0 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs @@ -8,485 +8,563 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.IO { - public class PbfWriterTests { - //resolution for default granularity - private const double _resolution = 1E-07; - - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; - - public PbfWriterTests() { - _details = new EntityMetadata() { - Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), - Uid = 127998, - User = "Luk@s", - Visible = true, - Version = 2, - Changeset = 6410629 - }; - - _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); - _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); - - _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); - _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); - _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); - _relationTags = new RelationInfo( - 1, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); +namespace Tests.SpatialLite.Osm.IO +{ + public class PbfWriterTests + { + //resolution for default granularity + private const double _resolution = 1E-07; + + private EntityMetadata _details; + private NodeInfo _node, _nodeTags, _nodeProperties; + private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; + + public PbfWriterTests() + { + _details = new EntityMetadata() + { + Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), + Uid = 127998, + User = "Luk@s", + Visible = true, + Version = 2, + Changeset = 6410629 + }; + + _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); + _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); + + _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); + _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); + + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationTags = new RelationInfo( + 1, + new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), + new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); } [Fact] - public void Constructor_FilenameSettings_SetsSettingsAndMakesThemReadOnly() { - string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-test.pbf"); - - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_FilenameSettings_CreatesOutputFile() { - string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-creates-output-test.pbf"); - - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) { - ; - } - - Assert.True(File.Exists(filename)); - } - - [Fact] - public void Constructor_FilenameSettings_WritesOsmHeader() { - string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-writes-header-test.pbf"); - - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) { - ; - } - - FileInfo fi = new FileInfo(filename); - Assert.True(fi.Length > 0); - } - - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(new MemoryStream(), settings)) { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } - - [Fact] - public void Constructor_StreamSettings_WritesOsmHeader() { - MemoryStream stream = new MemoryStream(); - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(stream, settings)) { - ; - } - - Assert.True(stream.ToArray().Length > 0); - } - - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() { - string filename = PathHelper.GetTempFilePath("pbfwriter-closes-output-filestream-test.pbf"); - - PbfWriterSettings settings = new PbfWriterSettings(); - PbfWriter target = new PbfWriter(filename, settings); - target.Dispose(); - - new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - } - - [Fact] - public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() { - using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) { - Assert.Throws(() => target.Write(_node)); - } - } - - [Fact] - public void Write_ThrowsArgumentNullExceptionIfMetadataContainsNullInsteadUsername() { - _nodeProperties.Metadata.User = null; - - using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) { - Assert.Throws(() => target.Write(_nodeProperties)); - } - } - - [Fact] - public void Write_IEntityInfo_WritesNode() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_node); - } - - this.TestPbfOutput(stream, _node); - } - - [Fact] - public void Write_IEntityInfo_WritesNodeWithTags() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_nodeTags); - } - - this.TestPbfOutput(stream, _nodeTags); - } - - [Fact] - public void Write_IEntityInfo_WritesNodeWithMetadata() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_nodeProperties); - } - - this.TestPbfOutput(stream, _nodeProperties); - } - - [Fact] - public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_nodeProperties); - } - - this.TestPbfOutput(stream, _node); - } - - [Fact] - public void Write_IEntityInfo_WritesNode_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_node); - } - - this.TestPbfOutput(stream, _node); - } - - [Fact] - public void Write_IEntityInfo_WritesNodeWithTags_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_nodeTags); - } + public void Constructor_FilenameSettings_SetsSettingsAndMakesThemReadOnly() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-test.pbf"); + + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(filename, settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_FilenameSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-creates-output-test.pbf"); + + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(filename, settings)) + { + ; + } + + Assert.True(File.Exists(filename)); + } + + [Fact] + public void Constructor_FilenameSettings_WritesOsmHeader() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-writes-header-test.pbf"); + + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(filename, settings)) + { + ; + } + + FileInfo fi = new FileInfo(filename); + Assert.True(fi.Length > 0); + } + + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + { + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(new MemoryStream(), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); + } + } + + [Fact] + public void Constructor_StreamSettings_WritesOsmHeader() + { + MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + ; + } + + Assert.True(stream.ToArray().Length > 0); + } + + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-closes-output-filestream-test.pbf"); + + PbfWriterSettings settings = new PbfWriterSettings(); + PbfWriter target = new PbfWriter(filename, settings); + target.Dispose(); + + new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + } + + [Fact] + public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() + { + using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) + { + Assert.Throws(() => target.Write(_node)); + } + } + + [Fact] + public void Write_ThrowsArgumentNullExceptionIfMetadataContainsNullInsteadUsername() + { + _nodeProperties.Metadata.User = null; + + using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) + { + Assert.Throws(() => target.Write(_nodeProperties)); + } + } + + [Fact] + public void Write_IEntityInfo_WritesNode() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_node); + } + + this.TestPbfOutput(stream, _node); + } + + [Fact] + public void Write_IEntityInfo_WritesNodeWithTags() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeTags); + } + + this.TestPbfOutput(stream, _nodeTags); + } + + [Fact] + public void Write_IEntityInfo_WritesNodeWithMetadata() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); + } + + this.TestPbfOutput(stream, _nodeProperties); + } + + [Fact] + public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); + } + + this.TestPbfOutput(stream, _node); + } + + [Fact] + public void Write_IEntityInfo_WritesNode_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _nodeTags); - } - - [Fact] - public void Write_IEntityInfo_WritesNodeWithMetadata_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_node); + } - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_nodeProperties); - } + this.TestPbfOutput(stream, _node); + } - this.TestPbfOutput(stream, _nodeProperties); - } - - [Fact] - public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + [Fact] + public void Write_IEntityInfo_WritesNodeWithTags_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_nodeProperties); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeTags); + } - this.TestPbfOutput(stream, _node); - } - - [Fact] - public void Write_IEntityInfo_WritesWay() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _nodeTags); + } - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_way); - } + [Fact] + public void Write_IEntityInfo_WritesNodeWithMetadata_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _way); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); + } - [Fact] - public void Write_IEntityInfo_WritesWayWithTags() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _nodeProperties); + } - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_wayTags); - } + [Fact] + public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _wayTags); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); + } - [Fact] - public void Write_IEntityInfo_WritesWayWithMetadata() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_wayProperties); - } + this.TestPbfOutput(stream, _node); + } - this.TestPbfOutput(stream, _wayProperties); - } + [Fact] + public void Write_IEntityInfo_WritesWay() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMetadataSettingsIsFalse() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_wayProperties); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_way); + } - this.TestPbfOutput(stream, _way); - } + this.TestPbfOutput(stream, _way); + } - [Fact] - public void Write_IEntityInfo_WritesRelationWithNode() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + [Fact] + public void Write_IEntityInfo_WritesWayWithTags() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_relationNode); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_wayTags); + } - this.TestPbfOutput(stream, _relationNode); - } + this.TestPbfOutput(stream, _wayTags); + } - [Fact] - public void Write_IEntityInfo_WritesRelationWithWay() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + [Fact] + public void Write_IEntityInfo_WritesWayWithMetadata() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_relationWay); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_wayProperties); + } - this.TestPbfOutput(stream, _relationWay); - } + this.TestPbfOutput(stream, _wayProperties); + } - [Fact] - public void Write_IEntityInfo_WritesRelationWithRelation() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + [Fact] + public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMetadataSettingsIsFalse() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_relationRelation); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_wayProperties); + } - this.TestPbfOutput(stream, _relationRelation); - } + this.TestPbfOutput(stream, _way); + } - [Fact] - public void Write_IEntityInfo_WritesRelationWithTags() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_relationTags); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithNode() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _relationTags); - } - - [Fact] - public void Write_IEntityInfo_WritesRelationWithMetadata() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_relationNodeProperties); - } - - this.TestPbfOutput(stream, _relationNodeProperties); - } - - [Fact] - public void Write_IEntityInfo_DoesntWritesRelationMetadataIfWriteMetasdataSettingsIsFalse() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(_relationNodeProperties); - } - - this.TestPbfOutput(stream, _relationNode); - } - - [Fact] - public void Write_IOsmGeometry_WritesNode() { - Node node = new Node(1, 11.1, 12.1); - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(node); - } - - this.TestPbfOutput(stream, new NodeInfo(node)); - } - - [Fact] - public void Write_IOsmGeometry_WritesWay() { - Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(way); - } - - this.TestPbfOutput(stream, new WayInfo(way)); - } - - [Fact] - public void Write_IOsmGeometry_WritesRelation() { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); - - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - target.Write(relation); - } - - this.TestPbfOutput(stream, new RelationInfo(relation)); - } - - [Fact] - public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); - - using (PbfWriter target = new PbfWriter(stream, settings)) { - IOsmGeometry entity = null; - Assert.Throws(() => target.Write(entity)); - } - } - - [Fact] - public void Flush_ForcesWriterToWriteDataToUnderalyingStorage() { - MemoryStream stream = new MemoryStream(); - - PbfWriter target = new PbfWriter(stream, new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }); - - //1000 nodes should fit into tokens - for (int i = 0; i < 1000; i++) { - NodeInfo node = new NodeInfo(i, 45.87, -126.5, new TagsCollection()); - target.Write(node); - } - int minimalExpectedLengthIncrease = 1000 * 8; - - long originalStreamLength = stream.Length; - target.Flush(); - - Assert.True(stream.Length > originalStreamLength + minimalExpectedLengthIncrease); - } - - private void TestPbfOutput(MemoryStream pbfStream, IEntityInfo expected) { - if (pbfStream.CanSeek) { - pbfStream.Seek(0, SeekOrigin.Begin); - } - else { - pbfStream = new MemoryStream(pbfStream.ToArray()); - } - - PbfReader reader = new PbfReader(pbfStream, new OsmReaderSettings() { ReadMetadata = true }); - IEntityInfo read = reader.Read(); - - switch (expected.EntityType) { - case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; - case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; - case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; - } - } - - private void CompareNodes(NodeInfo expected, NodeInfo actual) { - Assert.Equal(expected.ID, actual.ID); - Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); - Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } - - private void CompareWays(WayInfo expected, WayInfo actual) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) { - Assert.Equal(expected.Nodes[i], actual.Nodes[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } - - private void CompareRelation(RelationInfo expected, RelationInfo actual) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) { - Assert.Equal(expected.Members[i], actual.Members[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } - - private void CompareTags(TagsCollection expected, TagsCollection actual) { - if (expected == null && actual == null) { - return; - } - - Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); - } - - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) { - if (expected == null && actual == null) { - return; - } - - Assert.NotNull(actual); - - Assert.Equal(expected.Timestamp, actual.Timestamp); - Assert.Equal(expected.Uid, actual.Uid); - Assert.Equal(expected.User, actual.User); - Assert.Equal(expected.Visible, actual.Visible); - Assert.Equal(expected.Version, actual.Version); - Assert.Equal(expected.Changeset, actual.Changeset); - } - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationNode); + } + + this.TestPbfOutput(stream, _relationNode); + } + + [Fact] + public void Write_IEntityInfo_WritesRelationWithWay() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationWay); + } + + this.TestPbfOutput(stream, _relationWay); + } + + [Fact] + public void Write_IEntityInfo_WritesRelationWithRelation() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationRelation); + } + + this.TestPbfOutput(stream, _relationRelation); + } + + [Fact] + public void Write_IEntityInfo_WritesRelationWithTags() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationTags); + } + + this.TestPbfOutput(stream, _relationTags); + } + + [Fact] + public void Write_IEntityInfo_WritesRelationWithMetadata() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationNodeProperties); + } + + this.TestPbfOutput(stream, _relationNodeProperties); + } + + [Fact] + public void Write_IEntityInfo_DoesntWritesRelationMetadataIfWriteMetasdataSettingsIsFalse() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationNodeProperties); + } + + this.TestPbfOutput(stream, _relationNode); + } + + [Fact] + public void Write_IOsmGeometry_WritesNode() + { + Node node = new Node(1, 11.1, 12.1); + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(node); + } + + this.TestPbfOutput(stream, new NodeInfo(node)); + } + + [Fact] + public void Write_IOsmGeometry_WritesWay() + { + Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(way); + } + + this.TestPbfOutput(stream, new WayInfo(way)); + } + + [Fact] + public void Write_IOsmGeometry_WritesRelation() + { + Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); + + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(relation); + } + + this.TestPbfOutput(stream, new RelationInfo(relation)); + } + + [Fact] + public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); + + using (PbfWriter target = new PbfWriter(stream, settings)) + { + IOsmGeometry entity = null; + Assert.Throws(() => target.Write(entity)); + } + } + + [Fact] + public void Flush_ForcesWriterToWriteDataToUnderalyingStorage() + { + MemoryStream stream = new MemoryStream(); + + PbfWriter target = new PbfWriter(stream, new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }); + + //1000 nodes should fit into tokens + for (int i = 0; i < 1000; i++) + { + NodeInfo node = new NodeInfo(i, 45.87, -126.5, new TagsCollection()); + target.Write(node); + } + int minimalExpectedLengthIncrease = 1000 * 8; + + long originalStreamLength = stream.Length; + target.Flush(); + + Assert.True(stream.Length > originalStreamLength + minimalExpectedLengthIncrease); + } + + private void TestPbfOutput(MemoryStream pbfStream, IEntityInfo expected) + { + if (pbfStream.CanSeek) + { + pbfStream.Seek(0, SeekOrigin.Begin); + } + else + { + pbfStream = new MemoryStream(pbfStream.ToArray()); + } + + PbfReader reader = new PbfReader(pbfStream, new OsmReaderSettings() { ReadMetadata = true }); + IEntityInfo read = reader.Read(); + + switch (expected.EntityType) + { + case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; + case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; + case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; + } + } + + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); + Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); + + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareWays(WayInfo expected, WayInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); + for (int i = 0; i < expected.Nodes.Count; i++) + { + Assert.Equal(expected.Nodes[i], actual.Nodes[i]); + } + + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Members.Count, actual.Members.Count); + for (int i = 0; i < expected.Members.Count; i++) + { + Assert.Equal(expected.Members[i], actual.Members[i]); + } + + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { + return; + } + + Assert.Equal(expected.Count, actual.Count); + Assert.True(expected.All(tag => actual.Contains(tag))); + } + + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) + { + return; + } + + Assert.NotNull(actual); + + Assert.Equal(expected.Timestamp, actual.Timestamp); + Assert.Equal(expected.Uid, actual.Uid); + Assert.Equal(expected.User, actual.User); + Assert.Equal(expected.Visible, actual.Visible); + Assert.Equal(expected.Version, actual.Version); + Assert.Equal(expected.Changeset, actual.Changeset); + } + } } diff --git a/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs b/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs index 8e3fcd4..05b57f9 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs @@ -1,178 +1,208 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; - -using Xunit; - -using SpatialLite.Osm; -using SpatialLite.Osm.IO; -using Tests.SpatialLite.Osm.Data; - -namespace Tests.SpatialLite.Osm.Integration.Pbf { - public class OsmosisIntegrationTests { - private const int TestFileNodesCount = 129337; - private const int TestFileWaysCount = 14461; - private const int TestFileRelationsCount = 124; - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseNoCompression() { - string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file.pbf"); - - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=none", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); - - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_DenseNoCompression() { - var pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-d.pbf"); - - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=none", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); - - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseDeflateCompression() { - string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-c.pbf"); - - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=deflate", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); - - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate() { - string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-dc.pbf"); - - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=deflate", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); - - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseNoCompression() { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file.pbf"); - - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) { - foreach (var entityInfo in this.GetTestData()) { - writer.Write(entityInfo); - } - } - - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); - - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseDeflate() { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-c.pbf"); - - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = false })) { - foreach (var entityInfo in this.GetTestData()) { - writer.Write(entityInfo); - } - } - - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); - - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseNoCompression() { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-d.pbf"); - - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = true })) { - foreach (var entityInfo in this.GetTestData()) { - writer.Write(entityInfo); - } - } - - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); - - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate() { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-dc.pbf"); - - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { - foreach (var entityInfo in this.GetTestData()) { - writer.Write(entityInfo); - } - } - - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); - - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } - - private void CallOsmosis(string arguments) { - ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); - osmosisInfo.Arguments = arguments; - - Process osmosis = Process.Start(osmosisInfo); - osmosis.WaitForExit(); - - Assert.Equal(0, osmosis.ExitCode); - } - - private void TestReader(IOsmReader reader) { - IEntityInfo info = null; - int nodesCount = 0, waysCount = 0, relationsCount = 0; - while ((info = reader.Read()) != null) { - switch (info.EntityType) { - case EntityType.Node: nodesCount++; break; - case EntityType.Way: waysCount++; break; - case EntityType.Relation: relationsCount++; break; - } - } - - Assert.Equal(TestFileNodesCount, nodesCount); - Assert.Equal(TestFileWaysCount, waysCount); - Assert.Equal(TestFileRelationsCount, relationsCount); - } - - private IEnumerable GetTestData() { - List data = new List(); - - using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - IEntityInfo info = null; - while ((info = reader.Read()) != null) { - data.Add(info); - } - } - } - - return data; - } - } -} +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +using Xunit; + +using SpatialLite.Osm; +using SpatialLite.Osm.IO; +using Tests.SpatialLite.Osm.Data; + +namespace Tests.SpatialLite.Osm.Integration.Pbf +{ + public class OsmosisIntegrationTests + { + private const int TestFileNodesCount = 129337; + private const int TestFileWaysCount = 14461; + private const int TestFileRelationsCount = 124; + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseNoCompression() + { + string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file.pbf"); + + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=none", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); + + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_DenseNoCompression() + { + var pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-d.pbf"); + + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=none", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); + + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseDeflateCompression() + { + string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-c.pbf"); + + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=deflate", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); + + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate() + { + string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-dc.pbf"); + + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=deflate", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); + + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseNoCompression() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file.pbf"); + + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) + { + foreach (var entityInfo in this.GetTestData()) + { + writer.Write(entityInfo); + } + } + + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); + + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseDeflate() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-c.pbf"); + + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = false })) + { + foreach (var entityInfo in this.GetTestData()) + { + writer.Write(entityInfo); + } + } + + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); + + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseNoCompression() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-d.pbf"); + + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = true })) + { + foreach (var entityInfo in this.GetTestData()) + { + writer.Write(entityInfo); + } + } + + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); + + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-dc.pbf"); + + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + { + foreach (var entityInfo in this.GetTestData()) + { + writer.Write(entityInfo); + } + } + + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); + + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } + + private void CallOsmosis(string arguments) + { + ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); + osmosisInfo.Arguments = arguments; + + Process osmosis = Process.Start(osmosisInfo); + osmosis.WaitForExit(); + + Assert.Equal(0, osmosis.ExitCode); + } + + private void TestReader(IOsmReader reader) + { + IEntityInfo info = null; + int nodesCount = 0, waysCount = 0, relationsCount = 0; + while ((info = reader.Read()) != null) + { + switch (info.EntityType) + { + case EntityType.Node: nodesCount++; break; + case EntityType.Way: waysCount++; break; + case EntityType.Relation: relationsCount++; break; + } + } + + Assert.Equal(TestFileNodesCount, nodesCount); + Assert.Equal(TestFileWaysCount, waysCount); + Assert.Equal(TestFileRelationsCount, relationsCount); + } + + private IEnumerable GetTestData() + { + List data = new List(); + + using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + { + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + IEntityInfo info = null; + while ((info = reader.Read()) != null) + { + data.Add(info); + } + } + } + + return data; + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs index 898c176..7a09f26 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs @@ -1,119 +1,144 @@ -using System.Collections.Generic; -using System.IO; - -using Xunit; - -using SpatialLite.Osm; -using SpatialLite.Osm.IO; -using Tests.SpatialLite.Osm.Data; - -namespace Tests.SpatialLite.Osm.Integration.Pbf { - public class PbfReaderPbfWriterComplianceTests { - private const int TestFileNodesCount = 129337; - private const int TestFileWaysCount = 14461; - private const int TestFileRelationsCount = 124; - - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseNoCompression() { - MemoryStream stream = new MemoryStream(); - - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.None })) { - foreach (var info in this.GetTestData()) { - writer.Write(info); - } - - writer.Flush(); - - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - } - - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_DenseNoCompression() { - MemoryStream stream = new MemoryStream(); - - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.None })) { - foreach (var info in this.GetTestData()) { - writer.Write(info); - } - - writer.Flush(); - - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - } - - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate() { - MemoryStream stream = new MemoryStream(); - - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.ZlibDeflate })) { - foreach (var info in this.GetTestData()) { - writer.Write(info); - } - - writer.Flush(); - - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - } - - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_DenseDeflate() { - MemoryStream stream = new MemoryStream(); - - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.ZlibDeflate })) { - foreach (var info in this.GetTestData()) { - writer.Write(info); - } - - writer.Flush(); - - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); - } - } - } - - private void TestReader(IOsmReader reader) { - IEntityInfo info = null; - int nodesCount = 0, waysCount = 0, relationsCount = 0; - while ((info = reader.Read()) != null) { - switch (info.EntityType) { - case EntityType.Node: nodesCount++; break; - case EntityType.Way: waysCount++; break; - case EntityType.Relation: relationsCount++; break; - } - } - - Assert.Equal(TestFileNodesCount, nodesCount); - Assert.Equal(TestFileWaysCount, waysCount); - Assert.Equal(TestFileRelationsCount, relationsCount); - } - - private IEnumerable GetTestData() { - List data = new List(); - - using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - IEntityInfo info = null; - while ((info = reader.Read()) != null) { - data.Add(info); - } - } - } - - return data; - } - } -} +using System.Collections.Generic; +using System.IO; + +using Xunit; + +using SpatialLite.Osm; +using SpatialLite.Osm.IO; +using Tests.SpatialLite.Osm.Data; + +namespace Tests.SpatialLite.Osm.Integration.Pbf +{ + public class PbfReaderPbfWriterComplianceTests + { + private const int TestFileNodesCount = 129337; + private const int TestFileWaysCount = 14461; + private const int TestFileRelationsCount = 124; + + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseNoCompression() + { + MemoryStream stream = new MemoryStream(); + + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.None })) + { + foreach (var info in this.GetTestData()) + { + writer.Write(info); + } + + writer.Flush(); + + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + } + + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_DenseNoCompression() + { + MemoryStream stream = new MemoryStream(); + + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.None })) + { + foreach (var info in this.GetTestData()) + { + writer.Write(info); + } + + writer.Flush(); + + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + } + + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate() + { + MemoryStream stream = new MemoryStream(); + + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.ZlibDeflate })) + { + foreach (var info in this.GetTestData()) + { + writer.Write(info); + } + + writer.Flush(); + + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + } + + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_DenseDeflate() + { + MemoryStream stream = new MemoryStream(); + + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.ZlibDeflate })) + { + foreach (var info in this.GetTestData()) + { + writer.Write(info); + } + + writer.Flush(); + + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); + } + } + } + + private void TestReader(IOsmReader reader) + { + IEntityInfo info = null; + int nodesCount = 0, waysCount = 0, relationsCount = 0; + while ((info = reader.Read()) != null) + { + switch (info.EntityType) + { + case EntityType.Node: nodesCount++; break; + case EntityType.Way: waysCount++; break; + case EntityType.Relation: relationsCount++; break; + } + } + + Assert.Equal(TestFileNodesCount, nodesCount); + Assert.Equal(TestFileWaysCount, waysCount); + Assert.Equal(TestFileRelationsCount, relationsCount); + } + + private IEnumerable GetTestData() + { + List data = new List(); + + using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + { + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + IEntityInfo info = null; + while ((info = reader.Read()) != null) + { + data.Add(info); + } + } + } + + return data; + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs index 2dfddb3..d34553a 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs @@ -1,32 +1,36 @@ -using System; -using System.Collections.Generic; -using System.Text; -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm.IO; -using Tests.SpatialLite.Osm.Data; -using Xunit; - -namespace Tests.SpatialLite.Osm.Integration.Xml { - public class OsmDatabaseTests { - [Fact, Trait("Category", "Osm.Integration")] - public void OsmEntityInfoDatabase_LoadesRealFile() { - OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - - Assert.Equal(6688, target.Nodes.Count); - Assert.Equal(740, target.Ways.Count); - Assert.Equal(75, target.Relations.Count); - } - - [Fact, Trait("Category", "Osm.Integration")] - public void OsmGeometryDatabase_LoadesRealFile() { - OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(6688, target.Nodes.Count); - Assert.Equal(740, target.Ways.Count); - Assert.Equal(75, target.Relations.Count); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.IO; +using Tests.SpatialLite.Osm.Data; +using Xunit; + +namespace Tests.SpatialLite.Osm.Integration.Xml +{ + public class OsmDatabaseTests + { + [Fact, Trait("Category", "Osm.Integration")] + public void OsmEntityInfoDatabase_LoadesRealFile() + { + OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + + Assert.Equal(6688, target.Nodes.Count); + Assert.Equal(740, target.Ways.Count); + Assert.Equal(75, target.Relations.Count); + } + + [Fact, Trait("Category", "Osm.Integration")] + public void OsmGeometryDatabase_LoadesRealFile() + { + OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(6688, target.Nodes.Count); + Assert.Equal(740, target.Ways.Count); + Assert.Equal(75, target.Relations.Count); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs index f7329ea..f3cd632 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs @@ -1,87 +1,102 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; - -using Xunit; - -using SpatialLite.Osm; -using SpatialLite.Osm.IO; -using Tests.SpatialLite.Osm.Data; - -namespace Tests.SpatialLite.Osm.Integration.Xml { - public class OsmosisIntegrationTests { - private const int TestFileNodesCount = 129337; - private const int TestFileWaysCount = 14461; - private const int TestFileRelationsCount = 124; - - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void XmlOsmReaderReadsFilesCreatedByOsmosis() { - string xmlFile = PathHelper.GetTempFilePath("xmlreader-osmosis-compatibility-test-osmosis-real-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", PathHelper.RealPbfFilePath, xmlFile); - this.CallOsmosis(osmosisArguments); - - using (OsmXmlReader reader = new OsmXmlReader(xmlFile, new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false })) { - this.TestReader(reader); - } - } - - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void XmlOsmWriterWritesFilesCompatibleWithOsmosis() { - string xmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-xmlwriter-real-file.osm"); - using (OsmXmlWriter writer = new OsmXmlWriter(xmlFile, new OsmWriterSettings() { WriteMetadata = true })) { - foreach (var entityInfo in this.GetTestData()) { - writer.Write(entityInfo); - } - } - - string osmosisXmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-xml file={0} --write-xml file={1}", xmlFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); - - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } - - private IEnumerable GetTestData() { - List data = new List(); - - using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - IEntityInfo info = null; - while ((info = reader.Read()) != null) { - data.Add(info); - } - } - } - - return data; - } - - private void CallOsmosis(string arguments) { - ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); - osmosisInfo.Arguments = arguments; - - Process osmosis = Process.Start(osmosisInfo); - osmosis.WaitForExit(); - - Assert.Equal(0, osmosis.ExitCode); - } - - private void TestReader(IOsmReader reader) { - IEntityInfo info = null; - int nodesCount = 0, waysCount = 0, relationsCount = 0; - while ((info = reader.Read()) != null) { - switch (info.EntityType) { - case EntityType.Node: nodesCount++; break; - case EntityType.Way: waysCount++; break; - case EntityType.Relation: relationsCount++; break; - } - } - - Assert.Equal(TestFileNodesCount, nodesCount); - Assert.Equal(TestFileWaysCount, waysCount); - Assert.Equal(TestFileRelationsCount, relationsCount); - } - } -} +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; + +using Xunit; + +using SpatialLite.Osm; +using SpatialLite.Osm.IO; +using Tests.SpatialLite.Osm.Data; + +namespace Tests.SpatialLite.Osm.Integration.Xml +{ + public class OsmosisIntegrationTests + { + private const int TestFileNodesCount = 129337; + private const int TestFileWaysCount = 14461; + private const int TestFileRelationsCount = 124; + + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void XmlOsmReaderReadsFilesCreatedByOsmosis() + { + string xmlFile = PathHelper.GetTempFilePath("xmlreader-osmosis-compatibility-test-osmosis-real-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", PathHelper.RealPbfFilePath, xmlFile); + this.CallOsmosis(osmosisArguments); + + using (OsmXmlReader reader = new OsmXmlReader(xmlFile, new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false })) + { + this.TestReader(reader); + } + } + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void XmlOsmWriterWritesFilesCompatibleWithOsmosis() + { + string xmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-xmlwriter-real-file.osm"); + using (OsmXmlWriter writer = new OsmXmlWriter(xmlFile, new OsmWriterSettings() { WriteMetadata = true })) + { + foreach (var entityInfo in this.GetTestData()) + { + writer.Write(entityInfo); + } + } + + string osmosisXmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-xml file={0} --write-xml file={1}", xmlFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); + + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } + + private IEnumerable GetTestData() + { + List data = new List(); + + using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + { + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + IEntityInfo info = null; + while ((info = reader.Read()) != null) + { + data.Add(info); + } + } + } + + return data; + } + + private void CallOsmosis(string arguments) + { + ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); + osmosisInfo.Arguments = arguments; + + Process osmosis = Process.Start(osmosisInfo); + osmosis.WaitForExit(); + + Assert.Equal(0, osmosis.ExitCode); + } + + private void TestReader(IOsmReader reader) + { + IEntityInfo info = null; + int nodesCount = 0, waysCount = 0, relationsCount = 0; + while ((info = reader.Read()) != null) + { + switch (info.EntityType) + { + case EntityType.Node: nodesCount++; break; + case EntityType.Way: waysCount++; break; + case EntityType.Relation: relationsCount++; break; + } + } + + Assert.Equal(TestFileNodesCount, nodesCount); + Assert.Equal(TestFileWaysCount, waysCount); + Assert.Equal(TestFileRelationsCount, relationsCount); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs index e000e87..d761578 100644 --- a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs @@ -1,64 +1,70 @@ -using System; - -using Xunit; - -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; - -namespace Tests.SpatialLite.Osm { - public class NodeInfoTests { - - [Fact] - public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() { - int id = 15; - double latitude = 15.4; - double longitude = -23.7; - TagsCollection tags = new TagsCollection(); - - NodeInfo target = new NodeInfo(id, latitude, longitude, tags); - - Assert.Equal(EntityType.Node, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Equal(latitude, target.Latitude); - Assert.Equal(longitude, target.Longitude); - Assert.Same(tags, target.Tags); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_Properties_SetsProperties() { - int id = 15; - double latitude = 15.4; - double longitude = -23.7; - TagsCollection tags = new TagsCollection(); - EntityMetadata details = new EntityMetadata(); - - NodeInfo target = new NodeInfo(id, latitude, longitude, tags, details); - - Assert.Equal(EntityType.Node, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Equal(latitude, target.Latitude); - Assert.Equal(longitude, target.Longitude); - Assert.Same(tags, target.Tags); - Assert.Same(details, target.Metadata); - } - - [Fact] - public void Constructor_Node_SetsProperties() { - Node node = new Node(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; - - NodeInfo target = new NodeInfo(node); - - Assert.Equal(node.ID, target.ID); - Assert.Equal(node.Position.X, target.Longitude); - Assert.Equal(node.Position.Y, target.Latitude); - Assert.Same(node.Tags, target.Tags); - Assert.Same(node.Metadata, target.Metadata); - } - - [Fact] - public void Constructor_Node_ThrowsExceptionIfNodeIsNull() { - Assert.Throws(() => new NodeInfo(null)); - } - } -} +using System; + +using Xunit; + +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm; + +namespace Tests.SpatialLite.Osm +{ + public class NodeInfoTests + { + + [Fact] + public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() + { + int id = 15; + double latitude = 15.4; + double longitude = -23.7; + TagsCollection tags = new TagsCollection(); + + NodeInfo target = new NodeInfo(id, latitude, longitude, tags); + + Assert.Equal(EntityType.Node, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Equal(latitude, target.Latitude); + Assert.Equal(longitude, target.Longitude); + Assert.Same(tags, target.Tags); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_Properties_SetsProperties() + { + int id = 15; + double latitude = 15.4; + double longitude = -23.7; + TagsCollection tags = new TagsCollection(); + EntityMetadata details = new EntityMetadata(); + + NodeInfo target = new NodeInfo(id, latitude, longitude, tags, details); + + Assert.Equal(EntityType.Node, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Equal(latitude, target.Latitude); + Assert.Equal(longitude, target.Longitude); + Assert.Same(tags, target.Tags); + Assert.Same(details, target.Metadata); + } + + [Fact] + public void Constructor_Node_SetsProperties() + { + Node node = new Node(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; + + NodeInfo target = new NodeInfo(node); + + Assert.Equal(node.ID, target.ID); + Assert.Equal(node.Position.X, target.Longitude); + Assert.Equal(node.Position.Y, target.Latitude); + Assert.Same(node.Tags, target.Tags); + Assert.Same(node.Metadata, target.Metadata); + } + + [Fact] + public void Constructor_Node_ThrowsExceptionIfNodeIsNull() + { + Assert.Throws(() => new NodeInfo(null)); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs index 27a8e9d..ad98b7f 100644 --- a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs @@ -1,419 +1,471 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using Xunit; - -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; - -namespace Tests.SpatialLite.Osm { - public class OsmDatabaseTests { - Node[] _nodeData; - Way[] _wayData; - Relation[] _relationData; - IOsmGeometry[] _data; - - public OsmDatabaseTests() { - _nodeData = new Node[3]; - _nodeData[0] = new Node(1); - _nodeData[1] = new Node(2); - _nodeData[2] = new Node(3); - - _wayData = new Way[2]; - _wayData[0] = new Way(1, _nodeData); - _wayData[1] = new Way(2, _nodeData.Skip(1)); - - _relationData = new Relation[2]; - _relationData[0] = new Relation(1, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); - _relationData[1] = new Relation(2, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); - - _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); - } - - [Fact] - public void Constructor__CreatesEmptyDatabase() { - OsmDatabase target = new OsmDatabase(); - - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } - - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - OsmDatabase target = new OsmDatabase(_data); - - for (int i = 0; i < _data.Length; i++) { - Assert.Contains(_data[i], target); - } - } - - [Fact] - public void Constructor_IEnumerable_AddEnittiesToCorrectCollections() { - OsmDatabase target = new OsmDatabase(_data); - - for (int i = 0; i < _nodeData.Length; i++) { - Assert.Contains(_nodeData[i], target.Nodes); - } - - for (int i = 0; i < _wayData.Length; i++) { - Assert.Contains(_wayData[i], target.Ways); - } - - for (int i = 0; i < _relationData.Length; i++) { - Assert.Contains(_relationData[i], target.Relations); - } - } - - [Fact] - public void Count_ReturnsNumberOfAllEntities() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.Equal(_data.Length, target.Count); - } - - [Fact] - public void IsReadOnly_ReturnsFalse() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.False(target.IsReadOnly); - } - - [Fact] - public void Item_ReturnsNullIfIDIsNotPresentInCollection() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.Null(target[10000, EntityType.Node]); - } - - [Fact] - public void Item_ReturnsNodeWithSpecificID() { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry entity = target[_nodeData[0].ID, EntityType.Node]; - - Assert.Same(_nodeData[0], entity); - } - - [Fact] - public void Item_ReturnsWayWithSpecificID() { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry entity = target[_wayData[0].ID, EntityType.Way]; - - Assert.Same(_wayData[0], entity); - } - - [Fact] - public void Item_ReturnsRelationWithSpecificID() { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry entity = target[_relationData[0].ID, EntityType.Relation]; - - Assert.Same(_relationData[0], entity); - } - - [Fact] - public void Add_AddsNodeToCollection() { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); - target.Add(_nodeData[0]); - - Assert.Contains(_nodeData[0], target); - } - - [Fact] - public void Add_AddsWayToCollection() { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); - target.Add(_wayData[0]); - - Assert.Contains(_wayData[0], target); - } - - [Fact] - public void Add_AddsRelationToCollection() { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); - target.Add(_relationData[0]); - - Assert.Contains(_relationData[0], target); - } - - [Fact] - public void Add_ThrowsArgumentNullExceptionIfItemIsNull() { - OsmDatabase target = new OsmDatabase(); - - Assert.Throws(() => target.Add(null)); - } - - [Fact] - public void Add_ThrowsExceptionWhenAddingDuplicateID() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.Throws(() => target.Add(_data[0])); - } - - [Fact] - public void Clear_RemovesAllItemsFromCollection() { - OsmDatabase target = new OsmDatabase(_data); - target.Clear(); - - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseForNull() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.DoesNotContain(null, target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainNode() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.DoesNotContain(new Node(10000), target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsNode() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.Contains(_nodeData[0], target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainWay() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.DoesNotContain(new Way(10000), target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsWay() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.Contains(_wayData[0], target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainRelation() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.DoesNotContain(new Relation(10000), target); - } - - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsRelation() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.Contains(_relationData[0], target); - } - - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainNodeID() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.False(target.Contains(10000, EntityType.Node)); - } - - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsNodeID() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.True(target.Contains(_nodeData[0].ID, EntityType.Node)); - } - - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainWayID() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.False(target.Contains(10000, EntityType.Way)); - } - - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsWayID() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.True(target.Contains(_wayData[0].ID, EntityType.Way)); - } - - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainRelationID() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.False(target.Contains(10000, EntityType.Relation)); - } - - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsRelationID() { - OsmDatabase target = new OsmDatabase(_data); - - Assert.True(target.Contains(_relationData[0].ID, EntityType.Relation)); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() { - OsmDatabase target = new OsmDatabase(_data); - - bool callResult = target.Remove(null); - - Assert.False(callResult); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); - - bool callResult = target.Remove(_nodeData[0]); - - Assert.False(callResult); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesNodeFromCollection() { - OsmDatabase target = new OsmDatabase(_nodeData); - - bool callResult = target.Remove(_data[0]); - - Assert.True(callResult); - Assert.DoesNotContain(_nodeData[0], target); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); - - bool callResult = target.Remove(_wayData[0]); - - Assert.False(callResult); - Assert.Contains(_wayData[1], target); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesWayFromCollection() { - OsmDatabase target = new OsmDatabase(_wayData); - - bool callResult = target.Remove(_wayData[0]); - - Assert.True(callResult); - Assert.DoesNotContain(_wayData[0], target); - Assert.Contains(_wayData[1], target); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); - - bool callResult = target.Remove(_relationData[0]); - - Assert.False(callResult); - Assert.Contains(_relationData[1], target); - } - - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesRelationFromCollection() { - OsmDatabase target = new OsmDatabase(_relationData); - - bool callResult = target.Remove(_relationData[0]); - - Assert.True(callResult); - Assert.DoesNotContain(_relationData[0], target); - Assert.Contains(_relationData[1], target); - } - - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); - - bool callResult = target.Remove(_nodeData[0].ID, EntityType.Node); - - Assert.False(callResult); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } - - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesNodeFromCollection() { - OsmDatabase target = new OsmDatabase(_nodeData); - - bool callResult = target.Remove(_data[0].ID, EntityType.Node); - - Assert.True(callResult); - Assert.DoesNotContain(_nodeData[0], target); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } - - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); - - bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); - - Assert.False(callResult); - Assert.Contains(_wayData[1], target); - } - - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesWayFromCollection() { - OsmDatabase target = new OsmDatabase(_wayData); - - bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); - - Assert.True(callResult); - Assert.DoesNotContain(_wayData[0], target); - Assert.Contains(_wayData[1], target); - } - - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); - - bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); - - Assert.False(callResult); - Assert.Contains(_relationData[1], target); - } - - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesRelationFromCollection() { - OsmDatabase target = new OsmDatabase(_relationData); - - bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); - - Assert.True(callResult); - Assert.DoesNotContain(_relationData[0], target); - Assert.Contains(_relationData[1], target); - } - - [Fact] - public void GetEnumerator_ReturnsEnumeratorThatEnumeratesAllEntities() { - OsmDatabase target = new OsmDatabase(_data); - - IEnumerable result = target; - - Assert.Equal(_data.Length, target.Count()); - foreach (var entity in target) { - Assert.Contains(entity, _data); - } - } - - [Fact] - public void CopyTo_CopiesEntitiesToArray() { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry[] array = new IOsmGeometry[_data.Length]; - - target.CopyTo(array, 0); - - for (int i = 0; i < _data.Length; i++) { - Assert.Same(_data[i], array[i]); - } - } - - } -} +using System; +using System.Collections.Generic; +using System.Linq; + +using Xunit; + +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; + +namespace Tests.SpatialLite.Osm +{ + public class OsmDatabaseTests + { + Node[] _nodeData; + Way[] _wayData; + Relation[] _relationData; + IOsmGeometry[] _data; + + public OsmDatabaseTests() + { + _nodeData = new Node[3]; + _nodeData[0] = new Node(1); + _nodeData[1] = new Node(2); + _nodeData[2] = new Node(3); + + _wayData = new Way[2]; + _wayData[0] = new Way(1, _nodeData); + _wayData[1] = new Way(2, _nodeData.Skip(1)); + + _relationData = new Relation[2]; + _relationData[0] = new Relation(1, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); + _relationData[1] = new Relation(2, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); + + _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); + } + + [Fact] + public void Constructor__CreatesEmptyDatabase() + { + OsmDatabase target = new OsmDatabase(); + + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } + + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + OsmDatabase target = new OsmDatabase(_data); + + for (int i = 0; i < _data.Length; i++) + { + Assert.Contains(_data[i], target); + } + } + + [Fact] + public void Constructor_IEnumerable_AddEnittiesToCorrectCollections() + { + OsmDatabase target = new OsmDatabase(_data); + + for (int i = 0; i < _nodeData.Length; i++) + { + Assert.Contains(_nodeData[i], target.Nodes); + } + + for (int i = 0; i < _wayData.Length; i++) + { + Assert.Contains(_wayData[i], target.Ways); + } + + for (int i = 0; i < _relationData.Length; i++) + { + Assert.Contains(_relationData[i], target.Relations); + } + } + + [Fact] + public void Count_ReturnsNumberOfAllEntities() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.Equal(_data.Length, target.Count); + } + + [Fact] + public void IsReadOnly_ReturnsFalse() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.False(target.IsReadOnly); + } + + [Fact] + public void Item_ReturnsNullIfIDIsNotPresentInCollection() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.Null(target[10000, EntityType.Node]); + } + + [Fact] + public void Item_ReturnsNodeWithSpecificID() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry entity = target[_nodeData[0].ID, EntityType.Node]; + + Assert.Same(_nodeData[0], entity); + } + + [Fact] + public void Item_ReturnsWayWithSpecificID() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry entity = target[_wayData[0].ID, EntityType.Way]; + + Assert.Same(_wayData[0], entity); + } + + [Fact] + public void Item_ReturnsRelationWithSpecificID() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry entity = target[_relationData[0].ID, EntityType.Relation]; + + Assert.Same(_relationData[0], entity); + } + + [Fact] + public void Add_AddsNodeToCollection() + { + OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + target.Add(_nodeData[0]); + + Assert.Contains(_nodeData[0], target); + } + + [Fact] + public void Add_AddsWayToCollection() + { + OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + target.Add(_wayData[0]); + + Assert.Contains(_wayData[0], target); + } + + [Fact] + public void Add_AddsRelationToCollection() + { + OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + target.Add(_relationData[0]); + + Assert.Contains(_relationData[0], target); + } + + [Fact] + public void Add_ThrowsArgumentNullExceptionIfItemIsNull() + { + OsmDatabase target = new OsmDatabase(); + + Assert.Throws(() => target.Add(null)); + } + + [Fact] + public void Add_ThrowsExceptionWhenAddingDuplicateID() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.Throws(() => target.Add(_data[0])); + } + + [Fact] + public void Clear_RemovesAllItemsFromCollection() + { + OsmDatabase target = new OsmDatabase(_data); + target.Clear(); + + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseForNull() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.DoesNotContain(null, target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainNode() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.DoesNotContain(new Node(10000), target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsNode() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.Contains(_nodeData[0], target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainWay() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.DoesNotContain(new Way(10000), target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsWay() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.Contains(_wayData[0], target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainRelation() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.DoesNotContain(new Relation(10000), target); + } + + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsRelation() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.Contains(_relationData[0], target); + } + + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainNodeID() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.False(target.Contains(10000, EntityType.Node)); + } + + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsNodeID() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.True(target.Contains(_nodeData[0].ID, EntityType.Node)); + } + + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainWayID() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.False(target.Contains(10000, EntityType.Way)); + } + + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsWayID() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.True(target.Contains(_wayData[0].ID, EntityType.Way)); + } + + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainRelationID() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.False(target.Contains(10000, EntityType.Relation)); + } + + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsRelationID() + { + OsmDatabase target = new OsmDatabase(_data); + + Assert.True(target.Contains(_relationData[0].ID, EntityType.Relation)); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() + { + OsmDatabase target = new OsmDatabase(_data); + + bool callResult = target.Remove(null); + + Assert.False(callResult); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + + bool callResult = target.Remove(_nodeData[0]); + + Assert.False(callResult); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesNodeFromCollection() + { + OsmDatabase target = new OsmDatabase(_nodeData); + + bool callResult = target.Remove(_data[0]); + + Assert.True(callResult); + Assert.DoesNotContain(_nodeData[0], target); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + + bool callResult = target.Remove(_wayData[0]); + + Assert.False(callResult); + Assert.Contains(_wayData[1], target); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesWayFromCollection() + { + OsmDatabase target = new OsmDatabase(_wayData); + + bool callResult = target.Remove(_wayData[0]); + + Assert.True(callResult); + Assert.DoesNotContain(_wayData[0], target); + Assert.Contains(_wayData[1], target); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + + bool callResult = target.Remove(_relationData[0]); + + Assert.False(callResult); + Assert.Contains(_relationData[1], target); + } + + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesRelationFromCollection() + { + OsmDatabase target = new OsmDatabase(_relationData); + + bool callResult = target.Remove(_relationData[0]); + + Assert.True(callResult); + Assert.DoesNotContain(_relationData[0], target); + Assert.Contains(_relationData[1], target); + } + + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + + bool callResult = target.Remove(_nodeData[0].ID, EntityType.Node); + + Assert.False(callResult); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } + + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesNodeFromCollection() + { + OsmDatabase target = new OsmDatabase(_nodeData); + + bool callResult = target.Remove(_data[0].ID, EntityType.Node); + + Assert.True(callResult); + Assert.DoesNotContain(_nodeData[0], target); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } + + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + + bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); + + Assert.False(callResult); + Assert.Contains(_wayData[1], target); + } + + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesWayFromCollection() + { + OsmDatabase target = new OsmDatabase(_wayData); + + bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); + + Assert.True(callResult); + Assert.DoesNotContain(_wayData[0], target); + Assert.Contains(_wayData[1], target); + } + + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + + bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); + + Assert.False(callResult); + Assert.Contains(_relationData[1], target); + } + + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesRelationFromCollection() + { + OsmDatabase target = new OsmDatabase(_relationData); + + bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); + + Assert.True(callResult); + Assert.DoesNotContain(_relationData[0], target); + Assert.Contains(_relationData[1], target); + } + + [Fact] + public void GetEnumerator_ReturnsEnumeratorThatEnumeratesAllEntities() + { + OsmDatabase target = new OsmDatabase(_data); + + IEnumerable result = target; + + Assert.Equal(_data.Length, target.Count()); + foreach (var entity in target) + { + Assert.Contains(entity, _data); + } + } + + [Fact] + public void CopyTo_CopiesEntitiesToArray() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry[] array = new IOsmGeometry[_data.Length]; + + target.CopyTo(array, 0); + + for (int i = 0; i < _data.Length; i++) + { + Assert.Same(_data[i], array[i]); + } + } + + } +} diff --git a/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs index a62145a..b14c339 100644 --- a/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs @@ -1,125 +1,140 @@ -using System.Collections.Generic; -using System.Linq; -using System.IO; - -using Xunit; -using Moq; - -using SpatialLite.Osm; -using SpatialLite.Osm.IO; -using Tests.SpatialLite.Osm.Data; - -namespace Tests.SpatialLite.Osm.Geometries { - public class OsmEntityInfoDatabaseTests { - NodeInfo[] _nodeData; - WayInfo[] _wayData; - RelationInfo[] _relationData; - IEntityInfo[] _data; - - public OsmEntityInfoDatabaseTests() { - _nodeData = new NodeInfo[3]; - _nodeData[0] = new NodeInfo(1, 10.1, 11.1, new TagsCollection()); - _nodeData[1] = new NodeInfo(2, 10.2, 11.2, new TagsCollection()); - _nodeData[2] = new NodeInfo(3, 10.3, 11.3, new TagsCollection()); - - _wayData = new WayInfo[2]; - _wayData[0] = new WayInfo(10, new TagsCollection(), _nodeData.Select(n => n.ID).ToArray()); - _wayData[1] = new WayInfo(11, new TagsCollection(), _nodeData.Select(n => n.ID).Skip(1).ToArray()); - - _relationData = new RelationInfo[2]; - _relationData[0] = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 10, Role = "way" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); - _relationData[1] = new RelationInfo(101, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 101, Role = "relation" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); - - _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); - } - - [Fact] - public void Constructor__CreatesEmptyDatabase() { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(); - - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } - - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); - - for (int i = 0; i < _data.Length; i++) { - Assert.Contains(_data[i], target); - } - } - - [Fact] - public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); - - for (int i = 0; i < _nodeData.Length; i++) { - Assert.Contains(_nodeData[i], target.Nodes); - } - - for (int i = 0; i < _wayData.Length; i++) { - Assert.Contains(_wayData[i], target.Ways); - } - - for (int i = 0; i < _relationData.Length; i++) { - Assert.Contains(_relationData[i], target.Relations); - } - } - - [Fact] - public void Load_IOsmReader_LoadsNodes() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); - } - - [Fact] - public void Load_IOsmReader_LoadsWay() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); - - Assert.Equal(1, target.Ways.Count); - Assert.True(target.Ways.Contains(10)); - } - - [Fact] - public void Load_IOsmReader_LoadsRelation() { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - - Assert.Equal(1, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - - Assert.Equal(1, target.Relations.Count); - Assert.True(target.Relations.Contains(100)); - } - - [Fact] - public void Save_CallsIOsmWriterWriteForAllEntities() { - List written = new List(); - Mock writerM = new Mock(); - - writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); - - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); - target.Save(writerM.Object); - - Assert.Equal(target.Count, written.Count); - foreach (var entity in target) { - Assert.Contains(entity, written); - } - } - } -} \ No newline at end of file +using System.Collections.Generic; +using System.Linq; +using System.IO; + +using Xunit; +using Moq; + +using SpatialLite.Osm; +using SpatialLite.Osm.IO; +using Tests.SpatialLite.Osm.Data; + +namespace Tests.SpatialLite.Osm.Geometries +{ + public class OsmEntityInfoDatabaseTests + { + NodeInfo[] _nodeData; + WayInfo[] _wayData; + RelationInfo[] _relationData; + IEntityInfo[] _data; + + public OsmEntityInfoDatabaseTests() + { + _nodeData = new NodeInfo[3]; + _nodeData[0] = new NodeInfo(1, 10.1, 11.1, new TagsCollection()); + _nodeData[1] = new NodeInfo(2, 10.2, 11.2, new TagsCollection()); + _nodeData[2] = new NodeInfo(3, 10.3, 11.3, new TagsCollection()); + + _wayData = new WayInfo[2]; + _wayData[0] = new WayInfo(10, new TagsCollection(), _nodeData.Select(n => n.ID).ToArray()); + _wayData[1] = new WayInfo(11, new TagsCollection(), _nodeData.Select(n => n.ID).Skip(1).ToArray()); + + _relationData = new RelationInfo[2]; + _relationData[0] = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 10, Role = "way" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); + _relationData[1] = new RelationInfo(101, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 101, Role = "relation" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); + + _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); + } + + [Fact] + public void Constructor__CreatesEmptyDatabase() + { + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(); + + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } + + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + + for (int i = 0; i < _data.Length; i++) + { + Assert.Contains(_data[i], target); + } + } + + [Fact] + public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() + { + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + + for (int i = 0; i < _nodeData.Length; i++) + { + Assert.Contains(_nodeData[i], target.Nodes); + } + + for (int i = 0; i < _wayData.Length; i++) + { + Assert.Contains(_wayData[i], target.Ways); + } + + for (int i = 0; i < _relationData.Length; i++) + { + Assert.Contains(_relationData[i], target.Relations); + } + } + + [Fact] + public void Load_IOsmReader_LoadsNodes() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); + } + + [Fact] + public void Load_IOsmReader_LoadsWay() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); + + Assert.Equal(1, target.Ways.Count); + Assert.True(target.Ways.Contains(10)); + } + + [Fact] + public void Load_IOsmReader_LoadsRelation() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + + Assert.Equal(1, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + + Assert.Equal(1, target.Relations.Count); + Assert.True(target.Relations.Contains(100)); + } + + [Fact] + public void Save_CallsIOsmWriterWriteForAllEntities() + { + List written = new List(); + Mock writerM = new Mock(); + + writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); + + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + target.Save(writerM.Object); + + Assert.Equal(target.Count, written.Count); + foreach (var entity in target) + { + Assert.Contains(entity, written); + } + } + } +} diff --git a/src/Tests.SpatialLite.Osm/PathHelper.cs b/src/Tests.SpatialLite.Osm/PathHelper.cs index a02dfac..96453d2 100644 --- a/src/Tests.SpatialLite.Osm/PathHelper.cs +++ b/src/Tests.SpatialLite.Osm/PathHelper.cs @@ -1,30 +1,35 @@ -using System.IO; - -namespace Tests.SpatialLite.Osm { - static class PathHelper { - private const string TempDirectoryName = "Temp"; - - private static string _osmosisPath = Path.GetFullPath(Path.Combine("Utils", "Osmosis", "bin", "osmosis.bat")); - public static string OsmosisPath => _osmosisPath; - - private static string _realXmlFilePath = Path.GetFullPath(Path.Combine("Data", "Xml", "osm-real-file.osm")); - public static string RealXmlFilePath => _realXmlFilePath; - - - private static string _realPbfFilePath = Path.GetFullPath(Path.Combine("Data", "Pbf", "pbf-real-file.pbf")); - public static string RealPbfFilePath => _realPbfFilePath; - - public static string GetTempFilePath(string filename) { - if (!Directory.Exists(TempDirectoryName)) { - Directory.CreateDirectory(TempDirectoryName); - } - - string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); - if (File.Exists(pbfFile)) { - File.Delete(pbfFile); - } - - return pbfFile; - } - } -} +using System.IO; + +namespace Tests.SpatialLite.Osm +{ + static class PathHelper + { + private const string TempDirectoryName = "Temp"; + + private static string _osmosisPath = Path.GetFullPath(Path.Combine("Utils", "Osmosis", "bin", "osmosis.bat")); + public static string OsmosisPath => _osmosisPath; + + private static string _realXmlFilePath = Path.GetFullPath(Path.Combine("Data", "Xml", "osm-real-file.osm")); + public static string RealXmlFilePath => _realXmlFilePath; + + + private static string _realPbfFilePath = Path.GetFullPath(Path.Combine("Data", "Pbf", "pbf-real-file.pbf")); + public static string RealPbfFilePath => _realPbfFilePath; + + public static string GetTempFilePath(string filename) + { + if (!Directory.Exists(TempDirectoryName)) + { + Directory.CreateDirectory(TempDirectoryName); + } + + string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); + if (File.Exists(pbfFile)) + { + File.Delete(pbfFile); + } + + return pbfFile; + } + } +} diff --git a/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs b/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs index 9d8b2db..b1b700a 100644 --- a/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs +++ b/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs @@ -1,19 +1,19 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tests.SpatialLite.Osm")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("31b15109-c9ad-428b-bd1a-6f13ea2cd852")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tests.SpatialLite.Osm")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("31b15109-c9ad-428b-bd1a-6f13ea2cd852")] diff --git a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs index 09c394d..abe78d8 100644 --- a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs @@ -1,71 +1,79 @@ -using System; -using System.Collections.Generic; - -using Xunit; - -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; - -namespace Tests.SpatialLite.Osm { - public class RelationMemberTests { - - [Fact] - public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() { - int id = 45; - TagsCollection tags = new TagsCollection(); - List members = new List(); - - RelationInfo target = new RelationInfo(id, tags, members); - - Assert.Equal(EntityType.Relation, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(members, target.Members); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_Properties_SetsProperties() { - int id = 45; - TagsCollection tags = new TagsCollection(); - List members = new List(); - EntityMetadata details = new EntityMetadata(); - - RelationInfo target = new RelationInfo(id, tags, members, details); - - Assert.Equal(EntityType.Relation, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(members, target.Members); - Assert.Same(details, target.Metadata); - } - - [Fact] - public void Constructor_Relation_SetsProperties() { - Relation relation = new Relation(100, new RelationMember[0], new TagsCollection()) { Metadata = new EntityMetadata() }; - - RelationInfo target = new RelationInfo(relation); - - Assert.Equal(relation.ID, target.ID); - Assert.Same(relation.Tags, target.Tags); - Assert.Same(relation.Metadata, target.Metadata); - } - - [Fact] - public void Constructor_Relation_SetsRelationMembers() { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)) }, new TagsCollection()) { Metadata = new EntityMetadata() }; - - RelationInfo target = new RelationInfo(relation); - - Assert.Equal(relation.Geometries.Count, target.Members.Count); - for (int i = 0; i < relation.Geometries.Count; i++) { - Assert.Equal(relation.Geometries[i].Member.ID, target.Members[i].Reference); - } - } - - [Fact] - public void Constructor_Relation_ThrowExceptionIfRelationIsNull() { - Assert.Throws(() => new RelationInfo(null)); - } - } -} +using System; +using System.Collections.Generic; + +using Xunit; + +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm; + +namespace Tests.SpatialLite.Osm +{ + public class RelationMemberTests + { + + [Fact] + public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List members = new List(); + + RelationInfo target = new RelationInfo(id, tags, members); + + Assert.Equal(EntityType.Relation, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(members, target.Members); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_Properties_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List members = new List(); + EntityMetadata details = new EntityMetadata(); + + RelationInfo target = new RelationInfo(id, tags, members, details); + + Assert.Equal(EntityType.Relation, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(members, target.Members); + Assert.Same(details, target.Metadata); + } + + [Fact] + public void Constructor_Relation_SetsProperties() + { + Relation relation = new Relation(100, new RelationMember[0], new TagsCollection()) { Metadata = new EntityMetadata() }; + + RelationInfo target = new RelationInfo(relation); + + Assert.Equal(relation.ID, target.ID); + Assert.Same(relation.Tags, target.Tags); + Assert.Same(relation.Metadata, target.Metadata); + } + + [Fact] + public void Constructor_Relation_SetsRelationMembers() + { + Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)) }, new TagsCollection()) { Metadata = new EntityMetadata() }; + + RelationInfo target = new RelationInfo(relation); + + Assert.Equal(relation.Geometries.Count, target.Members.Count); + for (int i = 0; i < relation.Geometries.Count; i++) + { + Assert.Equal(relation.Geometries[i].Member.ID, target.Members[i].Reference); + } + } + + [Fact] + public void Constructor_Relation_ThrowExceptionIfRelationIsNull() + { + Assert.Throws(() => new RelationInfo(null)); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs index da718d6..9d639f5 100644 --- a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs @@ -1,20 +1,23 @@ -using Xunit; - -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; - -namespace Tests.SpatialLite.Osm { - public class RelationMemberInfoTests { - - [Fact] - public void Constructor_RelationMember_SetsProperties() { - RelationMember member = new RelationMember(new Node(1), "test-role"); - - RelationMemberInfo target = new RelationMemberInfo(member); - - Assert.Equal(member.Member.ID, target.Reference); - Assert.Equal(member.MemberType, target.MemberType); - Assert.Equal(member.Role, target.Role); - } - } -} +using Xunit; + +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; + +namespace Tests.SpatialLite.Osm +{ + public class RelationMemberInfoTests + { + + [Fact] + public void Constructor_RelationMember_SetsProperties() + { + RelationMember member = new RelationMember(new Node(1), "test-role"); + + RelationMemberInfo target = new RelationMemberInfo(member); + + Assert.Equal(member.Member.ID, target.Reference); + Assert.Equal(member.MemberType, target.MemberType); + Assert.Equal(member.Role, target.Role); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/TagTests.cs b/src/Tests.SpatialLite.Osm/TagTests.cs index 4ac7c51..25ee471 100644 --- a/src/Tests.SpatialLite.Osm/TagTests.cs +++ b/src/Tests.SpatialLite.Osm/TagTests.cs @@ -1,94 +1,106 @@ -using System; - -using Xunit; - -using SpatialLite.Osm; - -namespace Tests.SpatialLite.Osm { - public class TagTests { - - [Fact] - public void Constructor_TagValue_SetsKeyAndValue() { - string key = "test-key"; - string value = "test-value"; - - Tag target = new Tag(key, value); - - Assert.Equal(key, target.Key); - Assert.Equal(value, target.Value); - } - - [Fact] - public void Constructor_TagValue_ThrowsExceptionIfKeyIsNull() { - string key = null; - string value = "test-value"; - - Assert.Throws(delegate { new Tag(key, value); }); - } - - [Fact] - public void Constructor_TagValue_ThrowsExceptionIfKeyIsEmpty() { - string key = string.Empty; - string value = "test-value"; - - Assert.Throws(delegate { new Tag(key, value); }); - } - - [Fact] - public void Constructor_TagValue_ThrowsExceptionIfValueIsNull() { - string key = "test-key"; - string value = null; - - Assert.Throws(delegate { new Tag(key, value); }); - } - - [Fact] - public void Equals_ReturnTrueForSameKeyAndValue() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "test-value"); - - Assert.True(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnTrueForSameKeyAndValueAsObject() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "test-value"); - - Assert.True(target.Equals((object)other)); - } - - [Fact] - public void Equals_ReturnFalseForDifferentKeys() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("different-key", "test-value"); - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnFalseForDifferentValues() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "different-value"); - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnFalseForOtherObject() { - Tag target = new Tag("test-key", "test-value"); - string other = "Test"; - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnFalseForNull() { - Tag target = new Tag("test-key", "test-value"); - object other = null; - - Assert.False(target.Equals(other)); - } - - } -} +using System; + +using Xunit; + +using SpatialLite.Osm; + +namespace Tests.SpatialLite.Osm +{ + public class TagTests + { + + [Fact] + public void Constructor_TagValue_SetsKeyAndValue() + { + string key = "test-key"; + string value = "test-value"; + + Tag target = new Tag(key, value); + + Assert.Equal(key, target.Key); + Assert.Equal(value, target.Value); + } + + [Fact] + public void Constructor_TagValue_ThrowsExceptionIfKeyIsNull() + { + string key = null; + string value = "test-value"; + + Assert.Throws(delegate { new Tag(key, value); }); + } + + [Fact] + public void Constructor_TagValue_ThrowsExceptionIfKeyIsEmpty() + { + string key = string.Empty; + string value = "test-value"; + + Assert.Throws(delegate { new Tag(key, value); }); + } + + [Fact] + public void Constructor_TagValue_ThrowsExceptionIfValueIsNull() + { + string key = "test-key"; + string value = null; + + Assert.Throws(delegate { new Tag(key, value); }); + } + + [Fact] + public void Equals_ReturnTrueForSameKeyAndValue() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("test-key", "test-value"); + + Assert.True(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnTrueForSameKeyAndValueAsObject() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("test-key", "test-value"); + + Assert.True(target.Equals((object)other)); + } + + [Fact] + public void Equals_ReturnFalseForDifferentKeys() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("different-key", "test-value"); + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnFalseForDifferentValues() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("test-key", "different-value"); + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnFalseForOtherObject() + { + Tag target = new Tag("test-key", "test-value"); + string other = "Test"; + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnFalseForNull() + { + Tag target = new Tag("test-key", "test-value"); + object other = null; + + Assert.False(target.Equals(other)); + } + + } +} diff --git a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs index 074270c..afea05c 100644 --- a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs @@ -1,305 +1,343 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using Xunit; - -using SpatialLite.Osm; - -namespace Tests.SpatialLite.Osm { - public class TagsCollectionTests { - Tag[] _tags = new Tag[] { - new Tag("test-key-1", "test-value-1"), - new Tag("test-key-2", "test-value-2"), - new Tag("test-key-3", "test-value-3") - }; - - Tag[] _tagsDuplicitKeys = new Tag[] { - new Tag("test-key-1", "test-value-1"), - new Tag("test-key-1", "test-value-2") - }; - - [Fact] - public void Constructor_CreatesEmptyTagsCollection() { - TagsCollection target = new TagsCollection(); - - Assert.Empty(target); - } - - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithGivetTags() { - TagsCollection target = new TagsCollection(_tags); - - Assert.Equal(_tags.Count(), target.Count()); - Assert.Contains(_tags[0], target); - Assert.Contains(_tags[1], target); - } - - [Fact] - public void Constructor_IEnumerable_ThrowsExceptionWithDuplicateKeys() { - Assert.Throws(() => new TagsCollection(_tagsDuplicitKeys)); - } - - [Fact] - public void Add_AddsTag() { - TagsCollection target = new TagsCollection(); - target.Add(_tags[0]); - - Assert.Contains(_tags[0], target); - } - - [Fact] - public void Add_ThrowsExceptionIfTagAlreadyPresent() { - TagsCollection target = new TagsCollection(); - target.Add(_tagsDuplicitKeys[0]); - - Assert.Throws(delegate { target.Add(_tagsDuplicitKeys[1]); }); - } - - [Fact] - public void Clear_DoesNothingOnEmptyCollection() { - TagsCollection target = new TagsCollection(); - - target.Clear(); - } - - [Fact] - public void Clear_RemovesAllItems() { - TagsCollection target = new TagsCollection(_tags); - target.Clear(); - - Assert.Empty(target); - } - - [Fact] - public void Contains_Tag_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); - - Assert.DoesNotContain(new Tag("key", "value"), target); - } - - [Fact] - public void Contains_Tag_ReturnsFalseIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); - - Tag testTag = new Tag("test-key-1", "other-value"); - Assert.DoesNotContain(testTag, target); - } - - [Fact] - public void Contains_Tag_ReturnsTrueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); - - Assert.Contains(_tags[0], target); - } - - [Fact] - public void Contains_string_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); - - Assert.False(target.Contains("key")); - } - - [Fact] - public void Contains_string_ReturnsFalseIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); - - Assert.False(target.Contains("non-existing-key")); - } - - [Fact] - public void Contains_string_ReturnsTrueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); - - Assert.True(target.Contains(_tags[0].Key)); - } - - [Fact] - public void CopyTo_ThrowsArgumentNullExceptionIfArrayIsNull() { - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.CopyTo(null, 0)); - } - - [Fact] - public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero() { - Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.CopyTo(array, -4)); - } - - [Fact] - public void CopyTo_ThrowsArgumentExceptionIfSpaceDesignedForCollectionInArrayIsShort() { - Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.CopyTo(array, 4)); - } - - [Fact] - public void CopyTo_CopiesElementsToArray() { - Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); - - target.CopyTo(array, 1); - - Assert.Null(array[0]); - Assert.Same(_tags[0], array[1]); - Assert.Same(_tags[1], array[2]); - Assert.Same(_tags[2], array[3]); - Assert.Null(array[4]); - } - - [Fact] - public void GetTag_ReturnsNullForEmptyCollection() { - TagsCollection target = new TagsCollection(); - - Assert.Throws(() => target.GetTag("other-key")); - } - - [Fact] - public void GetTag_ReturnsNullIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.GetTag("other-key")); - } - - [Fact] - public void GetTag_ReturnsTagIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); - Tag returned = target.GetTag(_tags[0].Key); - - Assert.Same(_tags[0], returned); - } - - [Fact] - public void Remove_Tag_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); - bool removed = target.Remove(new Tag("key", "value")); - - Assert.False(removed); - } - - [Fact] - public void Remove_Tag_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); - - Tag testTag = new Tag("other-key", "other-value"); - Assert.False(target.Remove(testTag)); - this.CompareCollections(_tags, target); - } - - [Fact] - public void Remove_Tag_RemovesItemAndReturnsTrueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); - - Assert.True(target.Remove(_tags[0])); - this.CompareCollections(_tags.Skip(1), target); - } - - [Fact] - public void Remove_string_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); - bool removed = target.Remove("key"); - - Assert.False(removed); - } - - [Fact] - public void Remove_string_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() { - Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; - - TagsCollection target = new TagsCollection(tags); - - Assert.False(target.Remove("non-existing-tag")); - } - - [Fact] - public void Remove_string_RemovesItemAndReturnsTrueIfCollectionContainsTag() { - Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; - - TagsCollection target = new TagsCollection(tags); - - Assert.True(target.Remove(tags[1].Key)); - Assert.Single(target); - Assert.Contains(tags[0], target); - } - - [Fact] - public void Count_ReturnsZeroForEmptyCollection() { - TagsCollection target = new TagsCollection(); - - Assert.Empty(target); - } - - [Fact] - public void Count_ReturnsTagsCount() { - TagsCollection target = new TagsCollection(_tags); - - Assert.Equal(_tags.Length, target.Count); - } - - [Fact] - public void IsReadOnly_ReturnsFalse() { - TagsCollection target = new TagsCollection(); - - Assert.False(target.IsReadOnly); - } - - [Fact] - public void Item_Get_ThrowsExceptionForEmptyCollection() { - TagsCollection target = new TagsCollection(); - - Assert.Throws(() => target["other-key"]); - } - - [Fact] - public void Item_Get_ThrowsExceptionIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target["other-key"]); - } - - [Fact] - public void Item_Get_ReturnsTagValueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); - string returnedValue = target[_tags[0].Key]; - - Assert.Equal(_tags[0].Value, returnedValue); - } - - [Fact] - public void Item_Set_AddsItemToEmptyCollection() { - TagsCollection target = new TagsCollection(); - - target["test-key"] = "test-value"; - - Assert.Single(target); - Assert.Equal("test-value", target["test-key"]); - } - - [Fact] - public void Item_Set_AddsItemToCollection() { - TagsCollection target = new TagsCollection(_tags); - - target["test-key-101"] = "test-value-101"; - - Assert.Equal(_tags.Length + 1, target.Count); - Assert.Equal("test-value-101", target["test-key-101"]); - } - - [Fact] - public void Item_Set_SetsTagValue() { - TagsCollection target = new TagsCollection(_tags); - target[_tags[0].Key] = "new-value"; - - Assert.Equal("new-value", target[_tags[0].Key]); - } - - private void CompareCollections(IEnumerable expected, IEnumerable actual) { - Assert.Equal(expected.Count(), actual.Count()); - Assert.True(expected.All(tag => actual.Contains(tag))); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; + +using Xunit; + +using SpatialLite.Osm; + +namespace Tests.SpatialLite.Osm +{ + public class TagsCollectionTests + { + Tag[] _tags = new Tag[] { + new Tag("test-key-1", "test-value-1"), + new Tag("test-key-2", "test-value-2"), + new Tag("test-key-3", "test-value-3") + }; + + Tag[] _tagsDuplicitKeys = new Tag[] { + new Tag("test-key-1", "test-value-1"), + new Tag("test-key-1", "test-value-2") + }; + + [Fact] + public void Constructor_CreatesEmptyTagsCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.Empty(target); + } + + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithGivetTags() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Equal(_tags.Count(), target.Count()); + Assert.Contains(_tags[0], target); + Assert.Contains(_tags[1], target); + } + + [Fact] + public void Constructor_IEnumerable_ThrowsExceptionWithDuplicateKeys() + { + Assert.Throws(() => new TagsCollection(_tagsDuplicitKeys)); + } + + [Fact] + public void Add_AddsTag() + { + TagsCollection target = new TagsCollection(); + target.Add(_tags[0]); + + Assert.Contains(_tags[0], target); + } + + [Fact] + public void Add_ThrowsExceptionIfTagAlreadyPresent() + { + TagsCollection target = new TagsCollection(); + target.Add(_tagsDuplicitKeys[0]); + + Assert.Throws(delegate { target.Add(_tagsDuplicitKeys[1]); }); + } + + [Fact] + public void Clear_DoesNothingOnEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + target.Clear(); + } + + [Fact] + public void Clear_RemovesAllItems() + { + TagsCollection target = new TagsCollection(_tags); + target.Clear(); + + Assert.Empty(target); + } + + [Fact] + public void Contains_Tag_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.DoesNotContain(new Tag("key", "value"), target); + } + + [Fact] + public void Contains_Tag_ReturnsFalseIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Tag testTag = new Tag("test-key-1", "other-value"); + Assert.DoesNotContain(testTag, target); + } + + [Fact] + public void Contains_Tag_ReturnsTrueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Contains(_tags[0], target); + } + + [Fact] + public void Contains_string_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.False(target.Contains("key")); + } + + [Fact] + public void Contains_string_ReturnsFalseIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.False(target.Contains("non-existing-key")); + } + + [Fact] + public void Contains_string_ReturnsTrueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.True(target.Contains(_tags[0].Key)); + } + + [Fact] + public void CopyTo_ThrowsArgumentNullExceptionIfArrayIsNull() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.CopyTo(null, 0)); + } + + [Fact] + public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero() + { + Tag[] array = new Tag[5]; + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.CopyTo(array, -4)); + } + + [Fact] + public void CopyTo_ThrowsArgumentExceptionIfSpaceDesignedForCollectionInArrayIsShort() + { + Tag[] array = new Tag[5]; + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.CopyTo(array, 4)); + } + + [Fact] + public void CopyTo_CopiesElementsToArray() + { + Tag[] array = new Tag[5]; + TagsCollection target = new TagsCollection(_tags); + + target.CopyTo(array, 1); + + Assert.Null(array[0]); + Assert.Same(_tags[0], array[1]); + Assert.Same(_tags[1], array[2]); + Assert.Same(_tags[2], array[3]); + Assert.Null(array[4]); + } + + [Fact] + public void GetTag_ReturnsNullForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.Throws(() => target.GetTag("other-key")); + } + + [Fact] + public void GetTag_ReturnsNullIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.GetTag("other-key")); + } + + [Fact] + public void GetTag_ReturnsTagIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + Tag returned = target.GetTag(_tags[0].Key); + + Assert.Same(_tags[0], returned); + } + + [Fact] + public void Remove_Tag_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + bool removed = target.Remove(new Tag("key", "value")); + + Assert.False(removed); + } + + [Fact] + public void Remove_Tag_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Tag testTag = new Tag("other-key", "other-value"); + Assert.False(target.Remove(testTag)); + this.CompareCollections(_tags, target); + } + + [Fact] + public void Remove_Tag_RemovesItemAndReturnsTrueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.True(target.Remove(_tags[0])); + this.CompareCollections(_tags.Skip(1), target); + } + + [Fact] + public void Remove_string_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + bool removed = target.Remove("key"); + + Assert.False(removed); + } + + [Fact] + public void Remove_string_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() + { + Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; + + TagsCollection target = new TagsCollection(tags); + + Assert.False(target.Remove("non-existing-tag")); + } + + [Fact] + public void Remove_string_RemovesItemAndReturnsTrueIfCollectionContainsTag() + { + Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; + + TagsCollection target = new TagsCollection(tags); + + Assert.True(target.Remove(tags[1].Key)); + Assert.Single(target); + Assert.Contains(tags[0], target); + } + + [Fact] + public void Count_ReturnsZeroForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.Empty(target); + } + + [Fact] + public void Count_ReturnsTagsCount() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Equal(_tags.Length, target.Count); + } + + [Fact] + public void IsReadOnly_ReturnsFalse() + { + TagsCollection target = new TagsCollection(); + + Assert.False(target.IsReadOnly); + } + + [Fact] + public void Item_Get_ThrowsExceptionForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.Throws(() => target["other-key"]); + } + + [Fact] + public void Item_Get_ThrowsExceptionIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target["other-key"]); + } + + [Fact] + public void Item_Get_ReturnsTagValueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + string returnedValue = target[_tags[0].Key]; + + Assert.Equal(_tags[0].Value, returnedValue); + } + + [Fact] + public void Item_Set_AddsItemToEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + target["test-key"] = "test-value"; + + Assert.Single(target); + Assert.Equal("test-value", target["test-key"]); + } + + [Fact] + public void Item_Set_AddsItemToCollection() + { + TagsCollection target = new TagsCollection(_tags); + + target["test-key-101"] = "test-value-101"; + + Assert.Equal(_tags.Length + 1, target.Count); + Assert.Equal("test-value-101", target["test-key-101"]); + } + + [Fact] + public void Item_Set_SetsTagValue() + { + TagsCollection target = new TagsCollection(_tags); + target[_tags[0].Key] = "new-value"; + + Assert.Equal("new-value", target[_tags[0].Key]); + } + + private void CompareCollections(IEnumerable expected, IEnumerable actual) + { + Assert.Equal(expected.Count(), actual.Count()); + Assert.True(expected.All(tag => actual.Contains(tag))); + } + } +} diff --git a/src/Tests.SpatialLite.Osm/WayInfoTests.cs b/src/Tests.SpatialLite.Osm/WayInfoTests.cs index bdc3e12..7383f5a 100644 --- a/src/Tests.SpatialLite.Osm/WayInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/WayInfoTests.cs @@ -6,66 +6,74 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm { - public class WayInfoTests { - - [Fact] - public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() { - int id = 45; - TagsCollection tags = new TagsCollection(); - List nodes = new List(); - - WayInfo target = new WayInfo(id, tags, nodes); - - Assert.Equal(EntityType.Way, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(nodes, target.Nodes); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_Properties_SetsProperties() { - int id = 45; - TagsCollection tags = new TagsCollection(); - List nodes = new List(); - EntityMetadata details = new EntityMetadata(); - - WayInfo target = new WayInfo(id, tags, nodes, details); - - Assert.Equal(EntityType.Way, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(nodes, target.Nodes); - Assert.Same(details, target.Metadata); - } - - [Fact] - public void Constructor_Way_SetsProperties() { - Way way = new Way(10, new Node[0], new TagsCollection()) { Metadata = new EntityMetadata() }; - - WayInfo target = new WayInfo(way); - - Assert.Equal(way.ID, target.ID); - Assert.Same(way.Tags, target.Tags); - Assert.Same(way.Metadata, target.Metadata); - } - - [Fact] - public void Constructor_Way_SetsNodesReferences() { - Way way = new Way(10, new Node[] {new Node(1), new Node(2), new Node(3)}, new TagsCollection()) { Metadata = new EntityMetadata() }; - - WayInfo target = new WayInfo(way); - - Assert.Equal(way.Nodes.Count, target.Nodes.Count); - for (int i = 0; i < way.Nodes.Count; i++) { - Assert.Equal(way.Nodes[i].ID, target.Nodes[i]); - } - } - - [Fact] - public void Constructor_Way_ThrowsExceptionIfWayIsNull() { - Assert.Throws(() => new WayInfo(null)); - } - } +namespace Tests.SpatialLite.Osm +{ + public class WayInfoTests + { + + [Fact] + public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List nodes = new List(); + + WayInfo target = new WayInfo(id, tags, nodes); + + Assert.Equal(EntityType.Way, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(nodes, target.Nodes); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_Properties_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List nodes = new List(); + EntityMetadata details = new EntityMetadata(); + + WayInfo target = new WayInfo(id, tags, nodes, details); + + Assert.Equal(EntityType.Way, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(nodes, target.Nodes); + Assert.Same(details, target.Metadata); + } + + [Fact] + public void Constructor_Way_SetsProperties() + { + Way way = new Way(10, new Node[0], new TagsCollection()) { Metadata = new EntityMetadata() }; + + WayInfo target = new WayInfo(way); + + Assert.Equal(way.ID, target.ID); + Assert.Same(way.Tags, target.Tags); + Assert.Same(way.Metadata, target.Metadata); + } + + [Fact] + public void Constructor_Way_SetsNodesReferences() + { + Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }, new TagsCollection()) { Metadata = new EntityMetadata() }; + + WayInfo target = new WayInfo(way); + + Assert.Equal(way.Nodes.Count, target.Nodes.Count); + for (int i = 0; i < way.Nodes.Count; i++) + { + Assert.Equal(way.Nodes[i].ID, target.Nodes[i]); + } + } + + [Fact] + public void Constructor_Way_ThrowsExceptionIfWayIsNull() + { + Assert.Throws(() => new WayInfo(null)); + } + } } From f3809c2769348f1b8640b6048d5cee5c5e083ef7 Mon Sep 17 00:00:00 2001 From: Lukas Kabrt Date: Thu, 22 May 2025 22:44:13 +0200 Subject: [PATCH 05/14] Convert to file scoped namespaces. --- src/Benchmark.SpatialLite.Osm/Program.cs | 311 +++-- src/SpatialLite.Core/API/Coordinate.cs | 313 +++-- src/SpatialLite.Core/API/Envelope.cs | 751 +++++----- src/SpatialLite.Core/API/ICoordinateList.cs | 93 +- src/SpatialLite.Core/API/IGeometry.cs | 49 +- .../API/IGeometryCollection.cs | 19 +- src/SpatialLite.Core/API/ILineString.cs | 47 +- src/SpatialLite.Core/API/IMultiLineString.cs | 13 +- src/SpatialLite.Core/API/IMultiPoint.cs | 13 +- src/SpatialLite.Core/API/IMultiPolygon.cs | 13 +- src/SpatialLite.Core/API/IPoint.cs | 17 +- src/SpatialLite.Core/API/IPolygon.cs | 25 +- .../Algorithms/Euclidean2DCalculator.cs | 140 +- .../Algorithms/Euclidean2DLocator.cs | 320 +++-- .../Algorithms/IDimensionsCalculator.cs | 53 +- .../Algorithms/IGeometryLocator.cs | 91 +- src/SpatialLite.Core/Algorithms/LineMode.cs | 25 +- .../Algorithms/Sphere2DCalculator.cs | 245 ++-- .../Geometries/CoordinateList.cs | 195 ++- src/SpatialLite.Core/Geometries/Geometry.cs | 51 +- .../Geometries/GeometryCollection.cs | 161 ++- src/SpatialLite.Core/Geometries/LineString.cs | 223 ++- .../Geometries/MultiLineString.cs | 51 +- src/SpatialLite.Core/Geometries/MultiPoint.cs | 51 +- .../Geometries/MultiPolygon.cs | 51 +- src/SpatialLite.Core/Geometries/Point.cs | 189 ++- src/SpatialLite.Core/Geometries/Polygon.cs | 153 ++- .../Geometries/ReadOnlyCoordinateList.cs | 185 ++- src/SpatialLite.Core/IO/BinaryEncoding.cs | 25 +- src/SpatialLite.Core/IO/TokenType.cs | 65 +- src/SpatialLite.Core/IO/WkbFormatException.cs | 21 +- src/SpatialLite.Core/IO/WkbGeometryType.cs | 93 +- src/SpatialLite.Core/IO/WkbReader.cs | 629 +++++---- src/SpatialLite.Core/IO/WkbWriter.cs | 573 ++++---- src/SpatialLite.Core/IO/WkbWriterSettings.cs | 67 +- src/SpatialLite.Core/IO/WktParseException.cs | 21 +- src/SpatialLite.Core/IO/WktReader.cs | 1203 ++++++++--------- src/SpatialLite.Core/IO/WktToken.cs | 33 +- src/SpatialLite.Core/IO/WktTokenizer.cs | 145 +- src/SpatialLite.Core/IO/WktTokensBuffer.cs | 211 ++- src/SpatialLite.Core/IO/WktWriter.cs | 855 ++++++------ src/SpatialLite.Core/IO/WktWriterSettings.cs | 31 +- src/SpatialLite.Core/Measurements.cs | 311 +++-- src/SpatialLite.Core/Topology.cs | 223 ++- src/SpatialLite.Gps/Geometries/GpsFix.cs | 49 +- src/SpatialLite.Gps/Geometries/GpsPoint.cs | 89 +- .../Geometries/GpsTrackBase.cs | 65 +- .../Geometries/GpxFixHelper.cs | 69 +- src/SpatialLite.Gps/Geometries/GpxLink.cs | 49 +- src/SpatialLite.Gps/Geometries/GpxMetadata.cs | 57 +- src/SpatialLite.Gps/Geometries/GpxPoint.cs | 99 +- .../Geometries/GpxPointMetadata.cs | 109 +- src/SpatialLite.Gps/Geometries/GpxRoute.cs | 59 +- src/SpatialLite.Gps/Geometries/GpxTrack.cs | 59 +- .../Geometries/GpxTrackMetadata.cs | 17 +- .../Geometries/GpxTrackSegment.cs | 40 +- src/SpatialLite.Gps/GpxDocument.cs | 215 ++- src/SpatialLite.Gps/GpxGeometryType.cs | 33 +- src/SpatialLite.Gps/IGpsPoint.cs | 17 +- src/SpatialLite.Gps/IGpxGeometry.cs | 17 +- src/SpatialLite.Gps/IO/GpxReader.cs | 691 +++++----- src/SpatialLite.Gps/IO/GpxReaderSettings.cs | 59 +- src/SpatialLite.Gps/IO/GpxWriter.cs | 475 ++++--- src/SpatialLite.Gps/IO/GpxWriterSettings.cs | 87 +- src/SpatialLite.Gps/IO/IGpxReader.cs | 17 +- src/SpatialLite.Gps/IO/IGpxWriter.cs | 39 +- src/SpatialLite.Osm/EntityCollection.cs | 275 ++-- src/SpatialLite.Osm/EntityMetadata.cs | 69 +- src/SpatialLite.Osm/EntityType.cs | 41 +- .../Geometries/IOsmGeometry.cs | 13 +- src/SpatialLite.Osm/Geometries/Node.cs | 163 ++- .../Geometries/OsmGeometryDatabase.cs | 157 ++- src/SpatialLite.Osm/Geometries/Relation.cs | 141 +- .../Geometries/RelationMember.cs | 225 ++- src/SpatialLite.Osm/Geometries/Way.cs | 189 ++- .../Geometries/WayCoordinateList.cs | 187 ++- src/SpatialLite.Osm/IEntityCollection.cs | 53 +- src/SpatialLite.Osm/IEntityInfo.cs | 13 +- src/SpatialLite.Osm/IO/CompressionMode.cs | 25 +- src/SpatialLite.Osm/IO/IOsmReader.cs | 19 +- src/SpatialLite.Osm/IO/IOsmWriter.cs | 37 +- src/SpatialLite.Osm/IO/OsmReaderSettings.cs | 59 +- src/SpatialLite.Osm/IO/OsmWriterSettings.cs | 89 +- src/SpatialLite.Osm/IO/OsmXmlReader.cs | 779 ++++++----- .../IO/OsmXmlReaderSettings.cs | 55 +- src/SpatialLite.Osm/IO/OsmXmlWriter.cs | 445 +++--- src/SpatialLite.Osm/IO/Pbf/Blob.cs | 43 +- src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs | 49 +- .../IO/Pbf/EntityInfoBuffer.cs | 271 ++-- src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs | 53 +- .../IO/Pbf/IStringTableBuilder.cs | 31 +- src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs | 87 +- src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs | 23 +- .../IO/Pbf/PbfDenseMetadata.cs | 185 ++- src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs | 161 ++- src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs | 73 +- src/SpatialLite.Osm/IO/Pbf/PbfNode.cs | 85 +- src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs | 149 +- .../IO/Pbf/PbfRelationMemberType.cs | 33 +- src/SpatialLite.Osm/IO/Pbf/PbfWay.cs | 101 +- src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs | 99 +- src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs | 73 +- src/SpatialLite.Osm/IO/Pbf/StringTable.cs | 101 +- src/SpatialLite.Osm/IO/PbfReader.cs | 785 ++++++----- src/SpatialLite.Osm/IO/PbfWriter.cs | 951 +++++++------ src/SpatialLite.Osm/IO/PbfWriterSettings.cs | 83 +- src/SpatialLite.Osm/IOsmEntity.cs | 43 +- src/SpatialLite.Osm/ITypedEntityCollection.cs | 47 +- src/SpatialLite.Osm/NodeInfo.cs | 125 +- src/SpatialLite.Osm/OsmDatabase.cs | 403 +++--- src/SpatialLite.Osm/OsmEntityInfoDatabase.cs | 89 +- src/SpatialLite.Osm/RelationInfo.cs | 117 +- src/SpatialLite.Osm/RelationMemberInfo.cs | 55 +- src/SpatialLite.Osm/Tag.cs | 161 ++- src/SpatialLite.Osm/TagsCollection.cs | 387 +++--- src/SpatialLite.Osm/WayInfo.cs | 123 +- .../API/CoordinateTests.cs | 413 +++--- .../API/EnvelopeTests.cs | 379 +++--- .../Algorithms/Euclidean2DCalculatorTests.cs | 389 +++--- .../Algorithms/Euclidean2DLocatorTests.cs | 423 +++--- .../Algorithms/Sphere2DCalculatorTests.cs | 229 ++-- .../Data/TestDataReader.cs | 27 +- .../Geometries/CoordinateListTests.cs | 239 ++-- .../Geometries/GeometryCollectionTests.cs | 173 ++- .../Geometries/LineStringTests.cs | 259 ++-- .../Geometries/MultiLineStringTests.cs | 9 +- .../Geometries/MultiPointTests.cs | 9 +- .../Geometries/MultiPolygonTests.cs | 9 +- .../Geometries/PointTests.cs | 247 ++-- .../Geometries/PolygonTests.cs | 189 ++- .../Geometries/ReadOnlyCoordinateListTests.cs | 125 +- .../IO/WkbReaderTests.cs | 1049 +++++++------- .../IO/WkbWriterSettingsTests.cs | 31 +- .../IO/WkbWriterTests.cs | 1095 ++++++++------- .../IO/WktReaderTests.cs | 1193 ++++++++-------- .../IO/WktTokenizerTests.cs | 191 ++- .../IO/WktTokensBufferTests.cs | 293 ++-- .../IO/WktWriterSettingsTests.cs | 19 +- .../IO/WktWriterTests.cs | 523 ++++--- .../MeasurementsTests.cs | 429 +++--- src/Tests.SpatialLite.Core/PathHelper.cs | 35 +- src/Tests.SpatialLite.Core/TopologyTests.cs | 17 +- .../Data/TestDataReader.cs | 27 +- .../Geometries/GpsPointTests.cs | 99 +- .../Geometries/GpsTrackBaseTests.cs | 89 +- .../Geometries/GpxFixHelperTests.cs | 63 +- .../Geometries/GpxLinkTests.cs | 19 +- .../Geometries/GpxMetadataTests.cs | 23 +- .../Geometries/GpxPointTests.cs | 113 +- .../Geometries/GpxRouteTests.cs | 55 +- .../Geometries/GpxTrackSegmentTests.cs | 41 +- .../Geometries/GpxTrackTests.cs | 47 +- src/Tests.SpatialLite.Gps/GpxDocumentTests.cs | 237 ++-- .../IO/GpxReaderSettingsTests.cs | 31 +- .../IO/GpxReaderTests.cs | 697 +++++----- .../IO/GpxWriterSettingsTests.cs | 45 +- .../IO/GpxWriterTests.cs | 547 ++++---- src/Tests.SpatialLite.Gps/PathHelper.cs | 35 +- .../XDocumentExtensions.cs | 67 +- .../Data/TestDataReader.cs | 33 +- .../EntityCollectionTests.cs | 325 +++-- .../Geometries/NodeTests.cs | 185 ++- .../Geometries/OsmGeometryDatabaseTests.cs | 261 ++-- .../Geometries/RelationMemberTests.cs | 321 +++-- .../Geometries/RelationTests.cs | 167 ++- .../Geometries/WayCoordinateListTests.cs | 125 +- .../Geometries/WayTests.cs | 241 ++-- .../IO/OsmReaderSettingsTests.cs | 29 +- .../IO/OsmWriterSettingsTests.cs | 53 +- .../IO/OsmXmlReaderTests.cs | 625 +++++---- .../IO/OsmXmlWriterTests.cs | 785 ++++++----- .../IO/PbfReaderTests.cs | 621 +++++---- .../IO/PbfWriterSettingsTests.cs | 57 +- .../IO/PbfWriterTests.cs | 829 ++++++------ .../Pbf/OsmosisIntegrationTests.cs | 277 ++-- .../Pbf/PbfReaderPbfWriterComplianceTests.cs | 181 ++- .../Integration/Xml/OsmDatabaseTests.cs | 39 +- .../Xml/OsmosisIntegrationTests.cs | 127 +- src/Tests.SpatialLite.Osm/NodeInfoTests.cs | 99 +- src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs | 693 +++++----- .../OsmEntityInfoDatabaseTests.cs | 195 ++- src/Tests.SpatialLite.Osm/PathHelper.cs | 45 +- .../RelationInfoTests.cs | 111 +- .../RelationMemberInfoTests.cs | 23 +- src/Tests.SpatialLite.Osm/TagTests.cs | 187 ++- .../TagsCollectionTests.cs | 651 +++++---- src/Tests.SpatialLite.Osm/WayInfoTests.cs | 111 +- 187 files changed, 18110 insertions(+), 18300 deletions(-) diff --git a/src/Benchmark.SpatialLite.Osm/Program.cs b/src/Benchmark.SpatialLite.Osm/Program.cs index 8dd1165..5dfc31f 100644 --- a/src/Benchmark.SpatialLite.Osm/Program.cs +++ b/src/Benchmark.SpatialLite.Osm/Program.cs @@ -6,249 +6,248 @@ using System.Diagnostics; using System.IO; -namespace Benchmark.SpatialLite.Osm +namespace Benchmark.SpatialLite.Osm; + +public class Program { - public class Program - { - static List _entities; + static List _entities; - static void Main(string[] args) - { - List> benchmarks = new List>(); - benchmarks.Add(new Tuple("XmlReader with metadata", TestXmlReaderSpeed)); - benchmarks.Add(new Tuple("XmlReader without metadata", TestXmlReaderSpeedWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfReader (no compression) with metadata", TestPbfReaderSpeedNoDenseNoCompression)); - //benchmarks.Add(new Tuple("PbfReader (no compression) without metadata", TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfReader (dense, deflate) with metadata", TestPbfReaderSpeedDenseDeflate)); - //benchmarks.Add(new Tuple("PbfReader (dense, deflate) without metadata", TestPbfReaderSpeedDenseDeflateWithoutMetadata)); + static void Main(string[] args) + { + List> benchmarks = new List>(); + benchmarks.Add(new Tuple("XmlReader with metadata", TestXmlReaderSpeed)); + benchmarks.Add(new Tuple("XmlReader without metadata", TestXmlReaderSpeedWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfReader (no compression) with metadata", TestPbfReaderSpeedNoDenseNoCompression)); + //benchmarks.Add(new Tuple("PbfReader (no compression) without metadata", TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfReader (dense, deflate) with metadata", TestPbfReaderSpeedDenseDeflate)); + //benchmarks.Add(new Tuple("PbfReader (dense, deflate) without metadata", TestPbfReaderSpeedDenseDeflateWithoutMetadata)); - //LoadSourceData(); - //benchmarks.Add(new Tuple("XmlWriter with metadata", TestXmlWriterSpeed)); - //benchmarks.Add(new Tuple("XmlWriter without metadata", TestXmlWriterSpeedWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfWriter (no compression) with metadata", TestPbfWriterSpeed)); - //benchmarks.Add(new Tuple("PbfWriter (no compression) without metadata", TestPbfWriterSpeedWithoutMetadata)); - //benchmarks.Add(new Tuple("PbfWritre (dense, deflate) with metadata", TestPbfWriterSpeedDenseDeflate)); - //benchmarks.Add(new Tuple("PbfWriter (dense, deflate) without metadata", TestPbfWriterSpeedDenseDeflateWithoutMetadata)); + //LoadSourceData(); + //benchmarks.Add(new Tuple("XmlWriter with metadata", TestXmlWriterSpeed)); + //benchmarks.Add(new Tuple("XmlWriter without metadata", TestXmlWriterSpeedWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfWriter (no compression) with metadata", TestPbfWriterSpeed)); + //benchmarks.Add(new Tuple("PbfWriter (no compression) without metadata", TestPbfWriterSpeedWithoutMetadata)); + //benchmarks.Add(new Tuple("PbfWritre (dense, deflate) with metadata", TestPbfWriterSpeedDenseDeflate)); + //benchmarks.Add(new Tuple("PbfWriter (dense, deflate) without metadata", TestPbfWriterSpeedDenseDeflateWithoutMetadata)); - //benchmarks.Add(new Tuple("OsmGeometryDatabase.Load(PbfReader)", TestOsmGeometryDatabaseLoadFromPbfReader)); - //benchmarks.Add(new Tuple("OsmEntityInfoDatabase.Load(PbfReader)", TestOsmEntityInfoDatabaseLoadFromPbfReader)); + //benchmarks.Add(new Tuple("OsmGeometryDatabase.Load(PbfReader)", TestOsmGeometryDatabaseLoadFromPbfReader)); + //benchmarks.Add(new Tuple("OsmEntityInfoDatabase.Load(PbfReader)", TestOsmEntityInfoDatabaseLoadFromPbfReader)); - Console.WriteLine("Benchmark.SpatialLite.Osm.IO requires 'test-file.osm', 'test-file.pbf' and 'test-file-dc.pbf' in 'TestFiles'folder"); + Console.WriteLine("Benchmark.SpatialLite.Osm.IO requires 'test-file.osm', 'test-file.pbf' and 'test-file-dc.pbf' in 'TestFiles'folder"); - using (var stream = new FileStream("Benchmark.SpatialLite.Osm.IO.log", FileMode.Create, FileAccess.Write)) + using (var stream = new FileStream("Benchmark.SpatialLite.Osm.IO.log", FileMode.Create, FileAccess.Write)) + { + using (TextWriter tw = new StreamWriter(stream)) { - using (TextWriter tw = new StreamWriter(stream)) + foreach (var benchmark in benchmarks) { - foreach (var benchmark in benchmarks) - { - long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); - tw.WriteLine(string.Format("{0} ms \t\t{1}", avgTime, benchmark.Item1)); - } + long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); + tw.WriteLine(string.Format("{0} ms \t\t{1}", avgTime, benchmark.Item1)); } } } + } - static long DoTest(Action testAction, string testName) + static long DoTest(Action testAction, string testName) + { + Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); + + long totalTime = 0; + for (int i = 0; i < 10; i++) { - Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); + Console.Write(string.Format("Run ({0}/{1}) ...", i + 1, 10)); + Stopwatch watch = new Stopwatch(); + watch.Start(); - long totalTime = 0; - for (int i = 0; i < 10; i++) - { - Console.Write(string.Format("Run ({0}/{1}) ...", i + 1, 10)); - Stopwatch watch = new Stopwatch(); - watch.Start(); + testAction(); - testAction(); + watch.Stop(); + totalTime += watch.ElapsedMilliseconds; + Console.WriteLine(string.Format("\t\t({0} ms)", watch.ElapsedMilliseconds)); + } - watch.Stop(); - totalTime += watch.ElapsedMilliseconds; - Console.WriteLine(string.Format("\t\t({0} ms)", watch.ElapsedMilliseconds)); - } + Console.WriteLine(); + Console.WriteLine("Average runnig time: {0} ms\n", totalTime / 10); + return totalTime / 10; + } - Console.WriteLine(); - Console.WriteLine("Average runnig time: {0} ms\n", totalTime / 10); - return totalTime / 10; - } + static void LoadSourceData() + { + _entities = new List(); - static void LoadSourceData() + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - _entities = new List(); - - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + while ((info = reader.Read()) != null) { - while ((info = reader.Read()) != null) - { - _entities.Add(info); - } + _entities.Add(info); } } + } - static void TestXmlReaderSpeed() - { - int entitiesRead = 0; + static void TestXmlReaderSpeed() + { + int entitiesRead = 0; - IEntityInfo info = null; - using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) + IEntityInfo info = null; + using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) + { + while ((info = reader.Read()) != null) { - while ((info = reader.Read()) != null) - { - entitiesRead++; - } + entitiesRead++; } } + } - static void TestXmlReaderSpeedWithoutMetadata() - { - int entitiesRead = 0; + static void TestXmlReaderSpeedWithoutMetadata() + { + int entitiesRead = 0; - IEntityInfo info = null; - using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) + IEntityInfo info = null; + using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) + { + while ((info = reader.Read()) != null) { - while ((info = reader.Read()) != null) - { - entitiesRead++; - } + entitiesRead++; } } + } - static void TestXmlWriterSpeed() + static void TestXmlWriterSpeed() + { + using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) { - using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) + foreach (var entity in _entities) { - foreach (var entity in _entities) - { - writer.Write(entity); - } + writer.Write(entity); } } + } - static void TestXmlWriterSpeedWithoutMetadata() + static void TestXmlWriterSpeedWithoutMetadata() + { + using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) { - using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) + foreach (var entity in _entities) { - foreach (var entity in _entities) - { - writer.Write(entity); - } + writer.Write(entity); } } + } - static void TestPbfReaderSpeedNoDenseNoCompression() - { - int entitiesRead = 0; + static void TestPbfReaderSpeedNoDenseNoCompression() + { + int entitiesRead = 0; - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) + { + while ((info = reader.Read()) != null) { - while ((info = reader.Read()) != null) - { - entitiesRead++; - } + entitiesRead++; } } + } - static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() - { - int entitiesRead = 0; + static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() + { + int entitiesRead = 0; - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) + { + while ((info = reader.Read()) != null) { - while ((info = reader.Read()) != null) - { - entitiesRead++; - } + entitiesRead++; } } + } - static void TestPbfReaderSpeedDenseDeflate() - { - int entitiesRead = 0; + static void TestPbfReaderSpeedDenseDeflate() + { + int entitiesRead = 0; - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + { + while ((info = reader.Read()) != null) { - while ((info = reader.Read()) != null) - { - entitiesRead++; - } + entitiesRead++; } } + } - static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() - { - int entitiesRead = 0; + static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() + { + int entitiesRead = 0; - IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) + IEntityInfo info = null; + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) + { + while ((info = reader.Read()) != null) { - while ((info = reader.Read()) != null) - { - entitiesRead++; - } + entitiesRead++; } } + } - static void TestPbfWriterSpeed() + static void TestPbfWriterSpeed() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) + foreach (var entity in _entities) { - foreach (var entity in _entities) - { - writer.Write(entity); - } + writer.Write(entity); } } + } - static void TestPbfWriterSpeedWithoutMetadata() + static void TestPbfWriterSpeedWithoutMetadata() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) + foreach (var entity in _entities) { - foreach (var entity in _entities) - { - writer.Write(entity); - } + writer.Write(entity); } } + } - static void TestPbfWriterSpeedDenseDeflate() + static void TestPbfWriterSpeedDenseDeflate() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + foreach (var entity in _entities) { - foreach (var entity in _entities) - { - writer.Write(entity); - } + writer.Write(entity); } } + } - static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() + static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() + { + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + foreach (var entity in _entities) { - foreach (var entity in _entities) - { - writer.Write(entity); - } + writer.Write(entity); } } + } - static void TestOsmGeometryDatabaseLoadFromPbfReader() + static void TestOsmGeometryDatabaseLoadFromPbfReader() + { + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) - { - OsmGeometryDatabase db = OsmGeometryDatabase.Load(reader, true); - } + OsmGeometryDatabase db = OsmGeometryDatabase.Load(reader, true); } + } - static void TestOsmEntityInfoDatabaseLoadFromPbfReader() + static void TestOsmEntityInfoDatabaseLoadFromPbfReader() + { + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) - { - OsmEntityInfoDatabase db = OsmEntityInfoDatabase.Load(reader); - } + OsmEntityInfoDatabase db = OsmEntityInfoDatabase.Load(reader); } } } diff --git a/src/SpatialLite.Core/API/Coordinate.cs b/src/SpatialLite.Core/API/Coordinate.cs index e03d437..b6e4571 100644 --- a/src/SpatialLite.Core/API/Coordinate.cs +++ b/src/SpatialLite.Core/API/Coordinate.cs @@ -1,186 +1,185 @@ using System; -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Represents a location in the coordinate space. +/// +/// +/// A Coordinate may include a M value. The M value allows an application to associate some measure with the Coordinate. +/// +public struct Coordinate : IEquatable { + /// - /// Represents a location in the coordinate space. + /// Represents an empty coordinate. /// /// - /// A Coordinate may include a M value. The M value allows an application to associate some measure with the Coordinate. + /// The empty coordinate has all coordinates equal to NaN. /// - public struct Coordinate : IEquatable + public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + /// + /// Initializes a new instance of the Coordinate struct with X, Y ordinates. + /// + /// X-coordinate value. + /// Y-coordinate value. + public Coordinate(double x, double y) { + X = x; + Y = y; + Z = double.NaN; + M = double.NaN; + } - /// - /// Represents an empty coordinate. - /// - /// - /// The empty coordinate has all coordinates equal to NaN. - /// - public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - /// - /// Initializes a new instance of the Coordinate struct with X, Y ordinates. - /// - /// X-coordinate value. - /// Y-coordinate value. - public Coordinate(double x, double y) - { - X = x; - Y = y; - Z = double.NaN; - M = double.NaN; - } + /// + /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates. + /// + /// X-coordinate value. + /// Y-coordinate value. + /// Z-coordinate value. + public Coordinate(double x, double y, double z) + { + X = x; + Y = y; + Z = z; + M = double.NaN; + } - /// - /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates. - /// - /// X-coordinate value. - /// Y-coordinate value. - /// Z-coordinate value. - public Coordinate(double x, double y, double z) - { - X = x; - Y = y; - Z = z; - M = double.NaN; - } + /// + /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates and M value. + /// + /// X-coordinate value. + /// Y-coordinate value. + /// Z-coordinate value. + /// Measured value associated with the Coordinate. + public Coordinate(double x, double y, double z, double m) + { + X = x; + Y = y; + Z = z; + M = m; + } - /// - /// Initializes a new instance of the Coordinate struct with X, Y, Z ordinates and M value. - /// - /// X-coordinate value. - /// Y-coordinate value. - /// Z-coordinate value. - /// Measured value associated with the Coordinate. - public Coordinate(double x, double y, double z, double m) - { - X = x; - Y = y; - Z = z; - M = m; - } + /// + /// Gets the X-coordinate + /// + public double X { get; set; } - /// - /// Gets the X-coordinate - /// - public double X { get; set; } - - /// - /// Gets the Y-coordinate - /// - public double Y { get; set; } - - /// - /// Gets the Z-coordinate - /// - public double Z { get; set; } - - /// - /// Gets the M value - /// - public double M { get; set; } - - /// - /// Gets a value indicating whether this coordinate has assigned coordinate. - /// - public bool Is3D - { - get - { - return !double.IsNaN(this.Z); - } - } + /// + /// Gets the Y-coordinate + /// + public double Y { get; set; } - /// - /// Gets a value indicating whether this coordinate has assigned value. - /// - public bool IsMeasured - { - get - { - return !double.IsNaN(this.M); - } - } + /// + /// Gets the Z-coordinate + /// + public double Z { get; set; } - /// - /// Determiens whether specific Coordinates values are equal - /// - /// Coordinate to compare - /// Coordinate to compare - /// true if the specified Coordinate values are equal; otherwise, false. - public static bool operator ==(Coordinate lhs, Coordinate rhs) - { - return lhs.Equals(rhs); - } + /// + /// Gets the M value + /// + public double M { get; set; } - /// - /// Determiens whether specific Coordinate values are not equal - /// - /// Coordinate to compare - /// Coordinate to compare - /// true if the specified Coordinate values are not equal; otherwise, false. - public static bool operator !=(Coordinate lhs, Coordinate rhs) + /// + /// Gets a value indicating whether this coordinate has assigned coordinate. + /// + public bool Is3D + { + get { - return !(lhs == rhs); + return !double.IsNaN(this.Z); } + } - /// - /// Returns a string that represents the current Coordinate. - /// - /// A string that represents the current Coordinate - public override string ToString() + /// + /// Gets a value indicating whether this coordinate has assigned value. + /// + public bool IsMeasured + { + get { - return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", this.X, this.Y, this.Z, this.M); + return !double.IsNaN(this.M); } + } - /// - /// Determines whether specific object instance is equal to the current Coordinate. - /// - /// The object to compare with the current Coordinate - /// true if the specified object is equal to the current Coordinate; otherwise, false. - public override bool Equals(object obj) - { - Coordinate? other = obj as Coordinate?; - if (other == null) - { - return false; - } + /// + /// Determiens whether specific Coordinates values are equal + /// + /// Coordinate to compare + /// Coordinate to compare + /// true if the specified Coordinate values are equal; otherwise, false. + public static bool operator ==(Coordinate lhs, Coordinate rhs) + { + return lhs.Equals(rhs); + } - return this.Equals(other.Value); - } + /// + /// Determiens whether specific Coordinate values are not equal + /// + /// Coordinate to compare + /// Coordinate to compare + /// true if the specified Coordinate values are not equal; otherwise, false. + public static bool operator !=(Coordinate lhs, Coordinate rhs) + { + return !(lhs == rhs); + } - /// - /// Determines whether two Coordinate values are equal. - /// - /// The Coordinate to compare with the current Coordinate - /// true if the specified Coordinate is equal to the current Coordinate; otherwise, false. - public bool Equals(Coordinate other) - { - return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && - ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))) && - ((this.Z == other.Z) || (double.IsNaN(this.Z) && double.IsNaN(other.Z))) && - ((this.M == other.M) || (double.IsNaN(this.M) && double.IsNaN(other.M))); - } + /// + /// Returns a string that represents the current Coordinate. + /// + /// A string that represents the current Coordinate + public override string ToString() + { + return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", this.X, this.Y, this.Z, this.M); + } - /// - /// Serves as a hash function for the Coordinate structure. - /// - /// Hash code for current Coordinate value. - public override int GetHashCode() + /// + /// Determines whether specific object instance is equal to the current Coordinate. + /// + /// The object to compare with the current Coordinate + /// true if the specified object is equal to the current Coordinate; otherwise, false. + public override bool Equals(object obj) + { + Coordinate? other = obj as Coordinate?; + if (other == null) { - return X.GetHashCode() + 7 * Y.GetHashCode() + 13 * Z.GetHashCode() + 17 * M.GetHashCode(); + return false; } - /// - /// Determines whether two Coordinate are equal in 2D space. - /// - /// The Coordinate to compare with the current Coordinate - /// true if the specified Coordinate is equal to the current Coordinate in 2D space otherwise, false. - public bool Equals2D(Coordinate other) - { - return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && - ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))); - } + return this.Equals(other.Value); + } + + /// + /// Determines whether two Coordinate values are equal. + /// + /// The Coordinate to compare with the current Coordinate + /// true if the specified Coordinate is equal to the current Coordinate; otherwise, false. + public bool Equals(Coordinate other) + { + return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && + ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))) && + ((this.Z == other.Z) || (double.IsNaN(this.Z) && double.IsNaN(other.Z))) && + ((this.M == other.M) || (double.IsNaN(this.M) && double.IsNaN(other.M))); + } + + /// + /// Serves as a hash function for the Coordinate structure. + /// + /// Hash code for current Coordinate value. + public override int GetHashCode() + { + return X.GetHashCode() + 7 * Y.GetHashCode() + 13 * Z.GetHashCode() + 17 * M.GetHashCode(); + } + + /// + /// Determines whether two Coordinate are equal in 2D space. + /// + /// The Coordinate to compare with the current Coordinate + /// true if the specified Coordinate is equal to the current Coordinate in 2D space otherwise, false. + public bool Equals2D(Coordinate other) + { + return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && + ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))); } } diff --git a/src/SpatialLite.Core/API/Envelope.cs b/src/SpatialLite.Core/API/Envelope.cs index 1ad55f9..3b8b42d 100644 --- a/src/SpatialLite.Core/API/Envelope.cs +++ b/src/SpatialLite.Core/API/Envelope.cs @@ -1,457 +1,456 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Represents minimal bounding box of a object. +/// +public class Envelope { + /// - /// Represents minimal bounding box of a object. + /// Empty Envelope, that has all it's bounds set to double.NaN /// - public class Envelope - { + public static Envelope Empty = new Envelope(); - /// - /// Empty Envelope, that has all it's bounds set to double.NaN - /// - public static Envelope Empty = new Envelope(); - - private const int XIndex = 0; - private const int YIndex = 1; - private const int ZIndex = 2; - private const int MIndex = 3; - - private double[][] _bounds = new double[][] { - new double[] { double.NaN, double.NaN }, - new double[] { double.NaN, double.NaN }, - new double[] { double.NaN, double.NaN }, - new double[] { double.NaN, double.NaN } }; - - /// - /// Initializes a new instance of the Envelope class that is empty and has all it's values initialized to double.NaN. - /// - public Envelope() - { - } + private const int XIndex = 0; + private const int YIndex = 1; + private const int ZIndex = 2; + private const int MIndex = 3; - /// - /// Initializes a new instance of the Envelope class with the single coordinate. - /// - /// The coordinate used initialize Envelope - public Envelope(Coordinate coord) - { - this.Initialize(coord.X, coord.X, coord.Y, coord.Y, coord.Z, coord.Z, coord.M, coord.M); - } + private double[][] _bounds = new double[][] { + new double[] { double.NaN, double.NaN }, + new double[] { double.NaN, double.NaN }, + new double[] { double.NaN, double.NaN }, + new double[] { double.NaN, double.NaN } }; - /// - /// Initializes a new instance of the Envelope class that covers specified coordinates. - /// - /// The coordinates to be covered. - public Envelope(IEnumerable coords) - { - this.Extend(coords); - } + /// + /// Initializes a new instance of the Envelope class that is empty and has all it's values initialized to double.NaN. + /// + public Envelope() + { + } - /// - /// Initializes a new instance of the Envelope class as copy of specified Envelope. - /// - /// The Envelope object whose values are to be copied. - public Envelope(Envelope source) - { - this.Initialize(source.MinX, source.MaxX, source.MinY, source.MaxY, source.MinZ, source.MaxZ, source.MinM, source.MaxM); - } + /// + /// Initializes a new instance of the Envelope class with the single coordinate. + /// + /// The coordinate used initialize Envelope + public Envelope(Coordinate coord) + { + this.Initialize(coord.X, coord.X, coord.Y, coord.Y, coord.Z, coord.Z, coord.M, coord.M); + } - /// - /// Gets Envelope's minimal x-coordinate. - /// - public double MinX - { - get { return _bounds[XIndex][0]; } - } + /// + /// Initializes a new instance of the Envelope class that covers specified coordinates. + /// + /// The coordinates to be covered. + public Envelope(IEnumerable coords) + { + this.Extend(coords); + } - /// - /// Gets Envelope's maximal x-coordinate. - /// - public double MaxX - { - get { return _bounds[XIndex][1]; } - } + /// + /// Initializes a new instance of the Envelope class as copy of specified Envelope. + /// + /// The Envelope object whose values are to be copied. + public Envelope(Envelope source) + { + this.Initialize(source.MinX, source.MaxX, source.MinY, source.MaxY, source.MinZ, source.MaxZ, source.MinM, source.MaxM); + } - /// - /// Gets Envelope's minimal y-coordinate. - /// - public double MinY - { - get { return _bounds[YIndex][0]; } - } + /// + /// Gets Envelope's minimal x-coordinate. + /// + public double MinX + { + get { return _bounds[XIndex][0]; } + } - /// - /// Gets Envelope's maximal y-coordinate. - /// - public double MaxY - { - get { return _bounds[YIndex][1]; } - } + /// + /// Gets Envelope's maximal x-coordinate. + /// + public double MaxX + { + get { return _bounds[XIndex][1]; } + } - /// - /// Gets Envelope's minimal z-coordinate. - /// - public double MinZ - { - get { return _bounds[ZIndex][0]; } - } + /// + /// Gets Envelope's minimal y-coordinate. + /// + public double MinY + { + get { return _bounds[YIndex][0]; } + } - /// - /// Gets Envelope's maximal z-coordinate. - /// - public double MaxZ - { - get { return _bounds[ZIndex][1]; } - } + /// + /// Gets Envelope's maximal y-coordinate. + /// + public double MaxY + { + get { return _bounds[YIndex][1]; } + } - /// - /// Gets Envelope's minimal m-coordinate. - /// - public double MinM - { - get { return _bounds[MIndex][0]; } - } + /// + /// Gets Envelope's minimal z-coordinate. + /// + public double MinZ + { + get { return _bounds[ZIndex][0]; } + } - /// - /// Gets Envelope's maximal m-coordinate. - /// - public double MaxM - { - get { return _bounds[MIndex][1]; } - } + /// + /// Gets Envelope's maximal z-coordinate. + /// + public double MaxZ + { + get { return _bounds[ZIndex][1]; } + } + + /// + /// Gets Envelope's minimal m-coordinate. + /// + public double MinM + { + get { return _bounds[MIndex][0]; } + } + + /// + /// Gets Envelope's maximal m-coordinate. + /// + public double MaxM + { + get { return _bounds[MIndex][1]; } + } - /// - /// Returns the difference between the maximum and minimum x values. - /// - /// max x - min x, or 0 if this is a null Envelope. - public double Width + /// + /// Returns the difference between the maximum and minimum x values. + /// + /// max x - min x, or 0 if this is a null Envelope. + public double Width + { + get { - get + if (this.IsEmpty) { - if (this.IsEmpty) - { - return 0; - } - - return _bounds[XIndex][1] - _bounds[XIndex][0]; + return 0; } + + return _bounds[XIndex][1] - _bounds[XIndex][0]; } + } - /// - /// Returns the difference between the maximum and minimum y values. - /// - /// max y - min y, or 0 if this is a null Envelope. - public double Height + /// + /// Returns the difference between the maximum and minimum y values. + /// + /// max y - min y, or 0 if this is a null Envelope. + public double Height + { + get { - get + if (this.IsEmpty) { - if (this.IsEmpty) - { - return 0; - } - - return _bounds[YIndex][1] - _bounds[YIndex][0]; + return 0; } + + return _bounds[YIndex][1] - _bounds[YIndex][0]; } + } - /// - /// Checks if this Envelope equals the empty Envelope. - /// - public bool IsEmpty + /// + /// Checks if this Envelope equals the empty Envelope. + /// + public bool IsEmpty + { + get { - get - { - return this.Equals(Envelope.Empty); - } + return this.Equals(Envelope.Empty); } + } - /// - /// Extends this Envelope to cover specified Coordinate. - /// - /// The Coordinate to be covered by extended Envelope. - public void Extend(Coordinate coord) + /// + /// Extends this Envelope to cover specified Coordinate. + /// + /// The Coordinate to be covered by extended Envelope. + public void Extend(Coordinate coord) + { + if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) { - if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) - { - _bounds[XIndex][0] = _bounds[XIndex][1] = coord.X; - _bounds[YIndex][0] = _bounds[YIndex][1] = coord.Y; - _bounds[ZIndex][0] = _bounds[ZIndex][1] = coord.Z; - _bounds[MIndex][0] = _bounds[MIndex][1] = coord.M; - } - else - { - if (coord.X < _bounds[XIndex][0]) { _bounds[XIndex][0] = coord.X; } - if (coord.X > _bounds[XIndex][1]) { _bounds[XIndex][1] = coord.X; } + _bounds[XIndex][0] = _bounds[XIndex][1] = coord.X; + _bounds[YIndex][0] = _bounds[YIndex][1] = coord.Y; + _bounds[ZIndex][0] = _bounds[ZIndex][1] = coord.Z; + _bounds[MIndex][0] = _bounds[MIndex][1] = coord.M; + } + else + { + if (coord.X < _bounds[XIndex][0]) { _bounds[XIndex][0] = coord.X; } + if (coord.X > _bounds[XIndex][1]) { _bounds[XIndex][1] = coord.X; } - if (coord.Y < _bounds[YIndex][0]) { _bounds[YIndex][0] = coord.Y; } - if (coord.Y > _bounds[YIndex][1]) { _bounds[YIndex][1] = coord.Y; } + if (coord.Y < _bounds[YIndex][0]) { _bounds[YIndex][0] = coord.Y; } + if (coord.Y > _bounds[YIndex][1]) { _bounds[YIndex][1] = coord.Y; } - if (coord.Z < _bounds[ZIndex][0]) { _bounds[ZIndex][0] = coord.Z; } - if (coord.Z > _bounds[ZIndex][1]) { _bounds[ZIndex][1] = coord.Z; } + if (coord.Z < _bounds[ZIndex][0]) { _bounds[ZIndex][0] = coord.Z; } + if (coord.Z > _bounds[ZIndex][1]) { _bounds[ZIndex][1] = coord.Z; } - if (coord.M < _bounds[MIndex][0]) { _bounds[MIndex][0] = coord.M; } - if (coord.M > _bounds[MIndex][1]) { _bounds[MIndex][1] = coord.M; } - } + if (coord.M < _bounds[MIndex][0]) { _bounds[MIndex][0] = coord.M; } + if (coord.M > _bounds[MIndex][1]) { _bounds[MIndex][1] = coord.M; } } + } - /// - /// Extends this Envelope to cover specified Coordinates. - /// - /// The collection of Coordinates to be covered by extended Envelope. - public void Extend(IEnumerable coords) + /// + /// Extends this Envelope to cover specified Coordinates. + /// + /// The collection of Coordinates to be covered by extended Envelope. + public void Extend(IEnumerable coords) + { + foreach (var coord in coords) { - foreach (var coord in coords) - { - this.Extend(coord); - } + this.Extend(coord); } + } - /// - /// Extends this Envelope to cover specified Envelope. - /// - /// The Envelope to be covered by extended Envelope. - public void Extend(Envelope envelope) + /// + /// Extends this Envelope to cover specified Envelope. + /// + /// The Envelope to be covered by extended Envelope. + public void Extend(Envelope envelope) + { + if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) { - if (double.IsNaN(_bounds[XIndex][0]) || double.IsNaN(_bounds[YIndex][0])) - { - _bounds[XIndex][0] = envelope.MinX; - _bounds[XIndex][1] = envelope.MaxX; + _bounds[XIndex][0] = envelope.MinX; + _bounds[XIndex][1] = envelope.MaxX; - _bounds[YIndex][0] = envelope.MinY; - _bounds[YIndex][1] = envelope.MaxY; + _bounds[YIndex][0] = envelope.MinY; + _bounds[YIndex][1] = envelope.MaxY; - _bounds[ZIndex][0] = envelope.MinZ; - _bounds[ZIndex][1] = envelope.MaxZ; + _bounds[ZIndex][0] = envelope.MinZ; + _bounds[ZIndex][1] = envelope.MaxZ; - _bounds[MIndex][0] = envelope.MinM; - _bounds[MIndex][1] = envelope.MaxM; - } - else - { - if (envelope.MinX < _bounds[XIndex][0]) { _bounds[XIndex][0] = envelope.MinX; } - if (envelope.MaxX > _bounds[XIndex][1]) { _bounds[XIndex][1] = envelope.MaxX; } + _bounds[MIndex][0] = envelope.MinM; + _bounds[MIndex][1] = envelope.MaxM; + } + else + { + if (envelope.MinX < _bounds[XIndex][0]) { _bounds[XIndex][0] = envelope.MinX; } + if (envelope.MaxX > _bounds[XIndex][1]) { _bounds[XIndex][1] = envelope.MaxX; } - if (envelope.MinY < _bounds[YIndex][0]) { _bounds[YIndex][0] = envelope.MinY; } - if (envelope.MaxY > _bounds[YIndex][1]) { _bounds[YIndex][1] = envelope.MaxY; } + if (envelope.MinY < _bounds[YIndex][0]) { _bounds[YIndex][0] = envelope.MinY; } + if (envelope.MaxY > _bounds[YIndex][1]) { _bounds[YIndex][1] = envelope.MaxY; } - if (envelope.MinZ < _bounds[ZIndex][0]) { _bounds[ZIndex][0] = envelope.MinZ; } - if (envelope.MaxZ > _bounds[ZIndex][1]) { _bounds[ZIndex][1] = envelope.MaxZ; } + if (envelope.MinZ < _bounds[ZIndex][0]) { _bounds[ZIndex][0] = envelope.MinZ; } + if (envelope.MaxZ > _bounds[ZIndex][1]) { _bounds[ZIndex][1] = envelope.MaxZ; } - if (envelope.MinM < _bounds[MIndex][0]) { _bounds[MIndex][0] = envelope.MinM; } - if (envelope.MaxM > _bounds[MIndex][1]) { _bounds[MIndex][1] = envelope.MaxM; } - } + if (envelope.MinM < _bounds[MIndex][0]) { _bounds[MIndex][0] = envelope.MinM; } + if (envelope.MaxM > _bounds[MIndex][1]) { _bounds[MIndex][1] = envelope.MaxM; } } + } - /// - /// Determines whether specific object instance is equal to the current Envelope. - /// - /// The object to compare with the current Envelope - /// true if the specified object is equal to the current Envelope; otherwise, false. - public override bool Equals(object obj) + /// + /// Determines whether specific object instance is equal to the current Envelope. + /// + /// The object to compare with the current Envelope + /// true if the specified object is equal to the current Envelope; otherwise, false. + public override bool Equals(object obj) + { + Envelope other = obj as Envelope; + if (other == null) { - Envelope other = obj as Envelope; - if (other == null) - { - return false; - } - - return this.Equals(other); + return false; } - /// - /// Determines whether two Envelope instances are equal. - /// - /// The Envelope to compare with the current Envelope - /// true if the specified Envelope is equal to the current Envelope; otherwise, false. - public bool Equals(Envelope other) + return this.Equals(other); + } + + /// + /// Determines whether two Envelope instances are equal. + /// + /// The Envelope to compare with the current Envelope + /// true if the specified Envelope is equal to the current Envelope; otherwise, false. + public bool Equals(Envelope other) + { + return ((this.MinX == other.MinX) || (double.IsNaN(this.MinX) && double.IsNaN(other.MinX))) && + ((this.MinY == other.MinY) || (double.IsNaN(this.MinY) && double.IsNaN(other.MinY))) && + ((this.MinZ == other.MinZ) || (double.IsNaN(this.MinZ) && double.IsNaN(other.MinZ))) && + ((this.MinM == other.MinM) || (double.IsNaN(this.MinM) && double.IsNaN(other.MinM))) && + ((this.MaxX == other.MaxX) || (double.IsNaN(this.MaxX) && double.IsNaN(other.MaxX))) && + ((this.MaxY == other.MaxY) || (double.IsNaN(this.MaxY) && double.IsNaN(other.MaxY))) && + ((this.MaxZ == other.MaxZ) || (double.IsNaN(this.MaxZ) && double.IsNaN(other.MaxZ))) && + ((this.MaxM == other.MaxM) || (double.IsNaN(this.MaxM) && double.IsNaN(other.MaxM))); + } + + /// + /// Check if the region defined by other + /// overlaps (intersects) the region of this Envelope. + /// + /// the Envelope which this Envelope is + /// being checked for overlapping. + /// + /// + /// true if the Envelopes overlap. + /// + public bool Intersects(Envelope other) + { + if (this.IsEmpty || other.IsEmpty) { - return ((this.MinX == other.MinX) || (double.IsNaN(this.MinX) && double.IsNaN(other.MinX))) && - ((this.MinY == other.MinY) || (double.IsNaN(this.MinY) && double.IsNaN(other.MinY))) && - ((this.MinZ == other.MinZ) || (double.IsNaN(this.MinZ) && double.IsNaN(other.MinZ))) && - ((this.MinM == other.MinM) || (double.IsNaN(this.MinM) && double.IsNaN(other.MinM))) && - ((this.MaxX == other.MaxX) || (double.IsNaN(this.MaxX) && double.IsNaN(other.MaxX))) && - ((this.MaxY == other.MaxY) || (double.IsNaN(this.MaxY) && double.IsNaN(other.MaxY))) && - ((this.MaxZ == other.MaxZ) || (double.IsNaN(this.MaxZ) && double.IsNaN(other.MaxZ))) && - ((this.MaxM == other.MaxM) || (double.IsNaN(this.MaxM) && double.IsNaN(other.MaxM))); + return false; } - /// - /// Check if the region defined by other - /// overlaps (intersects) the region of this Envelope. - /// - /// the Envelope which this Envelope is - /// being checked for overlapping. - /// - /// - /// true if the Envelopes overlap. - /// - public bool Intersects(Envelope other) - { - if (this.IsEmpty || other.IsEmpty) - { - return false; - } + return !(other.MinX > this.MaxX || other.MaxX < this.MinX || other.MinY > this.MaxY || other.MaxY < other.MinY); + } - return !(other.MinX > this.MaxX || other.MaxX < this.MinX || other.MinY > this.MaxY || other.MaxY < other.MinY); + /// + /// Tests if the given point lies in or on the envelope. + /// + /// the x-coordinate of the point which this Envelope is being checked for containing + /// the y-coordinate of the point which this Envelope is being checked for containing + /// true if (x, y) lies in the interior or on the boundary of this Envelope. + public bool Covers(double x, double y) + { + if (this.IsEmpty) + { + return false; } - /// - /// Tests if the given point lies in or on the envelope. - /// - /// the x-coordinate of the point which this Envelope is being checked for containing - /// the y-coordinate of the point which this Envelope is being checked for containing - /// true if (x, y) lies in the interior or on the boundary of this Envelope. - public bool Covers(double x, double y) - { - if (this.IsEmpty) - { - return false; - } + return x >= this.MinX && + x <= this.MaxX && + y >= this.MinY && + y <= this.MaxY; + } - return x >= this.MinX && - x <= this.MaxX && - y >= this.MinY && - y <= this.MaxY; - } + /// + /// Tests if the given point lies in or on the envelope. + /// + /// the point which this Envelope is being checked for containing + /// true if the point lies in the interior or on the boundary of this Envelope. + public bool Covers(Coordinate p) + { + return Covers(p.X, p.Y); + } - /// - /// Tests if the given point lies in or on the envelope. - /// - /// the point which this Envelope is being checked for containing - /// true if the point lies in the interior or on the boundary of this Envelope. - public bool Covers(Coordinate p) + /// + /// Tests if the Envelope other lies wholely inside this Envelope (inclusive of the boundary). + /// + /// the Envelope to check + /// true if this Envelope covers the other + public bool Covers(Envelope other) + { + if (this.IsEmpty || other.IsEmpty) { - return Covers(p.X, p.Y); + return false; } - /// - /// Tests if the Envelope other lies wholely inside this Envelope (inclusive of the boundary). - /// - /// the Envelope to check - /// true if this Envelope covers the other - public bool Covers(Envelope other) - { - if (this.IsEmpty || other.IsEmpty) - { - return false; - } + return other.MinX >= this.MinX && + other.MaxX <= this.MaxX && + other.MinY >= this.MinY && + other.MaxY <= this.MaxY; + } - return other.MinX >= this.MinX && - other.MaxX <= this.MaxX && - other.MinY >= this.MinY && - other.MaxY <= this.MaxY; - } + /// + /// Serves as a hash function for the Envelope class. + /// + /// Hash code for current Envelope object. + public override int GetHashCode() + { + return _bounds.GetHashCode(); + } - /// - /// Serves as a hash function for the Envelope class. - /// - /// Hash code for current Envelope object. - public override int GetHashCode() - { - return _bounds.GetHashCode(); - } + /// + /// Initializes MinX, MaxX, MinY, MaxY, MinZ and MaxZ properties from the given coordinates. + /// + /// First x-coordinate. + /// Second x-coordinate. + /// First y-coordinate. + /// Second y-coordinate. + public void Initialize(double x1, double x2, double y1, double y2) + { + var sortedX = this.SortCoordinates(x1, x2); + _bounds[XIndex][0] = sortedX[0]; + _bounds[XIndex][1] = sortedX[1]; - /// - /// Initializes MinX, MaxX, MinY, MaxY, MinZ and MaxZ properties from the given coordinates. - /// - /// First x-coordinate. - /// Second x-coordinate. - /// First y-coordinate. - /// Second y-coordinate. - public void Initialize(double x1, double x2, double y1, double y2) - { - var sortedX = this.SortCoordinates(x1, x2); - _bounds[XIndex][0] = sortedX[0]; - _bounds[XIndex][1] = sortedX[1]; + var sortedY = this.SortCoordinates(y1, y2); + _bounds[YIndex][0] = sortedY[0]; + _bounds[YIndex][1] = sortedY[1]; + } - var sortedY = this.SortCoordinates(y1, y2); - _bounds[YIndex][0] = sortedY[0]; - _bounds[YIndex][1] = sortedY[1]; - } + /// + /// Initializes MinX, MaxX, MinY, MaxY, MinZ and MaxZ properties from the given coordinates. + /// + /// First x-coordinate. + /// Second x-coordinate. + /// First y-coordinate. + /// Second y-coordinate. + /// First z-coordinate. + /// Second z-coordinate. + public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2) + { + var sortedX = this.SortCoordinates(x1, x2); + _bounds[XIndex][0] = sortedX[0]; + _bounds[XIndex][1] = sortedX[1]; - /// - /// Initializes MinX, MaxX, MinY, MaxY, MinZ and MaxZ properties from the given coordinates. - /// - /// First x-coordinate. - /// Second x-coordinate. - /// First y-coordinate. - /// Second y-coordinate. - /// First z-coordinate. - /// Second z-coordinate. - public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2) - { - var sortedX = this.SortCoordinates(x1, x2); - _bounds[XIndex][0] = sortedX[0]; - _bounds[XIndex][1] = sortedX[1]; + var sortedY = this.SortCoordinates(y1, y2); + _bounds[YIndex][0] = sortedY[0]; + _bounds[YIndex][1] = sortedY[1]; - var sortedY = this.SortCoordinates(y1, y2); - _bounds[YIndex][0] = sortedY[0]; - _bounds[YIndex][1] = sortedY[1]; + var sortedZ = this.SortCoordinates(z1, z2); + _bounds[ZIndex][0] = sortedZ[0]; + _bounds[ZIndex][1] = sortedZ[1]; + } - var sortedZ = this.SortCoordinates(z1, z2); - _bounds[ZIndex][0] = sortedZ[0]; - _bounds[ZIndex][1] = sortedZ[1]; - } + /// + /// Initializes MinX, MaxX, MinY, MaxY, MinZ and MaxZ properties from the given coordinates. + /// + /// First x-coordinate. + /// Second x-coordinate. + /// First y-coordinate. + /// Second y-coordinate. + /// First z-coordinate. + /// Second z-coordinate. + /// First measure value. + /// Second measure value. + public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2, double m1, double m2) + { + var sortedX = this.SortCoordinates(x1, x2); + _bounds[XIndex][0] = sortedX[0]; + _bounds[XIndex][1] = sortedX[1]; - /// - /// Initializes MinX, MaxX, MinY, MaxY, MinZ and MaxZ properties from the given coordinates. - /// - /// First x-coordinate. - /// Second x-coordinate. - /// First y-coordinate. - /// Second y-coordinate. - /// First z-coordinate. - /// Second z-coordinate. - /// First measure value. - /// Second measure value. - public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2, double m1, double m2) - { - var sortedX = this.SortCoordinates(x1, x2); - _bounds[XIndex][0] = sortedX[0]; - _bounds[XIndex][1] = sortedX[1]; + var sortedY = this.SortCoordinates(y1, y2); + _bounds[YIndex][0] = sortedY[0]; + _bounds[YIndex][1] = sortedY[1]; - var sortedY = this.SortCoordinates(y1, y2); - _bounds[YIndex][0] = sortedY[0]; - _bounds[YIndex][1] = sortedY[1]; + var sortedZ = this.SortCoordinates(z1, z2); + _bounds[ZIndex][0] = sortedZ[0]; + _bounds[ZIndex][1] = sortedZ[1]; - var sortedZ = this.SortCoordinates(z1, z2); - _bounds[ZIndex][0] = sortedZ[0]; - _bounds[ZIndex][1] = sortedZ[1]; + var sortedM = this.SortCoordinates(m1, m2); + _bounds[MIndex][0] = sortedM[0]; + _bounds[MIndex][1] = sortedM[1]; + } - var sortedM = this.SortCoordinates(m1, m2); - _bounds[MIndex][0] = sortedM[0]; - _bounds[MIndex][1] = sortedM[1]; + /// + /// Sorts two coordinates + /// + /// First coordinate. + /// Second coordinate. + /// Array with sorted coordinates - [min, max] + /// If any value is double.NaN the other is used for min and max. + private double[] SortCoordinates(double c1, double c2) + { + if (double.IsNaN(c1)) + { + c1 = c2; } - /// - /// Sorts two coordinates - /// - /// First coordinate. - /// Second coordinate. - /// Array with sorted coordinates - [min, max] - /// If any value is double.NaN the other is used for min and max. - private double[] SortCoordinates(double c1, double c2) + if (double.IsNaN(c2)) { - if (double.IsNaN(c1)) - { - c1 = c2; - } - - if (double.IsNaN(c2)) - { - c2 = c1; - } + c2 = c1; + } - if (c1 > c2) - { - return new double[] { c2, c1 }; - } - else - { - return new double[] { c1, c2 }; - } + if (c1 > c2) + { + return new double[] { c2, c1 }; + } + else + { + return new double[] { c1, c2 }; } } } diff --git a/src/SpatialLite.Core/API/ICoordinateList.cs b/src/SpatialLite.Core/API/ICoordinateList.cs index bdae7fb..f35b6ed 100644 --- a/src/SpatialLite.Core/API/ICoordinateList.cs +++ b/src/SpatialLite.Core/API/ICoordinateList.cs @@ -1,53 +1,52 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines properties and methods for collection of coordinates. +/// +public interface ICoordinateList : IEnumerable { /// - /// Defines properties and methods for collection of coordinates. + /// Gets number of Coordinates in the list + /// + int Count { get; } + + /// + /// Gets or sets Coordinate at the given index. + /// + /// The zero-based index of the Coordinate to get or set. + /// The element at the specified index. + Coordinate this[int index] { get; set; } + + /// + /// Adds Coordinate to the end of the list. + /// + /// The Coordinate to add to the list + void Add(Coordinate coord); + + /// + /// Adds collection of coordinates to the end of the list. + /// + /// The collection of coordinates to add to the list + void Add(IEnumerable coords); + + /// + /// Inserts Coordinate to the list at the specified index. + /// + /// The zero-based index at which coord should be inserted. + /// The Coordinate to insert into list. + /// If index equals the number of items in the list, then item is appended to the list. + void Insert(int index, Coordinate coord); + + /// + /// Removes Coordinate at the specified index from the list. + /// + /// The zero-based index of the Coordinate to remove. + void RemoveAt(int index); + + /// + /// Removes all Coordinates from the collection. /// - public interface ICoordinateList : IEnumerable - { - /// - /// Gets number of Coordinates in the list - /// - int Count { get; } - - /// - /// Gets or sets Coordinate at the given index. - /// - /// The zero-based index of the Coordinate to get or set. - /// The element at the specified index. - Coordinate this[int index] { get; set; } - - /// - /// Adds Coordinate to the end of the list. - /// - /// The Coordinate to add to the list - void Add(Coordinate coord); - - /// - /// Adds collection of coordinates to the end of the list. - /// - /// The collection of coordinates to add to the list - void Add(IEnumerable coords); - - /// - /// Inserts Coordinate to the list at the specified index. - /// - /// The zero-based index at which coord should be inserted. - /// The Coordinate to insert into list. - /// If index equals the number of items in the list, then item is appended to the list. - void Insert(int index, Coordinate coord); - - /// - /// Removes Coordinate at the specified index from the list. - /// - /// The zero-based index of the Coordinate to remove. - void RemoveAt(int index); - - /// - /// Removes all Coordinates from the collection. - /// - void Clear(); - } + void Clear(); } diff --git a/src/SpatialLite.Core/API/IGeometry.cs b/src/SpatialLite.Core/API/IGeometry.cs index 8983ee6..b4a4ce8 100644 --- a/src/SpatialLite.Core/API/IGeometry.cs +++ b/src/SpatialLite.Core/API/IGeometry.cs @@ -1,34 +1,33 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines common properties and methods for all geometry objects. +/// +public interface IGeometry { /// - /// Defines common properties and methods for all geometry objects. + /// Gets a value indicating whether the IGeometry object has Z coordinates. /// - public interface IGeometry - { - /// - /// Gets a value indicating whether the IGeometry object has Z coordinates. - /// - bool Is3D { get; } + bool Is3D { get; } - /// - /// Gets a value indicating whether the IGeometry object has M values. - /// - bool IsMeasured { get; } + /// + /// Gets a value indicating whether the IGeometry object has M values. + /// + bool IsMeasured { get; } - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the IGeometry object. - /// - Envelope GetEnvelope(); + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the IGeometry object. + /// + Envelope GetEnvelope(); - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - IEnumerable GetCoordinates(); - } + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + IEnumerable GetCoordinates(); } diff --git a/src/SpatialLite.Core/API/IGeometryCollection.cs b/src/SpatialLite.Core/API/IGeometryCollection.cs index 6b1a624..99d6e09 100644 --- a/src/SpatialLite.Core/API/IGeometryCollection.cs +++ b/src/SpatialLite.Core/API/IGeometryCollection.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines properties and methods for Geometry collection. +/// +/// The type of the objects included in the collection. +public interface IGeometryCollection : IGeometry where T : IGeometry { /// - /// Defines properties and methods for Geometry collection. + /// Gets the collection of geometry objects from the IGeometryCollection. /// - /// The type of the objects included in the collection. - public interface IGeometryCollection : IGeometry where T : IGeometry - { - /// - /// Gets the collection of geometry objects from the IGeometryCollection. - /// - IEnumerable Geometries { get; } - } + IEnumerable Geometries { get; } } diff --git a/src/SpatialLite.Core/API/ILineString.cs b/src/SpatialLite.Core/API/ILineString.cs index 5792240..d644fde 100644 --- a/src/SpatialLite.Core/API/ILineString.cs +++ b/src/SpatialLite.Core/API/ILineString.cs @@ -1,31 +1,30 @@ -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defiens properties and methods for line strings. A line string is a curve with linear connection between concesutive points. +/// +public interface ILineString : IGeometry { /// - /// Defiens properties and methods for line strings. A line string is a curve with linear connection between concesutive points. + /// Gets a value indicating whether the ILineString is closed. /// - public interface ILineString : IGeometry - { - /// - /// Gets a value indicating whether the ILineString is closed. - /// - /// - /// The ILineString is closed if and are identical. - /// - bool IsClosed { get; } + /// + /// The ILineString is closed if and are identical. + /// + bool IsClosed { get; } - /// - /// Gets the first coordinate of the ILineString object. - /// - Coordinate Start { get; } + /// + /// Gets the first coordinate of the ILineString object. + /// + Coordinate Start { get; } - /// - /// Gets the last coordinate of the ILineString object. - /// - Coordinate End { get; } + /// + /// Gets the last coordinate of the ILineString object. + /// + Coordinate End { get; } - /// - /// Gets the list of çoordinates that define this LisneString - /// - ICoordinateList Coordinates { get; } - } + /// + /// Gets the list of çoordinates that define this LisneString + /// + ICoordinateList Coordinates { get; } } diff --git a/src/SpatialLite.Core/API/IMultiLineString.cs b/src/SpatialLite.Core/API/IMultiLineString.cs index 511b681..74e2da8 100644 --- a/src/SpatialLite.Core/API/IMultiLineString.cs +++ b/src/SpatialLite.Core/API/IMultiLineString.cs @@ -1,9 +1,8 @@ -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines properties and methodss for Collection of LineStrings. +/// +public interface IMultiLineString : IGeometryCollection { - /// - /// Defines properties and methodss for Collection of LineStrings. - /// - public interface IMultiLineString : IGeometryCollection - { - } } diff --git a/src/SpatialLite.Core/API/IMultiPoint.cs b/src/SpatialLite.Core/API/IMultiPoint.cs index 994d9a5..76794b0 100644 --- a/src/SpatialLite.Core/API/IMultiPoint.cs +++ b/src/SpatialLite.Core/API/IMultiPoint.cs @@ -1,9 +1,8 @@ -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines properties and methods collections of points. +/// +public interface IMultiPoint : IGeometryCollection { - /// - /// Defines properties and methods collections of points. - /// - public interface IMultiPoint : IGeometryCollection - { - } } diff --git a/src/SpatialLite.Core/API/IMultiPolygon.cs b/src/SpatialLite.Core/API/IMultiPolygon.cs index 4b0f4d9..a5873fe 100644 --- a/src/SpatialLite.Core/API/IMultiPolygon.cs +++ b/src/SpatialLite.Core/API/IMultiPolygon.cs @@ -1,9 +1,8 @@ -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines properties and methods for collections of polygons. +/// +public interface IMultiPolygon : IGeometryCollection { - /// - /// Defines properties and methods for collections of polygons. - /// - public interface IMultiPolygon : IGeometryCollection - { - } } diff --git a/src/SpatialLite.Core/API/IPoint.cs b/src/SpatialLite.Core/API/IPoint.cs index a973d3f..adfd25b 100644 --- a/src/SpatialLite.Core/API/IPoint.cs +++ b/src/SpatialLite.Core/API/IPoint.cs @@ -1,13 +1,12 @@ -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines properties and methods for points. +/// +public interface IPoint : IGeometry { /// - /// Defines properties and methods for points. + /// Gets position of the point. /// - public interface IPoint : IGeometry - { - /// - /// Gets position of the point. - /// - Coordinate Position { get; } - } + Coordinate Position { get; } } diff --git a/src/SpatialLite.Core/API/IPolygon.cs b/src/SpatialLite.Core/API/IPolygon.cs index 0b59146..c4ab23a 100644 --- a/src/SpatialLite.Core/API/IPolygon.cs +++ b/src/SpatialLite.Core/API/IPolygon.cs @@ -1,20 +1,19 @@ using System.Collections.Generic; -namespace SpatialLite.Core.API +namespace SpatialLite.Core.API; + +/// +/// Defines properties and methods for polygons. +/// +public interface IPolygon : IGeometry { /// - /// Defines properties and methods for polygons. + /// Gets the exterior boundary of the polygon /// - public interface IPolygon : IGeometry - { - /// - /// Gets the exterior boundary of the polygon - /// - ICoordinateList ExteriorRing { get; } + ICoordinateList ExteriorRing { get; } - /// - /// Gets a collection of interior boundaries that define holes in the polygon - /// - IEnumerable InteriorRings { get; } - } + /// + /// Gets a collection of interior boundaries that define holes in the polygon + /// + IEnumerable InteriorRings { get; } } diff --git a/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs b/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs index fd3aa61..bf1253c 100644 --- a/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs @@ -1,49 +1,49 @@ using System; using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms +namespace SpatialLite.Core.Algorithms; + +/// +/// Provides methods for calculating distance and area in 2D euclidean space +/// +public class Euclidean2DCalculator : IDimensionsCalculator { + /// - /// Provides methods for calculating distance and area in 2D euclidean space + /// Calculates distance between two points /// - public class Euclidean2DCalculator : IDimensionsCalculator + /// The first point + /// The second point + /// distance between two point in coordinate's units. + public double CalculateDistance(Coordinate c1, Coordinate c2) { + double deltaX = c1.X - c2.X; + double deltaY = c1.Y - c2.Y; - /// - /// Calculates distance between two points - /// - /// The first point - /// The second point - /// distance between two point in coordinate's units. - public double CalculateDistance(Coordinate c1, Coordinate c2) - { - double deltaX = c1.X - c2.X; - double deltaY = c1.Y - c2.Y; - - return Math.Sqrt(deltaX * deltaX + deltaY * deltaY); - } + return Math.Sqrt(deltaX * deltaX + deltaY * deltaY); + } - /// - /// Calculates distance between a point and a line AB - /// - /// The coordinate to compute the distance for. - /// One point of the line. - /// Another point of the line. - /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. - /// The distance from C to line AB in coordinate's units. - public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + /// + /// Calculates distance between a point and a line AB + /// + /// The coordinate to compute the distance for. + /// One point of the line. + /// Another point of the line. + /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. + /// The distance from C to line AB in coordinate's units. + public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + if (a.Equals2D(b)) { - if (a.Equals2D(b)) - { - return this.CalculateDistance(c, a); - } + return this.CalculateDistance(c, a); + } - double deltaX = b.X - a.X; - double deltaY = b.Y - a.Y; + double deltaX = b.X - a.X; + double deltaY = b.Y - a.Y; - if (mode == LineMode.LineSegment) - { - /* + if (mode == LineMode.LineSegment) + { + /* Let P be the point of perpendicular projection of C on AB. The parameter r, which indicates P's position along AB, is computed by the dot product of AC and AB divided by the square of the length of AB: @@ -61,20 +61,20 @@ AC dot AB 0= 1.0) - { - return this.CalculateDistance(c, b); - } + if (r >= 1.0) + { + return this.CalculateDistance(c, b); } + } - /* + /* Use another parameter s to indicate the location along PC, with the following meaning: s<0 C is left of AB s>0 C is right of AB @@ -89,42 +89,40 @@ AC dot AB L^2 */ - double s = ((a.Y - c.Y) * deltaX - (a.X - c.X) * deltaY) / (deltaX * deltaX + deltaY * deltaY); + double s = ((a.Y - c.Y) * deltaX - (a.X - c.X) * deltaY) / (deltaX * deltaX + deltaY * deltaY); - /* + /* Then the distance from C to P = |s|*L. */ - return Math.Abs(s) * Math.Sqrt(deltaX * deltaX + deltaY * deltaY); - } + return Math.Abs(s) * Math.Sqrt(deltaX * deltaX + deltaY * deltaY); + } - /// - /// Calculates area of the polygon specified by given vertices - /// - /// The vertices of the polygon - /// The area of the polygon in squareed coordinate's units - /// Polygon is expected to be simple. ComputeArea method handles correctly CoordinateList from Polygon class, where first and last vertices are the same. - public double CalculateArea(ICoordinateList vertices) + /// + /// Calculates area of the polygon specified by given vertices + /// + /// The vertices of the polygon + /// The area of the polygon in squareed coordinate's units + /// Polygon is expected to be simple. ComputeArea method handles correctly CoordinateList from Polygon class, where first and last vertices are the same. + public double CalculateArea(ICoordinateList vertices) + { + if (vertices.Count < 3) { - if (vertices.Count < 3) - { - throw new ArgumentException("List must contain at least 3 vertices.", nameof(vertices)); - } - - double area = 0; - int maxIndex = vertices.Count - 1; - if (vertices[0] != vertices[maxIndex]) - { - maxIndex++; - } + throw new ArgumentException("List must contain at least 3 vertices.", nameof(vertices)); + } - for (int i = 0; i < maxIndex; i++) - { - area += (vertices[(i + 1) % vertices.Count].X + vertices[i % vertices.Count].X) * (vertices[(i + 1) % vertices.Count].Y - vertices[i % vertices.Count].Y); - } + double area = 0; + int maxIndex = vertices.Count - 1; + if (vertices[0] != vertices[maxIndex]) + { + maxIndex++; + } - return area / 2.0; + for (int i = 0; i < maxIndex; i++) + { + area += (vertices[(i + 1) % vertices.Count].X + vertices[i % vertices.Count].X) * (vertices[(i + 1) % vertices.Count].Y - vertices[i % vertices.Count].Y); } + return area / 2.0; } } diff --git a/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs b/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs index 539204b..9252164 100644 --- a/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs +++ b/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs @@ -2,224 +2,222 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms +namespace SpatialLite.Core.Algorithms; + +/// +/// Provides methods for determining relative position of geometries in Euclidean 2D space. +/// +public class Euclidean2DLocator : IGeometryLocator { + /// - /// Provides methods for determining relative position of geometries in Euclidean 2D space. + /// Determines whether specific coordinate is on the line defined by two points. /// - public class Euclidean2DLocator : IGeometryLocator + /// The coordinate to be tested + /// The first point of the line. + /// The second point of the line. + /// LineMode value that specifies whether AB should be treated as infinite line or as line segment + /// true if coordinate C is on line AB, otherwise false + public bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - - /// - /// Determines whether specific coordinate is on the line defined by two points. - /// - /// The coordinate to be tested - /// The first point of the line. - /// The second point of the line. - /// LineMode value that specifies whether AB should be treated as infinite line or as line segment - /// true if coordinate C is on line AB, otherwise false - public bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode) - { - /* + /* Express line in analytic form paramA * x + paramB * y + paramC = 0 */ - double paramA = b.Y - a.Y; - double paramB = a.X - b.X; - double paramC = b.X * a.Y - a.X * b.Y; + double paramA = b.Y - a.Y; + double paramB = a.X - b.X; + double paramC = b.X * a.Y - a.X * b.Y; - /* + /* induct coordinate C into equation of the line - if equation paramA * c.X + paramB * c.Y + paramC = 0 is valid, point lies on the line */ - double cLineResult = paramA * c.X + paramB * c.Y + paramC; + double cLineResult = paramA * c.X + paramB * c.Y + paramC; - if (cLineResult != 0.0) - { - return false; - } + if (cLineResult != 0.0) + { + return false; + } - if (mode == LineMode.Line) - { - return true; - } + if (mode == LineMode.Line) + { + return true; + } - // compute distance of the C along vector AB - double r; - double dx = Math.Abs(b.X - a.X); - double dy = Math.Abs(b.Y - a.Y); + // compute distance of the C along vector AB + double r; + double dx = Math.Abs(b.X - a.X); + double dy = Math.Abs(b.Y - a.Y); - if (dx > dy) - { - r = (c.X - a.X) / (b.X - a.X); - } - else - { - r = (c.Y - a.Y) / (b.Y - a.Y); - } + if (dx > dy) + { + r = (c.X - a.X) / (b.X - a.X); + } + else + { + r = (c.Y - a.Y) / (b.Y - a.Y); + } - if (r < 0.0 || r > 1.0) - { - return false; - } - else - { - return true; - } + if (r < 0.0 || r > 1.0) + { + return false; + } + else + { + return true; } + } - /// - /// Determines whether specific coordinate is on the given polyline - /// - /// The coordinate to be tested - /// The polyline - /// true if coordinate C is on the line, otherwise false - public bool IsOnLine(Coordinate c, ICoordinateList line) + /// + /// Determines whether specific coordinate is on the given polyline + /// + /// The coordinate to be tested + /// The polyline + /// true if coordinate C is on the line, otherwise false + public bool IsOnLine(Coordinate c, ICoordinateList line) + { + for (int i = 1; i < line.Count; i++) { - for (int i = 1; i < line.Count; i++) + if (this.IsOnLine(c, line[i - 1], line[i], LineMode.LineSegment)) { - if (this.IsOnLine(c, line[i - 1], line[i], LineMode.LineSegment)) - { - return true; - } + return true; } + } - return false; + return false; + } + + /// + /// Determines if specific point is in ring + /// + /// The coordinate to be tested + /// The ring to locate point in + /// True if point lies inside ring, otherwise false + public bool IsInRing(Coordinate c, ICoordinateList ring) + { + if (ring.Count < 3) + { + throw new ArgumentException("Ring must contain at least 3 points", nameof(ring)); } - /// - /// Determines if specific point is in ring - /// - /// The coordinate to be tested - /// The ring to locate point in - /// True if point lies inside ring, otherwise false - public bool IsInRing(Coordinate c, ICoordinateList ring) + if (ring[0].Equals2D(ring[ring.Count - 1]) == false) { - if (ring.Count < 3) - { - throw new ArgumentException("Ring must contain at least 3 points", nameof(ring)); - } + throw new ArgumentException("Ring does not have the same endpoints", nameof(ring)); + } - if (ring[0].Equals2D(ring[ring.Count - 1]) == false) - { - throw new ArgumentException("Ring does not have the same endpoints", nameof(ring)); - } + // determine if point is in ring using ray-tracing algorithm + // ray is casted from c in the direction of positive x-axis + int crossings = 0; + + for (int i = 0; i < ring.Count; i++) + { + Coordinate p1 = ring[i]; + Coordinate p2 = ring[(i + 1) % ring.Count]; - // determine if point is in ring using ray-tracing algorithm - // ray is casted from c in the direction of positive x-axis - int crossings = 0; + double y1 = p1.Y - c.Y; + double y2 = p2.Y - c.Y; - for (int i = 0; i < ring.Count; i++) + // check there can be crossing - c lies between P1 and P2 on y-axis + if (((y1 > 0) && (y2 <= 0)) || ((y2 > 0) && (y1 <= 0))) { - Coordinate p1 = ring[i]; - Coordinate p2 = ring[(i + 1) % ring.Count]; + double x1 = p1.X - c.X; + double x2 = p2.X - c.X; - double y1 = p1.Y - c.Y; - double y2 = p2.Y - c.Y; + // compute intersection + double intersection = (x1 * y2 - x2 * y1) / (y2 - y1); - // check there can be crossing - c lies between P1 and P2 on y-axis - if (((y1 > 0) && (y2 <= 0)) || ((y2 > 0) && (y1 <= 0))) + if (intersection > 0) { - double x1 = p1.X - c.X; - double x2 = p2.X - c.X; - - // compute intersection - double intersection = (x1 * y2 - x2 * y1) / (y2 - y1); - - if (intersection > 0) - { - crossings++; - } + crossings++; } } - - // p is inside if an odd number of crossings - if ((crossings % 2) == 1) - { - return true; - } - else - { - return false; - } } - /// - /// Determines whether two lines or line segments intersects - /// - /// The first point of the first line - /// The second point of the first line - /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment - /// The first point of the second line - /// The second point of the second line - /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment - /// true if A1B1 intersects A2B2, otherwise returns false - public bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode) + // p is inside if an odd number of crossings + if ((crossings % 2) == 1) { - double paramA1 = b1.Y - a1.Y; - double paramB1 = a1.X - b1.X; - double paramC1 = paramA1 * a1.X + paramB1 * a1.Y; + return true; + } + else + { + return false; + } + } + + /// + /// Determines whether two lines or line segments intersects + /// + /// The first point of the first line + /// The second point of the first line + /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment + /// The first point of the second line + /// The second point of the second line + /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment + /// true if A1B1 intersects A2B2, otherwise returns false + public bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode) + { + double paramA1 = b1.Y - a1.Y; + double paramB1 = a1.X - b1.X; + double paramC1 = paramA1 * a1.X + paramB1 * a1.Y; - double paramA2 = b2.Y - a2.Y; - double paramB2 = a2.X - b2.X; - double paramC2 = paramA2 * a2.X + paramB2 * a2.Y; + double paramA2 = b2.Y - a2.Y; + double paramB2 = a2.X - b2.X; + double paramC2 = paramA2 * a2.X + paramB2 * a2.Y; - double det = paramA1 * paramB2 - paramA2 * paramB1; - if (det == 0) - { - return false; - } - else - { - double x = (paramB2 * paramC1 - paramB1 * paramC2) / det; - double y = (paramA1 * paramC2 - paramA2 * paramC1) / det; + double det = paramA1 * paramB2 - paramA2 * paramB1; + if (det == 0) + { + return false; + } + else + { + double x = (paramB2 * paramC1 - paramB1 * paramC2) / det; + double y = (paramA1 * paramC2 - paramA2 * paramC1) / det; - if (line1Mode == LineMode.LineSegment) + if (line1Mode == LineMode.LineSegment) + { + if (x < Math.Min(a1.X, b1.X) || x > Math.Max(a1.X, b1.X) || y < Math.Min(a1.Y, b1.Y) || y > Math.Max(a1.Y, b1.Y)) { - if (x < Math.Min(a1.X, b1.X) || x > Math.Max(a1.X, b1.X) || y < Math.Min(a1.Y, b1.Y) || y > Math.Max(a1.Y, b1.Y)) - { - return false; - } + return false; } + } - if (line2Mode == LineMode.LineSegment) + if (line2Mode == LineMode.LineSegment) + { + if (x < Math.Min(a2.X, b2.X) || x > Math.Max(a2.X, b2.X) || y < Math.Min(a2.Y, b2.Y) || y > Math.Max(a2.Y, b2.Y)) { - if (x < Math.Min(a2.X, b2.X) || x > Math.Max(a2.X, b2.X) || y < Math.Min(a2.Y, b2.Y) || y > Math.Max(a2.Y, b2.Y)) - { - return false; - } + return false; } - - return true; } + + return true; } + } - /// - /// Determines whether two polylines defined by series of coordinates intersects - /// - /// The first polyline to test - /// The second polyline to test - /// true if polylines intersets, otherwise false - public bool Intersects(ICoordinateList line1, ICoordinateList line2) - { - //TODO implement more efficient algorithm + /// + /// Determines whether two polylines defined by series of coordinates intersects + /// + /// The first polyline to test + /// The second polyline to test + /// true if polylines intersets, otherwise false + public bool Intersects(ICoordinateList line1, ICoordinateList line2) + { + //TODO implement more efficient algorithm - for (int i = 1; i < line1.Count; i++) + for (int i = 1; i < line1.Count; i++) + { + for (int ii = 1; ii < line2.Count; ii++) { - for (int ii = 1; ii < line2.Count; ii++) + if (this.Intersects(line1[i - 1], line1[i], LineMode.LineSegment, line2[ii - 1], line2[ii], LineMode.LineSegment)) { - if (this.Intersects(line1[i - 1], line1[i], LineMode.LineSegment, line2[ii - 1], line2[ii], LineMode.LineSegment)) - { - return true; - } + return true; } } - - return false; } + return false; } } diff --git a/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs b/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs index a9e3709..14b3d84 100644 --- a/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/IDimensionsCalculator.cs @@ -1,35 +1,34 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms +namespace SpatialLite.Core.Algorithms; + +/// +/// Defines methods that a class providing distance and area calculations capabilities must implement +/// +public interface IDimensionsCalculator { /// - /// Defines methods that a class providing distance and area calculations capabilities must implement + /// Calculates distance between two points /// - public interface IDimensionsCalculator - { - /// - /// Calculates distance between two points - /// - /// The first point - /// The second point - /// distance between two point - double CalculateDistance(Coordinate c1, Coordinate c2); + /// The first point + /// The second point + /// distance between two point + double CalculateDistance(Coordinate c1, Coordinate c2); - /// - /// Calculates distance between a point and a line AB - /// - /// The coordinate to compute the distance for. - /// One point of the line. - /// Another point of the line. - /// LineDistanceMode value that specifies whether AB should be treated as infinite line or as line segment - /// The distance from c to line AB. - double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode); + /// + /// Calculates distance between a point and a line AB + /// + /// The coordinate to compute the distance for. + /// One point of the line. + /// Another point of the line. + /// LineDistanceMode value that specifies whether AB should be treated as infinite line or as line segment + /// The distance from c to line AB. + double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode); - /// - /// Calculates area of the polygon specified by given vertices - /// - /// The vertices of the polygon - /// The area of the polygon - double CalculateArea(ICoordinateList vertices); - } + /// + /// Calculates area of the polygon specified by given vertices + /// + /// The vertices of the polygon + /// The area of the polygon + double CalculateArea(ICoordinateList vertices); } diff --git a/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs b/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs index b0b68af..b687947 100644 --- a/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs +++ b/src/SpatialLite.Core/Algorithms/IGeometryLocator.cs @@ -1,56 +1,55 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms +namespace SpatialLite.Core.Algorithms; + +/// +/// Defines methods that a class providing relative geometry position computation capabilities must implement. +/// +public interface IGeometryLocator { /// - /// Defines methods that a class providing relative geometry position computation capabilities must implement. + /// Determines whether specific coordinate is on line defined by two points. /// - public interface IGeometryLocator - { - /// - /// Determines whether specific coordinate is on line defined by two points. - /// - /// The coordinate to be tested. - /// The first point of the line. - /// The second point of the line. - /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. - /// true if coordinate C is on line AB, otherwise false. - bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode); + /// The coordinate to be tested. + /// The first point of the line. + /// The second point of the line. + /// LineMode value that specifies whether AB should be treated as infinite line or as line segment. + /// true if coordinate C is on line AB, otherwise false. + bool IsOnLine(Coordinate c, Coordinate a, Coordinate b, LineMode mode); - /// - /// Determines whether specific coordinate is on the given polyline. - /// - /// The coordinate to be tested. - /// The polyline. - /// true if coordinate C is on the line, otherwise false. - bool IsOnLine(Coordinate c, ICoordinateList line); + /// + /// Determines whether specific coordinate is on the given polyline. + /// + /// The coordinate to be tested. + /// The polyline. + /// true if coordinate C is on the line, otherwise false. + bool IsOnLine(Coordinate c, ICoordinateList line); - /// - /// Determines whether specific point is in ring. - /// - /// The coordinate to be tested. - /// The ring to locate point in. - /// True if point lies inside ring, otherwise false. - bool IsInRing(Coordinate c, ICoordinateList ring); + /// + /// Determines whether specific point is in ring. + /// + /// The coordinate to be tested. + /// The ring to locate point in. + /// True if point lies inside ring, otherwise false. + bool IsInRing(Coordinate c, ICoordinateList ring); - /// - /// Determines whether two lines or line segments defined by two points each intersects. - /// - /// The first point of the first line. - /// The second point of the first line. - /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment. - /// The first point of the second line. - /// The second point of the second line. - /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment. - /// true if A1B1 intersects A2B2, otherwise returns false. - bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode); + /// + /// Determines whether two lines or line segments defined by two points each intersects. + /// + /// The first point of the first line. + /// The second point of the first line. + /// LineMode value that specifies whether A1B1 should be treated as infinite line or as line segment. + /// The first point of the second line. + /// The second point of the second line. + /// LineMode value that specifies whether A2B2 should be treated as infinite line or as line segment. + /// true if A1B1 intersects A2B2, otherwise returns false. + bool Intersects(Coordinate a1, Coordinate b1, LineMode line1Mode, Coordinate a2, Coordinate b2, LineMode line2Mode); - /// - /// Determines whether two polylines defined by series of coordinates intersects. - /// - /// The first polyline to test. - /// The second polyline to test. - /// true if polylines intersets, otherwise false. - bool Intersects(ICoordinateList line1, ICoordinateList line2); - } + /// + /// Determines whether two polylines defined by series of coordinates intersects. + /// + /// The first polyline to test. + /// The second polyline to test. + /// true if polylines intersets, otherwise false. + bool Intersects(ICoordinateList line1, ICoordinateList line2); } diff --git a/src/SpatialLite.Core/Algorithms/LineMode.cs b/src/SpatialLite.Core/Algorithms/LineMode.cs index 926fa17..01d0e09 100644 --- a/src/SpatialLite.Core/Algorithms/LineMode.cs +++ b/src/SpatialLite.Core/Algorithms/LineMode.cs @@ -1,18 +1,17 @@ -namespace SpatialLite.Core.Algorithms +namespace SpatialLite.Core.Algorithms; + +/// +/// Specifies how algorithms treats line defined by two points. +/// +public enum LineMode { /// - /// Specifies how algorithms treats line defined by two points. + /// Line is treated as line segment. /// - public enum LineMode - { - /// - /// Line is treated as line segment. - /// - LineSegment, + LineSegment, - /// - /// Line is treated as infinite line. - /// - Line - } + /// + /// Line is treated as infinite line. + /// + Line } diff --git a/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs b/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs index 7286297..4bbbb08 100644 --- a/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs @@ -2,160 +2,159 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Algorithms +namespace SpatialLite.Core.Algorithms; + +/// +/// Provides methods for calculating distance and area on the surface of a sphere. +/// +/// +/// +/// All calulations ignore coordinate. +/// +/// All coordinate are expected to be a long/lat pairs in degrees. +/// +public class Sphere2DCalculator : IDimensionsCalculator { + /// - /// Provides methods for calculating distance and area on the surface of a sphere. + /// The radius of spheric approximation of the Earth. /// - /// - /// - /// All calulations ignore coordinate. - /// - /// All coordinate are expected to be a long/lat pairs in degrees. - /// - public class Sphere2DCalculator : IDimensionsCalculator - { + public const double EarthRadius = 6371010; - /// - /// The radius of spheric approximation of the Earth. - /// - public const double EarthRadius = 6371010; + /// + /// Initializes a new instance of the Sphere2DCalculator that uses sphere approximation of the Earth. + /// + public Sphere2DCalculator() + { + this.Radius = Sphere2DCalculator.EarthRadius; + } - /// - /// Initializes a new instance of the Sphere2DCalculator that uses sphere approximation of the Earth. - /// - public Sphere2DCalculator() - { - this.Radius = Sphere2DCalculator.EarthRadius; - } + /// + /// Gets radius of the sphere that Sphere2DCalculator uses for calculations. + /// + public double Radius { get; private set; } - /// - /// Gets radius of the sphere that Sphere2DCalculator uses for calculations. - /// - public double Radius { get; private set; } - - /// - /// Calculates distance between 2 objects using great circle path. - /// - /// The first coordinate. - /// The second coordinate. - /// The distance of the points in units of the property. - public double CalculateDistance(Coordinate c1, Coordinate c2) - { - double dLon = (c2.X - c1.X) * Math.PI / 180; - double dLat = (c2.Y - c1.Y) * Math.PI / 180; + /// + /// Calculates distance between 2 objects using great circle path. + /// + /// The first coordinate. + /// The second coordinate. + /// The distance of the points in units of the property. + public double CalculateDistance(Coordinate c1, Coordinate c2) + { + double dLon = (c2.X - c1.X) * Math.PI / 180; + double dLat = (c2.Y - c1.Y) * Math.PI / 180; - double sinLat = Math.Sin(dLat / 2); - double sinLon = Math.Sin(dLon / 2); + double sinLat = Math.Sin(dLat / 2); + double sinLon = Math.Sin(dLon / 2); - double a = sinLat * sinLat + Math.Cos(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * sinLon * sinLon; + double a = sinLat * sinLat + Math.Cos(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * sinLon * sinLon; - //length or arc in radians - double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); + //length or arc in radians + double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); - return c * this.Radius; - } + return c * this.Radius; + } - /// - /// Calculates distance between a point and a great circle path connecting points A and B. - /// - /// The coordinate to compute the distance for. - /// The first point of the great circle. - /// The second point of the great circle. - /// LineMode value that specifies whether great circle should be treated as whole circle or as arc segment between points A and B. - /// The distance from c to great circle connecting points AB in units of the property. - public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) - { - double bearingAB = this.CalculateBearing(a, b); - double bearingAC = this.CalculateBearing(a, c); + /// + /// Calculates distance between a point and a great circle path connecting points A and B. + /// + /// The coordinate to compute the distance for. + /// The first point of the great circle. + /// The second point of the great circle. + /// LineMode value that specifies whether great circle should be treated as whole circle or as arc segment between points A and B. + /// The distance from c to great circle connecting points AB in units of the property. + public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + double bearingAB = this.CalculateBearing(a, b); + double bearingAC = this.CalculateBearing(a, c); - double distAC = this.CalculateDistance(a, c); + double distAC = this.CalculateDistance(a, c); - //Sign can be used to determine if point is left/right of the great circle - double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / Sphere2DCalculator.EarthRadius) * Math.Sin(bearingAC - bearingAB)) * Sphere2DCalculator.EarthRadius); + //Sign can be used to determine if point is left/right of the great circle + double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / Sphere2DCalculator.EarthRadius) * Math.Sin(bearingAC - bearingAB)) * Sphere2DCalculator.EarthRadius); - if (mode == LineMode.Line) - { - return distCircleC; - } - else - { - double bearingBA = this.CalculateBearing(b, a); - double bearingBC = this.CalculateBearing(b, c); - - if (Math.Abs(bearingAC - bearingAB) > Math.PI / 2) - { - return distAC; - } - else if (Math.Abs(bearingBC - bearingBA) > Math.PI / 2) - { - return this.CalculateDistance(b, c); - } - else - { - return distCircleC; - } - } + if (mode == LineMode.Line) + { + return distCircleC; } - - /// - /// Calculates area of the polygon on the surface of a sphere specified by given vertices. - /// - /// The vertices of the polygon. - /// The area of the polygon in squared units of the property. - /// Polygon is expected to be simple. - public double CalculateArea(ICoordinateList vertices) + else { - if (vertices.Count < 3) + double bearingBA = this.CalculateBearing(b, a); + double bearingBC = this.CalculateBearing(b, c); + + if (Math.Abs(bearingAC - bearingAB) > Math.PI / 2) { - throw new ArgumentException("List must contain at least 3 vertices.", nameof(vertices)); + return distAC; } - - double area = 0; - int maxIndex = vertices.Count - 1; - if (vertices[0] != vertices[maxIndex]) + else if (Math.Abs(bearingBC - bearingBA) > Math.PI / 2) { - maxIndex++; + return this.CalculateDistance(b, c); } - - for (int i = 0; i <= maxIndex; i++) + else { - area += (this.ToRadians(vertices[(i + 1) % maxIndex].X) - this.ToRadians(vertices[(i - 1) % maxIndex].X)) * Math.Sin(this.ToRadians(vertices[i % maxIndex].Y)); + return distCircleC; } - - return Math.Abs(area * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius); } + } - /// - /// Calculates initial course when moving from point C1 to point C2 on great circle path. - /// - /// The first point. - /// The second point - /// The bearing in radians. - /// The bearing changes as traveling along great circle. - private double CalculateBearing(Coordinate c1, Coordinate c2) + /// + /// Calculates area of the polygon on the surface of a sphere specified by given vertices. + /// + /// The vertices of the polygon. + /// The area of the polygon in squared units of the property. + /// Polygon is expected to be simple. + public double CalculateArea(ICoordinateList vertices) + { + if (vertices.Count < 3) { - double dLon = (c2.X - c1.X) * Math.PI / 180; - - double y = Math.Sin(dLon) * Math.Cos(c2.Y * Math.PI / 180); - double x = Math.Cos(c1.Y * Math.PI / 180) * Math.Sin(c2.Y * Math.PI / 180) - - Math.Sin(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * Math.Cos(c2.X * Math.PI / 180); - - double bearing = Math.Atan2(y, x); + throw new ArgumentException("List must contain at least 3 vertices.", nameof(vertices)); + } - return bearing; + double area = 0; + int maxIndex = vertices.Count - 1; + if (vertices[0] != vertices[maxIndex]) + { + maxIndex++; } - /// - /// Converts angle in degrees to radians - /// - /// Angle in degrees - /// angle in radians - private double ToRadians(double degrees) + for (int i = 0; i <= maxIndex; i++) { - return degrees * Math.PI / 180; + area += (this.ToRadians(vertices[(i + 1) % maxIndex].X) - this.ToRadians(vertices[(i - 1) % maxIndex].X)) * Math.Sin(this.ToRadians(vertices[i % maxIndex].Y)); } + + return Math.Abs(area * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius); + } + + /// + /// Calculates initial course when moving from point C1 to point C2 on great circle path. + /// + /// The first point. + /// The second point + /// The bearing in radians. + /// The bearing changes as traveling along great circle. + private double CalculateBearing(Coordinate c1, Coordinate c2) + { + double dLon = (c2.X - c1.X) * Math.PI / 180; + + double y = Math.Sin(dLon) * Math.Cos(c2.Y * Math.PI / 180); + double x = Math.Cos(c1.Y * Math.PI / 180) * Math.Sin(c2.Y * Math.PI / 180) - + Math.Sin(c1.Y * Math.PI / 180) * Math.Cos(c2.Y * Math.PI / 180) * Math.Cos(c2.X * Math.PI / 180); + + double bearing = Math.Atan2(y, x); + + return bearing; + } + + /// + /// Converts angle in degrees to radians + /// + /// Angle in degrees + /// angle in radians + private double ToRadians(double degrees) + { + return degrees * Math.PI / 180; } } diff --git a/src/SpatialLite.Core/Geometries/CoordinateList.cs b/src/SpatialLite.Core/Geometries/CoordinateList.cs index 05ec6b2..c2c5acc 100644 --- a/src/SpatialLite.Core/Geometries/CoordinateList.cs +++ b/src/SpatialLite.Core/Geometries/CoordinateList.cs @@ -3,123 +3,122 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents read-write list of Coordinates. +/// +public class CoordinateList : ICoordinateList { + + private List _storage; + /// - /// Represents read-write list of Coordinates. + /// Initializes a new instance of the CoordinateList class, that is empty. /// - public class CoordinateList : ICoordinateList + public CoordinateList() { + _storage = new List(); + } - private List _storage; - - /// - /// Initializes a new instance of the CoordinateList class, that is empty. - /// - public CoordinateList() - { - _storage = new List(); - } + /// + /// Initializes a new instance of the CoordinateList class that contains coordinates from the given collection. + /// + /// The collection whose elements are used to fill CoordinateList. + public CoordinateList(IEnumerable coords) + { + _storage = new List(coords); + } - /// - /// Initializes a new instance of the CoordinateList class that contains coordinates from the given collection. - /// - /// The collection whose elements are used to fill CoordinateList. - public CoordinateList(IEnumerable coords) + /// + /// Gets number of Coordinates in the list. + /// + public int Count + { + get { - _storage = new List(coords); + return _storage.Count; } + } - /// - /// Gets number of Coordinates in the list. - /// - public int Count + /// + /// Gets or sets Coordinate at the given index. + /// + /// The zero-based index of the Coordinate to get or set. + /// The element at the specified index. + public Coordinate this[int index] + { + get { - get - { - return _storage.Count; - } + return _storage[index]; } - - /// - /// Gets or sets Coordinate at the given index. - /// - /// The zero-based index of the Coordinate to get or set. - /// The element at the specified index. - public Coordinate this[int index] + set { - get - { - return _storage[index]; - } - set - { - _storage[index] = value; - } + _storage[index] = value; } + } - /// - /// Adds Coordinate to the end of the list. - /// - /// The Coordinate to add to the list. - public void Add(Coordinate coord) - { - _storage.Add(coord); - } + /// + /// Adds Coordinate to the end of the list. + /// + /// The Coordinate to add to the list. + public void Add(Coordinate coord) + { + _storage.Add(coord); + } - /// - /// Adds collection of coordinates to the end of the list. - /// - /// The collection of coordinates to add to the list. - public void Add(IEnumerable coords) - { - _storage.AddRange(coords); - } + /// + /// Adds collection of coordinates to the end of the list. + /// + /// The collection of coordinates to add to the list. + public void Add(IEnumerable coords) + { + _storage.AddRange(coords); + } - /// - /// Insertes Coordinate to the list at the specified index. - /// - /// The zero-based index at which coord should be inserted. - /// The Coordinate to insert into list. - /// If index equals the number of items in the list, then item is appended to the list. - public void Insert(int index, Coordinate coord) - { - _storage.Insert(index, coord); - } + /// + /// Insertes Coordinate to the list at the specified index. + /// + /// The zero-based index at which coord should be inserted. + /// The Coordinate to insert into list. + /// If index equals the number of items in the list, then item is appended to the list. + public void Insert(int index, Coordinate coord) + { + _storage.Insert(index, coord); + } - /// - /// Removes Coordinate at the specified index from the list. - /// - /// The zero-based index of the Coordinate to remove. - public void RemoveAt(int index) - { - _storage.RemoveAt(index); - } + /// + /// Removes Coordinate at the specified index from the list. + /// + /// The zero-based index of the Coordinate to remove. + public void RemoveAt(int index) + { + _storage.RemoveAt(index); + } - /// - /// Removes all Coordinates from the collection. - /// - public void Clear() - { - _storage.Clear(); - } + /// + /// Removes all Coordinates from the collection. + /// + public void Clear() + { + _storage.Clear(); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - public IEnumerator GetEnumerator() - { - return _storage.GetEnumerator(); - } + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + public IEnumerator GetEnumerator() + { + return _storage.GetEnumerator(); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable)_storage).GetEnumerator(); - } + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + IEnumerator IEnumerable.GetEnumerator() + { + return ((IEnumerable)_storage).GetEnumerator(); } } diff --git a/src/SpatialLite.Core/Geometries/Geometry.cs b/src/SpatialLite.Core/Geometries/Geometry.cs index c443558..be2d834 100644 --- a/src/SpatialLite.Core/Geometries/Geometry.cs +++ b/src/SpatialLite.Core/Geometries/Geometry.cs @@ -2,36 +2,35 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represetns the base class for all geometry object. +/// +public abstract class Geometry : IGeometry { + /// - /// Represetns the base class for all geometry object. + /// Gets a value indicating whether this has Z-coordinates. /// - public abstract class Geometry : IGeometry - { - - /// - /// Gets a value indicating whether this has Z-coordinates. - /// - public abstract bool Is3D { get; } + public abstract bool Is3D { get; } - /// - /// Gets a value indicating whether this has M values. - /// - public abstract bool IsMeasured { get; } + /// + /// Gets a value indicating whether this has M values. + /// + public abstract bool IsMeasured { get; } - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the Geometry object. - /// - public abstract Envelope GetEnvelope(); + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the Geometry object. + /// + public abstract Envelope GetEnvelope(); - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - public abstract IEnumerable GetCoordinates(); - } + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + public abstract IEnumerable GetCoordinates(); } diff --git a/src/SpatialLite.Core/Geometries/GeometryCollection.cs b/src/SpatialLite.Core/Geometries/GeometryCollection.cs index f27bb06..6e080fa 100644 --- a/src/SpatialLite.Core/Geometries/GeometryCollection.cs +++ b/src/SpatialLite.Core/Geometries/GeometryCollection.cs @@ -3,104 +3,103 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents generic collection of geometry objects. +/// +/// All objects should be in the same spatial reference system, but it isn't enforced by this class. +/// The type of objects in the collection +public class GeometryCollection : Geometry, IGeometryCollection where T : IGeometry { + private readonly List _geometries; + /// - /// Represents generic collection of geometry objects. + /// Initializes a new instance of the GeometryCollection class that is empty and has assigned WSG84 coordinate reference system. /// - /// All objects should be in the same spatial reference system, but it isn't enforced by this class. - /// The type of objects in the collection - public class GeometryCollection : Geometry, IGeometryCollection where T : IGeometry + public GeometryCollection() + : base() { - private readonly List _geometries; + _geometries = new List(); + } - /// - /// Initializes a new instance of the GeometryCollection class that is empty and has assigned WSG84 coordinate reference system. - /// - public GeometryCollection() - : base() - { - _geometries = new List(); - } + /// + /// Initializes a new instance of the GeometryCollection class in WSG84 coordinate reference system and fills it with specified geometries. + /// + /// Geometry objects to be added to the collection + public GeometryCollection(IEnumerable geometries) + : base() + { + _geometries = new List(geometries); + } - /// - /// Initializes a new instance of the GeometryCollection class in WSG84 coordinate reference system and fills it with specified geometries. - /// - /// Geometry objects to be added to the collection - public GeometryCollection(IEnumerable geometries) - : base() + /// + /// Gets a value indicating whether the this "/> has Z ordinates set. + /// + /// + /// Is3D returns true if any of the geometries contained in this GeometryCollection has Z ordinate set. + /// + public override bool Is3D + { + get { - _geometries = new List(geometries); + return _geometries.Any(geometry => geometry.Is3D); } + } - /// - /// Gets a value indicating whether the this "/> has Z ordinates set. - /// - /// - /// Is3D returns true if any of the geometries contained in this GeometryCollection has Z ordinate set. - /// - public override bool Is3D - { - get - { - return _geometries.Any(geometry => geometry.Is3D); - } - } + /// + /// Gets a value indicating whether this has M values. + /// + /// + /// IsMeasured returns true if any of the geometries in this GeometryCollection has M value set. + /// + public override bool IsMeasured + { + get { return _geometries.Any(c => c.IsMeasured); } + } - /// - /// Gets a value indicating whether this has M values. - /// - /// - /// IsMeasured returns true if any of the geometries in this GeometryCollection has M value set. - /// - public override bool IsMeasured + /// + /// Gets the list of IGeometry objects in this collection + /// + public List Geometries + { + get { - get { return _geometries.Any(c => c.IsMeasured); } + return _geometries; } + } - /// - /// Gets the list of IGeometry objects in this collection - /// - public List Geometries - { - get - { - return _geometries; - } - } + /// + /// Gets collection of geometry obejcts from this GeometryCollection as the collection of IGeometry objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return _geometries; } + } - /// - /// Gets collection of geometry obejcts from this GeometryCollection as the collection of IGeometry objects. - /// - IEnumerable IGeometryCollection.Geometries + /// + /// Computes envelope of the GeometryCollection object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the GeometryCollection object. + /// + public override Envelope GetEnvelope() + { + Envelope result = new Envelope(); + foreach (var item in _geometries) { - get { return _geometries; } + result.Extend(item.GetEnvelope()); } - /// - /// Computes envelope of the GeometryCollection object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the GeometryCollection object. - /// - public override Envelope GetEnvelope() - { - Envelope result = new Envelope(); - foreach (var item in _geometries) - { - result.Extend(item.GetEnvelope()); - } - - return result; - } + return result; + } - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - public override IEnumerable GetCoordinates() - { - return this.Geometries.SelectMany(o => o.GetCoordinates()); - } + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + public override IEnumerable GetCoordinates() + { + return this.Geometries.SelectMany(o => o.GetCoordinates()); } } diff --git a/src/SpatialLite.Core/Geometries/LineString.cs b/src/SpatialLite.Core/Geometries/LineString.cs index cb9aafd..1ac9c9f 100644 --- a/src/SpatialLite.Core/Geometries/LineString.cs +++ b/src/SpatialLite.Core/Geometries/LineString.cs @@ -2,144 +2,143 @@ using System.Linq; using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents a curve with linear interpolation between consecutive vertices. +/// +public class LineString : Geometry, ILineString { + + private CoordinateList _coordinates; + /// - /// Represents a curve with linear interpolation between consecutive vertices. + /// Initializes a new instance of the LineString class that is empty and has assigned WSG84 coordinate reference system. /// - public class LineString : Geometry, ILineString + public LineString() + : base() { + _coordinates = new CoordinateList(); + } - private CoordinateList _coordinates; + /// + /// Initializes a new instance of the LineString class with specified coordinates and WSG84 coordinate reference system. + /// + /// The collection of coordinates to be copied to the new LineString. + public LineString(IEnumerable coords) + : base() + { + _coordinates = new CoordinateList(coords); + } - /// - /// Initializes a new instance of the LineString class that is empty and has assigned WSG84 coordinate reference system. - /// - public LineString() - : base() - { - _coordinates = new CoordinateList(); - } + /// + /// Gets a value indicating whether the this has Z-coordinates set. + /// + /// + /// Is3D returns true if any of the coordinates in this LineString has Z-coordinate set. + /// + public override bool Is3D + { + get { return _coordinates.Any(c => c.Is3D); } + } - /// - /// Initializes a new instance of the LineString class with specified coordinates and WSG84 coordinate reference system. - /// - /// The collection of coordinates to be copied to the new LineString. - public LineString(IEnumerable coords) - : base() - { - _coordinates = new CoordinateList(coords); - } + /// + /// Gets a value indicating whether this has M values. + /// + /// + /// IsMeasured returns true if any of the coordinates in this LineString has M value set. + /// + public override bool IsMeasured + { + get { return _coordinates.Any(c => c.IsMeasured); } + } - /// - /// Gets a value indicating whether the this has Z-coordinates set. - /// - /// - /// Is3D returns true if any of the coordinates in this LineString has Z-coordinate set. - /// - public override bool Is3D - { - get { return _coordinates.Any(c => c.Is3D); } - } + /// + /// Gets the list of çoordinates that define this LisneString + /// + public virtual ICoordinateList Coordinates + { + get { return _coordinates; } + } - /// - /// Gets a value indicating whether this has M values. - /// - /// - /// IsMeasured returns true if any of the coordinates in this LineString has M value set. - /// - public override bool IsMeasured - { - get { return _coordinates.Any(c => c.IsMeasured); } - } + /// + /// Gets the list of çoordinates that define this LisneString + /// + ICoordinateList ILineString.Coordinates + { + get { return this.Coordinates; } + } - /// - /// Gets the list of çoordinates that define this LisneString - /// - public virtual ICoordinateList Coordinates + /// + /// Gets the first coordinate of the ILineString object. + /// + public Coordinate Start + { + get { - get { return _coordinates; } - } + if (_coordinates.Count == 0) + { + return Coordinate.Empty; + } - /// - /// Gets the list of çoordinates that define this LisneString - /// - ICoordinateList ILineString.Coordinates - { - get { return this.Coordinates; } + return _coordinates[0]; } + } - /// - /// Gets the first coordinate of the ILineString object. - /// - public Coordinate Start + /// + /// Gets the last coordinate of the ILineString object. + /// + public Coordinate End + { + get { - get + if (_coordinates.Count == 0) { - if (_coordinates.Count == 0) - { - return Coordinate.Empty; - } - - return _coordinates[0]; + return Coordinate.Empty; } + + return _coordinates[_coordinates.Count - 1]; } + } - /// - /// Gets the last coordinate of the ILineString object. - /// - public Coordinate End + /// + /// Gets a value indicating whether this LineString is closed. + /// + /// + /// The LineStringBase is closed if and are identical. + /// + public virtual bool IsClosed + { + get { - get + if (_coordinates.Count == 0) { - if (_coordinates.Count == 0) - { - return Coordinate.Empty; - } - - return _coordinates[_coordinates.Count - 1]; + return false; } - } - - /// - /// Gets a value indicating whether this LineString is closed. - /// - /// - /// The LineStringBase is closed if and are identical. - /// - public virtual bool IsClosed - { - get + else { - if (_coordinates.Count == 0) - { - return false; - } - else - { - return this.Start.Equals(this.End); - } + return this.Start.Equals(this.End); } } + } - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the IGeometry object. - /// - public override Envelope GetEnvelope() - { - return new Envelope(_coordinates); - } + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the IGeometry object. + /// + public override Envelope GetEnvelope() + { + return new Envelope(_coordinates); + } - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - public override IEnumerable GetCoordinates() - { - return this.Coordinates; - } + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + public override IEnumerable GetCoordinates() + { + return this.Coordinates; } } diff --git a/src/SpatialLite.Core/Geometries/MultiLineString.cs b/src/SpatialLite.Core/Geometries/MultiLineString.cs index 32893ed..58a3c82 100644 --- a/src/SpatialLite.Core/Geometries/MultiLineString.cs +++ b/src/SpatialLite.Core/Geometries/MultiLineString.cs @@ -2,37 +2,36 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents a collection of LineStrings +/// +public class MultiLineString : GeometryCollection, IMultiLineString { + /// - /// Represents a collection of LineStrings + /// Initializes a new instance of the MultiLineString class that is empty and has assigned WSG84 coordinate reference system. /// - public class MultiLineString : GeometryCollection, IMultiLineString + public MultiLineString() + : base() { + } - /// - /// Initializes a new instance of the MultiLineString class that is empty and has assigned WSG84 coordinate reference system. - /// - public MultiLineString() - : base() - { - } - - /// - /// Initializes a new instance of the MultiLineString class with specified LineStrings - /// - /// The collection of LineString to be copied to the new MultiLineString. - public MultiLineString(IEnumerable linestrings) - : base(linestrings) - { - } + /// + /// Initializes a new instance of the MultiLineString class with specified LineStrings + /// + /// The collection of LineString to be copied to the new MultiLineString. + public MultiLineString(IEnumerable linestrings) + : base(linestrings) + { + } - /// - /// Gets collection of geometry obejcts from this MultiLineString as the collection of IMultiLineString objects. - /// - IEnumerable IGeometryCollection.Geometries - { - get { return base.Geometries; } - } + /// + /// Gets collection of geometry obejcts from this MultiLineString as the collection of IMultiLineString objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return base.Geometries; } } } diff --git a/src/SpatialLite.Core/Geometries/MultiPoint.cs b/src/SpatialLite.Core/Geometries/MultiPoint.cs index c674ca2..1d0430b 100644 --- a/src/SpatialLite.Core/Geometries/MultiPoint.cs +++ b/src/SpatialLite.Core/Geometries/MultiPoint.cs @@ -2,37 +2,36 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents a collection of Points +/// +public class MultiPoint : GeometryCollection, IMultiPoint { + /// - /// Represents a collection of Points + /// Initializes a new instance of the MultiPoint class that is empty and has assigned WSG84 coordinate reference system. /// - public class MultiPoint : GeometryCollection, IMultiPoint + public MultiPoint() + : base() { + } - /// - /// Initializes a new instance of the MultiPoint class that is empty and has assigned WSG84 coordinate reference system. - /// - public MultiPoint() - : base() - { - } - - /// - /// Initializes a new instance of the MultiPoint class with specified points. - /// - /// The collection of points to be copied to the new MultiPoint. - public MultiPoint(IEnumerable points) - : base(points) - { - } + /// + /// Initializes a new instance of the MultiPoint class with specified points. + /// + /// The collection of points to be copied to the new MultiPoint. + public MultiPoint(IEnumerable points) + : base(points) + { + } - /// - /// Gets collection of points from this Multipoint as the collection of IPoint objects. - /// - IEnumerable IGeometryCollection.Geometries - { - get { return base.Geometries; } - } + /// + /// Gets collection of points from this Multipoint as the collection of IPoint objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return base.Geometries; } } } diff --git a/src/SpatialLite.Core/Geometries/MultiPolygon.cs b/src/SpatialLite.Core/Geometries/MultiPolygon.cs index 99a5f55..8af6a6d 100644 --- a/src/SpatialLite.Core/Geometries/MultiPolygon.cs +++ b/src/SpatialLite.Core/Geometries/MultiPolygon.cs @@ -2,37 +2,36 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents a collection of Polygons +/// +public class MultiPolygon : GeometryCollection, IMultiPolygon { + /// - /// Represents a collection of Polygons + /// Initializes a new instance of the MultiPolygon class that is empty and has assigned WSG84 coordinate reference system. /// - public class MultiPolygon : GeometryCollection, IMultiPolygon + public MultiPolygon() + : base() { + } - /// - /// Initializes a new instance of the MultiPolygon class that is empty and has assigned WSG84 coordinate reference system. - /// - public MultiPolygon() - : base() - { - } - - /// - /// Initializes a new instance of the MultiPolygon class with specified Polygons - /// - /// The collection of Polygons to be copied to the new MultiPolygon. - public MultiPolygon(IEnumerable polygons) - : base(polygons) - { - } + /// + /// Initializes a new instance of the MultiPolygon class with specified Polygons + /// + /// The collection of Polygons to be copied to the new MultiPolygon. + public MultiPolygon(IEnumerable polygons) + : base(polygons) + { + } - /// - /// Gets collection of polygons from this MultiPolygon as the collection of IPolygon objects. - /// - IEnumerable IGeometryCollection.Geometries - { - get { return base.Geometries; } - } + /// + /// Gets collection of polygons from this MultiPolygon as the collection of IPolygon objects. + /// + IEnumerable IGeometryCollection.Geometries + { + get { return base.Geometries; } } } diff --git a/src/SpatialLite.Core/Geometries/Point.cs b/src/SpatialLite.Core/Geometries/Point.cs index e2bf7b1..4ae87d2 100644 --- a/src/SpatialLite.Core/Geometries/Point.cs +++ b/src/SpatialLite.Core/Geometries/Point.cs @@ -2,118 +2,117 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents a location in the coordinate space. +/// +public class Point : Geometry, IPoint { + + private Coordinate _position = Coordinate.Empty; + /// - /// Represents a location in the coordinate space. + /// Initializes a new instance of the Point class that is empty and has assigned the WSG84 coordinate reference system. /// - public class Point : Geometry, IPoint + public Point() + : base() { + } - private Coordinate _position = Coordinate.Empty; - - /// - /// Initializes a new instance of the Point class that is empty and has assigned the WSG84 coordinate reference system. - /// - public Point() - : base() - { - } + /// + /// Initializes a new instance of the Point class with specified X and Y coordinates in WSG84 coordinate reference system. + /// + /// The X-coordinate of the Point + /// The Y-coordinate of the Point + public Point(double x, double y) + : base() + { + _position = new Coordinate(x, y); + } - /// - /// Initializes a new instance of the Point class with specified X and Y coordinates in WSG84 coordinate reference system. - /// - /// The X-coordinate of the Point - /// The Y-coordinate of the Point - public Point(double x, double y) - : base() - { - _position = new Coordinate(x, y); - } + /// + /// Initializes a new instance of the Point class with specified X, Y and Z coordinates in WSG84 coordinate reference system. + /// + /// The X-coordinate of the Point + /// The Y-coordinate of the Point + /// The Z-coordinate of the Point + public Point(double x, double y, double z) + : base() + { + _position = new Coordinate(x, y, z); + } - /// - /// Initializes a new instance of the Point class with specified X, Y and Z coordinates in WSG84 coordinate reference system. - /// - /// The X-coordinate of the Point - /// The Y-coordinate of the Point - /// The Z-coordinate of the Point - public Point(double x, double y, double z) - : base() - { - _position = new Coordinate(x, y, z); - } + /// + /// Initializes a new instance of the Point class with specified X, Y, Z coordinates and M value in WSG84 coordinate reference system. + /// + /// The X-coordinate of the Point + /// The Y-coordinate of the Point + /// The Z-coordinate of the Point + /// The measured value of the Point + public Point(double x, double y, double z, double m) + : base() + { + _position = new Coordinate(x, y, z, m); + } - /// - /// Initializes a new instance of the Point class with specified X, Y, Z coordinates and M value in WSG84 coordinate reference system. - /// - /// The X-coordinate of the Point - /// The Y-coordinate of the Point - /// The Z-coordinate of the Point - /// The measured value of the Point - public Point(double x, double y, double z, double m) - : base() - { - _position = new Coordinate(x, y, z, m); - } + /// + /// Initializes a new instance of the Point class with specific Position in WSG84 coordinate reference system. + /// + /// The position of this Point + public Point(Coordinate position) + : base() + { + _position = position; + } - /// - /// Initializes a new instance of the Point class with specific Position in WSG84 coordinate reference system. - /// - /// The position of this Point - public Point(Coordinate position) - : base() + /// + /// Gets or sets position of this Point + /// + public Coordinate Position + { + get { - _position = position; + return _position; } - /// - /// Gets or sets position of this Point - /// - public Coordinate Position + set { - get - { - return _position; - } - - set - { - _position = value; - } + _position = value; } + } - /// - /// Gets a value indicating whether the this Point has Z-coordinate set. - /// - public override bool Is3D - { - get { return _position.Is3D; } - } + /// + /// Gets a value indicating whether the this Point has Z-coordinate set. + /// + public override bool Is3D + { + get { return _position.Is3D; } + } - /// - /// Gets a value indicating whether the this Point has M value set. - /// - public override bool IsMeasured - { - get { return _position.IsMeasured; } - } + /// + /// Gets a value indicating whether the this Point has M value set. + /// + public override bool IsMeasured + { + get { return _position.IsMeasured; } + } - /// - /// Returns Envelope, that covers this Point. - /// - /// Envelope, that covers this Point. - public override Envelope GetEnvelope() - { - return new Envelope(this.Position); - } + /// + /// Returns Envelope, that covers this Point. + /// + /// Envelope, that covers this Point. + public override Envelope GetEnvelope() + { + return new Envelope(this.Position); + } - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - public override IEnumerable GetCoordinates() - { - yield return this.Position; - } + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + public override IEnumerable GetCoordinates() + { + yield return this.Position; } } diff --git a/src/SpatialLite.Core/Geometries/Polygon.cs b/src/SpatialLite.Core/Geometries/Polygon.cs index 5849fc6..f31fddd 100644 --- a/src/SpatialLite.Core/Geometries/Polygon.cs +++ b/src/SpatialLite.Core/Geometries/Polygon.cs @@ -3,95 +3,94 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Represents a polygon, which may include holes. +/// +public class Polygon : Geometry, IPolygon { /// - /// Represents a polygon, which may include holes. + /// Initializes a new instance of the Polygon class in WSG84 coordinate reference system that without ExteriorRing and no InteriorRings. /// - public class Polygon : Geometry, IPolygon + public Polygon() + : base() { - /// - /// Initializes a new instance of the Polygon class in WSG84 coordinate reference system that without ExteriorRing and no InteriorRings. - /// - public Polygon() - : base() - { - this.ExteriorRing = new CoordinateList(); - this.InteriorRings = new List(0); - } + this.ExteriorRing = new CoordinateList(); + this.InteriorRings = new List(0); + } - /// - /// Initializes a new instance of the Polygon class with the given exterior boundary in WSG84 coordinate reference system. - /// - /// The exterior boundary of the polygon. - public Polygon(ICoordinateList exteriorRing) - { - this.ExteriorRing = exteriorRing; - this.InteriorRings = new List(0); - } + /// + /// Initializes a new instance of the Polygon class with the given exterior boundary in WSG84 coordinate reference system. + /// + /// The exterior boundary of the polygon. + public Polygon(ICoordinateList exteriorRing) + { + this.ExteriorRing = exteriorRing; + this.InteriorRings = new List(0); + } - /// - /// Gets or sets the exterior boundary of the polygon. - /// - public ICoordinateList ExteriorRing { get; set; } + /// + /// Gets or sets the exterior boundary of the polygon. + /// + public ICoordinateList ExteriorRing { get; set; } - /// - /// Gets the exterior boundary of the polygon. - /// - ICoordinateList IPolygon.ExteriorRing - { - get { return this.ExteriorRing; } - } + /// + /// Gets the exterior boundary of the polygon. + /// + ICoordinateList IPolygon.ExteriorRing + { + get { return this.ExteriorRing; } + } - /// - /// Gets the list of holes in the polygon. - /// - public List InteriorRings { get; private set; } + /// + /// Gets the list of holes in the polygon. + /// + public List InteriorRings { get; private set; } - /// - /// Gets the list of holes in the polygon. - /// - IEnumerable IPolygon.InteriorRings - { - get { return this.InteriorRings; } - } + /// + /// Gets the list of holes in the polygon. + /// + IEnumerable IPolygon.InteriorRings + { + get { return this.InteriorRings; } + } - /// - /// Gets a value indicating whether the this has Z-coordinate set. - /// - public override bool Is3D - { - //TODO consider using InteriorRings as well - get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.Is3D); } - } + /// + /// Gets a value indicating whether the this has Z-coordinate set. + /// + public override bool Is3D + { + //TODO consider using InteriorRings as well + get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.Is3D); } + } - /// - /// Gets a value indicating whether this has M values. - /// - public override bool IsMeasured - { - //TODO consider using InteriorRings as well - get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.IsMeasured); } - } + /// + /// Gets a value indicating whether this has M values. + /// + public override bool IsMeasured + { + //TODO consider using InteriorRings as well + get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.IsMeasured); } + } - /// - /// Computes envelope of the Polygon object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the Polygon object. - /// - public override Envelope GetEnvelope() - { - return this.ExteriorRing.Count == 0 ? new Envelope() : new Envelope(this.ExteriorRing); - } + /// + /// Computes envelope of the Polygon object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the Polygon object. + /// + public override Envelope GetEnvelope() + { + return this.ExteriorRing.Count == 0 ? new Envelope() : new Envelope(this.ExteriorRing); + } - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - public override IEnumerable GetCoordinates() - { - return this.ExteriorRing.Concat(this.InteriorRings.SelectMany(o => o)); - } + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + public override IEnumerable GetCoordinates() + { + return this.ExteriorRing.Concat(this.InteriorRings.SelectMany(o => o)); } } diff --git a/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs b/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs index 61dd35b..2bb6a69 100644 --- a/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs +++ b/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs @@ -3,120 +3,119 @@ using System.Collections.Generic; using SpatialLite.Core.API; -namespace SpatialLite.Core.Geometries +namespace SpatialLite.Core.Geometries; + +/// +/// Provides read-only ICoordinateList wrapper around collection of points +/// +public class ReadOnlyCoordinateList : ICoordinateList where T : IPoint { /// - /// Provides read-only ICoordinateList wrapper around collection of points + /// Initializes a new instance of the ReadOnlyCoordinateList class with specified source list fo nodes /// - public class ReadOnlyCoordinateList : ICoordinateList where T : IPoint + /// The list of Points to be used as source for this ReadOnlyCoordinateList + public ReadOnlyCoordinateList(IReadOnlyList source) { - /// - /// Initializes a new instance of the ReadOnlyCoordinateList class with specified source list fo nodes - /// - /// The list of Points to be used as source for this ReadOnlyCoordinateList - public ReadOnlyCoordinateList(IReadOnlyList source) - { - this.Source = source; - } + this.Source = source; + } - /// - /// Gets number of Coordinates in the list. - /// - public int Count + /// + /// Gets number of Coordinates in the list. + /// + public int Count + { + get { - get - { - return this.Source.Count; - } + return this.Source.Count; } + } - /// - /// Gets the List of Points used as source for this ReadOnlyCoordinateList. - /// - public IReadOnlyList Source { get; private set; } + /// + /// Gets the List of Points used as source for this ReadOnlyCoordinateList. + /// + public IReadOnlyList Source { get; private set; } - /// - /// Gets or sets Coordinate at the given index. - /// - /// The zero-based index of the Coordinate to get or set. - /// The element at the specified index. - public Coordinate this[int index] + /// + /// Gets or sets Coordinate at the given index. + /// + /// The zero-based index of the Coordinate to get or set. + /// The element at the specified index. + public Coordinate this[int index] + { + get { - get - { - return this.Source[index].Position; - } - set - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + return this.Source[index].Position; } - - /// - /// Adds Coordinate to the end of the list. - /// - /// The Coordinate to add to the list. - public void Add(Coordinate coord) + set { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } + } - /// - /// Adds collection of coordinates to the end of the list. - /// - /// The collection of coordinates to add to the list. - public void Add(IEnumerable coords) - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Adds Coordinate to the end of the list. + /// + /// The Coordinate to add to the list. + public void Add(Coordinate coord) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Insertes Coordinate to the list at the specified index. - /// - /// The zero-based index at which coord should be inserted. - /// The Coordinate to insert into list. - /// If index equals the number of items in the list, then item is appended to the list. - public void Insert(int index, Coordinate coord) - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Adds collection of coordinates to the end of the list. + /// + /// The collection of coordinates to add to the list. + public void Add(IEnumerable coords) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Removes Coordinate at the specified index from the list. - /// - /// The zero-based index of the Coordinate to remove. - public void RemoveAt(int index) - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Insertes Coordinate to the list at the specified index. + /// + /// The zero-based index at which coord should be inserted. + /// The Coordinate to insert into list. + /// If index equals the number of items in the list, then item is appended to the list. + public void Insert(int index, Coordinate coord) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Removes all Coordinates from the collection. - /// - public void Clear() - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Removes Coordinate at the specified index from the list. + /// + /// The zero-based index of the Coordinate to remove. + public void RemoveAt(int index) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - public IEnumerator GetEnumerator() - { - foreach (var node in this.Source) - { - yield return node.Position; - } - } + /// + /// Removes all Coordinates from the collection. + /// + public void Clear() + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - IEnumerator IEnumerable.GetEnumerator() + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + public IEnumerator GetEnumerator() + { + foreach (var node in this.Source) { - return this.GetEnumerator(); + yield return node.Position; } } + + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } } diff --git a/src/SpatialLite.Core/IO/BinaryEncoding.cs b/src/SpatialLite.Core/IO/BinaryEncoding.cs index ddcbc1c..97fd1fe 100644 --- a/src/SpatialLite.Core/IO/BinaryEncoding.cs +++ b/src/SpatialLite.Core/IO/BinaryEncoding.cs @@ -1,17 +1,16 @@ -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Specifies byte ordering in multibyte values. +/// +public enum BinaryEncoding : byte { /// - /// Specifies byte ordering in multibyte values. + /// Most significant byte first. /// - public enum BinaryEncoding : byte - { - /// - /// Most significant byte first. - /// - BigEndian = 0, - /// - /// Least significant byte first. - /// - LittleEndian = 1 - } + BigEndian = 0, + /// + /// Least significant byte first. + /// + LittleEndian = 1 } diff --git a/src/SpatialLite.Core/IO/TokenType.cs b/src/SpatialLite.Core/IO/TokenType.cs index 655b2d5..8411133 100644 --- a/src/SpatialLite.Core/IO/TokenType.cs +++ b/src/SpatialLite.Core/IO/TokenType.cs @@ -1,43 +1,42 @@ -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Represents type of the WKT token. +/// +internal enum TokenType { /// - /// Represents type of the WKT token. + /// String token - it consists of a-zA-Z characters /// - internal enum TokenType - { - /// - /// String token - it consists of a-zA-Z characters - /// - STRING, + STRING, - /// - /// WHITESPACE token (' ', '\t', '\r', '\n'). - /// - WHITESPACE, + /// + /// WHITESPACE token (' ', '\t', '\r', '\n'). + /// + WHITESPACE, - /// - /// '(' token - /// - LEFT_PARENTHESIS, + /// + /// '(' token + /// + LEFT_PARENTHESIS, - /// - /// ')' token - /// - RIGHT_PARENTHESIS, + /// + /// ')' token + /// + RIGHT_PARENTHESIS, - /// - /// ',' token - /// - COMMA, + /// + /// ',' token + /// + COMMA, - /// - /// Number token - it consists of '-','0'-'9' and '.' characters - /// - NUMBER, + /// + /// Number token - it consists of '-','0'-'9' and '.' characters + /// + NUMBER, - /// - /// Token that represents end of available data - /// - END_OF_DATA - } + /// + /// Token that represents end of available data + /// + END_OF_DATA } diff --git a/src/SpatialLite.Core/IO/WkbFormatException.cs b/src/SpatialLite.Core/IO/WkbFormatException.cs index e460505..b672e0b 100644 --- a/src/SpatialLite.Core/IO/WkbFormatException.cs +++ b/src/SpatialLite.Core/IO/WkbFormatException.cs @@ -1,19 +1,18 @@ using System; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Represents exception that occurs if WkbReader encouters invalid data. +/// +public class WkbFormatException : Exception { /// - /// Represents exception that occurs if WkbReader encouters invalid data. + /// Initializes a new instance of the WktParseException class. /// - public class WkbFormatException : Exception + /// The message that describes the error. + public WkbFormatException(string message) + : base(message) { - /// - /// Initializes a new instance of the WktParseException class. - /// - /// The message that describes the error. - public WkbFormatException(string message) - : base(message) - { - } } } diff --git a/src/SpatialLite.Core/IO/WkbGeometryType.cs b/src/SpatialLite.Core/IO/WkbGeometryType.cs index 14dd964..7c97cb6 100644 --- a/src/SpatialLite.Core/IO/WkbGeometryType.cs +++ b/src/SpatialLite.Core/IO/WkbGeometryType.cs @@ -1,52 +1,51 @@ -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Defines WkbGeometryType. +/// +internal enum WkbGeometryType : uint { - /// - /// Defines WkbGeometryType. - /// - internal enum WkbGeometryType : uint - { - Point = 1, - LineString = 2, - Polygon = 3, - Triangle = 17, - MultiPoint = 4, - MultiLineString = 5, - MultiPolygon = 6, - GeometryCollection = 7, - PolyhedralSurface = 15, - TIN = 16, + Point = 1, + LineString = 2, + Polygon = 3, + Triangle = 17, + MultiPoint = 4, + MultiLineString = 5, + MultiPolygon = 6, + GeometryCollection = 7, + PolyhedralSurface = 15, + TIN = 16, - PointZ = 1001, - LineStringZ = 1002, - PolygonZ = 1003, - Trianglez = 1017, - MultiPointZ = 1004, - MultiLineStringZ = 1005, - MultiPolygonZ = 1006, - GeometryCollectionZ = 1007, - PolyhedralSurfaceZ = 1015, - TINZ = 1016, + PointZ = 1001, + LineStringZ = 1002, + PolygonZ = 1003, + Trianglez = 1017, + MultiPointZ = 1004, + MultiLineStringZ = 1005, + MultiPolygonZ = 1006, + GeometryCollectionZ = 1007, + PolyhedralSurfaceZ = 1015, + TINZ = 1016, - PointM = 2001, - LineStringM = 2002, - PolygonM = 2003, - TriangleM = 2017, - MultiPointM = 2004, - MultiLineStringM = 2005, - MultiPolygonM = 2006, - GeometryCollectionM = 2007, - PolyhedralSurfaceM = 2015, - TINM = 2016, + PointM = 2001, + LineStringM = 2002, + PolygonM = 2003, + TriangleM = 2017, + MultiPointM = 2004, + MultiLineStringM = 2005, + MultiPolygonM = 2006, + GeometryCollectionM = 2007, + PolyhedralSurfaceM = 2015, + TINM = 2016, - PointZM = 3001, - LineStringZM = 3002, - PolygonZM = 3003, - TriangleZM = 3017, - MultiPointZM = 3004, - MultiLineStringZM = 3005, - MultiPolygonZM = 3006, - GeometryCollectionZM = 3007, - PolyhedralSurfaceZM = 3015, - TinZM = 3016 - } + PointZM = 3001, + LineStringZM = 3002, + PolygonZM = 3003, + TriangleZM = 3017, + MultiPointZM = 3004, + MultiLineStringZM = 3005, + MultiPolygonZM = 3006, + GeometryCollectionZM = 3007, + PolyhedralSurfaceZM = 3015, + TinZM = 3016 } diff --git a/src/SpatialLite.Core/IO/WkbReader.cs b/src/SpatialLite.Core/IO/WkbReader.cs index 0b6ce51..d6e7a6d 100644 --- a/src/SpatialLite.Core/IO/WkbReader.cs +++ b/src/SpatialLite.Core/IO/WkbReader.cs @@ -5,405 +5,404 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Provides functions for reading and parsing geometries from WKB format. +/// +public class WkbReader : IDisposable { + + private BinaryReader _inputReader; + private FileStream _inputFileStream; + private bool _disposed = false; + /// - /// Provides functions for reading and parsing geometries from WKB format. + /// Initializes a new instance of the WkbReader class that reads data from specific stream. /// - public class WkbReader : IDisposable + /// The stream to read data from. + public WkbReader(Stream input) { - - private BinaryReader _inputReader; - private FileStream _inputFileStream; - private bool _disposed = false; - - /// - /// Initializes a new instance of the WkbReader class that reads data from specific stream. - /// - /// The stream to read data from. - public WkbReader(Stream input) + if (input == null) { - if (input == null) - { - throw new ArgumentNullException(nameof(input), "Input stream cannot be null"); - } - - _inputReader = new BinaryReader(input); + throw new ArgumentNullException(nameof(input), "Input stream cannot be null"); } - /// - /// Initializes a new instance of the WkbReader class that reads data from specific file. - /// - /// Path to the file to read data from. - public WkbReader(string path) + _inputReader = new BinaryReader(input); + } + + /// + /// Initializes a new instance of the WkbReader class that reads data from specific file. + /// + /// Path to the file to read data from. + public WkbReader(string path) + { + _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _inputReader = new BinaryReader(_inputFileStream); + } + + /// + /// Parses data from the binnary array. + /// + /// The binary array with WKB serialized geometry. + /// Parsed geometry. + /// Throws exception if wkb array does not contrains valid WKB geometry. + public static Geometry Parse(byte[] wkb) + { + if (wkb == null) { - _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); - _inputReader = new BinaryReader(_inputFileStream); + throw new ArgumentNullException(nameof(wkb)); } - /// - /// Parses data from the binnary array. - /// - /// The binary array with WKB serialized geometry. - /// Parsed geometry. - /// Throws exception if wkb array does not contrains valid WKB geometry. - public static Geometry Parse(byte[] wkb) + using (MemoryStream ms = new MemoryStream(wkb)) { - if (wkb == null) + using (BinaryReader reader = new BinaryReader(ms)) { - throw new ArgumentNullException(nameof(wkb)); - } + if (reader.PeekChar() == -1) + { + return null; + } - using (MemoryStream ms = new MemoryStream(wkb)) - { - using (BinaryReader reader = new BinaryReader(ms)) + try { - if (reader.PeekChar() == -1) + BinaryEncoding encoding = (BinaryEncoding)reader.ReadByte(); + if (encoding == BinaryEncoding.BigEndian) { - return null; + throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); } - try - { - BinaryEncoding encoding = (BinaryEncoding)reader.ReadByte(); - if (encoding == BinaryEncoding.BigEndian) - { - throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); - } - - Geometry parsed = WkbReader.ReadGeometry(reader); + Geometry parsed = WkbReader.ReadGeometry(reader); - return parsed; - } - catch (EndOfStreamException) - { - throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); - } + return parsed; } - } - } - - /// - /// Parses data from the binary array as given geometry type. - /// - /// The Geometry type to be parsed. - /// The binary array with WKB serialized geometry. - /// Parsed geometry. - /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. - public static T Parse(byte[] wkb) where T : Geometry - { - Geometry parsed = WkbReader.Parse(wkb); - - if (parsed != null) - { - T result = parsed as T; - if (result == null) + catch (EndOfStreamException) { - throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); + throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); } - - return result; - } - else - { - return null; } } + } - /// - /// Releases all resources used by the ComponentLibrary. - /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + /// + /// Parses data from the binary array as given geometry type. + /// + /// The Geometry type to be parsed. + /// The binary array with WKB serialized geometry. + /// Parsed geometry. + /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. + public static T Parse(byte[] wkb) where T : Geometry + { + Geometry parsed = WkbReader.Parse(wkb); - /// - /// Read geometry in WKB format from the input. - /// - /// Parsed geometry or null if no other geometry is available. - public Geometry Read() + if (parsed != null) { - if (_inputReader.PeekChar() == -1) + T result = parsed as T; + if (result == null) { - return null; + throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); } - try - { - BinaryEncoding encoding = (BinaryEncoding)_inputReader.ReadByte(); - if (encoding == BinaryEncoding.BigEndian) - { - throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); - } - - return WkbReader.ReadGeometry(_inputReader); - } - catch (EndOfStreamException) - { - throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); - } + return result; } - - /// - /// Read geometry in WKB format from the input. - /// - /// The Geometry type to be parsed. - /// Geometry obejct of specific type read from the input, or null if no other geometry is available. - /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. - public T Read() where T : Geometry + else { - Geometry parsed = this.Read(); - - if (parsed != null) - { - T result = parsed as T; - if (result == null) - { - throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); - } - - return result; - } - else - { - return null; - } + return null; } + } - /// - /// Reads Coordinate from the BinaryReader. - /// - /// The reader to read from. - /// Bool value indicating whether Coordinate has Z value. - /// Bool value indicating whether Coordinate has M value. - /// Parsed Coordinate. - private static Coordinate ReadCoordinate(BinaryReader reader, bool is3D, bool isMeasured) - { - double x = reader.ReadDouble(); - double y = reader.ReadDouble(); - double z = is3D ? reader.ReadDouble() : double.NaN; - double m = isMeasured ? reader.ReadDouble() : double.NaN; + /// + /// Releases all resources used by the ComponentLibrary. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - return new Coordinate(x, y, z, m); + /// + /// Read geometry in WKB format from the input. + /// + /// Parsed geometry or null if no other geometry is available. + public Geometry Read() + { + if (_inputReader.PeekChar() == -1) + { + return null; } - /// - /// Reads a list of coordinates from the BinaryReader. - /// - /// The reader to read from. - /// Bool value indicating whether coordinates has Z value. - /// Bool value indicating whether coordinates has M value. - /// Parsed Coordinate. - private static IEnumerable ReadCoordinates(BinaryReader reader, bool is3D, bool isMeasured) + try { - int pointCount = (int)reader.ReadUInt32(); - - List result = new List(pointCount); - for (int i = 0; i < pointCount; i++) + BinaryEncoding encoding = (BinaryEncoding)_inputReader.ReadByte(); + if (encoding == BinaryEncoding.BigEndian) { - result.Add(WkbReader.ReadCoordinate(reader, is3D, isMeasured)); + throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); } - return result; + return WkbReader.ReadGeometry(_inputReader); } - - /// - /// Reads Geometry from the reader. - /// - /// The reader used to read data from input stream. - /// Geometry read from the input. - private static Geometry ReadGeometry(BinaryReader reader) + catch (EndOfStreamException) { - WkbGeometryType geometryType = (WkbGeometryType)reader.ReadUInt32(); + throw new WkbFormatException("End of stream reached before end of valid WKB geometry end."); + } + } - bool is3D, isMeasured; - WkbGeometryType basicType; - WkbReader.GetGeometryTypeDetails(geometryType, out basicType, out is3D, out isMeasured); + /// + /// Read geometry in WKB format from the input. + /// + /// The Geometry type to be parsed. + /// Geometry obejct of specific type read from the input, or null if no other geometry is available. + /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. + public T Read() where T : Geometry + { + Geometry parsed = this.Read(); - switch (basicType) + if (parsed != null) + { + T result = parsed as T; + if (result == null) { - case WkbGeometryType.Point: return WkbReader.ReadPoint(reader, is3D, isMeasured); - case WkbGeometryType.LineString: return WkbReader.ReadLineString(reader, is3D, isMeasured); - case WkbGeometryType.Polygon: return WkbReader.ReadPolygon(reader, is3D, isMeasured); - case WkbGeometryType.MultiPoint: return WkbReader.ReadMultiPoint(reader, is3D, isMeasured); - case WkbGeometryType.MultiLineString: return WkbReader.ReadMultiLineString(reader, is3D, isMeasured); - case WkbGeometryType.MultiPolygon: return WkbReader.ReadMultiPolygon(reader, is3D, isMeasured); - case WkbGeometryType.GeometryCollection: return WkbReader.ReadGeometryCollection(reader, is3D, isMeasured); - default: throw new WkbFormatException("Unknown geometry type."); + throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); } - } - /// - /// Reads Point from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether point beeing read has Z-dimension. - /// bool value indicating whether point beeing read has M-value. - /// Point read from the input - private static Point ReadPoint(BinaryReader reader, bool is3D, bool isMeasured) + return result; + } + else { - Coordinate position = WkbReader.ReadCoordinate(reader, is3D, isMeasured); - return new Point(position); + return null; } + } - /// - /// Reads LineString from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether linestring beeing read has Z-dimension. - /// bool value indicating whether linestring beeing read has M-value. - /// Linestring read from the input. - private static LineString ReadLineString(BinaryReader reader, bool is3D, bool isMeasured) + /// + /// Reads Coordinate from the BinaryReader. + /// + /// The reader to read from. + /// Bool value indicating whether Coordinate has Z value. + /// Bool value indicating whether Coordinate has M value. + /// Parsed Coordinate. + private static Coordinate ReadCoordinate(BinaryReader reader, bool is3D, bool isMeasured) + { + double x = reader.ReadDouble(); + double y = reader.ReadDouble(); + double z = is3D ? reader.ReadDouble() : double.NaN; + double m = isMeasured ? reader.ReadDouble() : double.NaN; + + return new Coordinate(x, y, z, m); + } + + /// + /// Reads a list of coordinates from the BinaryReader. + /// + /// The reader to read from. + /// Bool value indicating whether coordinates has Z value. + /// Bool value indicating whether coordinates has M value. + /// Parsed Coordinate. + private static IEnumerable ReadCoordinates(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointCount = (int)reader.ReadUInt32(); + + List result = new List(pointCount); + for (int i = 0; i < pointCount; i++) { - IEnumerable coordinates = WkbReader.ReadCoordinates(reader, is3D, isMeasured); - return new LineString(coordinates); + result.Add(WkbReader.ReadCoordinate(reader, is3D, isMeasured)); } - /// - /// Reads Polygon from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether polygon beeing read has Z-dimension. - /// bool value indicating whether polygon beeing read has M-value. - /// Polygon read from the input. - private static Polygon ReadPolygon(BinaryReader reader, bool is3D, bool isMeasured) + return result; + } + + /// + /// Reads Geometry from the reader. + /// + /// The reader used to read data from input stream. + /// Geometry read from the input. + private static Geometry ReadGeometry(BinaryReader reader) + { + WkbGeometryType geometryType = (WkbGeometryType)reader.ReadUInt32(); + + bool is3D, isMeasured; + WkbGeometryType basicType; + WkbReader.GetGeometryTypeDetails(geometryType, out basicType, out is3D, out isMeasured); + + switch (basicType) { - int ringsCount = (int)reader.ReadUInt32(); + case WkbGeometryType.Point: return WkbReader.ReadPoint(reader, is3D, isMeasured); + case WkbGeometryType.LineString: return WkbReader.ReadLineString(reader, is3D, isMeasured); + case WkbGeometryType.Polygon: return WkbReader.ReadPolygon(reader, is3D, isMeasured); + case WkbGeometryType.MultiPoint: return WkbReader.ReadMultiPoint(reader, is3D, isMeasured); + case WkbGeometryType.MultiLineString: return WkbReader.ReadMultiLineString(reader, is3D, isMeasured); + case WkbGeometryType.MultiPolygon: return WkbReader.ReadMultiPolygon(reader, is3D, isMeasured); + case WkbGeometryType.GeometryCollection: return WkbReader.ReadGeometryCollection(reader, is3D, isMeasured); + default: throw new WkbFormatException("Unknown geometry type."); + } + } - if (ringsCount == 0) - { - return new Polygon(); - } + /// + /// Reads Point from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether point beeing read has Z-dimension. + /// bool value indicating whether point beeing read has M-value. + /// Point read from the input + private static Point ReadPoint(BinaryReader reader, bool is3D, bool isMeasured) + { + Coordinate position = WkbReader.ReadCoordinate(reader, is3D, isMeasured); + return new Point(position); + } - IEnumerable exterior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); - Polygon result = new Polygon(new CoordinateList(exterior)); + /// + /// Reads LineString from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether linestring beeing read has Z-dimension. + /// bool value indicating whether linestring beeing read has M-value. + /// Linestring read from the input. + private static LineString ReadLineString(BinaryReader reader, bool is3D, bool isMeasured) + { + IEnumerable coordinates = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + return new LineString(coordinates); + } - for (int i = 1; i < ringsCount; i++) - { - IEnumerable interior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); - result.InteriorRings.Add(new CoordinateList(interior)); - } + /// + /// Reads Polygon from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether polygon beeing read has Z-dimension. + /// bool value indicating whether polygon beeing read has M-value. + /// Polygon read from the input. + private static Polygon ReadPolygon(BinaryReader reader, bool is3D, bool isMeasured) + { + int ringsCount = (int)reader.ReadUInt32(); - return result; + if (ringsCount == 0) + { + return new Polygon(); } - /// - /// Reads MultiLineString from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether multilinestring beeing read has Z-dimension. - /// bool value indicating whether multilinestring beeing read has M-value. - /// MultiLineString read from the input. - private static MultiPoint ReadMultiPoint(BinaryReader reader, bool is3D, bool isMeasured) + IEnumerable exterior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + Polygon result = new Polygon(new CoordinateList(exterior)); + + for (int i = 1; i < ringsCount; i++) { - int pointsCount = (int)reader.ReadUInt32(); + IEnumerable interior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + result.InteriorRings.Add(new CoordinateList(interior)); + } - MultiPoint result = new MultiPoint(); - for (int i = 0; i < pointsCount; i++) - { - result.Geometries.Add(WkbReader.ReadPoint(reader, is3D, isMeasured)); - } + return result; + } - return result; - } + /// + /// Reads MultiLineString from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether multilinestring beeing read has Z-dimension. + /// bool value indicating whether multilinestring beeing read has M-value. + /// MultiLineString read from the input. + private static MultiPoint ReadMultiPoint(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); - /// - /// Reads MultiLineString from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether multilinestring beeing read has Z-dimension. - /// bool value indicating whether multilinestring beeing read has M-value. - /// MultiLineString read from the input - private static MultiLineString ReadMultiLineString(BinaryReader reader, bool is3D, bool isMeasured) + MultiPoint result = new MultiPoint(); + for (int i = 0; i < pointsCount; i++) { - int pointsCount = (int)reader.ReadUInt32(); + result.Geometries.Add(WkbReader.ReadPoint(reader, is3D, isMeasured)); + } - MultiLineString result = new MultiLineString(); - for (int i = 0; i < pointsCount; i++) - { - result.Geometries.Add(WkbReader.ReadLineString(reader, is3D, isMeasured)); - } + return result; + } - return result; - } + /// + /// Reads MultiLineString from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether multilinestring beeing read has Z-dimension. + /// bool value indicating whether multilinestring beeing read has M-value. + /// MultiLineString read from the input + private static MultiLineString ReadMultiLineString(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); - /// - /// Reads MultiPolygon from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether MultiPolygon beeing read has Z-dimension. - /// bool value indicating whether MultiPolygon beeing read has M-value. - /// MultiPolygon read from the input. - private static MultiPolygon ReadMultiPolygon(BinaryReader reader, bool is3D, bool isMeasured) + MultiLineString result = new MultiLineString(); + for (int i = 0; i < pointsCount; i++) { - int pointsCount = (int)reader.ReadUInt32(); + result.Geometries.Add(WkbReader.ReadLineString(reader, is3D, isMeasured)); + } - MultiPolygon result = new MultiPolygon(); - for (int i = 0; i < pointsCount; i++) - { - result.Geometries.Add(WkbReader.ReadPolygon(reader, is3D, isMeasured)); - } + return result; + } - return result; - } + /// + /// Reads MultiPolygon from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether MultiPolygon beeing read has Z-dimension. + /// bool value indicating whether MultiPolygon beeing read has M-value. + /// MultiPolygon read from the input. + private static MultiPolygon ReadMultiPolygon(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); - /// - /// Reads GeometryCollection from the reader. - /// - /// The reader used to read data from input stream. - /// bool value indicating whether GeometryCollection beeing read has Z-dimension. - /// bool value indicating whether GeometryCollection beeing read has M-value. - /// GeometryCollection read from the input. - private static GeometryCollection ReadGeometryCollection(BinaryReader reader, bool is3D, bool isMeasured) + MultiPolygon result = new MultiPolygon(); + for (int i = 0; i < pointsCount; i++) { - int pointsCount = (int)reader.ReadUInt32(); + result.Geometries.Add(WkbReader.ReadPolygon(reader, is3D, isMeasured)); + } - GeometryCollection result = new GeometryCollection(); - for (int i = 0; i < pointsCount; i++) - { - result.Geometries.Add(WkbReader.ReadGeometry(reader)); - } + return result; + } - return result; - } + /// + /// Reads GeometryCollection from the reader. + /// + /// The reader used to read data from input stream. + /// bool value indicating whether GeometryCollection beeing read has Z-dimension. + /// bool value indicating whether GeometryCollection beeing read has M-value. + /// GeometryCollection read from the input. + private static GeometryCollection ReadGeometryCollection(BinaryReader reader, bool is3D, bool isMeasured) + { + int pointsCount = (int)reader.ReadUInt32(); - /// - /// Gets details form the WkbGeometryType value. - /// - /// The value to be examined. - /// Outputs type striped of dimension information. - /// Outputs bool value indicating whether type represents 3D geometry. - /// Outputs bool value indicating whether type represents measured geometry. - private static void GetGeometryTypeDetails(WkbGeometryType type, out WkbGeometryType basicType, out bool is3D, out bool isMeasured) + GeometryCollection result = new GeometryCollection(); + for (int i = 0; i < pointsCount; i++) { - is3D = ((int)type > 1000 && (int)type < 2000) || (int)type > 3000; - isMeasured = (int)type > 2000; - basicType = (WkbGeometryType)((int)type % 1000); + result.Geometries.Add(WkbReader.ReadGeometry(reader)); } - /// - /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + return result; + } + + /// + /// Gets details form the WkbGeometryType value. + /// + /// The value to be examined. + /// Outputs type striped of dimension information. + /// Outputs bool value indicating whether type represents 3D geometry. + /// Outputs bool value indicating whether type represents measured geometry. + private static void GetGeometryTypeDetails(WkbGeometryType type, out WkbGeometryType basicType, out bool is3D, out bool isMeasured) + { + is3D = ((int)type > 1000 && (int)type < 2000) || (int)type > 3000; + isMeasured = (int)type > 2000; + basicType = (WkbGeometryType)((int)type % 1000); + } + + /// + /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) { - if (!this._disposed) + if (disposing) { - if (disposing) - { - _inputReader.Dispose(); + _inputReader.Dispose(); - if (_inputFileStream != null) - { - _inputFileStream.Dispose(); - } + if (_inputFileStream != null) + { + _inputFileStream.Dispose(); } - - _disposed = true; } - } + _disposed = true; + } } + } diff --git a/src/SpatialLite.Core/IO/WkbWriter.cs b/src/SpatialLite.Core/IO/WkbWriter.cs index 982902d..48b7fd7 100644 --- a/src/SpatialLite.Core/IO/WkbWriter.cs +++ b/src/SpatialLite.Core/IO/WkbWriter.cs @@ -4,366 +4,365 @@ using SpatialLite.Core.API; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Provides function for writing geometry objects into WKB format. +/// +public class WkbWriter : IDisposable { + + private bool _disposed = false; + private BinaryWriter _writer = null; + private Stream _output = null; + /// - /// Provides function for writing geometry objects into WKB format. + /// Initializes a new instance of the WkbWriter class with specific settings. /// - public class WkbWriter : IDisposable + /// The settings defining behaviour of the writer. + protected WkbWriter(WkbWriterSettings settings) { + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } - private bool _disposed = false; - private BinaryWriter _writer = null; - private Stream _output = null; - - /// - /// Initializes a new instance of the WkbWriter class with specific settings. - /// - /// The settings defining behaviour of the writer. - protected WkbWriter(WkbWriterSettings settings) + if (settings.Encoding == BinaryEncoding.BigEndian) { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } + throw new NotSupportedException("BigEndian encoding is not supported in current version of the WkbWriter."); + } - if (settings.Encoding == BinaryEncoding.BigEndian) - { - throw new NotSupportedException("BigEndian encoding is not supported in current version of the WkbWriter."); - } + this.Settings = settings; + this.Settings.IsReadOnly = true; + } - this.Settings = settings; - this.Settings.IsReadOnly = true; + /// + /// Initializes a new instance of the WkbWriter class that writes geometries to a stream with specific settings. + /// + /// The stream to write geometries to. + /// The settings defining behaviour of the writer. + public WkbWriter(Stream stream, WkbWriterSettings settings) + : this(settings) + { + if (stream == null) + { + throw new ArgumentNullException(nameof(stream)); } - /// - /// Initializes a new instance of the WkbWriter class that writes geometries to a stream with specific settings. - /// - /// The stream to write geometries to. - /// The settings defining behaviour of the writer. - public WkbWriter(Stream stream, WkbWriterSettings settings) - : this(settings) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } + _writer = new BinaryWriter(stream); + } - _writer = new BinaryWriter(stream); + /// + /// Initializes a new instance of the WkbWriter class that writes geometreis to a file with specific settings. + /// + /// The path to the file to write geometrie to. + /// The settings defining behaviour of the writer. + public WkbWriter(string path, WkbWriterSettings settings) + : this(settings) + { + if (path == null) + { + throw new ArgumentNullException(nameof(path)); } - /// - /// Initializes a new instance of the WkbWriter class that writes geometreis to a file with specific settings. - /// - /// The path to the file to write geometrie to. - /// The settings defining behaviour of the writer. - public WkbWriter(string path, WkbWriterSettings settings) - : this(settings) - { - if (path == null) - { - throw new ArgumentNullException(nameof(path)); - } + _output = new FileStream(path, FileMode.Create, FileAccess.Write); + _writer = new BinaryWriter(_output); + } - _output = new FileStream(path, FileMode.Create, FileAccess.Write); - _writer = new BinaryWriter(_output); - } + /// + /// Gets the settings that detedmine behaviour of this instance of the WkbWriter. + /// + public WkbWriterSettings Settings { get; private set; } - /// - /// Gets the settings that detedmine behaviour of this instance of the WkbWriter. - /// - public WkbWriterSettings Settings { get; private set; } - - /// - /// Writes specified Geometry in the WKB format to a binary arrray using default WkbWriterSettings. - /// - /// The geometry to write. - /// The binary array with WKB representation of the Geometry. - public static byte[] WriteToArray(IGeometry geometry) + /// + /// Writes specified Geometry in the WKB format to a binary arrray using default WkbWriterSettings. + /// + /// The geometry to write. + /// The binary array with WKB representation of the Geometry. + public static byte[] WriteToArray(IGeometry geometry) + { + using (MemoryStream dataStream = new MemoryStream()) { - using (MemoryStream dataStream = new MemoryStream()) + using (BinaryWriter writer = new BinaryWriter(dataStream)) { - using (BinaryWriter writer = new BinaryWriter(dataStream)) - { - WkbWriterSettings defaultSettings = new WkbWriterSettings(); + WkbWriterSettings defaultSettings = new WkbWriterSettings(); - WkbWriter.WriteEncoding(writer, defaultSettings.Encoding); - WkbWriter.Write(geometry, writer); + WkbWriter.WriteEncoding(writer, defaultSettings.Encoding); + WkbWriter.Write(geometry, writer); - return dataStream.ToArray(); - } + return dataStream.ToArray(); } } + } + + /// + /// Releases all resources used by the WkbWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Writes specified Geometry in the WKB format to the output. + /// + /// The geometry to write. + public void Write(IGeometry geometry) + { + WkbWriter.WriteEncoding(_writer, this.Settings.Encoding); + WkbWriter.Write(geometry, _writer); + } - /// - /// Releases all resources used by the WkbWriter. - /// - public void Dispose() + /// + /// Writes the Encoding byte defined by property to the output stream. + /// + /// The BinaryWriter to be used. + /// The encoding of binary data. + private static void WriteEncoding(BinaryWriter writer, BinaryEncoding encoding) + { + writer.Write((byte)encoding); + } + + /// + /// Writes geometry to the output using specified writer. + /// + /// The geometry to write. + /// The BinaryWriter used to write geometry to the output. + private static void Write(IGeometry geometry, BinaryWriter writer) + { + if (geometry is IPoint) { - Dispose(true); - GC.SuppressFinalize(this); + WkbWriter.WritePoint((IPoint)geometry, writer); } - - /// - /// Writes specified Geometry in the WKB format to the output. - /// - /// The geometry to write. - public void Write(IGeometry geometry) + else if (geometry is ILineString) { - WkbWriter.WriteEncoding(_writer, this.Settings.Encoding); - WkbWriter.Write(geometry, _writer); + WkbWriter.WriteLineString((ILineString)geometry, writer); } - - /// - /// Writes the Encoding byte defined by property to the output stream. - /// - /// The BinaryWriter to be used. - /// The encoding of binary data. - private static void WriteEncoding(BinaryWriter writer, BinaryEncoding encoding) + else if (geometry is IPolygon) { - writer.Write((byte)encoding); + WkbWriter.WritePolygon((IPolygon)geometry, writer); } - - /// - /// Writes geometry to the output using specified writer. - /// - /// The geometry to write. - /// The BinaryWriter used to write geometry to the output. - private static void Write(IGeometry geometry, BinaryWriter writer) + else if (geometry is IMultiPoint) { - if (geometry is IPoint) - { - WkbWriter.WritePoint((IPoint)geometry, writer); - } - else if (geometry is ILineString) - { - WkbWriter.WriteLineString((ILineString)geometry, writer); - } - else if (geometry is IPolygon) - { - WkbWriter.WritePolygon((IPolygon)geometry, writer); - } - else if (geometry is IMultiPoint) - { - WkbWriter.WriteMultiPoint((IMultiPoint)geometry, writer); - } - else if (geometry is IMultiLineString) - { - WkbWriter.WriteMultiLineString((IMultiLineString)geometry, writer); - } - else if (geometry is IMultiPolygon) - { - WkbWriter.WriteMultiPolygon((IMultiPolygon)geometry, writer); - } - else if (geometry is IGeometryCollection) - { - WkbWriter.WriteGeometryCollection((IGeometryCollection)geometry, writer); - } + WkbWriter.WriteMultiPoint((IMultiPoint)geometry, writer); } - - /// - /// Writes Coordinate to the output using specified writer. - /// - /// The Coordinate to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteCoordinate(Coordinate coordinate, BinaryWriter writer) + else if (geometry is IMultiLineString) + { + WkbWriter.WriteMultiLineString((IMultiLineString)geometry, writer); + } + else if (geometry is IMultiPolygon) + { + WkbWriter.WriteMultiPolygon((IMultiPolygon)geometry, writer); + } + else if (geometry is IGeometryCollection) { - writer.Write(coordinate.X); - writer.Write(coordinate.Y); + WkbWriter.WriteGeometryCollection((IGeometryCollection)geometry, writer); + } + } - if (coordinate.Is3D) - { - writer.Write(coordinate.Z); - } + /// + /// Writes Coordinate to the output using specified writer. + /// + /// The Coordinate to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteCoordinate(Coordinate coordinate, BinaryWriter writer) + { + writer.Write(coordinate.X); + writer.Write(coordinate.Y); - if (coordinate.IsMeasured) - { - writer.Write(coordinate.M); - } + if (coordinate.Is3D) + { + writer.Write(coordinate.Z); } - /// - /// Writes list of Coordinates to the output using specified writer. - /// - /// The list od Coordinates to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteCoordinates(ICoordinateList coordinates, BinaryWriter writer) + if (coordinate.IsMeasured) { - writer.Write((uint)coordinates.Count); - - for (int i = 0; i < coordinates.Count; i++) - { - WkbWriter.WriteCoordinate(coordinates[i], writer); - } + writer.Write(coordinate.M); } + } - /// - /// Writes Point to the output using specified writer. - /// - /// The Point to write. - /// The BinaryWriter used to write geometry to the output. - private static void WritePoint(IPoint point, BinaryWriter writer) + /// + /// Writes list of Coordinates to the output using specified writer. + /// + /// The list od Coordinates to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteCoordinates(ICoordinateList coordinates, BinaryWriter writer) + { + writer.Write((uint)coordinates.Count); + + for (int i = 0; i < coordinates.Count; i++) { - if (point.Position.Equals(Coordinate.Empty)) - { - writer.Write((uint)WkbGeometryType.GeometryCollection); - writer.Write(0u); - } - else - { - writer.Write((uint)WkbWriter.AdjustGeometryType(point, WkbGeometryType.Point)); - WkbWriter.WriteCoordinate(point.Position, writer); - } + WkbWriter.WriteCoordinate(coordinates[i], writer); } + } - /// - /// Writes LineString to the output using specified writer. - /// - /// The LineString to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteLineString(ILineString linestring, BinaryWriter writer) + /// + /// Writes Point to the output using specified writer. + /// + /// The Point to write. + /// The BinaryWriter used to write geometry to the output. + private static void WritePoint(IPoint point, BinaryWriter writer) + { + if (point.Position.Equals(Coordinate.Empty)) { - writer.Write((uint)WkbWriter.AdjustGeometryType(linestring, WkbGeometryType.LineString)); - WkbWriter.WriteCoordinates(linestring.Coordinates, writer); + writer.Write((uint)WkbGeometryType.GeometryCollection); + writer.Write(0u); } - - /// - /// Writes Polygon to the output using specified writer. - /// - /// The Polygon to write. - /// The BinaryWriter used to write geometry to the output. - private static void WritePolygon(IPolygon polygon, BinaryWriter writer) + else { - writer.Write((uint)WkbWriter.AdjustGeometryType(polygon, WkbGeometryType.Polygon)); - WkbWriter.WritePolygonContent(polygon, writer); + writer.Write((uint)WkbWriter.AdjustGeometryType(point, WkbGeometryType.Point)); + WkbWriter.WriteCoordinate(point.Position, writer); } + } - /// - /// Writes content of the Polygon to the output using specified writer. - /// - /// The Polygon to write. - /// The BinaryWriter used to write geometry to the output. - private static void WritePolygonContent(IPolygon polygon, BinaryWriter writer) - { - if (polygon.ExteriorRing.Count == 0) - { - writer.Write(0u); - } - else - { - writer.Write((uint)(1 + polygon.InteriorRings.Count())); - WkbWriter.WriteCoordinates(polygon.ExteriorRing, writer); + /// + /// Writes LineString to the output using specified writer. + /// + /// The LineString to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteLineString(ILineString linestring, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(linestring, WkbGeometryType.LineString)); + WkbWriter.WriteCoordinates(linestring.Coordinates, writer); + } - foreach (var ring in polygon.InteriorRings) - { - WkbWriter.WriteCoordinates(ring, writer); - } - } - } + /// + /// Writes Polygon to the output using specified writer. + /// + /// The Polygon to write. + /// The BinaryWriter used to write geometry to the output. + private static void WritePolygon(IPolygon polygon, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(polygon, WkbGeometryType.Polygon)); + WkbWriter.WritePolygonContent(polygon, writer); + } - /// - /// Writes MultiPoint to the output using specified writer. - /// - /// The MultiPoint to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteMultiPoint(IMultiPoint multipoint, BinaryWriter writer) + /// + /// Writes content of the Polygon to the output using specified writer. + /// + /// The Polygon to write. + /// The BinaryWriter used to write geometry to the output. + private static void WritePolygonContent(IPolygon polygon, BinaryWriter writer) + { + if (polygon.ExteriorRing.Count == 0) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multipoint, WkbGeometryType.MultiPoint)); - writer.Write((uint)multipoint.Geometries.Count()); - foreach (var point in multipoint.Geometries) + writer.Write(0u); + } + else + { + writer.Write((uint)(1 + polygon.InteriorRings.Count())); + WkbWriter.WriteCoordinates(polygon.ExteriorRing, writer); + + foreach (var ring in polygon.InteriorRings) { - WkbWriter.WriteCoordinate(point.Position, writer); + WkbWriter.WriteCoordinates(ring, writer); } } + } - /// - /// Writes MultiLineString to the output using specified writer. - /// - /// The MultiLineString to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteMultiLineString(IMultiLineString multiLineString, BinaryWriter writer) + /// + /// Writes MultiPoint to the output using specified writer. + /// + /// The MultiPoint to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteMultiPoint(IMultiPoint multipoint, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(multipoint, WkbGeometryType.MultiPoint)); + writer.Write((uint)multipoint.Geometries.Count()); + foreach (var point in multipoint.Geometries) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multiLineString, WkbGeometryType.MultiLineString)); - writer.Write((uint)multiLineString.Geometries.Count()); - foreach (var linestring in multiLineString.Geometries) - { - WkbWriter.WriteCoordinates(linestring.Coordinates, writer); - } + WkbWriter.WriteCoordinate(point.Position, writer); } + } - /// - /// Writes MultiPolygon to the output using specified writer. - /// - /// The MultiPolygon to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteMultiPolygon(IMultiPolygon multiPolygon, BinaryWriter writer) + /// + /// Writes MultiLineString to the output using specified writer. + /// + /// The MultiLineString to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteMultiLineString(IMultiLineString multiLineString, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(multiLineString, WkbGeometryType.MultiLineString)); + writer.Write((uint)multiLineString.Geometries.Count()); + foreach (var linestring in multiLineString.Geometries) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multiPolygon, WkbGeometryType.MultiPolygon)); - writer.Write((uint)multiPolygon.Geometries.Count()); - foreach (var polygon in multiPolygon.Geometries) - { - WkbWriter.WritePolygonContent(polygon, writer); - } + WkbWriter.WriteCoordinates(linestring.Coordinates, writer); } + } - /// - /// Writes GeometryCollection to the output using specified writer. - /// - /// The GeometryCollection to write. - /// The BinaryWriter used to write geometry to the output. - private static void WriteGeometryCollection(IGeometryCollection collection, BinaryWriter writer) + /// + /// Writes MultiPolygon to the output using specified writer. + /// + /// The MultiPolygon to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteMultiPolygon(IMultiPolygon multiPolygon, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(multiPolygon, WkbGeometryType.MultiPolygon)); + writer.Write((uint)multiPolygon.Geometries.Count()); + foreach (var polygon in multiPolygon.Geometries) { - writer.Write((uint)WkbWriter.AdjustGeometryType(collection, WkbGeometryType.GeometryCollection)); - writer.Write((uint)collection.Geometries.Count()); - foreach (var geometry in collection.Geometries) - { - WkbWriter.Write(geometry, writer); - } + WkbWriter.WritePolygonContent(polygon, writer); } + } - /// - /// Adjust WkbGeometryType according to the Geometry object dimensions. - /// - /// The geometry object. - /// WkbGeometryType for the 2D, non-measured version of the geometry object. - /// The WkbGeometryType of the geometry object. - private static WkbGeometryType AdjustGeometryType(IGeometry geometry, WkbGeometryType baseType) + /// + /// Writes GeometryCollection to the output using specified writer. + /// + /// The GeometryCollection to write. + /// The BinaryWriter used to write geometry to the output. + private static void WriteGeometryCollection(IGeometryCollection collection, BinaryWriter writer) + { + writer.Write((uint)WkbWriter.AdjustGeometryType(collection, WkbGeometryType.GeometryCollection)); + writer.Write((uint)collection.Geometries.Count()); + foreach (var geometry in collection.Geometries) { - WkbGeometryType result = baseType; + WkbWriter.Write(geometry, writer); + } + } - if (geometry.Is3D) - { - result += 1000; - } + /// + /// Adjust WkbGeometryType according to the Geometry object dimensions. + /// + /// The geometry object. + /// WkbGeometryType for the 2D, non-measured version of the geometry object. + /// The WkbGeometryType of the geometry object. + private static WkbGeometryType AdjustGeometryType(IGeometry geometry, WkbGeometryType baseType) + { + WkbGeometryType result = baseType; - if (geometry.IsMeasured) - { - result += 2000; - } + if (geometry.Is3D) + { + result += 1000; + } - return result; + if (geometry.IsMeasured) + { + result += 2000; } - /// - /// Releases the unmanaged resources used by the WkbWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + return result; + } + + /// + /// Releases the unmanaged resources used by the WkbWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!_disposed) { - if (!_disposed) + if (disposing) { - if (disposing) - { - _writer.Dispose(); + _writer.Dispose(); - if (_output != null) - { - _output.Dispose(); - } + if (_output != null) + { + _output.Dispose(); } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Core/IO/WkbWriterSettings.cs b/src/SpatialLite.Core/IO/WkbWriterSettings.cs index c2647df..0c7a58d 100644 --- a/src/SpatialLite.Core/IO/WkbWriterSettings.cs +++ b/src/SpatialLite.Core/IO/WkbWriterSettings.cs @@ -1,52 +1,51 @@ using System; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Contains settings that determine behaviour of the WkbWriter +/// +public class WkbWriterSettings { + + private BinaryEncoding _encoding; + /// - /// Contains settings that determine behaviour of the WkbWriter + /// Initializes a new instance of the WkbWriterSettings class with default values. /// - public class WkbWriterSettings + public WkbWriterSettings() + : base() { + this.Encoding = BinaryEncoding.LittleEndian; + } - private BinaryEncoding _encoding; - - /// - /// Initializes a new instance of the WkbWriterSettings class with default values. - /// - public WkbWriterSettings() - : base() + /// + /// Gets or sets a encoding that WkbWriter will use for writing geometries. + /// + /// + /// BigEnndian encoding is not supported in current version of the class. + /// + public BinaryEncoding Encoding + { + get { - this.Encoding = BinaryEncoding.LittleEndian; + return _encoding; } - /// - /// Gets or sets a encoding that WkbWriter will use for writing geometries. - /// - /// - /// BigEnndian encoding is not supported in current version of the class. - /// - public BinaryEncoding Encoding + set { - get + if (this.IsReadOnly) { - return _encoding; + throw new InvalidOperationException("Cannot change the 'Encoding' property. The WkbWriterSettings instance is read-only"); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'Encoding' property. The WkbWriterSettings instance is read-only"); - } - - _encoding = value; - } + _encoding = value; } + } - /// - /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } + /// + /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } - } } diff --git a/src/SpatialLite.Core/IO/WktParseException.cs b/src/SpatialLite.Core/IO/WktParseException.cs index 7214207..c35afed 100644 --- a/src/SpatialLite.Core/IO/WktParseException.cs +++ b/src/SpatialLite.Core/IO/WktParseException.cs @@ -1,19 +1,18 @@ using System; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Represents exception that can occur during WKT parsing. +/// +public class WktParseException : Exception { /// - /// Represents exception that can occur during WKT parsing. + /// Initializes a new instance of the WktParseException class. /// - public class WktParseException : Exception + /// The message that describes the error. + public WktParseException(string message) + : base(message) { - /// - /// Initializes a new instance of the WktParseException class. - /// - /// The message that describes the error. - public WktParseException(string message) - : base(message) - { - } } } diff --git a/src/SpatialLite.Core/IO/WktReader.cs b/src/SpatialLite.Core/IO/WktReader.cs index c8d5768..225ea47 100644 --- a/src/SpatialLite.Core/IO/WktReader.cs +++ b/src/SpatialLite.Core/IO/WktReader.cs @@ -7,781 +7,780 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Provides functions for reading and parsing geometries from WKT format. +/// +public class WktReader : IDisposable { + + private static CultureInfo _invarianCulture = CultureInfo.InvariantCulture; + + private TextReader _inputReader; + private FileStream _inputFileStream; + private WktTokensBuffer _tokens; + + private bool _disposed = false; + /// - /// Provides functions for reading and parsing geometries from WKT format. + /// Initializes a new instance of the WktReader class that reads data from specific stream. /// - public class WktReader : IDisposable + /// The stream to read data from. + public WktReader(Stream input) { + if (input == null) + { + throw new ArgumentNullException(nameof(input), "Input stream cannot be null"); + } - private static CultureInfo _invarianCulture = CultureInfo.InvariantCulture; + _inputReader = new StreamReader(input); + _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); + } - private TextReader _inputReader; - private FileStream _inputFileStream; - private WktTokensBuffer _tokens; + /// + /// Initializes a new instance of the WktReader class that reads data from specific file. + /// + /// Path to the file to read data from. + public WktReader(string path) + { + _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); + _inputReader = new StreamReader(_inputFileStream); + _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); + } + + /// + /// Parses a Geometry from WKT string. + /// + /// The string with WKT representation of a Geometry. + /// The parsed Geometry. + public static Geometry Parse(string wkt) + { + WktTokensBuffer tokens = new WktTokensBuffer(WktTokenizer.Tokenize(wkt)); + return WktReader.ParseGeometryTaggedText(tokens); + } - private bool _disposed = false; + /// + /// Parses a Geometry of specific type from the WKT string. + /// + /// The type of the Geometry to be parsed. + /// The string with WKT representation of a Geometry. + /// The parsed Geometry of given type. + public static T Parse(string wkt) where T : Geometry + { + Geometry parsed = WktReader.Parse(wkt); - /// - /// Initializes a new instance of the WktReader class that reads data from specific stream. - /// - /// The stream to read data from. - public WktReader(Stream input) + if (parsed != null) { - if (input == null) + T result = parsed as T; + if (result == null) { - throw new ArgumentNullException(nameof(input), "Input stream cannot be null"); + throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); } - _inputReader = new StreamReader(input); - _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); - } - - /// - /// Initializes a new instance of the WktReader class that reads data from specific file. - /// - /// Path to the file to read data from. - public WktReader(string path) - { - _inputFileStream = new FileStream(path, FileMode.Open, FileAccess.Read); - _inputReader = new StreamReader(_inputFileStream); - _tokens = new WktTokensBuffer(WktTokenizer.Tokenize(_inputReader)); + return result; } - - /// - /// Parses a Geometry from WKT string. - /// - /// The string with WKT representation of a Geometry. - /// The parsed Geometry. - public static Geometry Parse(string wkt) + else { - WktTokensBuffer tokens = new WktTokensBuffer(WktTokenizer.Tokenize(wkt)); - return WktReader.ParseGeometryTaggedText(tokens); + return null; } + } - /// - /// Parses a Geometry of specific type from the WKT string. - /// - /// The type of the Geometry to be parsed. - /// The string with WKT representation of a Geometry. - /// The parsed Geometry of given type. - public static T Parse(string wkt) where T : Geometry - { - Geometry parsed = WktReader.Parse(wkt); + /// + /// Reads next geometry from the input. + /// + /// The geometry object read from the reader or null if no more geometries are available. + public Geometry Read() + { + return WktReader.ParseGeometryTaggedText(_tokens); + } - if (parsed != null) - { - T result = parsed as T; - if (result == null) - { - throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); - } + /// + /// Reads next geometry from the input. + /// + /// The type of Geometry to be parsed. + /// The geometry object of specific type read from the reader or null if no more geometries are available. + public T Read() where T : Geometry + { + Geometry parsed = WktReader.ParseGeometryTaggedText(_tokens); - return result; - } - else + if (parsed != null) + { + T result = parsed as T; + if (result == null) { - return null; + throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); } - } - /// - /// Reads next geometry from the input. - /// - /// The geometry object read from the reader or null if no more geometries are available. - public Geometry Read() + return result; + } + else { - return WktReader.ParseGeometryTaggedText(_tokens); + return null; } + } - /// - /// Reads next geometry from the input. - /// - /// The type of Geometry to be parsed. - /// The geometry object of specific type read from the reader or null if no more geometries are available. - public T Read() where T : Geometry - { - Geometry parsed = WktReader.ParseGeometryTaggedText(_tokens); + /// + /// Releases all resources used by the ComponentLibrary. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - if (parsed != null) - { - T result = parsed as T; - if (result == null) - { - throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); - } + /// + /// Parses a geometry tagged text. + /// + /// The list of tokens. + /// A geometry specified by tokens. + private static Geometry ParseGeometryTaggedText(WktTokensBuffer tokens) + { + WktToken t = tokens.Peek(true); - return result; + if (t.Type == TokenType.STRING) + { + if (t.Value.ToUpperInvariant() == "POINT") + { + return WktReader.ParsePointTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "LINESTRING") + { + return WktReader.ParseLineStringTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "POLYGON") + { + return WktReader.ParsePolygonTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "MULTIPOINT") + { + return WktReader.ParseMultiPointTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "MULTILINESTRING") + { + return WktReader.ParseMultiLineStringTaggedText(tokens); + } + else if (t.Value.ToUpperInvariant() == "MULTIPOLYGON") + { + return WktReader.ParseMultiPolygonTaggedText(tokens); } - else + else if (t.Value.ToUpperInvariant() == "GEOMETRYCOLLECTION") { - return null; + return WktReader.ParseGeometryCollectionTaggedText(tokens); } } - /// - /// Releases all resources used by the ComponentLibrary. - /// - public void Dispose() + if (t.Type == TokenType.END_OF_DATA) { - Dispose(true); - GC.SuppressFinalize(this); + return null; } - /// - /// Parses a geometry tagged text. - /// - /// The list of tokens. - /// A geometry specified by tokens. - private static Geometry ParseGeometryTaggedText(WktTokensBuffer tokens) - { - WktToken t = tokens.Peek(true); - - if (t.Type == TokenType.STRING) - { - if (t.Value.ToUpperInvariant() == "POINT") - { - return WktReader.ParsePointTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "LINESTRING") - { - return WktReader.ParseLineStringTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "POLYGON") - { - return WktReader.ParsePolygonTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "MULTIPOINT") - { - return WktReader.ParseMultiPointTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "MULTILINESTRING") - { - return WktReader.ParseMultiLineStringTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "MULTIPOLYGON") - { - return WktReader.ParseMultiPolygonTaggedText(tokens); - } - else if (t.Value.ToUpperInvariant() == "GEOMETRYCOLLECTION") - { - return WktReader.ParseGeometryCollectionTaggedText(tokens); - } - } + throw new WktParseException(string.Format("Invalid geometry type '{0}'", t.Value)); + } - if (t.Type == TokenType.END_OF_DATA) - { - return null; - } + /// + /// Parses a point tagged text. + /// + /// The list of tokens. + /// A point specified by tokens. + /// ::= point {z}{m} ]]> + private static Point ParsePointTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("point", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); - throw new WktParseException(string.Format("Invalid geometry type '{0}'", t.Value)); - } + bool is3D = false; + bool isMeasured = false; - /// - /// Parses a point tagged text. - /// - /// The list of tokens. - /// A point specified by tokens. - /// ::= point {z}{m} ]]> - private static Point ParsePointTaggedText(WktTokensBuffer tokens) + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - WktReader.Expect("point", tokens); + tokens.GetToken(true); WktReader.Expect(TokenType.WHITESPACE, tokens); + } - bool is3D = false; - bool isMeasured = false; + return WktReader.ParsePointText(tokens, is3D, isMeasured); + } - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } + /// + /// Parses a point tagged text. + /// + /// The list of tokens. + /// bool value indicating whether point being parsed has z-coordinate. + /// bool value indicating whether point beeing parsed has m-value. + /// A point specified by tokens + /// | ]]> + private static Point ParsePointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); - return WktReader.ParsePointText(tokens, is3D, isMeasured); + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new Point(); } - /// - /// Parses a point tagged text. - /// - /// The list of tokens. - /// bool value indicating whether point being parsed has z-coordinate. - /// bool value indicating whether point beeing parsed has m-value. - /// A point specified by tokens - /// | ]]> - private static Point ParsePointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) - { - WktToken t = tokens.Peek(true); + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + Point result = new Point(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") - { - tokens.GetToken(true); - return new Point(); - } + return result; + } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - Point result = new Point(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + /// + /// Parses multiple Points separated by comma. + /// + /// The list of tokens. + /// bool value indicating whether point being parsed had z-coordinate. + /// bool value indicating whether point being parsed has m-value. + /// A list of point specified by tokens. + private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List points = new List(); - return result; - } + points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); - /// - /// Parses multiple Points separated by comma. - /// - /// The list of tokens. - /// bool value indicating whether point being parsed had z-coordinate. - /// bool value indicating whether point being parsed has m-value. - /// A list of point specified by tokens. - private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool isMeasured) + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) { - List points = new List(); - + tokens.GetToken(true); points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) - { - tokens.GetToken(true); - points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } + return points; + } - return points; - } + /// + /// Parses a coordinate. + /// + /// The list of tokens. + /// bool value indicating whether coordinate being parsed had z-coordinate. + /// bool value indicating whether coordinate beeing parsed has m-value. + /// A coordinate specified by tokens. + /// {} {}]]> + private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = WktReader.Expect(TokenType.NUMBER, tokens); + double x = double.Parse(t.Value, _invarianCulture); - /// - /// Parses a coordinate. - /// - /// The list of tokens. - /// bool value indicating whether coordinate being parsed had z-coordinate. - /// bool value indicating whether coordinate beeing parsed has m-value. - /// A coordinate specified by tokens. - /// {} {}]]> - private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, bool isMeasured) - { - WktToken t = WktReader.Expect(TokenType.NUMBER, tokens); - double x = double.Parse(t.Value, _invarianCulture); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + t = WktReader.Expect(TokenType.NUMBER, tokens); + double y = double.Parse(t.Value, _invarianCulture); + + double z = double.NaN; + double m = double.NaN; + if (is3D) + { WktReader.Expect(TokenType.WHITESPACE, tokens); t = WktReader.Expect(TokenType.NUMBER, tokens); - double y = double.Parse(t.Value, _invarianCulture); - - double z = double.NaN; - double m = double.NaN; + z = double.Parse(t.Value, _invarianCulture); + } - if (is3D) - { - WktReader.Expect(TokenType.WHITESPACE, tokens); + if (isMeasured) + { + WktReader.Expect(TokenType.WHITESPACE, tokens); - t = WktReader.Expect(TokenType.NUMBER, tokens); - z = double.Parse(t.Value, _invarianCulture); - } + t = WktReader.Expect(TokenType.NUMBER, tokens); + m = double.Parse(t.Value, _invarianCulture); + } - if (isMeasured) - { - WktReader.Expect(TokenType.WHITESPACE, tokens); + return new Coordinate(x, y, z, m); + } - t = WktReader.Expect(TokenType.NUMBER, tokens); - m = double.Parse(t.Value, _invarianCulture); - } + /// + /// Parses a series of coordinate. + /// + /// The list of tokens. + /// bool value indicating whether coordinate being parsed had z-coordinate. + /// bool value indicating whether coordinate beeing parsed has m-value. + /// A list of coordinates specified by tokens. + private static IEnumerable ParseCoordinates(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List coordinates = new List(); - return new Coordinate(x, y, z, m); - } + coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); - /// - /// Parses a series of coordinate. - /// - /// The list of tokens. - /// bool value indicating whether coordinate being parsed had z-coordinate. - /// bool value indicating whether coordinate beeing parsed has m-value. - /// A list of coordinates specified by tokens. - private static IEnumerable ParseCoordinates(WktTokensBuffer tokens, bool is3D, bool isMeasured) + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) { - List coordinates = new List(); - + tokens.GetToken(true); + WktReader.Expect(TokenType.WHITESPACE, tokens); coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } + return coordinates; + } - return coordinates; - } + /// + /// Parses a linestring tagged text. + /// + /// The list of tokens. + /// A linestring specified by tokens. + /// ::= linestring {z}{m} ]]> + private static LineString ParseLineStringTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("linestring", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); + + bool is3D = false; + bool isMeasured = false; - /// - /// Parses a linestring tagged text. - /// - /// The list of tokens. - /// A linestring specified by tokens. - /// ::= linestring {z}{m} ]]> - private static LineString ParseLineStringTaggedText(WktTokensBuffer tokens) + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - WktReader.Expect("linestring", tokens); + tokens.GetToken(true); WktReader.Expect(TokenType.WHITESPACE, tokens); + } - bool is3D = false; - bool isMeasured = false; + return WktReader.ParseLineStringText(tokens, is3D, isMeasured); + } - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } + /// + /// Parses a linestring text. + /// + /// The list of tokens. + /// bool value indicating whether linestring being parsed has z-coordinate. + /// bool value indicating whether linestring being parsed has m-value. + /// A linestring specified by tokens. + /// | { }* ]]> + private static LineString ParseLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); - return WktReader.ParseLineStringText(tokens, is3D, isMeasured); + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new LineString(); } - /// - /// Parses a linestring text. - /// - /// The list of tokens. - /// bool value indicating whether linestring being parsed has z-coordinate. - /// bool value indicating whether linestring being parsed has m-value. - /// A linestring specified by tokens. - /// | { }* ]]> - private static LineString ParseLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) - { - WktToken t = tokens.Peek(true); + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + IEnumerable coords = WktReader.ParseCoordinates(tokens, is3D, isMeasured); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") - { - tokens.GetToken(true); - return new LineString(); - } + return new LineString(coords); + } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - IEnumerable coords = WktReader.ParseCoordinates(tokens, is3D, isMeasured); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + /// + /// Parses multiple LineStrings separated by comma. + /// + /// The list of tokens. + /// bool value indicating whether linestring being parsed had z-coordinate. + /// bool value indicating whether linestring being parsed has m-value. + /// A list of linestrings specified by tokens. + private static List ParseLineStrings(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List linestrigns = new List(); - return new LineString(coords); - } + linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); - /// - /// Parses multiple LineStrings separated by comma. - /// - /// The list of tokens. - /// bool value indicating whether linestring being parsed had z-coordinate. - /// bool value indicating whether linestring being parsed has m-value. - /// A list of linestrings specified by tokens. - private static List ParseLineStrings(WktTokensBuffer tokens, bool is3D, bool isMeasured) + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) { - List linestrigns = new List(); - + tokens.GetToken(true); linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) - { - tokens.GetToken(true); - linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } + return linestrigns; + } - return linestrigns; - } + /// + /// Parses a polygon tagged text. + /// + /// The list of tokens. + /// A polygon specified by tokens. + /// ::= polygon {z}{m} ]]> + private static Polygon ParsePolygonTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("polygon", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); - /// - /// Parses a polygon tagged text. - /// - /// The list of tokens. - /// A polygon specified by tokens. - /// ::= polygon {z}{m} ]]> - private static Polygon ParsePolygonTaggedText(WktTokensBuffer tokens) + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - WktReader.Expect("polygon", tokens); + tokens.GetToken(true); WktReader.Expect(TokenType.WHITESPACE, tokens); + } - bool is3D = false; - bool isMeasured = false; + return WktReader.ParsePolygonText(tokens, is3D, isMeasured); + } - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } + /// + /// Parses a polygon text. + /// + /// The list of tokens. + /// bool value indicating whether polygon being parsed has z-coordinate. + /// bool value indicating whether polygon being parsed has m-value. + /// A polygon specified by tokens. + /// | { }* ]]> + private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); - return WktReader.ParsePolygonText(tokens, is3D, isMeasured); + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new Polygon(); } - /// - /// Parses a polygon text. - /// - /// The list of tokens. - /// bool value indicating whether polygon being parsed has z-coordinate. - /// bool value indicating whether polygon being parsed has m-value. - /// A polygon specified by tokens. - /// | { }* ]]> - private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) - { - WktToken t = tokens.Peek(true); + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") - { - tokens.GetToken(true); - return new Polygon(); - } + IEnumerable linestrings = WktReader.ParseLineStrings(tokens, is3D, isMeasured); + Polygon result = new Polygon(linestrings.First().Coordinates); - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + foreach (var inner in linestrings.Skip(1)) + { + result.InteriorRings.Add(inner.Coordinates); + } - IEnumerable linestrings = WktReader.ParseLineStrings(tokens, is3D, isMeasured); - Polygon result = new Polygon(linestrings.First().Coordinates); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - foreach (var inner in linestrings.Skip(1)) - { - result.InteriorRings.Add(inner.Coordinates); - } + return result; + } - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + /// + /// Parses series of polygons. + /// + /// The list of tokens. + /// bool value indicating whether polygon being parsed has z-coordinate. + /// bool value indicating whether polygon being parsed has m-value. + /// A list of polygons specified by tokens. + private static IEnumerable ParsePolygons(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + List polygons = new List(); - return result; - } + polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); - /// - /// Parses series of polygons. - /// - /// The list of tokens. - /// bool value indicating whether polygon being parsed has z-coordinate. - /// bool value indicating whether polygon being parsed has m-value. - /// A list of polygons specified by tokens. - private static IEnumerable ParsePolygons(WktTokensBuffer tokens, bool is3D, bool isMeasured) + WktToken t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) { - List polygons = new List(); - + tokens.GetToken(true); polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); + t = tokens.Peek(true); + } - WktToken t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) - { - tokens.GetToken(true); - polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); - t = tokens.Peek(true); - } + return polygons; + } - return polygons; - } + /// + /// Parses a multilinestring tagged text. + /// + /// The list of tokens. + /// A multilinestring specified by tokens. + /// ::= multilinestring {z}{m} ]]> + private static MultiLineString ParseMultiLineStringTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("multilinestring", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); - /// - /// Parses a multilinestring tagged text. - /// - /// The list of tokens. - /// A multilinestring specified by tokens. - /// ::= multilinestring {z}{m} ]]> - private static MultiLineString ParseMultiLineStringTaggedText(WktTokensBuffer tokens) + bool is3D = false; + bool isMeasured = false; + + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - WktReader.Expect("multilinestring", tokens); + tokens.GetToken(true); WktReader.Expect(TokenType.WHITESPACE, tokens); + } - bool is3D = false; - bool isMeasured = false; + return WktReader.ParseMultiLineStringText(tokens, is3D, isMeasured); + } - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } + /// + /// Parses a multilinestring text. + /// + /// The list of tokens. + /// bool value indicating whether multilinestring being parsed has z-coordinate. + /// bool value indicating whether multilinestring being parsed has m-value. + /// A multilinestring specified by tokens. + /// ::= | { }* ]]> + private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); - return WktReader.ParseMultiLineStringText(tokens, is3D, isMeasured); + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new MultiLineString(); } - /// - /// Parses a multilinestring text. - /// - /// The list of tokens. - /// bool value indicating whether multilinestring being parsed has z-coordinate. - /// bool value indicating whether multilinestring being parsed has m-value. - /// A multilinestring specified by tokens. - /// ::= | { }* ]]> - private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) - { - WktToken t = tokens.Peek(true); + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiLineString result = new MultiLineString(WktReader.ParseLineStrings(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") - { - tokens.GetToken(true); - return new MultiLineString(); - } + return result; + } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiLineString result = new MultiLineString(WktReader.ParseLineStrings(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + /// + /// Parses a multipoint tagged text. + /// + /// The list of tokens. + /// A multipoint specified by tokens. + /// ::= multipoint {z}{m} ]]> + private static MultiPoint ParseMultiPointTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("multipoint", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); - return result; - } + bool is3D = false; + bool isMeasured = false; - /// - /// Parses a multipoint tagged text. - /// - /// The list of tokens. - /// A multipoint specified by tokens. - /// ::= multipoint {z}{m} ]]> - private static MultiPoint ParseMultiPointTaggedText(WktTokensBuffer tokens) + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - WktReader.Expect("multipoint", tokens); + tokens.GetToken(true); WktReader.Expect(TokenType.WHITESPACE, tokens); + } - bool is3D = false; - bool isMeasured = false; + return WktReader.ParseMultiPointText(tokens, is3D, isMeasured); + } - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } + /// + /// Parses a multipoint text. + /// + /// The list of tokens. + /// bool value indicating whether multipoint being parsed has z-coordinate. + /// bool value indicating whether multipoint being parsed has m-value. + /// A multipoint specified by tokens. + /// ::= | { }* ]]> + private static MultiPoint ParseMultiPointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); - return WktReader.ParseMultiPointText(tokens, is3D, isMeasured); + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new MultiPoint(); } - /// - /// Parses a multipoint text. - /// - /// The list of tokens. - /// bool value indicating whether multipoint being parsed has z-coordinate. - /// bool value indicating whether multipoint being parsed has m-value. - /// A multipoint specified by tokens. - /// ::= | { }* ]]> - private static MultiPoint ParseMultiPointText(WktTokensBuffer tokens, bool is3D, bool isMeasured) - { - WktToken t = tokens.Peek(true); + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiPoint result = new MultiPoint(WktReader.ParsePoints(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") - { - tokens.GetToken(true); - return new MultiPoint(); - } + return result; + } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPoint result = new MultiPoint(WktReader.ParsePoints(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + /// + /// Parses a multipolyugon tagged text. + /// + /// The list of tokens. + /// A multipolygon specified by tokens. + /// ::= multipolygon {z}{m} ]]> + private static MultiPolygon ParseMultiPolygonTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("multipolygon", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); - return result; - } + bool is3D = false; + bool isMeasured = false; - /// - /// Parses a multipolyugon tagged text. - /// - /// The list of tokens. - /// A multipolygon specified by tokens. - /// ::= multipolygon {z}{m} ]]> - private static MultiPolygon ParseMultiPolygonTaggedText(WktTokensBuffer tokens) + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - WktReader.Expect("multipolygon", tokens); + tokens.GetToken(true); WktReader.Expect(TokenType.WHITESPACE, tokens); + } - bool is3D = false; - bool isMeasured = false; + return WktReader.ParseMultiPolygonText(tokens, is3D, isMeasured); + } - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } + /// + /// Parses a multipolygon text. + /// + /// The list of tokens. + /// bool value indicating whether multipolygon being parsed has z-coordinate. + /// bool value indicating whether multipolygon being parsed has m-value. + /// A multipolygon specified by tokens. + /// ::= | { }* ]]> + private static MultiPolygon ParseMultiPolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); - return WktReader.ParseMultiPolygonText(tokens, is3D, isMeasured); + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") + { + tokens.GetToken(true); + return new MultiPolygon(); } - /// - /// Parses a multipolygon text. - /// - /// The list of tokens. - /// bool value indicating whether multipolygon being parsed has z-coordinate. - /// bool value indicating whether multipolygon being parsed has m-value. - /// A multipolygon specified by tokens. - /// ::= | { }* ]]> - private static MultiPolygon ParseMultiPolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) - { - WktToken t = tokens.Peek(true); + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiPolygon result = new MultiPolygon(WktReader.ParsePolygons(tokens, is3D, isMeasured)); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") - { - tokens.GetToken(true); - return new MultiPolygon(); - } + return result; + } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPolygon result = new MultiPolygon(WktReader.ParsePolygons(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + /// + /// Parses a multipolyugon tagged text. + /// + /// The list of tokens. + /// A GeometryCollection specified by tokens. + /// ::= GeometryCollection {z}{m} ]]> + private static GeometryCollection ParseGeometryCollectionTaggedText(WktTokensBuffer tokens) + { + WktReader.Expect("geometrycollection", tokens); + WktReader.Expect(TokenType.WHITESPACE, tokens); - return result; - } + bool is3D = false; + bool isMeasured = false; - /// - /// Parses a multipolyugon tagged text. - /// - /// The list of tokens. - /// A GeometryCollection specified by tokens. - /// ::= GeometryCollection {z}{m} ]]> - private static GeometryCollection ParseGeometryCollectionTaggedText(WktTokensBuffer tokens) + WktToken t = tokens.Peek(true); + if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) { - WktReader.Expect("geometrycollection", tokens); + tokens.GetToken(true); WktReader.Expect(TokenType.WHITESPACE, tokens); + } - bool is3D = false; - bool isMeasured = false; - - WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) - { - tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - } + return WktReader.ParseGeometryCollectionText(tokens, is3D, isMeasured); + } - return WktReader.ParseGeometryCollectionText(tokens, is3D, isMeasured); - } + /// + /// Parses a GeometryCollection text. + /// + /// The list of tokens. + /// bool value indicating whether GeometryCollection being parsed has z-coordinate. + /// bool value indicating whether GeometryCollection being parsed has m-value. + /// A GeometryCollection specified by tokens. + /// ::= | { }* ]]> + private static GeometryCollection ParseGeometryCollectionText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + { + WktToken t = tokens.Peek(true); - /// - /// Parses a GeometryCollection text. - /// - /// The list of tokens. - /// bool value indicating whether GeometryCollection being parsed has z-coordinate. - /// bool value indicating whether GeometryCollection being parsed has m-value. - /// A GeometryCollection specified by tokens. - /// ::= | { }* ]]> - private static GeometryCollection ParseGeometryCollectionText(WktTokensBuffer tokens, bool is3D, bool isMeasured) + if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { - WktToken t = tokens.Peek(true); + tokens.GetToken(true); + return new GeometryCollection(); + } - if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") - { - tokens.GetToken(true); - return new GeometryCollection(); - } + WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + GeometryCollection result = new GeometryCollection(); + result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); - GeometryCollection result = new GeometryCollection(); + t = tokens.Peek(true); + while (t.Type == TokenType.COMMA) + { + tokens.GetToken(true); result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); - t = tokens.Peek(true); - while (t.Type == TokenType.COMMA) - { - tokens.GetToken(true); - result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); - t = tokens.Peek(true); - } + } - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); - return result; - } + return result; + } - /// - /// Retrieves the next token from the tokens and checks if it has expected type. - /// - /// Expected type of token. - /// The list of tokens. - /// The head of the tokens queue. - private static WktToken Expect(TokenType type, WktTokensBuffer tokens) - { - bool ignoreWhitespace = type != TokenType.WHITESPACE; + /// + /// Retrieves the next token from the tokens and checks if it has expected type. + /// + /// Expected type of token. + /// The list of tokens. + /// The head of the tokens queue. + private static WktToken Expect(TokenType type, WktTokensBuffer tokens) + { + bool ignoreWhitespace = type != TokenType.WHITESPACE; - WktToken t = tokens.GetToken(ignoreWhitespace); + WktToken t = tokens.GetToken(ignoreWhitespace); - if (t.Type != type) + if (t.Type != type) + { + string expected = string.Empty; + switch (type) { - string expected = string.Empty; - switch (type) - { - case TokenType.WHITESPACE: expected = " "; break; - case TokenType.LEFT_PARENTHESIS: expected = "("; break; - case TokenType.RIGHT_PARENTHESIS: expected = ")"; break; - case TokenType.STRING: expected = "STRING"; break; - case TokenType.NUMBER: expected = "NUMBER"; break; - } - - throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}'", expected, t.Value)); + case TokenType.WHITESPACE: expected = " "; break; + case TokenType.LEFT_PARENTHESIS: expected = "("; break; + case TokenType.RIGHT_PARENTHESIS: expected = ")"; break; + case TokenType.STRING: expected = "STRING"; break; + case TokenType.NUMBER: expected = "NUMBER"; break; } - return t; + throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}'", expected, t.Value)); } - /// - /// Retrieves the next token from tokens and checks if it is TokenType.STRING and if it has correct value. - /// - /// Expected string value of the token. - /// The list of tokens. - /// The head of the tokens queue. - /// String comparsion is not case-sensitive. - private static WktToken Expect(string value, WktTokensBuffer tokens) - { - WktToken t = tokens.GetToken(true); + return t; + } - if (t.Type != TokenType.STRING || string.Equals(value, t.Value, StringComparison.OrdinalIgnoreCase) == false) - { - throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}", value, t.Value)); - } + /// + /// Retrieves the next token from tokens and checks if it is TokenType.STRING and if it has correct value. + /// + /// Expected string value of the token. + /// The list of tokens. + /// The head of the tokens queue. + /// String comparsion is not case-sensitive. + private static WktToken Expect(string value, WktTokensBuffer tokens) + { + WktToken t = tokens.GetToken(true); - return t; + if (t.Type != TokenType.STRING || string.Equals(value, t.Value, StringComparison.OrdinalIgnoreCase) == false) + { + throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}", value, t.Value)); } - /// - /// Examines the given token and tries to parse it as WKT dimensions text. - /// - /// The WKT token to parse. - /// Parameter that specified whether dimension text contains {z}. - /// Parameter that specified whether dimension text contains {m}. - /// true if token was successfuly parsed as WKT dimension text, oterwise returns false. - private static bool TryParseDimensions(WktToken token, out bool is3D, out bool isMeasured) - { - is3D = false; - isMeasured = false; + return t; + } - if (token.Type == TokenType.STRING) - { - if (token.Value.ToUpperInvariant() == "Z") - { - is3D = true; - } - else if (token.Value.ToUpperInvariant() == "M") - { - isMeasured = true; - } - else if (token.Value.ToUpperInvariant() == "ZM") - { - is3D = true; - isMeasured = true; - } + /// + /// Examines the given token and tries to parse it as WKT dimensions text. + /// + /// The WKT token to parse. + /// Parameter that specified whether dimension text contains {z}. + /// Parameter that specified whether dimension text contains {m}. + /// true if token was successfuly parsed as WKT dimension text, oterwise returns false. + private static bool TryParseDimensions(WktToken token, out bool is3D, out bool isMeasured) + { + is3D = false; + isMeasured = false; - return is3D || isMeasured; + if (token.Type == TokenType.STRING) + { + if (token.Value.ToUpperInvariant() == "Z") + { + is3D = true; } - else + else if (token.Value.ToUpperInvariant() == "M") { - return false; + isMeasured = true; } + else if (token.Value.ToUpperInvariant() == "ZM") + { + is3D = true; + isMeasured = true; + } + + return is3D || isMeasured; } + else + { + return false; + } + } - /// - /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + /// + /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) { - if (!this._disposed) + if (disposing) { - if (disposing) - { - _inputReader.Dispose(); + _inputReader.Dispose(); - if (_inputFileStream != null) - { - _inputFileStream.Dispose(); - } + if (_inputFileStream != null) + { + _inputFileStream.Dispose(); } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Core/IO/WktToken.cs b/src/SpatialLite.Core/IO/WktToken.cs index 2adb04e..c68599f 100644 --- a/src/SpatialLite.Core/IO/WktToken.cs +++ b/src/SpatialLite.Core/IO/WktToken.cs @@ -1,23 +1,22 @@ -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Represents token of the wkt string. +/// +internal struct WktToken { /// - /// Represents token of the wkt string. + /// Special token that represents end of available data. /// - internal struct WktToken - { - /// - /// Special token that represents end of available data. - /// - public static WktToken EndOfDataToken = new WktToken() { Type = TokenType.END_OF_DATA, Value = string.Empty }; + public static WktToken EndOfDataToken = new WktToken() { Type = TokenType.END_OF_DATA, Value = string.Empty }; - /// - /// The type of the tooken. - /// - public TokenType Type; + /// + /// The type of the tooken. + /// + public TokenType Type; - /// - /// The string value of the token. - /// - public string Value; - } + /// + /// The string value of the token. + /// + public string Value; } diff --git a/src/SpatialLite.Core/IO/WktTokenizer.cs b/src/SpatialLite.Core/IO/WktTokenizer.cs index 9d55735..0744ddd 100644 --- a/src/SpatialLite.Core/IO/WktTokenizer.cs +++ b/src/SpatialLite.Core/IO/WktTokenizer.cs @@ -3,97 +3,96 @@ using System.IO; using System.Text; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Implemets tokenizer that splits wkt string to list of tokens. +/// +internal static class WktTokenizer { + /// - /// Implemets tokenizer that splits wkt string to list of tokens. + /// Splits text to tokens. /// - internal static class WktTokenizer + /// The text to be splitted. + /// The list of parsed tokens of the input string. + public static IEnumerable Tokenize(string text) { + StringReader reader = new StringReader(text); + return WktTokenizer.Tokenize(reader); + } - /// - /// Splits text to tokens. - /// - /// The text to be splitted. - /// The list of parsed tokens of the input string. - public static IEnumerable Tokenize(string text) + /// + /// Processes text from TextReader and splits it into tokens. + /// + /// The TextReader to read string from + /// The collection parsed tokens of the input string + public static IEnumerable Tokenize(TextReader reader) + { + StringBuilder stringBuffer = new StringBuilder(); + + if (reader.Peek() == -1) { - StringReader reader = new StringReader(text); - return WktTokenizer.Tokenize(reader); + yield break; } - /// - /// Processes text from TextReader and splits it into tokens. - /// - /// The TextReader to read string from - /// The collection parsed tokens of the input string - public static IEnumerable Tokenize(TextReader reader) + char ch = (char)reader.Read(); + stringBuffer.Append(ch); + TokenType lastToken = WktTokenizer.GetTokenType(ch); + + while (reader.Peek() != -1) { - StringBuilder stringBuffer = new StringBuilder(); + ch = (char)reader.Read(); + TokenType token = WktTokenizer.GetTokenType(ch); - if (reader.Peek() == -1) + // tokens COMMA, LEFT_PARENTHESIS and RIGHT_PARENTHESIS can not be grupped together + if ((token != lastToken) || token == TokenType.COMMA || token == TokenType.LEFT_PARENTHESIS || token == TokenType.RIGHT_PARENTHESIS) { - yield break; + yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; + + stringBuffer.Clear(); + lastToken = token; } - char ch = (char)reader.Read(); stringBuffer.Append(ch); - TokenType lastToken = WktTokenizer.GetTokenType(ch); - - while (reader.Peek() != -1) - { - ch = (char)reader.Read(); - TokenType token = WktTokenizer.GetTokenType(ch); - - // tokens COMMA, LEFT_PARENTHESIS and RIGHT_PARENTHESIS can not be grupped together - if ((token != lastToken) || token == TokenType.COMMA || token == TokenType.LEFT_PARENTHESIS || token == TokenType.RIGHT_PARENTHESIS) - { - yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; - - stringBuffer.Clear(); - lastToken = token; - } + } - stringBuffer.Append(ch); - } + yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; + } - yield return new WktToken() { Type = lastToken, Value = stringBuffer.ToString() }; + /// + /// Gets type of the token. + /// + /// Character to get type. + /// the type of token for ch. + /// In WKT can characters be divided into token types without context - every character is member of thne one token type only. + private static TokenType GetTokenType(char ch) + { + if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) + { + return TokenType.STRING; } - - /// - /// Gets type of the token. - /// - /// Character to get type. - /// the type of token for ch. - /// In WKT can characters be divided into token types without context - every character is member of thne one token type only. - private static TokenType GetTokenType(char ch) + else if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') { - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) - { - return TokenType.STRING; - } - else if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') - { - return TokenType.WHITESPACE; - } - else if (ch == ',') - { - return TokenType.COMMA; - } - else if (ch == '(') - { - return TokenType.LEFT_PARENTHESIS; - } - else if (ch == ')') - { - return TokenType.RIGHT_PARENTHESIS; - } - else if (ch == '-' || ch == '.' || (ch >= '0' && ch <= '9')) - { - return TokenType.NUMBER; - } - - throw new Exception(); + return TokenType.WHITESPACE; + } + else if (ch == ',') + { + return TokenType.COMMA; + } + else if (ch == '(') + { + return TokenType.LEFT_PARENTHESIS; } + else if (ch == ')') + { + return TokenType.RIGHT_PARENTHESIS; + } + else if (ch == '-' || ch == '.' || (ch >= '0' && ch <= '9')) + { + return TokenType.NUMBER; + } + + throw new Exception(); } } diff --git a/src/SpatialLite.Core/IO/WktTokensBuffer.cs b/src/SpatialLite.Core/IO/WktTokensBuffer.cs index 5fceca9..d8041b9 100644 --- a/src/SpatialLite.Core/IO/WktTokensBuffer.cs +++ b/src/SpatialLite.Core/IO/WktTokensBuffer.cs @@ -1,143 +1,142 @@ using System.Collections.Generic; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Represents collection of WktToken obejcts with specialized methods to access it's items. +/// +internal class WktTokensBuffer : IEnumerable { + + private List _buffer; + /// - /// Represents collection of WktToken obejcts with specialized methods to access it's items. + /// Initializes a new instance of the WktTokenBuffer class that is empty. /// - internal class WktTokensBuffer : IEnumerable + public WktTokensBuffer() { + _buffer = new List(); + } - private List _buffer; - - /// - /// Initializes a new instance of the WktTokenBuffer class that is empty. - /// - public WktTokensBuffer() - { - _buffer = new List(); - } + /// + /// Initializes a new instance of the WktTokensBuffer class and fills it with specified tokens. + /// + /// Tokens to add to the buffer. + public WktTokensBuffer(IEnumerable tokens) + { + _buffer = new List(tokens); + } - /// - /// Initializes a new instance of the WktTokensBuffer class and fills it with specified tokens. - /// - /// Tokens to add to the buffer. - public WktTokensBuffer(IEnumerable tokens) + /// + /// Gets number of items in the collection + /// + public int Count + { + get { - _buffer = new List(tokens); + return _buffer.Count; } + } - /// - /// Gets number of items in the collection - /// - public int Count - { - get - { - return _buffer.Count; - } - } + /// + /// Adds specific token to the end of tokens tokens + /// + /// The WktToken to add to the tokens + public void Add(WktToken item) + { + _buffer.Add(item); + } - /// - /// Adds specific token to the end of tokens tokens - /// - /// The WktToken to add to the tokens - public void Add(WktToken item) - { - _buffer.Add(item); - } + /// + /// Adds tokens from specific collection to the ent of tokens + /// + /// The collection whose items to add to this collection + public void Add(IEnumerable items) + { + _buffer.AddRange(items); + } - /// - /// Adds tokens from specific collection to the ent of tokens - /// - /// The collection whose items to add to this collection - public void Add(IEnumerable items) - { - _buffer.AddRange(items); - } + /// + /// Removes all tokens from the collection + /// + public void Clear() + { + _buffer.Clear(); + } - /// - /// Removes all tokens from the collection - /// - public void Clear() + /// + /// Gets next token from the tokens + /// + /// bool value indicating whether whitespace tokens should be ignored + /// Next token form the tokens + public WktToken Peek(bool ignoreWhitespace) + { + if (this.Count == 0) { - _buffer.Clear(); + return WktToken.EndOfDataToken; } - /// - /// Gets next token from the tokens - /// - /// bool value indicating whether whitespace tokens should be ignored - /// Next token form the tokens - public WktToken Peek(bool ignoreWhitespace) + WktToken t = _buffer[0]; + if (t.Type == TokenType.WHITESPACE && ignoreWhitespace) { - if (this.Count == 0) + int index = 0; + while (index < _buffer.Count && t.Type == TokenType.WHITESPACE) { - return WktToken.EndOfDataToken; + t = _buffer[index++]; } - WktToken t = _buffer[0]; - if (t.Type == TokenType.WHITESPACE && ignoreWhitespace) + if (t.Type == TokenType.WHITESPACE) { - int index = 0; - while (index < _buffer.Count && t.Type == TokenType.WHITESPACE) - { - t = _buffer[index++]; - } - - if (t.Type == TokenType.WHITESPACE) - { - return WktToken.EndOfDataToken; - } - - return t; + return WktToken.EndOfDataToken; } return t; } - /// - /// Gets next token from the tokens and proceeds to the next token - /// - /// bool value indicating whether whitespace tokens should be ignored - /// Next token form the tokens - public WktToken GetToken(bool ignoreWhitespace) - { - if (ignoreWhitespace) - { - while (_buffer.Count > 0 && _buffer[0].Type == TokenType.WHITESPACE) - { - _buffer.RemoveAt(0); - } - } + return t; + } - if (_buffer.Count == 0) + /// + /// Gets next token from the tokens and proceeds to the next token + /// + /// bool value indicating whether whitespace tokens should be ignored + /// Next token form the tokens + public WktToken GetToken(bool ignoreWhitespace) + { + if (ignoreWhitespace) + { + while (_buffer.Count > 0 && _buffer[0].Type == TokenType.WHITESPACE) { - return WktToken.EndOfDataToken; + _buffer.RemoveAt(0); } - - WktToken result = _buffer[0]; - _buffer.RemoveAt(0); - - return result; } - /// - /// Returns an enumerator that iterates through the items of collection - /// - /// An enumerator that iterates through the collection - public IEnumerator GetEnumerator() + if (_buffer.Count == 0) { - return _buffer.GetEnumerator(); + return WktToken.EndOfDataToken; } - /// - /// Returns an enumerator that iterates through the items of collection - /// - /// An enumerator that iterates through the collection - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } + WktToken result = _buffer[0]; + _buffer.RemoveAt(0); + + return result; + } + + /// + /// Returns an enumerator that iterates through the items of collection + /// + /// An enumerator that iterates through the collection + public IEnumerator GetEnumerator() + { + return _buffer.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the items of collection + /// + /// An enumerator that iterates through the collection + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); } } diff --git a/src/SpatialLite.Core/IO/WktWriter.cs b/src/SpatialLite.Core/IO/WktWriter.cs index 762bcd0..9e3ab15 100644 --- a/src/SpatialLite.Core/IO/WktWriter.cs +++ b/src/SpatialLite.Core/IO/WktWriter.cs @@ -3,550 +3,549 @@ using SpatialLite.Core.API; using System.Linq; -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Provides methods for writing Geomerty objects into WKT format. +/// +public class WktWriter : IDisposable { + + private static System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + + private bool _disposed = false; + private TextWriter _writer; + private Stream _outputStream; + /// - /// Provides methods for writing Geomerty objects into WKT format. + /// Initializes a new instance of the WkbWriter class with specific settings. /// - public class WktWriter : IDisposable + /// The settings defining behaviour of the writer. + protected WktWriter(WktWriterSettings settings) { + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } - private static System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; - - private bool _disposed = false; - private TextWriter _writer; - private Stream _outputStream; + this.Settings = settings; + this.Settings.IsReadOnly = true; + } - /// - /// Initializes a new instance of the WkbWriter class with specific settings. - /// - /// The settings defining behaviour of the writer. - protected WktWriter(WktWriterSettings settings) + /// + /// Initializes a new instance of the WktWriter class that writes geometries to stream with specific settings. + /// + /// The stream to write geometries to. + /// The settings defining behaviour of the writer. + public WktWriter(Stream stream, WktWriterSettings settings) + : this(settings) + { + if (stream == null) { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } - - this.Settings = settings; - this.Settings.IsReadOnly = true; + throw new ArgumentNullException(nameof(stream)); } - /// - /// Initializes a new instance of the WktWriter class that writes geometries to stream with specific settings. - /// - /// The stream to write geometries to. - /// The settings defining behaviour of the writer. - public WktWriter(Stream stream, WktWriterSettings settings) - : this(settings) - { - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } + _writer = new StreamWriter(stream); + } - _writer = new StreamWriter(stream); + /// + /// Initializes a new instance of the WktWriter class that writes geometreis to file with specific settings. + /// + /// The path to the file to write geometries to. + /// The settings defining behaviour of the writer. + public WktWriter(string path, WktWriterSettings settings) + : this(settings) + { + if (path == null) + { + throw new ArgumentNullException(nameof(path)); } - /// - /// Initializes a new instance of the WktWriter class that writes geometreis to file with specific settings. - /// - /// The path to the file to write geometries to. - /// The settings defining behaviour of the writer. - public WktWriter(string path, WktWriterSettings settings) - : this(settings) - { - if (path == null) - { - throw new ArgumentNullException(nameof(path)); - } + _outputStream = new FileStream(path, FileMode.Create, FileAccess.Write); + _writer = new StreamWriter(_outputStream); + } - _outputStream = new FileStream(path, FileMode.Create, FileAccess.Write); - _writer = new StreamWriter(_outputStream); - } + /// + /// Gets the settings that determines behaviour of this instance of the WktWriter. + /// + public WktWriterSettings Settings { get; private set; } + + /// + /// Writes the Geometry object in the WKT format to the output. + /// + /// The geometry to write. + public void Write(IGeometry geometry) + { + WktWriter.Write(geometry, _writer); + } - /// - /// Gets the settings that determines behaviour of this instance of the WktWriter. - /// - public WktWriterSettings Settings { get; private set; } + /// + /// Releases all resources used by the WktWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Writes the Geometry object to the string in WKT format. + /// + /// The Geometry to be written. + /// The WKT representation of the Geometry. + public static string WriteToString(IGeometry geometry) + { + StringWriter tw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); + WktWriter.Write(geometry, tw); - /// - /// Writes the Geometry object in the WKT format to the output. - /// - /// The geometry to write. - public void Write(IGeometry geometry) + return tw.ToString(); + } + + /// + /// Writes specified Geometry to the TextWriter in WKT format. + /// + /// The geometry to be written. + /// The output Stream the Geometry will be written to. + protected static void Write(IGeometry geometry, TextWriter writer) + { + if (geometry is IPoint) { - WktWriter.Write(geometry, _writer); + WktWriter.AppendPointTaggedText((IPoint)geometry, writer); } - - /// - /// Releases all resources used by the WktWriter. - /// - public void Dispose() + else if (geometry is ILineString) { - Dispose(true); - GC.SuppressFinalize(this); + WktWriter.AppendLineStringTaggedText((ILineString)geometry, writer); } - - /// - /// Writes the Geometry object to the string in WKT format. - /// - /// The Geometry to be written. - /// The WKT representation of the Geometry. - public static string WriteToString(IGeometry geometry) + else if (geometry is IPolygon) { - StringWriter tw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); - WktWriter.Write(geometry, tw); - - return tw.ToString(); + WktWriter.AppendPolygonTaggedText((IPolygon)geometry, writer); } - - /// - /// Writes specified Geometry to the TextWriter in WKT format. - /// - /// The geometry to be written. - /// The output Stream the Geometry will be written to. - protected static void Write(IGeometry geometry, TextWriter writer) + else if (geometry is IMultiPoint) { - if (geometry is IPoint) - { - WktWriter.AppendPointTaggedText((IPoint)geometry, writer); - } - else if (geometry is ILineString) - { - WktWriter.AppendLineStringTaggedText((ILineString)geometry, writer); - } - else if (geometry is IPolygon) - { - WktWriter.AppendPolygonTaggedText((IPolygon)geometry, writer); - } - else if (geometry is IMultiPoint) - { - WktWriter.AppendMultiPointTaggedText((IMultiPoint)geometry, writer); - } - else if (geometry is IMultiLineString) - { - WktWriter.AppendMultiLineStringTaggedText((IMultiLineString)geometry, writer); - } - else if (geometry is IMultiPolygon) - { - WktWriter.AppendMultiPolygonTaggetText((IMultiPolygon)geometry, writer); - } - else if (geometry is IGeometryCollection) - { - WktWriter.AppendGeometryCollectionTaggedText((IGeometryCollection)geometry, writer); - } + WktWriter.AppendMultiPointTaggedText((IMultiPoint)geometry, writer); } - - /// - /// Converts the Coordinate to the format used in WKT and appends it to the output Stream. - /// - /// The Coordinate to be converted. - /// The output Stream to Appent WKT representation to. - private static void AppendCoordinate(Coordinate coordinate, TextWriter writer) + else if (geometry is IMultiLineString) { - writer.Write(coordinate.X.ToString(_invariantCulture)); - writer.Write(' '); - writer.Write(coordinate.Y.ToString(_invariantCulture)); + WktWriter.AppendMultiLineStringTaggedText((IMultiLineString)geometry, writer); + } + else if (geometry is IMultiPolygon) + { + WktWriter.AppendMultiPolygonTaggetText((IMultiPolygon)geometry, writer); + } + else if (geometry is IGeometryCollection) + { + WktWriter.AppendGeometryCollectionTaggedText((IGeometryCollection)geometry, writer); + } + } - if (coordinate.Is3D) - { - writer.Write(' '); - writer.Write(coordinate.Z.ToString(_invariantCulture)); - } + /// + /// Converts the Coordinate to the format used in WKT and appends it to the output Stream. + /// + /// The Coordinate to be converted. + /// The output Stream to Appent WKT representation to. + private static void AppendCoordinate(Coordinate coordinate, TextWriter writer) + { + writer.Write(coordinate.X.ToString(_invariantCulture)); + writer.Write(' '); + writer.Write(coordinate.Y.ToString(_invariantCulture)); - if (coordinate.IsMeasured) - { - writer.Write(' '); - writer.Write(coordinate.M.ToString(_invariantCulture)); - } + if (coordinate.Is3D) + { + writer.Write(' '); + writer.Write(coordinate.Z.ToString(_invariantCulture)); } - /// - /// Converts the List of Coordinates to WKT format and appends it to output stream. - /// - /// The list of coordinates to be converted. - /// The output stream. - /// bool value indicating whether the list of coordinates should be enclosed in parathenes. - private static void AppendCoordinates(ICoordinateList coordinates, TextWriter writer, bool wrap) + if (coordinate.IsMeasured) { - if (coordinates.Count == 0) - { - return; - } + writer.Write(' '); + writer.Write(coordinate.M.ToString(_invariantCulture)); + } + } - if (wrap) - { - writer.Write("("); - } + /// + /// Converts the List of Coordinates to WKT format and appends it to output stream. + /// + /// The list of coordinates to be converted. + /// The output stream. + /// bool value indicating whether the list of coordinates should be enclosed in parathenes. + private static void AppendCoordinates(ICoordinateList coordinates, TextWriter writer, bool wrap) + { + if (coordinates.Count == 0) + { + return; + } - WktWriter.AppendCoordinate(coordinates[0], writer); + if (wrap) + { + writer.Write("("); + } - for (int i = 1; i < coordinates.Count; i++) - { - writer.Write(", "); - WktWriter.AppendCoordinate(coordinates[i], writer); - } + WktWriter.AppendCoordinate(coordinates[0], writer); - if (wrap) - { - writer.Write(")"); - } + for (int i = 1; i < coordinates.Count; i++) + { + writer.Write(", "); + WktWriter.AppendCoordinate(coordinates[i], writer); } - /// - /// Converts Point to WKT format and appends WKT representation to the output stream. - /// - /// The Point to be converted. - /// The output Stream to append WKT representation to. - private static void AppendPointTaggedText(IPoint point, TextWriter writer) + if (wrap) { - writer.Write("point "); + writer.Write(")"); + } + } - string dimension = WktWriter.GetDimensionText(point); - if (string.IsNullOrEmpty(dimension) == false) - { - writer.Write(dimension); - writer.Write(" "); - } + /// + /// Converts Point to WKT format and appends WKT representation to the output stream. + /// + /// The Point to be converted. + /// The output Stream to append WKT representation to. + private static void AppendPointTaggedText(IPoint point, TextWriter writer) + { + writer.Write("point "); - WktWriter.AppendPointText(point, writer); + string dimension = WktWriter.GetDimensionText(point); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); } - /// - /// Converts Point's content to WKT format and appends it to the output stream. - /// - /// The Point to be converted. - /// The output Stream to append WKT representation to. - private static void AppendPointText(IPoint point, TextWriter writer) + WktWriter.AppendPointText(point, writer); + } + + /// + /// Converts Point's content to WKT format and appends it to the output stream. + /// + /// The Point to be converted. + /// The output Stream to append WKT representation to. + private static void AppendPointText(IPoint point, TextWriter writer) + { + if (point.Position.Equals(Coordinate.Empty)) { - if (point.Position.Equals(Coordinate.Empty)) - { - writer.Write("empty"); - } - else - { - writer.Write("("); - WktWriter.AppendCoordinate(point.Position, writer); - writer.Write(")"); - } + writer.Write("empty"); } - - /// - /// Converts LineString to WKT format and appends WKT representation to the output stream. - /// - /// The LineString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendLineStringTaggedText(ILineString linestring, TextWriter writer) + else { - writer.Write("linestring "); + writer.Write("("); + WktWriter.AppendCoordinate(point.Position, writer); + writer.Write(")"); + } + } - string dimension = WktWriter.GetDimensionText(linestring); - if (string.IsNullOrEmpty(dimension) == false) - { - writer.Write(dimension); - writer.Write(" "); - } + /// + /// Converts LineString to WKT format and appends WKT representation to the output stream. + /// + /// The LineString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendLineStringTaggedText(ILineString linestring, TextWriter writer) + { + writer.Write("linestring "); - WktWriter.AppendLineStringText(linestring, writer); + string dimension = WktWriter.GetDimensionText(linestring); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); } - /// - /// Converts LineString's content to WKT and appends it to the output stream. - /// - /// The LineString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendLineStringText(ILineString linestring, TextWriter writer) + WktWriter.AppendLineStringText(linestring, writer); + } + + /// + /// Converts LineString's content to WKT and appends it to the output stream. + /// + /// The LineString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendLineStringText(ILineString linestring, TextWriter writer) + { + if (linestring.Coordinates.Count == 0) { - if (linestring.Coordinates.Count == 0) - { - writer.Write("empty"); - } - else - { - WktWriter.AppendCoordinates(linestring.Coordinates, writer, true); - } + writer.Write("empty"); } - - /// - /// Converts Polygon to WKT format and appends WKT representation to the output stream. - /// - /// The Polygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendPolygonTaggedText(IPolygon polygon, TextWriter writer) + else { - writer.Write("polygon "); + WktWriter.AppendCoordinates(linestring.Coordinates, writer, true); + } + } - string dimension = WktWriter.GetDimensionText(polygon); - if (string.IsNullOrEmpty(dimension) == false) - { - writer.Write(dimension); - writer.Write(" "); - } + /// + /// Converts Polygon to WKT format and appends WKT representation to the output stream. + /// + /// The Polygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendPolygonTaggedText(IPolygon polygon, TextWriter writer) + { + writer.Write("polygon "); - WktWriter.AppendPolygonText(polygon, writer); + string dimension = WktWriter.GetDimensionText(polygon); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); } - /// - /// Converts Polygon's content to WKT format and appends WKT representation to the output stream. - /// - /// The Polygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendPolygonText(IPolygon polygon, TextWriter writer) + WktWriter.AppendPolygonText(polygon, writer); + } + + /// + /// Converts Polygon's content to WKT format and appends WKT representation to the output stream. + /// + /// The Polygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendPolygonText(IPolygon polygon, TextWriter writer) + { + if (polygon.ExteriorRing.Count == 0) { - if (polygon.ExteriorRing.Count == 0) - { - writer.Write("empty"); - } - else + writer.Write("empty"); + } + else + { + writer.Write("("); + WktWriter.AppendCoordinates(polygon.ExteriorRing, writer, true); + + if (polygon.InteriorRings.Count() > 0) { - writer.Write("("); - WktWriter.AppendCoordinates(polygon.ExteriorRing, writer, true); + writer.Write(","); + WktWriter.AppendCoordinates(polygon.InteriorRings.First(), writer, true); - if (polygon.InteriorRings.Count() > 0) + foreach (var ring in polygon.InteriorRings.Skip(1)) { writer.Write(","); - WktWriter.AppendCoordinates(polygon.InteriorRings.First(), writer, true); - - foreach (var ring in polygon.InteriorRings.Skip(1)) - { - writer.Write(","); - WktWriter.AppendCoordinates(ring, writer, true); - } + WktWriter.AppendCoordinates(ring, writer, true); } - - writer.Write(")"); } + + writer.Write(")"); } + } + + /// + /// Converts MultiPoint to WKT format and appends WKT representation to the output stream. + /// + /// The MultiPoint to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPointTaggedText(IMultiPoint multipoint, TextWriter writer) + { + writer.Write("multipoint "); - /// - /// Converts MultiPoint to WKT format and appends WKT representation to the output stream. - /// - /// The MultiPoint to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPointTaggedText(IMultiPoint multipoint, TextWriter writer) + string dimension = WktWriter.GetDimensionText(multipoint); + if (string.IsNullOrEmpty(dimension) == false) { - writer.Write("multipoint "); + writer.Write(dimension); + writer.Write(" "); + } - string dimension = WktWriter.GetDimensionText(multipoint); - if (string.IsNullOrEmpty(dimension) == false) - { - writer.Write(dimension); - writer.Write(" "); - } + WktWriter.AppendMultiPointText(multipoint, writer); + } - WktWriter.AppendMultiPointText(multipoint, writer); + /// + /// Converts MultiPoint's content to WKT format and appends WKT representation to the output stream. + /// + /// The MultiPoint to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPointText(IMultiPoint multipoint, TextWriter writer) + { + if (multipoint.Geometries.Count() == 0) + { + writer.Write("empty"); } - - /// - /// Converts MultiPoint's content to WKT format and appends WKT representation to the output stream. - /// - /// The MultiPoint to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPointText(IMultiPoint multipoint, TextWriter writer) + else { - if (multipoint.Geometries.Count() == 0) - { - writer.Write("empty"); - } - else + writer.Write("("); + + if (multipoint.Geometries.Count() > 0) { - writer.Write("("); + WktWriter.AppendPointText(multipoint.Geometries.First(), writer); - if (multipoint.Geometries.Count() > 0) + foreach (var point in multipoint.Geometries.Skip(1)) { - WktWriter.AppendPointText(multipoint.Geometries.First(), writer); - - foreach (var point in multipoint.Geometries.Skip(1)) - { - writer.Write(","); - WktWriter.AppendPointText(point, writer); - } + writer.Write(","); + WktWriter.AppendPointText(point, writer); } - - writer.Write(")"); } + + writer.Write(")"); } + } - /// - /// Converts MultiLineString to WKT format and appends WKT representation to the output stream. - /// - /// The MultiLineString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiLineStringTaggedText(IMultiLineString mls, TextWriter writer) + /// + /// Converts MultiLineString to WKT format and appends WKT representation to the output stream. + /// + /// The MultiLineString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiLineStringTaggedText(IMultiLineString mls, TextWriter writer) + { + writer.Write("multilinestring "); + + string dimension = WktWriter.GetDimensionText(mls); + if (string.IsNullOrEmpty(dimension) == false) { - writer.Write("multilinestring "); + writer.Write(dimension); + writer.Write(" "); + } - string dimension = WktWriter.GetDimensionText(mls); - if (string.IsNullOrEmpty(dimension) == false) - { - writer.Write(dimension); - writer.Write(" "); - } + WktWriter.AppendMultiLineStringText(mls, writer); + } - WktWriter.AppendMultiLineStringText(mls, writer); + /// + /// Converts MultiLineString's content to WKT format and appends WKT representation to the output stream. + /// + /// The MultiLIneString to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiLineStringText(IMultiLineString mls, TextWriter writer) + { + if (mls.Geometries.Count() == 0) + { + writer.Write("empty"); } - - /// - /// Converts MultiLineString's content to WKT format and appends WKT representation to the output stream. - /// - /// The MultiLIneString to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiLineStringText(IMultiLineString mls, TextWriter writer) + else { - if (mls.Geometries.Count() == 0) + writer.Write("("); + + WktWriter.AppendLineStringText(mls.Geometries.First(), writer); + + foreach (var linestring in mls.Geometries.Skip(1)) { - writer.Write("empty"); + writer.Write(","); + WktWriter.AppendLineStringText(linestring, writer); } - else - { - writer.Write("("); - WktWriter.AppendLineStringText(mls.Geometries.First(), writer); + writer.Write(")"); + } + } - foreach (var linestring in mls.Geometries.Skip(1)) - { - writer.Write(","); - WktWriter.AppendLineStringText(linestring, writer); - } + /// + /// Converts MultiPolygon to WKT format and appends WKT representation to the output stream. + /// + /// The Multipolygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPolygonTaggetText(IMultiPolygon mp, TextWriter writer) + { + writer.Write("multipolygon "); - writer.Write(")"); - } + string dimension = WktWriter.GetDimensionText(mp); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); } - /// - /// Converts MultiPolygon to WKT format and appends WKT representation to the output stream. - /// - /// The Multipolygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPolygonTaggetText(IMultiPolygon mp, TextWriter writer) + WktWriter.AppendMultiPolygonText(mp, writer); + } + + /// + /// Converts MultiPolygon's content to WKT format and appends WKT representation to the output stream. + /// + /// The MultiPolygon to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendMultiPolygonText(IMultiPolygon multipolygon, TextWriter writer) + { + if (multipolygon.Geometries.Count() == 0) { - writer.Write("multipolygon "); + writer.Write("empty"); + } + else + { + writer.Write("("); - string dimension = WktWriter.GetDimensionText(mp); - if (string.IsNullOrEmpty(dimension) == false) + WktWriter.AppendPolygonText(multipolygon.Geometries.First(), writer); + + foreach (var polygon in multipolygon.Geometries.Skip(1)) { - writer.Write(dimension); - writer.Write(" "); + writer.Write(","); + WktWriter.AppendPolygonText(polygon, writer); } - WktWriter.AppendMultiPolygonText(mp, writer); + writer.Write(")"); } + } - /// - /// Converts MultiPolygon's content to WKT format and appends WKT representation to the output stream. - /// - /// The MultiPolygon to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendMultiPolygonText(IMultiPolygon multipolygon, TextWriter writer) - { - if (multipolygon.Geometries.Count() == 0) - { - writer.Write("empty"); - } - else - { - writer.Write("("); + /// + /// Converts GeometryCollection to WKT format and appends WKT representation to the output stream. + /// + /// The GeometryCollection be converted. + /// The output Stream to Append WKT representation to. + private static void AppendGeometryCollectionTaggedText(IGeometryCollection collection, TextWriter writer) + { + writer.Write("geometrycollection "); - WktWriter.AppendPolygonText(multipolygon.Geometries.First(), writer); + string dimension = WktWriter.GetDimensionText(collection); + if (string.IsNullOrEmpty(dimension) == false) + { + writer.Write(dimension); + writer.Write(" "); + } - foreach (var polygon in multipolygon.Geometries.Skip(1)) - { - writer.Write(","); - WktWriter.AppendPolygonText(polygon, writer); - } + WktWriter.AppendGeometryCollectionText(collection, writer); + } - writer.Write(")"); - } + /// + /// Converts GeometryCollection's content to WKT format and appends WKT representation to the output stream. + /// + /// The GeometryCollection to be converted. + /// The output Stream to Append WKT representation to. + private static void AppendGeometryCollectionText(IGeometryCollection collection, TextWriter writer) + { + if (collection.Geometries.Count() == 0) + { + writer.Write("empty"); } - - /// - /// Converts GeometryCollection to WKT format and appends WKT representation to the output stream. - /// - /// The GeometryCollection be converted. - /// The output Stream to Append WKT representation to. - private static void AppendGeometryCollectionTaggedText(IGeometryCollection collection, TextWriter writer) + else { - writer.Write("geometrycollection "); + writer.Write("("); + WktWriter.Write(collection.Geometries.First(), writer); - string dimension = WktWriter.GetDimensionText(collection); - if (string.IsNullOrEmpty(dimension) == false) + foreach (var geometry in collection.Geometries.Skip(1)) { - writer.Write(dimension); - writer.Write(" "); + writer.Write(","); + WktWriter.Write(geometry, writer); } - WktWriter.AppendGeometryCollectionText(collection, writer); + writer.Write(")"); } + } - /// - /// Converts GeometryCollection's content to WKT format and appends WKT representation to the output stream. - /// - /// The GeometryCollection to be converted. - /// The output Stream to Append WKT representation to. - private static void AppendGeometryCollectionText(IGeometryCollection collection, TextWriter writer) - { - if (collection.Geometries.Count() == 0) - { - writer.Write("empty"); - } - else - { - writer.Write("("); - WktWriter.Write(collection.Geometries.First(), writer); - - foreach (var geometry in collection.Geometries.Skip(1)) - { - writer.Write(","); - WktWriter.Write(geometry, writer); - } + /// + /// Gets string that represents dimension of the geometry. + /// + /// The geometry to examine. + /// The string representing dimension of the geometry - empty string for 2D geometry, 'm' for measured geometry, 'z' for 3D geometry. + private static string GetDimensionText(IGeometry geometry) + { + string dimension = string.Empty; - writer.Write(")"); - } + if (geometry.Is3D) + { + dimension += "z"; } - /// - /// Gets string that represents dimension of the geometry. - /// - /// The geometry to examine. - /// The string representing dimension of the geometry - empty string for 2D geometry, 'm' for measured geometry, 'z' for 3D geometry. - private static string GetDimensionText(IGeometry geometry) + if (geometry.IsMeasured) { - string dimension = string.Empty; - - if (geometry.Is3D) - { - dimension += "z"; - } - - if (geometry.IsMeasured) - { - dimension += "m"; - } - - return dimension; + dimension += "m"; } - /// - /// Releases the unmanaged resources used by the WktWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + return dimension; + } + + /// + /// Releases the unmanaged resources used by the WktWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!_disposed) { - if (!_disposed) + if (disposing) { - if (disposing) - { - _writer.Dispose(); + _writer.Dispose(); - if (_outputStream != null) - { - _outputStream.Dispose(); - } + if (_outputStream != null) + { + _outputStream.Dispose(); } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Core/IO/WktWriterSettings.cs b/src/SpatialLite.Core/IO/WktWriterSettings.cs index 7c2b381..be193d2 100644 --- a/src/SpatialLite.Core/IO/WktWriterSettings.cs +++ b/src/SpatialLite.Core/IO/WktWriterSettings.cs @@ -1,22 +1,21 @@ -namespace SpatialLite.Core.IO +namespace SpatialLite.Core.IO; + +/// +/// Specifies settings that determine behaviour of the WkbWriter. +/// +public class WktWriterSettings { + /// - /// Specifies settings that determine behaviour of the WkbWriter. + /// Initializes a new instance of the WkbWriterSettings class with default values. /// - public class WktWriterSettings + public WktWriterSettings() + : base() { - - /// - /// Initializes a new instance of the WkbWriterSettings class with default values. - /// - public WktWriterSettings() - : base() - { - } - - /// - /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } } + + /// + /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } } diff --git a/src/SpatialLite.Core/Measurements.cs b/src/SpatialLite.Core/Measurements.cs index 56161af..da6951e 100644 --- a/src/SpatialLite.Core/Measurements.cs +++ b/src/SpatialLite.Core/Measurements.cs @@ -3,207 +3,206 @@ using SpatialLite.Core.API; using SpatialLite.Core.Algorithms; -namespace SpatialLite.Core +namespace SpatialLite.Core; + +/// +/// Provides methods for measuring geometry objects. +/// +public class Measurements { + + private static readonly Measurements _euclidean2D; + private static readonly Measurements _sphere2D; + /// - /// Provides methods for measuring geometry objects. + /// Initializes static members of the Measurements class. /// - public class Measurements + static Measurements() { + _euclidean2D = new Measurements(new Euclidean2DCalculator()); + _sphere2D = new Measurements(new Sphere2DCalculator()); + } - private static readonly Measurements _euclidean2D; - private static readonly Measurements _sphere2D; + /// + /// Initializes a new instance of the Measurements class that uses specific IDistanceCalculator. + /// + /// The IDistance calculator to be used. + public Measurements(IDimensionsCalculator distanceCalculator) + { + this.DimensionsCalculator = distanceCalculator; + } - /// - /// Initializes static members of the Measurements class. - /// - static Measurements() + /// + /// Gets Measurments class instance that uses 2D Euclidean space. + /// + public static Measurements Euclidean2D + { + get { - _euclidean2D = new Measurements(new Euclidean2DCalculator()); - _sphere2D = new Measurements(new Sphere2DCalculator()); + return _euclidean2D; } + } - /// - /// Initializes a new instance of the Measurements class that uses specific IDistanceCalculator. - /// - /// The IDistance calculator to be used. - public Measurements(IDimensionsCalculator distanceCalculator) + /// + /// Gets Measurements class instance that uses sphere approximation of the Earth and ignores Z coordinates. + /// + public static Measurements Sphere2D + { + get { - this.DimensionsCalculator = distanceCalculator; + return _sphere2D; } + } - /// - /// Gets Measurments class instance that uses 2D Euclidean space. - /// - public static Measurements Euclidean2D - { - get - { - return _euclidean2D; - } - } + /// + /// Gets IDistanceCalculator object used by this Measurements to compute dimensions of geometries. + /// + public IDimensionsCalculator DimensionsCalculator { get; private set; } - /// - /// Gets Measurements class instance that uses sphere approximation of the Earth and ignores Z coordinates. - /// - public static Measurements Sphere2D - { - get - { - return _sphere2D; - } - } + /// + /// Computes distance between two points + /// + /// The first point + /// The second point + /// distance between two point + public double ComputeDistance(Coordinate c1, Coordinate c2) + { + return this.DimensionsCalculator.CalculateDistance(c1, c2); + } - /// - /// Gets IDistanceCalculator object used by this Measurements to compute dimensions of geometries. - /// - public IDimensionsCalculator DimensionsCalculator { get; private set; } - - /// - /// Computes distance between two points - /// - /// The first point - /// The second point - /// distance between two point - public double ComputeDistance(Coordinate c1, Coordinate c2) + /// + /// Computes distance of a point from LineString + /// + /// The point + /// The LineString + /// The distance of the point from the LineString + public double ComputeDistance(IPoint point, ILineString linestring) + { + if (point.Position == Coordinate.Empty || linestring.Coordinates.Count == 0) { - return this.DimensionsCalculator.CalculateDistance(c1, c2); + return double.NaN; } - /// - /// Computes distance of a point from LineString - /// - /// The point - /// The LineString - /// The distance of the point from the LineString - public double ComputeDistance(IPoint point, ILineString linestring) + double minDistance = double.PositiveInfinity; + + for (int i = 1; i < linestring.Coordinates.Count; i++) { - if (point.Position == Coordinate.Empty || linestring.Coordinates.Count == 0) + double distance = this.DimensionsCalculator.CalculateDistance(point.Position, linestring.Coordinates[i - 1], linestring.Coordinates[i], LineMode.LineSegment); + if (distance < minDistance) { - return double.NaN; + minDistance = distance; } + } - double minDistance = double.PositiveInfinity; - - for (int i = 1; i < linestring.Coordinates.Count; i++) - { - double distance = this.DimensionsCalculator.CalculateDistance(point.Position, linestring.Coordinates[i - 1], linestring.Coordinates[i], LineMode.LineSegment); - if (distance < minDistance) - { - minDistance = distance; - } - } + return minDistance; + } - return minDistance; + /// + /// Computes distance of a point from MultiLineString + /// + /// The point + /// The MultiLineString + /// The distance of the point from the MultiLineString + public double ComputeDistance(IPoint point, IMultiLineString multilinestring) + { + if (point.Position == Coordinate.Empty || multilinestring.Geometries.Count() == 0) + { + return double.NaN; } - /// - /// Computes distance of a point from MultiLineString - /// - /// The point - /// The MultiLineString - /// The distance of the point from the MultiLineString - public double ComputeDistance(IPoint point, IMultiLineString multilinestring) + double minDistance = double.PositiveInfinity; + foreach (var linestring in multilinestring.Geometries) { - if (point.Position == Coordinate.Empty || multilinestring.Geometries.Count() == 0) - { - return double.NaN; - } - - double minDistance = double.PositiveInfinity; - foreach (var linestring in multilinestring.Geometries) + double distance = this.ComputeDistance(point, linestring); + if (distance < minDistance) { - double distance = this.ComputeDistance(point, linestring); - if (distance < minDistance) - { - minDistance = distance; - } + minDistance = distance; } - - return minDistance; } - /// - /// Computes distance between two points - /// - /// The first point - /// The second point - /// distance between two point - public double ComputeDistance(IPoint p1, IPoint p2) - { - if (p1.Position == Coordinate.Empty || p2.Position == Coordinate.Empty) - { - return double.NaN; - } + return minDistance; + } - return this.DimensionsCalculator.CalculateDistance(p1.Position, p2.Position); + /// + /// Computes distance between two points + /// + /// The first point + /// The second point + /// distance between two point + public double ComputeDistance(IPoint p1, IPoint p2) + { + if (p1.Position == Coordinate.Empty || p2.Position == Coordinate.Empty) + { + return double.NaN; } - /// - /// Compute length of the linestring - /// - /// The linestring to measure - /// The length of the Linestring - public double ComputeLength(ILineString line) - { - double length = 0; - for (int i = 1; i < line.Coordinates.Count; i++) - { - length += this.DimensionsCalculator.CalculateDistance(line.Coordinates[i - 1], line.Coordinates[i]); - } + return this.DimensionsCalculator.CalculateDistance(p1.Position, p2.Position); + } - return length; + /// + /// Compute length of the linestring + /// + /// The linestring to measure + /// The length of the Linestring + public double ComputeLength(ILineString line) + { + double length = 0; + for (int i = 1; i < line.Coordinates.Count; i++) + { + length += this.DimensionsCalculator.CalculateDistance(line.Coordinates[i - 1], line.Coordinates[i]); } - /// - /// Compute length of all linestrings in specific multilinestring - /// - /// The MultiLineString to measure - /// The length of the Linestring - public double ComputeLength(IMultiLineString multilinestring) - { - double length = 0; + return length; + } - foreach (var line in multilinestring.Geometries) - { - length += this.ComputeLength(line); - } + /// + /// Compute length of all linestrings in specific multilinestring + /// + /// The MultiLineString to measure + /// The length of the Linestring + public double ComputeLength(IMultiLineString multilinestring) + { + double length = 0; - return length; + foreach (var line in multilinestring.Geometries) + { + length += this.ComputeLength(line); } - /// - /// Computes area of the Polygon - /// - /// Polygon to be measured - /// The area of the Polygon - public double ComputeArea(IPolygon polygon) - { - double area = this.DimensionsCalculator.CalculateArea(polygon.ExteriorRing); + return length; + } - foreach (var interiorRing in polygon.InteriorRings) - { - area -= this.DimensionsCalculator.CalculateArea(interiorRing); - } + /// + /// Computes area of the Polygon + /// + /// Polygon to be measured + /// The area of the Polygon + public double ComputeArea(IPolygon polygon) + { + double area = this.DimensionsCalculator.CalculateArea(polygon.ExteriorRing); - return area; + foreach (var interiorRing in polygon.InteriorRings) + { + area -= this.DimensionsCalculator.CalculateArea(interiorRing); } - /// - /// Computes area of the MultiPolygon - /// - /// MultiPolygon to be measured - /// The area of the MultiPolygon - public double ComputeArea(IMultiPolygon multiPolygon) - { - double area = 0; + return area; + } - foreach (var polygon in multiPolygon.Geometries) - { - area += this.ComputeArea(polygon); - } + /// + /// Computes area of the MultiPolygon + /// + /// MultiPolygon to be measured + /// The area of the MultiPolygon + public double ComputeArea(IMultiPolygon multiPolygon) + { + double area = 0; - return area; + foreach (var polygon in multiPolygon.Geometries) + { + area += this.ComputeArea(polygon); } + + return area; } } diff --git a/src/SpatialLite.Core/Topology.cs b/src/SpatialLite.Core/Topology.cs index 30b89df..dfcab8c 100644 --- a/src/SpatialLite.Core/Topology.cs +++ b/src/SpatialLite.Core/Topology.cs @@ -3,153 +3,152 @@ using SpatialLite.Core.Algorithms; using SpatialLite.Core.API; -namespace SpatialLite.Core +namespace SpatialLite.Core; + +/// +/// Provides methods for basic topology analysis of geometry objects and relationships among them. +/// +public class Topology { + + private static Topology _euclidean2D; + /// - /// Provides methods for basic topology analysis of geometry objects and relationships among them. + /// Initializes static members of the Topology class. /// - public class Topology + static Topology() { + _euclidean2D = new Topology(new Euclidean2DLocator()); + } - private static Topology _euclidean2D; - - /// - /// Initializes static members of the Topology class. - /// - static Topology() + /// + /// Gets Topology class instance that uses Euclidean2DLocator to determine relationships among geometries. + /// + public static Topology Euclidean2D + { + get { - _euclidean2D = new Topology(new Euclidean2DLocator()); + return _euclidean2D; } + } - /// - /// Gets Topology class instance that uses Euclidean2DLocator to determine relationships among geometries. - /// - public static Topology Euclidean2D + /// + /// Initializes a new instance of the Topology class with specific geometry locator. + /// + /// The IGeometryLocator object to use. + public Topology(IGeometryLocator geometryLocator) + { + if (geometryLocator == null) { - get - { - return _euclidean2D; - } + throw new ArgumentNullException(nameof(geometryLocator), "GeometryLocator can't be null"); } - /// - /// Initializes a new instance of the Topology class with specific geometry locator. - /// - /// The IGeometryLocator object to use. - public Topology(IGeometryLocator geometryLocator) - { - if (geometryLocator == null) - { - throw new ArgumentNullException(nameof(geometryLocator), "GeometryLocator can't be null"); - } + this.GeometryLocator = geometryLocator; + } - this.GeometryLocator = geometryLocator; - } + /// + /// Gets IGeometryLocator that this Topology class instance uses to determine relationships among geometries. + /// + public IGeometryLocator GeometryLocator { get; private set; } - /// - /// Gets IGeometryLocator that this Topology class instance uses to determine relationships among geometries. - /// - public IGeometryLocator GeometryLocator { get; private set; } - - /// - /// Determines whether specific Coordinate is in the given polygon. - /// - /// The coordinate to chec.k - /// The polygon to check coordinate against. - /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. - /// true if coordinate lies inside outer polygon boundary and outside polygon's inner boundaries (holes), otherwise returns false. - public bool IsInside(Coordinate c, IPolygon polygon, bool includeBoundaries) - { - bool insideExterior = this.GeometryLocator.IsInRing(c, polygon.ExteriorRing); + /// + /// Determines whether specific Coordinate is in the given polygon. + /// + /// The coordinate to chec.k + /// The polygon to check coordinate against. + /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. + /// true if coordinate lies inside outer polygon boundary and outside polygon's inner boundaries (holes), otherwise returns false. + public bool IsInside(Coordinate c, IPolygon polygon, bool includeBoundaries) + { + bool insideExterior = this.GeometryLocator.IsInRing(c, polygon.ExteriorRing); - if (insideExterior == false) + if (insideExterior == false) + { + if (includeBoundaries) { - if (includeBoundaries) - { - return this.GeometryLocator.IsOnLine(c, polygon.ExteriorRing); - } - else - { - return false; - } + return this.GeometryLocator.IsOnLine(c, polygon.ExteriorRing); } else { - foreach (var ring in polygon.InteriorRings) - { - if (this.GeometryLocator.IsInRing(c, ring)) - { - return false; - } - else if (includeBoundaries && this.GeometryLocator.IsOnLine(c, ring)) - { - return true; - } - } + return false; } - - return true; } - - /// - /// Determines whether specific Coordinate is in the given multipolygon. - /// - /// The coordinate to check. - /// The multipolygon to check coordinate against. - /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. - /// true if coordinate lies inside any polygon of the given multipolygon, otherwise false. - public bool IsInside(Coordinate c, IMultiPolygon multipolygon, bool includeBoundaries) + else { - foreach (var polygon in multipolygon.Geometries) + foreach (var ring in polygon.InteriorRings) { - if (this.IsInside(c, polygon, includeBoundaries)) + if (this.GeometryLocator.IsInRing(c, ring)) + { + return false; + } + else if (includeBoundaries && this.GeometryLocator.IsOnLine(c, ring)) { return true; } } - - return false; } - /// - /// Determines whether specific Coordinate is on the given polyline. - /// - /// The coordinate to check. - /// The line to check coordinate against. - /// true if coordinate lies on the polyline, otherwise false. - public bool IsOnLine(Coordinate c, ILineString line) - { - return this.GeometryLocator.IsOnLine(c, line.Coordinates); - } + return true; + } - /// - /// Determines whether specific Coordinate in on the given multiline. - /// - /// The coordinate to check. - /// The multiline to check coordinate against. - /// true if coordinate lies on any line of the given multiline, otherwise false. - public bool IsOnLine(Coordinate c, IMultiLineString multiline) + /// + /// Determines whether specific Coordinate is in the given multipolygon. + /// + /// The coordinate to check. + /// The multipolygon to check coordinate against. + /// bool values that specifies whether points on boundaries of the polygon should be considered as inside. + /// true if coordinate lies inside any polygon of the given multipolygon, otherwise false. + public bool IsInside(Coordinate c, IMultiPolygon multipolygon, bool includeBoundaries) + { + foreach (var polygon in multipolygon.Geometries) { - foreach (var line in multiline.Geometries) + if (this.IsInside(c, polygon, includeBoundaries)) { - if (this.IsOnLine(c, line)) - { - return true; - } + return true; } - - return false; } - /// - /// Determines whether two polylines defined by series of coordinates intersects. - /// - /// The first polyline to test. - /// The second polyline to test. - /// true if polylines intersets, otherwise false. - public bool Intersects(ILineString line1, ILineString line2) + return false; + } + + /// + /// Determines whether specific Coordinate is on the given polyline. + /// + /// The coordinate to check. + /// The line to check coordinate against. + /// true if coordinate lies on the polyline, otherwise false. + public bool IsOnLine(Coordinate c, ILineString line) + { + return this.GeometryLocator.IsOnLine(c, line.Coordinates); + } + + /// + /// Determines whether specific Coordinate in on the given multiline. + /// + /// The coordinate to check. + /// The multiline to check coordinate against. + /// true if coordinate lies on any line of the given multiline, otherwise false. + public bool IsOnLine(Coordinate c, IMultiLineString multiline) + { + foreach (var line in multiline.Geometries) { - return this.GeometryLocator.Intersects(line1.Coordinates, line2.Coordinates); + if (this.IsOnLine(c, line)) + { + return true; + } } + + return false; + } + + /// + /// Determines whether two polylines defined by series of coordinates intersects. + /// + /// The first polyline to test. + /// The second polyline to test. + /// true if polylines intersets, otherwise false. + public bool Intersects(ILineString line1, ILineString line2) + { + return this.GeometryLocator.Intersects(line1.Coordinates, line2.Coordinates); } } diff --git a/src/SpatialLite.Gps/Geometries/GpsFix.cs b/src/SpatialLite.Gps/Geometries/GpsFix.cs index ab0a184..82e65d0 100644 --- a/src/SpatialLite.Gps/Geometries/GpsFix.cs +++ b/src/SpatialLite.Gps/Geometries/GpsFix.cs @@ -1,33 +1,32 @@ -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Defines type of the GPS fix +/// +public enum GpsFix { /// - /// Defines type of the GPS fix + /// No fix /// - public enum GpsFix - { - /// - /// No fix - /// - None, + None, - /// - /// Position only - /// - Fix2D, + /// + /// Position only + /// + Fix2D, - /// - /// Position and elevation - /// - Fix3D, + /// + /// Position and elevation + /// + Fix3D, - /// - /// Differential GPS - /// - Dgps, + /// + /// Differential GPS + /// + Dgps, - /// - /// Military signal used - /// - Pps - } + /// + /// Military signal used + /// + Pps } diff --git a/src/SpatialLite.Gps/Geometries/GpsPoint.cs b/src/SpatialLite.Gps/Geometries/GpsPoint.cs index 5dc2015..bb1049e 100644 --- a/src/SpatialLite.Gps/Geometries/GpsPoint.cs +++ b/src/SpatialLite.Gps/Geometries/GpsPoint.cs @@ -2,57 +2,56 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Represents location on the earth surface with timestamp that defines time when the point was recorded +/// +public class GpsPoint : Point, IGpsPoint { + /// - /// Represents location on the earth surface with timestamp that defines time when the point was recorded + /// Creates a new, empty instance of the GpsPoint /// - public class GpsPoint : Point, IGpsPoint + public GpsPoint() { + } - /// - /// Creates a new, empty instance of the GpsPoint - /// - public GpsPoint() - { - } - - /// - /// Creates a new instance of the GpsPoint with given position - /// - /// The position of the point - public GpsPoint(Coordinate position) - : base(position) - { - } - - /// - /// Creates a new instance of the GpsPoint with given coordinates and timestamp - /// - /// The longitude of the point - /// The latitude of the point - /// The elevation of the point - /// The time when the point was recorded - public GpsPoint(double longitude, double latitude, double elevation, DateTime time) - : base(longitude, latitude, elevation) - { - Timestamp = time; - } + /// + /// Creates a new instance of the GpsPoint with given position + /// + /// The position of the point + public GpsPoint(Coordinate position) + : base(position) + { + } - /// - /// Creates a new instance of the GpsPoint with given position and time - /// - /// The position of the point - /// The time when the point was recorded - public GpsPoint(Coordinate position, DateTime time) - : base(position) - { - Timestamp = time; - } + /// + /// Creates a new instance of the GpsPoint with given coordinates and timestamp + /// + /// The longitude of the point + /// The latitude of the point + /// The elevation of the point + /// The time when the point was recorded + public GpsPoint(double longitude, double latitude, double elevation, DateTime time) + : base(longitude, latitude, elevation) + { + Timestamp = time; + } - /// - /// Gets or sets time when the point was recorded. - /// - public DateTime? Timestamp { get; set; } + /// + /// Creates a new instance of the GpsPoint with given position and time + /// + /// The position of the point + /// The time when the point was recorded + public GpsPoint(Coordinate position, DateTime time) + : base(position) + { + Timestamp = time; } + + /// + /// Gets or sets time when the point was recorded. + /// + public DateTime? Timestamp { get; set; } } diff --git a/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs b/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs index 505c627..8147326 100644 --- a/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs +++ b/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs @@ -2,47 +2,46 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Represents base class for Gps tracks +/// +/// The type of the Gps points +public class GpsTrackBase : LineString where T : IGpsPoint { + private ICoordinateList _coordinatesAdapter; + /// - /// Represents base class for Gps tracks + /// Creates a new instance of the GpsTrackBase class /// - /// The type of the Gps points - public class GpsTrackBase : LineString where T : IGpsPoint + public GpsTrackBase() : this(new T[] { }) { - private ICoordinateList _coordinatesAdapter; - - /// - /// Creates a new instance of the GpsTrackBase class - /// - public GpsTrackBase() : this(new T[] { }) - { - } + } - /// - /// Creates a new instance of GpsTrackBase with given points - /// - /// The points of the track - public GpsTrackBase(IEnumerable points) - { - this.Points = new List(points); - _coordinatesAdapter = new ReadOnlyCoordinateList(this.Points); - } + /// + /// Creates a new instance of GpsTrackBase with given points + /// + /// The points of the track + public GpsTrackBase(IEnumerable points) + { + this.Points = new List(points); + _coordinatesAdapter = new ReadOnlyCoordinateList(this.Points); + } - /// - /// Gets the collection of track points of this track - /// - public List Points { get; private set; } + /// + /// Gets the collection of track points of this track + /// + public List Points { get; private set; } - /// - /// Gets the list of çoordinates of this track. - /// - public override ICoordinateList Coordinates + /// + /// Gets the list of çoordinates of this track. + /// + public override ICoordinateList Coordinates + { + get { - get - { - return _coordinatesAdapter; - } + return _coordinatesAdapter; } } } diff --git a/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs b/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs index 6a18c74..82141f8 100644 --- a/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs +++ b/src/SpatialLite.Gps/Geometries/GpxFixHelper.cs @@ -1,46 +1,45 @@ -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Contains helper function for parsing / formating GpxFix enum +/// +public static class GpxFixHelper { /// - /// Contains helper function for parsing / formating GpxFix enum + /// Converts string representation of the GpsFix to it's GpxFix enum equivalent. /// - public static class GpxFixHelper + /// A string containing a value to convert + /// A GpxFix enum equivalent of the s parameter or null if s can not be converted to GpsFix enum + /// ParseGpsFix should be used instead Enum.Parse function becouse string representation of the GpsFix values do not equal to their names. + public static GpsFix? ParseGpsFix(string s) { - /// - /// Converts string representation of the GpsFix to it's GpxFix enum equivalent. - /// - /// A string containing a value to convert - /// A GpxFix enum equivalent of the s parameter or null if s can not be converted to GpsFix enum - /// ParseGpsFix should be used instead Enum.Parse function becouse string representation of the GpsFix values do not equal to their names. - public static GpsFix? ParseGpsFix(string s) + switch (s) { - switch (s) - { - case "none": return GpsFix.None; - case "2d": return GpsFix.Fix2D; - case "3d": return GpsFix.Fix3D; - case "dgps": return GpsFix.Dgps; - case "pps": return GpsFix.Pps; - default: return null; - } + case "none": return GpsFix.None; + case "2d": return GpsFix.Fix2D; + case "3d": return GpsFix.Fix3D; + case "dgps": return GpsFix.Dgps; + case "pps": return GpsFix.Pps; + default: return null; } + } - /// - /// Converts GpsFix enum value to it's string equivalent - /// - /// A GpxFix value to convert - /// A string equivalent of the fix parameter - /// ConvertGpsFixToString shoul be used instead ToString() function becouse string representation of the GpsFix values if GPX schema do not equal to their names. - public static string GpsFixToString(GpsFix fix) + /// + /// Converts GpsFix enum value to it's string equivalent + /// + /// A GpxFix value to convert + /// A string equivalent of the fix parameter + /// ConvertGpsFixToString shoul be used instead ToString() function becouse string representation of the GpsFix values if GPX schema do not equal to their names. + public static string GpsFixToString(GpsFix fix) + { + switch (fix) { - switch (fix) - { - case GpsFix.None: return "none"; - case GpsFix.Fix2D: return "2d"; - case GpsFix.Fix3D: return "3d"; - case GpsFix.Dgps: return "dgps"; - case GpsFix.Pps: return "pps"; - default: return null; - } + case GpsFix.None: return "none"; + case GpsFix.Fix2D: return "2d"; + case GpsFix.Fix3D: return "3d"; + case GpsFix.Dgps: return "dgps"; + case GpsFix.Pps: return "pps"; + default: return null; } } } diff --git a/src/SpatialLite.Gps/Geometries/GpxLink.cs b/src/SpatialLite.Gps/Geometries/GpxLink.cs index 0e90bb8..14dfd59 100644 --- a/src/SpatialLite.Gps/Geometries/GpxLink.cs +++ b/src/SpatialLite.Gps/Geometries/GpxLink.cs @@ -1,35 +1,34 @@ using System; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Represents a link to an external resource (Web page, digital photo, video clip, etc) with additional information. +/// +public class GpxLink { + /// - /// Represents a link to an external resource (Web page, digital photo, video clip, etc) with additional information. + /// Gets the URL of the link /// - public class GpxLink - { + public Uri Url { get; set; } - /// - /// Gets the URL of the link - /// - public Uri Url { get; set; } - - /// - /// Gets the text of the hyperlink - /// - public string Text { get; set; } + /// + /// Gets the text of the hyperlink + /// + public string Text { get; set; } - /// - /// Gets the mime type of the linked content - /// - public string Type { get; set; } + /// + /// Gets the mime type of the linked content + /// + public string Type { get; set; } - /// - /// Creates a new instance of the GpxLink with given url - /// - /// The url of the link - public GpxLink(Uri url) - { - Url = url; - } + /// + /// Creates a new instance of the GpxLink with given url + /// + /// The url of the link + public GpxLink(Uri url) + { + Url = url; } } diff --git a/src/SpatialLite.Gps/Geometries/GpxMetadata.cs b/src/SpatialLite.Gps/Geometries/GpxMetadata.cs index b44a335..ec162d5 100644 --- a/src/SpatialLite.Gps/Geometries/GpxMetadata.cs +++ b/src/SpatialLite.Gps/Geometries/GpxMetadata.cs @@ -1,43 +1,42 @@ using System.Collections.Generic; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Contains additional information about Gpx entity +/// +public abstract class GpxMetadata { /// - /// Contains additional information about Gpx entity - /// - public abstract class GpxMetadata - { - /// /// Gets or sets the name of the entity /// public string Name { get; set; } - /// - /// Gets or sets the comment for the entity - /// - public string Comment { get; set; } + /// + /// Gets or sets the comment for the entity + /// + public string Comment { get; set; } - /// - /// Gets or sets the description of the entity. Holds additional information about the element intended for the user, not the GPS. - /// - public string Description { get; set; } + /// + /// Gets or sets the description of the entity. Holds additional information about the element intended for the user, not the GPS. + /// + public string Description { get; set; } - /// - /// Gets or sets the source of the data. Included to give user some idea of reliability and accuracy of data. - /// - public string Source { get; set; } + /// + /// Gets or sets the source of the data. Included to give user some idea of reliability and accuracy of data. + /// + public string Source { get; set; } - /// - /// Get or sets the list of link associated with the entity - /// - public ICollection Links { get; set; } + /// + /// Get or sets the list of link associated with the entity + /// + public ICollection Links { get; set; } - /// - /// Creates a new instance of the GpxMetadata class and initializes it's properties to default values. - /// - protected GpxMetadata() - { - Links = new List(); - } + /// + /// Creates a new instance of the GpxMetadata class and initializes it's properties to default values. + /// + protected GpxMetadata() + { + Links = new List(); } } diff --git a/src/SpatialLite.Gps/Geometries/GpxPoint.cs b/src/SpatialLite.Gps/Geometries/GpxPoint.cs index 7111b2f..98bd2b4 100644 --- a/src/SpatialLite.Gps/Geometries/GpxPoint.cs +++ b/src/SpatialLite.Gps/Geometries/GpxPoint.cs @@ -1,64 +1,63 @@ using System; using SpatialLite.Core.API; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Represents a Gpx point +/// +public class GpxPoint : GpsPoint, IGpxGeometry { + /// - /// Represents a Gpx point + /// Creates a new, empty instance of the GpxPoint /// - public class GpxPoint : GpsPoint, IGpxGeometry + public GpxPoint() { + } - /// - /// Creates a new, empty instance of the GpxPoint - /// - public GpxPoint() - { - } - - /// - /// Creates a new instance of the GpxPoint with given position - /// - /// The position of the point - public GpxPoint(Coordinate position) - : base(position) - { - } + /// + /// Creates a new instance of the GpxPoint with given position + /// + /// The position of the point + public GpxPoint(Coordinate position) + : base(position) + { + } - /// - /// Creates a new instance of the GpxPoint with given coordinates and timestamp - /// - /// The longitude of the point - /// The latitude of the point - /// The elevation of the point - /// The time when the point was recorded - public GpxPoint(double longitude, double latitude, double elevation, DateTime time) - : base(longitude, latitude, elevation, time) - { - } + /// + /// Creates a new instance of the GpxPoint with given coordinates and timestamp + /// + /// The longitude of the point + /// The latitude of the point + /// The elevation of the point + /// The time when the point was recorded + public GpxPoint(double longitude, double latitude, double elevation, DateTime time) + : base(longitude, latitude, elevation, time) + { + } - /// - /// Creates a new instance of the GpxPoint with given position and time - /// - /// The position of the point - /// The time when the point was recorded - public GpxPoint(Coordinate position, DateTime time) - : base(position) - { - Timestamp = time; - } + /// + /// Creates a new instance of the GpxPoint with given position and time + /// + /// The position of the point + /// The time when the point was recorded + public GpxPoint(Coordinate position, DateTime time) + : base(position) + { + Timestamp = time; + } - /// - /// Gets or sets additional information about point - /// - public GpxPointMetadata Metadata { get; set; } + /// + /// Gets or sets additional information about point + /// + public GpxPointMetadata Metadata { get; set; } - /// - /// Get the type of geometry - /// - public GpxGeometryType GeometryType - { - get { return GpxGeometryType.Waypoint; } - } + /// + /// Get the type of geometry + /// + public GpxGeometryType GeometryType + { + get { return GpxGeometryType.Waypoint; } } } diff --git a/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs b/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs index 7570d7c..c9c4b4f 100644 --- a/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs +++ b/src/SpatialLite.Gps/Geometries/GpxPointMetadata.cs @@ -1,58 +1,57 @@ -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Contains additional information about Gpx point +/// +public class GpxPointMetadata : GpxMetadata { /// - /// Contains additional information about Gpx point - /// - public class GpxPointMetadata : GpxMetadata - { - /// - /// Gets or sets magnetic variation (in degrees) at the point - /// - public double? MagVar { get; set; } - - /// - /// Gets or sets height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message. - /// - public double? GeoidHeight { get; set; } - - /// - /// Gets or sets text of GPS symbol name. - /// - public string Symbol { get; set; } - - /// - /// Gets or sets type of the Gps fix. To signify "the fix info is unknown", set value to null. - /// - public GpsFix? Fix { get; set; } - - /// - /// Gets or sets number of satellites used to calculate the GPX fix. - /// - public int? SatellitesCount { get; set; } - - /// - /// Gets or sets horizontal dilution of precision. - /// - public double? Hdop { get; set; } - - /// - /// Gets or sets vertical dilution of precision. - /// - public double? Vdop { get; set; } - - /// - /// Gets or sets position dilution of precision. - /// - public double? Pdop { get; set; } - - /// - /// Gets or sets age of DGPS data - a number of seconds since last DGPS update. - /// - public double? AgeOfDgpsData { get; set; } - - /// - /// Gets or sets ID of DGPS station used in differential correction. - /// - public int? DgpsId { get; set; } - } + /// Gets or sets magnetic variation (in degrees) at the point + /// + public double? MagVar { get; set; } + + /// + /// Gets or sets height (in meters) of geoid (mean sea level) above WGS84 earth ellipsoid. As defined in NMEA GGA message. + /// + public double? GeoidHeight { get; set; } + + /// + /// Gets or sets text of GPS symbol name. + /// + public string Symbol { get; set; } + + /// + /// Gets or sets type of the Gps fix. To signify "the fix info is unknown", set value to null. + /// + public GpsFix? Fix { get; set; } + + /// + /// Gets or sets number of satellites used to calculate the GPX fix. + /// + public int? SatellitesCount { get; set; } + + /// + /// Gets or sets horizontal dilution of precision. + /// + public double? Hdop { get; set; } + + /// + /// Gets or sets vertical dilution of precision. + /// + public double? Vdop { get; set; } + + /// + /// Gets or sets position dilution of precision. + /// + public double? Pdop { get; set; } + + /// + /// Gets or sets age of DGPS data - a number of seconds since last DGPS update. + /// + public double? AgeOfDgpsData { get; set; } + + /// + /// Gets or sets ID of DGPS station used in differential correction. + /// + public int? DgpsId { get; set; } } diff --git a/src/SpatialLite.Gps/Geometries/GpxRoute.cs b/src/SpatialLite.Gps/Geometries/GpxRoute.cs index 6c70e9e..8ac4dbd 100644 --- a/src/SpatialLite.Gps/Geometries/GpxRoute.cs +++ b/src/SpatialLite.Gps/Geometries/GpxRoute.cs @@ -1,40 +1,39 @@ using System.Collections.Generic; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Represents route - an ordered list of waypoints representing a series of turn points leading to a destination. +/// +public class GpxRoute : GpxTrackSegment, IGpxGeometry { /// - /// Represents route - an ordered list of waypoints representing a series of turn points leading to a destination. + /// Get or sets additional info about the route /// - public class GpxRoute : GpxTrackSegment, IGpxGeometry - { - /// - /// Get or sets additional info about the route - /// - public GpxTrackMetadata Metadata { get; set; } + public GpxTrackMetadata Metadata { get; set; } - /// - /// Get the type of geometry - /// - public GpxGeometryType GeometryType - { - get { return GpxGeometryType.Route; } - } + /// + /// Get the type of geometry + /// + public GpxGeometryType GeometryType + { + get { return GpxGeometryType.Route; } + } - /// - /// Creates a new, empty instance of the GpxRoute class - /// - public GpxRoute() - : base() - { - } + /// + /// Creates a new, empty instance of the GpxRoute class + /// + public GpxRoute() + : base() + { + } - /// - /// Creates a new instance of the GpxRoute class with given points - /// - /// The points to be added to the route - public GpxRoute(IEnumerable points) - : base(points) - { - } + /// + /// Creates a new instance of the GpxRoute class with given points + /// + /// The points to be added to the route + public GpxRoute(IEnumerable points) + : base(points) + { } } diff --git a/src/SpatialLite.Gps/Geometries/GpxTrack.cs b/src/SpatialLite.Gps/Geometries/GpxTrack.cs index 5b92815..e83b354 100644 --- a/src/SpatialLite.Gps/Geometries/GpxTrack.cs +++ b/src/SpatialLite.Gps/Geometries/GpxTrack.cs @@ -1,42 +1,41 @@ using System.Collections.Generic; using SpatialLite.Core.Geometries; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Represents a track - an ordered list of points describing a path. Points can be gouped in more GpxTrackSegments. +/// +public class GpxTrack : GeometryCollection, IGpxGeometry { + /// - /// Represents a track - an ordered list of points describing a path. Points can be gouped in more GpxTrackSegments. + /// Creates a new, empty instance of the GpxTrack class instance. /// - public class GpxTrack : GeometryCollection, IGpxGeometry + public GpxTrack() + : base() { + } - /// - /// Creates a new, empty instance of the GpxTrack class instance. - /// - public GpxTrack() - : base() - { - } - - /// - /// Creates a new instance of the GpxTrack with given segments - /// - /// The segments to add into track - public GpxTrack(IEnumerable segments) - : base(segments) - { - } + /// + /// Creates a new instance of the GpxTrack with given segments + /// + /// The segments to add into track + public GpxTrack(IEnumerable segments) + : base(segments) + { + } - /// - /// Get or sets additional info about GPX entity - /// - public GpxTrackMetadata Metadata { get; set; } + /// + /// Get or sets additional info about GPX entity + /// + public GpxTrackMetadata Metadata { get; set; } - /// - /// Get the type of geometry - /// - public GpxGeometryType GeometryType - { - get { return GpxGeometryType.Track; } - } + /// + /// Get the type of geometry + /// + public GpxGeometryType GeometryType + { + get { return GpxGeometryType.Track; } } } diff --git a/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs b/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs index fd90c8d..8886cfb 100644 --- a/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs +++ b/src/SpatialLite.Gps/Geometries/GpxTrackMetadata.cs @@ -1,13 +1,12 @@ -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Contains additional information about Gpx tracks and routes +/// +public class GpxTrackMetadata : GpxMetadata { /// - /// Contains additional information about Gpx tracks and routes + /// Gets or sets yype (classification) of route. /// - public class GpxTrackMetadata : GpxMetadata - { - /// - /// Gets or sets yype (classification) of route. - /// - public string Type { get; set; } - } + public string Type { get; set; } } diff --git a/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs b/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs index 0c637fd..a6caef1 100644 --- a/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs +++ b/src/SpatialLite.Gps/Geometries/GpxTrackSegment.cs @@ -1,30 +1,28 @@ using System.Collections.Generic; -namespace SpatialLite.Gps.Geometries +namespace SpatialLite.Gps.Geometries; + +/// +/// Holds a list of track points which are logically connected in order. +/// +/// +/// To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data. +/// +public class GpxTrackSegment : GpsTrackBase { /// - /// Holds a list of track points which are logically connected in order. + /// Creates a new instance of the empty GpxTrackSegment /// - /// - /// To represent a single GPS track where GPS reception was lost, or the GPS receiver was turned off, start a new Track Segment for each continuous span of track data. - /// - public class GpxTrackSegment : GpsTrackBase + public GpxTrackSegment() { - /// - /// Creates a new instance of the empty GpxTrackSegment - /// - public GpxTrackSegment() - { - } - - /// - /// Creates a new instance of GpxTrackSegment with given points - /// - /// The points of the track segment - public GpxTrackSegment(IEnumerable points) - : base(points) - { - } } + /// + /// Creates a new instance of GpxTrackSegment with given points + /// + /// The points of the track segment + public GpxTrackSegment(IEnumerable points) + : base(points) + { + } } diff --git a/src/SpatialLite.Gps/GpxDocument.cs b/src/SpatialLite.Gps/GpxDocument.cs index f6b60e1..046fe6b 100644 --- a/src/SpatialLite.Gps/GpxDocument.cs +++ b/src/SpatialLite.Gps/GpxDocument.cs @@ -3,140 +3,139 @@ using SpatialLite.Gps.Geometries; using SpatialLite.Gps.IO; -namespace SpatialLite.Gps +namespace SpatialLite.Gps; + +/// +/// Represents an in-memory GPX document with it's waypoints, routes and tracks +/// +public class GpxDocument { /// - /// Represents an in-memory GPX document with it's waypoints, routes and tracks + /// Initializes a new instance of the GpxDocument class that is empty + /// + public GpxDocument() + { + this.Waypoints = new List(); + this.Routes = new List(); + this.Tracks = new List(); + } + + /// + /// Initializes a new instance of the GpxDocument class with given GPX entities /// - public class GpxDocument + /// A collection of waypoints to add to the document. + /// A collection of routes to add to the document. + /// A collection of tracks to add to the document. + public GpxDocument(IEnumerable waypoints, IEnumerable routes, IEnumerable tracks) { - /// - /// Initializes a new instance of the GpxDocument class that is empty - /// - public GpxDocument() + this.Waypoints = new List(waypoints); + this.Routes = new List(routes); + this.Tracks = new List(tracks); + } + + /// + /// Gets collection of waypoints from the document. + /// + public List Waypoints { get; private set; } + + /// + /// Gets collection of routes from the document. + /// + public List Routes { get; private set; } + + /// + /// Gets collection of tracks from the document. + /// + public List Tracks { get; private set; } + + /// + /// Saves content of the GpxDocument to file. + /// + /// Path to the file. + public void Save(string path) + { + using (GpxWriter writer = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = true })) { - this.Waypoints = new List(); - this.Routes = new List(); - this.Tracks = new List(); + this.Save(writer); } + } - /// - /// Initializes a new instance of the GpxDocument class with given GPX entities - /// - /// A collection of waypoints to add to the document. - /// A collection of routes to add to the document. - /// A collection of tracks to add to the document. - public GpxDocument(IEnumerable waypoints, IEnumerable routes, IEnumerable tracks) + /// + /// Saves content of the GpxDocument using suplied writer. + /// + /// GpxWriter to be used + public void Save(IGpxWriter writer) + { + if (writer == null) { - this.Waypoints = new List(waypoints); - this.Routes = new List(routes); - this.Tracks = new List(tracks); + throw new ArgumentNullException(nameof(writer)); } - /// - /// Gets collection of waypoints from the document. - /// - public List Waypoints { get; private set; } - - /// - /// Gets collection of routes from the document. - /// - public List Routes { get; private set; } - - /// - /// Gets collection of tracks from the document. - /// - public List Tracks { get; private set; } - - /// - /// Saves content of the GpxDocument to file. - /// - /// Path to the file. - public void Save(string path) + foreach (var waypoint in this.Waypoints) { - using (GpxWriter writer = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = true })) - { - this.Save(writer); - } + writer.Write(waypoint); } - /// - /// Saves content of the GpxDocument using suplied writer. - /// - /// GpxWriter to be used - public void Save(IGpxWriter writer) + foreach (var route in this.Routes) { - if (writer == null) - { - throw new ArgumentNullException(nameof(writer)); - } - - foreach (var waypoint in this.Waypoints) - { - writer.Write(waypoint); - } - - foreach (var route in this.Routes) - { - writer.Write(route); - } - - foreach (var track in this.Tracks) - { - writer.Write(track); - } + writer.Write(route); } - /// - /// Loads Gpx data from reader to this instance of the GpxDocument class - /// - /// The reader to read data from - private void LoadFromReader(IGpxReader reader) + foreach (var track in this.Tracks) { - IGpxGeometry geometry = null; - while ((geometry = reader.Read()) != null) - { - switch (geometry.GeometryType) - { - case GpxGeometryType.Waypoint: this.Waypoints.Add((GpxPoint)geometry); break; - case GpxGeometryType.Route: this.Routes.Add((GpxRoute)geometry); break; - case GpxGeometryType.Track: this.Tracks.Add((GpxTrack)geometry); break; - } - } + writer.Write(track); } + } - /// - /// Loads Gpx data from a file. - /// - /// Path to the GPX file. - /// GpxDocument instance with data from GPX file - public static GpxDocument Load(string path) + /// + /// Loads Gpx data from reader to this instance of the GpxDocument class + /// + /// The reader to read data from + private void LoadFromReader(IGpxReader reader) + { + IGpxGeometry geometry = null; + while ((geometry = reader.Read()) != null) { - GpxDocument result = new GpxDocument(); - - using (GpxReader reader = new GpxReader(path, new GpxReaderSettings() { ReadMetadata = true })) + switch (geometry.GeometryType) { - result.LoadFromReader(reader); + case GpxGeometryType.Waypoint: this.Waypoints.Add((GpxPoint)geometry); break; + case GpxGeometryType.Route: this.Routes.Add((GpxRoute)geometry); break; + case GpxGeometryType.Track: this.Tracks.Add((GpxTrack)geometry); break; } - - return result; } + } - /// - /// Loads Gpx data from IGpxReader - /// - /// The reader to read data from - /// GpxDocument instance with data from GpxReader - public static GpxDocument Load(IGpxReader reader) - { - if (reader == null) - { - throw new ArgumentNullException(nameof(reader)); - } + /// + /// Loads Gpx data from a file. + /// + /// Path to the GPX file. + /// GpxDocument instance with data from GPX file + public static GpxDocument Load(string path) + { + GpxDocument result = new GpxDocument(); - GpxDocument result = new GpxDocument(); + using (GpxReader reader = new GpxReader(path, new GpxReaderSettings() { ReadMetadata = true })) + { result.LoadFromReader(reader); - return result; } + + return result; + } + + /// + /// Loads Gpx data from IGpxReader + /// + /// The reader to read data from + /// GpxDocument instance with data from GpxReader + public static GpxDocument Load(IGpxReader reader) + { + if (reader == null) + { + throw new ArgumentNullException(nameof(reader)); + } + + GpxDocument result = new GpxDocument(); + result.LoadFromReader(reader); + return result; } } diff --git a/src/SpatialLite.Gps/GpxGeometryType.cs b/src/SpatialLite.Gps/GpxGeometryType.cs index d2d36ec..04e25f9 100644 --- a/src/SpatialLite.Gps/GpxGeometryType.cs +++ b/src/SpatialLite.Gps/GpxGeometryType.cs @@ -1,23 +1,22 @@ -namespace SpatialLite.Gps +namespace SpatialLite.Gps; + +/// +/// Defines possible types of GpxGeometry +/// +public enum GpxGeometryType { /// - /// Defines possible types of GpxGeometry + /// Waypoint /// - public enum GpxGeometryType - { - /// - /// Waypoint - /// - Waypoint, + Waypoint, - /// - /// Route - /// - Route, + /// + /// Route + /// + Route, - /// - /// Recorder track - /// - Track - } + /// + /// Recorder track + /// + Track } diff --git a/src/SpatialLite.Gps/IGpsPoint.cs b/src/SpatialLite.Gps/IGpsPoint.cs index becc437..0d88f62 100644 --- a/src/SpatialLite.Gps/IGpsPoint.cs +++ b/src/SpatialLite.Gps/IGpsPoint.cs @@ -1,16 +1,15 @@ using System; using SpatialLite.Core.API; -namespace SpatialLite.Gps +namespace SpatialLite.Gps; + +/// +/// Represents location on the earth surface with timestamp that defines time when the point was recorded +/// +public interface IGpsPoint : IPoint { /// - /// Represents location on the earth surface with timestamp that defines time when the point was recorded + /// Gets or sets time when the point was recorded. /// - public interface IGpsPoint : IPoint - { - /// - /// Gets or sets time when the point was recorded. - /// - DateTime? Timestamp { get; set; } - } + DateTime? Timestamp { get; set; } } diff --git a/src/SpatialLite.Gps/IGpxGeometry.cs b/src/SpatialLite.Gps/IGpxGeometry.cs index 3294c47..91b7fd1 100644 --- a/src/SpatialLite.Gps/IGpxGeometry.cs +++ b/src/SpatialLite.Gps/IGpxGeometry.cs @@ -1,15 +1,14 @@ using SpatialLite.Core.API; -namespace SpatialLite.Gps +namespace SpatialLite.Gps; + +/// +/// Defines common properties for all GpxGeometry types +/// +public interface IGpxGeometry : IGeometry { /// - /// Defines common properties for all GpxGeometry types + /// Get the type of geometry /// - public interface IGpxGeometry : IGeometry - { - /// - /// Get the type of geometry - /// - GpxGeometryType GeometryType { get; } - } + GpxGeometryType GeometryType { get; } } diff --git a/src/SpatialLite.Gps/IO/GpxReader.cs b/src/SpatialLite.Gps/IO/GpxReader.cs index 31c44c3..337b394 100644 --- a/src/SpatialLite.Gps/IO/GpxReader.cs +++ b/src/SpatialLite.Gps/IO/GpxReader.cs @@ -3,449 +3,448 @@ using System.Xml; using SpatialLite.Gps.Geometries; -namespace SpatialLite.Gps.IO +namespace SpatialLite.Gps.IO; + +/// +/// Implements data reader that can read GPX data from streams and files. +/// +public class GpxReader : IGpxReader, IDisposable { + + private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + + private bool _disposed = false; + private XmlReader _xmlReader; + /// - /// Implements data reader that can read GPX data from streams and files. + /// Underlaying stream to read data from /// - public class GpxReader : IGpxReader, IDisposable + private Stream _input; + private bool _ownsInputStream = false; + + private bool _insideGpx = false; + + /// + /// Initializes a new instance of the GpxReader class that reads data from the specified file. + /// + /// Path to the .gpx file. + /// The GpxReaderSettings object that determines behaviour of the reader. + public GpxReader(string path, GpxReaderSettings settings) { + _input = new FileStream(path, FileMode.Open, FileAccess.Read); + _ownsInputStream = true; - private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } - private bool _disposed = false; - private XmlReader _xmlReader; + /// + /// Initializes a new instance of the GpxReader class that reads data from the specified stream. + /// + /// The stream with osm xml data. + /// The GpxReaderSettings object that determines behaviour of the reader. + public GpxReader(Stream stream, GpxReaderSettings settings) + { + _input = stream; - /// - /// Underlaying stream to read data from - /// - private Stream _input; - private bool _ownsInputStream = false; + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } - private bool _insideGpx = false; + /// + /// Gets GpxReaderSettings object that determines behaviour of the reader. + /// + public GpxReaderSettings Settings { get; private set; } - /// - /// Initializes a new instance of the GpxReader class that reads data from the specified file. - /// - /// Path to the .gpx file. - /// The GpxReaderSettings object that determines behaviour of the reader. - public GpxReader(string path, GpxReaderSettings settings) - { - _input = new FileStream(path, FileMode.Open, FileAccess.Read); - _ownsInputStream = true; + /// + /// Releases all resources used by the GpxReader. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); + /// + /// Parses next element of the GPX file + /// + public IGpxGeometry Read() + { + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "gpx") == false) + { + switch (_xmlReader.Name) + { + case "wpt": + return ReadPoint("wpt"); + case "trk": + return ReadTrack(); + case "rte": + return ReadRoute(); + default: + _xmlReader.Read(); + break; + } } - /// - /// Initializes a new instance of the GpxReader class that reads data from the specified stream. - /// - /// The stream with osm xml data. - /// The GpxReaderSettings object that determines behaviour of the reader. - public GpxReader(Stream stream, GpxReaderSettings settings) - { - _input = stream; + return null; + } - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); - } + /// + /// Reads a GPX point from the internal XmlReader + /// + /// The name of the surrounding xml element + /// the point parsed from the XmlReader + private GpxPoint ReadPoint(string pointElementName) + { + string latValue = _xmlReader.GetAttribute("lat"); + if (string.IsNullOrEmpty(latValue)) + throw new InvalidDataException("Requested attribute 'lat' not found."); + double lat = double.Parse(latValue, _invariantCulture); - /// - /// Gets GpxReaderSettings object that determines behaviour of the reader. - /// - public GpxReaderSettings Settings { get; private set; } + string lonValue = _xmlReader.GetAttribute("lon"); + if (string.IsNullOrEmpty(lonValue)) + throw new InvalidDataException("Requested attribute 'lon' not found."); + double lon = double.Parse(lonValue, _invariantCulture); - /// - /// Releases all resources used by the GpxReader. - /// - public void Dispose() + double ele = double.NaN; + DateTime timestamp = new DateTime(); + + GpxPointMetadata metadata = null; + if (this.Settings.ReadMetadata) { - Dispose(true); - GC.SuppressFinalize(this); + metadata = new GpxPointMetadata(); } - /// - /// Parses next element of the GPX file - /// - public IGpxGeometry Read() + if (_xmlReader.IsEmptyElement == false) { - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "gpx") == false) + _xmlReader.Read(); + + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == pointElementName) == false) { - switch (_xmlReader.Name) + bool elementParsed = false; + + if (_xmlReader.Name == "ele") { - case "wpt": - return ReadPoint("wpt"); - case "trk": - return ReadTrack(); - case "rte": - return ReadRoute(); - default: - _xmlReader.Read(); - break; + string eleValue = _xmlReader.ReadElementContentAsString(); + ele = double.Parse(eleValue, _invariantCulture); + elementParsed = true; + } + + if (_xmlReader.Name == "time") + { + string timeValue = _xmlReader.ReadElementContentAsString(); + timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture); + elementParsed = true; } - } - return null; + if (this.Settings.ReadMetadata) + { + elementParsed = elementParsed || this.TryReadPointMetadata(metadata); + } + + if (!elementParsed) + { + _xmlReader.Skip(); + } + } } + _xmlReader.Skip(); - /// - /// Reads a GPX point from the internal XmlReader - /// - /// The name of the surrounding xml element - /// the point parsed from the XmlReader - private GpxPoint ReadPoint(string pointElementName) - { - string latValue = _xmlReader.GetAttribute("lat"); - if (string.IsNullOrEmpty(latValue)) - throw new InvalidDataException("Requested attribute 'lat' not found."); - double lat = double.Parse(latValue, _invariantCulture); + GpxPoint result = new GpxPoint(lon, lat, ele, timestamp); + result.Metadata = metadata; + + return result; + } - string lonValue = _xmlReader.GetAttribute("lon"); - if (string.IsNullOrEmpty(lonValue)) - throw new InvalidDataException("Requested attribute 'lon' not found."); - double lon = double.Parse(lonValue, _invariantCulture); + /// + /// Reades a GPX track from the internal XmlReader + /// + /// the track parsed form the XmlReader + private GpxTrack ReadTrack() + { + GpxTrack result = new GpxTrack(); - double ele = double.NaN; - DateTime timestamp = new DateTime(); + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); - GpxPointMetadata metadata = null; + GpxTrackMetadata metadata = null; if (this.Settings.ReadMetadata) { - metadata = new GpxPointMetadata(); + metadata = new GpxTrackMetadata(); } - if (_xmlReader.IsEmptyElement == false) + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trk") == false) { - _xmlReader.Read(); - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == pointElementName) == false) + bool elementParsed = false; + if (_xmlReader.Name == "trkseg") { - bool elementParsed = false; - - if (_xmlReader.Name == "ele") - { - string eleValue = _xmlReader.ReadElementContentAsString(); - ele = double.Parse(eleValue, _invariantCulture); - elementParsed = true; - } - - if (_xmlReader.Name == "time") - { - string timeValue = _xmlReader.ReadElementContentAsString(); - timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture); - elementParsed = true; - } - - if (this.Settings.ReadMetadata) - { - elementParsed = elementParsed || this.TryReadPointMetadata(metadata); - } - - if (!elementParsed) - { - _xmlReader.Skip(); - } + GpxTrackSegment segment = ReadTrackSegment(); + result.Geometries.Add(segment); + elementParsed = true; } - } - _xmlReader.Skip(); - - GpxPoint result = new GpxPoint(lon, lat, ele, timestamp); - result.Metadata = metadata; - - return result; - } - - /// - /// Reades a GPX track from the internal XmlReader - /// - /// the track parsed form the XmlReader - private GpxTrack ReadTrack() - { - GpxTrack result = new GpxTrack(); - - if (_xmlReader.IsEmptyElement == false) - { - _xmlReader.Read(); - GpxTrackMetadata metadata = null; if (this.Settings.ReadMetadata) { - metadata = new GpxTrackMetadata(); + elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); } - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trk") == false) + if (!elementParsed) { - bool elementParsed = false; - if (_xmlReader.Name == "trkseg") - { - GpxTrackSegment segment = ReadTrackSegment(); - result.Geometries.Add(segment); - elementParsed = true; - } - - if (this.Settings.ReadMetadata) - { - elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); - } - - if (!elementParsed) - { - _xmlReader.Skip(); - } + _xmlReader.Skip(); } - - result.Metadata = metadata; } - _xmlReader.Skip(); - return result; + result.Metadata = metadata; } + _xmlReader.Skip(); + + return result; + } + + /// + /// Reads a GPX traxk segment from the intrnal XmlReader. + /// + /// the track parsed from the XmlReader + private GpxTrackSegment ReadTrackSegment() + { + GpxTrackSegment result = new GpxTrackSegment(); - /// - /// Reads a GPX traxk segment from the intrnal XmlReader. - /// - /// the track parsed from the XmlReader - private GpxTrackSegment ReadTrackSegment() + if (_xmlReader.IsEmptyElement == false) { - GpxTrackSegment result = new GpxTrackSegment(); + _xmlReader.Read(); - if (_xmlReader.IsEmptyElement == false) + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trkseg") == false) { - _xmlReader.Read(); - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "trkseg") == false) + if (_xmlReader.Name == "trkpt") + { + GpxPoint point = ReadPoint("trkpt"); + result.Points.Add(point); + } + else { - if (_xmlReader.Name == "trkpt") - { - GpxPoint point = ReadPoint("trkpt"); - result.Points.Add(point); - } - else - { - _xmlReader.Skip(); - } + _xmlReader.Skip(); } } - _xmlReader.Skip(); - - return result; } + _xmlReader.Skip(); + + return result; + } - /// - /// Reads a GPX route from the internal XmlReader - /// - /// the route parsed from the XmlReader - private GpxRoute ReadRoute() + /// + /// Reads a GPX route from the internal XmlReader + /// + /// the route parsed from the XmlReader + private GpxRoute ReadRoute() + { + GpxRoute result = new GpxRoute(); + + if (_xmlReader.IsEmptyElement == false) { - GpxRoute result = new GpxRoute(); + _xmlReader.Read(); - if (_xmlReader.IsEmptyElement == false) + GpxTrackMetadata metadata = null; + if (this.Settings.ReadMetadata) { - _xmlReader.Read(); + metadata = new GpxTrackMetadata(); + } - GpxTrackMetadata metadata = null; - if (this.Settings.ReadMetadata) + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "rte") == false) + { + bool elementParsed = false; + + if (_xmlReader.Name == "rtept") { - metadata = new GpxTrackMetadata(); + result.Points.Add(ReadPoint("rtept")); + elementParsed = true; } - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "rte") == false) + if (this.Settings.ReadMetadata) { - bool elementParsed = false; - - if (_xmlReader.Name == "rtept") - { - result.Points.Add(ReadPoint("rtept")); - elementParsed = true; - } - - if (this.Settings.ReadMetadata) - { - elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); - } - - if (!elementParsed) - { - _xmlReader.Skip(); - } + elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); } - result.Metadata = metadata; + if (!elementParsed) + { + _xmlReader.Skip(); + } } - _xmlReader.Skip(); - return result; + result.Metadata = metadata; } + _xmlReader.Skip(); - /// - /// Initializes internal properties - /// - private void InitializeReader() - { - XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); - xmlReaderSettings.IgnoreComments = true; - xmlReaderSettings.IgnoreProcessingInstructions = true; - xmlReaderSettings.IgnoreWhitespace = true; + return result; + } - _xmlReader = XmlReader.Create(_input, xmlReaderSettings); + /// + /// Initializes internal properties + /// + private void InitializeReader() + { + XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); + xmlReaderSettings.IgnoreComments = true; + xmlReaderSettings.IgnoreProcessingInstructions = true; + xmlReaderSettings.IgnoreWhitespace = true; - _xmlReader.Read(); - while (_xmlReader.EOF == false && _insideGpx == false) + _xmlReader = XmlReader.Create(_input, xmlReaderSettings); + + _xmlReader.Read(); + while (_xmlReader.EOF == false && _insideGpx == false) + { + if (_xmlReader.NodeType == XmlNodeType.Element) { - if (_xmlReader.NodeType == XmlNodeType.Element) + if (_xmlReader.Name != "gpx") { - if (_xmlReader.Name != "gpx") - { - throw new InvalidDataException("Invalid gpx root element. Expected ."); - } + throw new InvalidDataException("Invalid gpx root element. Expected ."); + } - string version = _xmlReader.GetAttribute("version"); - if (version == null || (version != "1.0" && version != "1.1")) - throw new InvalidDataException(String.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); + string version = _xmlReader.GetAttribute("version"); + if (version == null || (version != "1.0" && version != "1.1")) + throw new InvalidDataException(String.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); - _insideGpx = true; + _insideGpx = true; - } - else - { - _xmlReader.Read(); - } + } + else + { + _xmlReader.Read(); } } + } + + /// + /// Reads a GPX Link from the internal XmlReader + /// + /// the link parsed from the XmlReader + private GpxLink ReadLink() + { + string href = _xmlReader.GetAttribute("href"); + string linkText = null; + string linkType = null; - /// - /// Reads a GPX Link from the internal XmlReader - /// - /// the link parsed from the XmlReader - private GpxLink ReadLink() + if (_xmlReader.IsEmptyElement == false) { - string href = _xmlReader.GetAttribute("href"); - string linkText = null; - string linkType = null; + _xmlReader.Read(); - if (_xmlReader.IsEmptyElement == false) + while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "link") == false) { - _xmlReader.Read(); - - while ((_xmlReader.NodeType == XmlNodeType.EndElement && _xmlReader.Name == "link") == false) + switch (_xmlReader.Name) { - switch (_xmlReader.Name) - { - case "text": - linkText = _xmlReader.ReadElementContentAsString(); break; - case "type": - linkType = _xmlReader.ReadElementContentAsString(); break; - default: - _xmlReader.Read(); - break; - } + case "text": + linkText = _xmlReader.ReadElementContentAsString(); break; + case "type": + linkType = _xmlReader.ReadElementContentAsString(); break; + default: + _xmlReader.Read(); + break; } } - _xmlReader.Skip(); - - return new GpxLink(new Uri(href)) { Text = linkText, Type = linkType }; } + _xmlReader.Skip(); - /// - /// Reads track/route metadata from the internal XmlReader. - /// - /// Objecto to store read metadata - /// true if piece of metadata was read, otherwise returns false - private bool TryReadTrackMetadata(GpxTrackMetadata metadata) - { - switch (_xmlReader.Name) - { - case "name": - metadata.Name = _xmlReader.ReadElementContentAsString(); return true; - case "cmt": - metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; - case "desc": - metadata.Description = _xmlReader.ReadElementContentAsString(); return true; - case "src": - metadata.Source = _xmlReader.ReadElementContentAsString(); return true; - case "type": - metadata.Type = _xmlReader.ReadElementContentAsString(); return true; - case "link": - metadata.Links.Add(ReadLink()); return true; - } + return new GpxLink(new Uri(href)) { Text = linkText, Type = linkType }; + } - return false; + /// + /// Reads track/route metadata from the internal XmlReader. + /// + /// Objecto to store read metadata + /// true if piece of metadata was read, otherwise returns false + private bool TryReadTrackMetadata(GpxTrackMetadata metadata) + { + switch (_xmlReader.Name) + { + case "name": + metadata.Name = _xmlReader.ReadElementContentAsString(); return true; + case "cmt": + metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; + case "desc": + metadata.Description = _xmlReader.ReadElementContentAsString(); return true; + case "src": + metadata.Source = _xmlReader.ReadElementContentAsString(); return true; + case "type": + metadata.Type = _xmlReader.ReadElementContentAsString(); return true; + case "link": + metadata.Links.Add(ReadLink()); return true; } - /// - /// Reads waypoint metadata from the internal XmlReader. - /// - /// Objecto to store read metadata - /// true if piece of metadata was read, otherwise returns false - private bool TryReadPointMetadata(GpxPointMetadata metadata) - { - switch (_xmlReader.Name) - { - case "name": - metadata.Name = _xmlReader.ReadElementContentAsString(); return true; - case "cmt": - metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; - case "desc": - metadata.Description = _xmlReader.ReadElementContentAsString(); return true; - case "src": - metadata.Source = _xmlReader.ReadElementContentAsString(); return true; - case "link": - metadata.Links.Add(ReadLink()); return true; - case "magvar": - string magvarValue = _xmlReader.ReadElementContentAsString(); - metadata.MagVar = double.Parse(magvarValue, _invariantCulture); return true; - case "geoidheight": - string geoidHeightValue = _xmlReader.ReadElementContentAsString(); - metadata.GeoidHeight = double.Parse(geoidHeightValue, _invariantCulture); return true; - case "hdop": - string HdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Hdop = double.Parse(HdopValue, _invariantCulture); return true; - case "vdop": - string vdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Vdop = double.Parse(vdopValue, _invariantCulture); return true; - case "pdop": - string pdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Pdop = double.Parse(pdopValue, _invariantCulture); return true; - case "ageofdgpsdata": - string ageValue = _xmlReader.ReadElementContentAsString(); - metadata.AgeOfDgpsData = double.Parse(ageValue, _invariantCulture); return true; - case "sat": - string satValue = _xmlReader.ReadElementContentAsString(); - metadata.SatellitesCount = int.Parse(satValue, _invariantCulture); return true; - case "dgpsid": - string dgpsidValue = _xmlReader.ReadElementContentAsString(); - metadata.DgpsId = int.Parse(dgpsidValue, _invariantCulture); return true; - case "fix": - string fixValue = _xmlReader.ReadElementContentAsString(); - metadata.Fix = GpxFixHelper.ParseGpsFix(fixValue); return true; - } + return false; + } - return false; + /// + /// Reads waypoint metadata from the internal XmlReader. + /// + /// Objecto to store read metadata + /// true if piece of metadata was read, otherwise returns false + private bool TryReadPointMetadata(GpxPointMetadata metadata) + { + switch (_xmlReader.Name) + { + case "name": + metadata.Name = _xmlReader.ReadElementContentAsString(); return true; + case "cmt": + metadata.Comment = _xmlReader.ReadElementContentAsString(); return true; + case "desc": + metadata.Description = _xmlReader.ReadElementContentAsString(); return true; + case "src": + metadata.Source = _xmlReader.ReadElementContentAsString(); return true; + case "link": + metadata.Links.Add(ReadLink()); return true; + case "magvar": + string magvarValue = _xmlReader.ReadElementContentAsString(); + metadata.MagVar = double.Parse(magvarValue, _invariantCulture); return true; + case "geoidheight": + string geoidHeightValue = _xmlReader.ReadElementContentAsString(); + metadata.GeoidHeight = double.Parse(geoidHeightValue, _invariantCulture); return true; + case "hdop": + string HdopValue = _xmlReader.ReadElementContentAsString(); + metadata.Hdop = double.Parse(HdopValue, _invariantCulture); return true; + case "vdop": + string vdopValue = _xmlReader.ReadElementContentAsString(); + metadata.Vdop = double.Parse(vdopValue, _invariantCulture); return true; + case "pdop": + string pdopValue = _xmlReader.ReadElementContentAsString(); + metadata.Pdop = double.Parse(pdopValue, _invariantCulture); return true; + case "ageofdgpsdata": + string ageValue = _xmlReader.ReadElementContentAsString(); + metadata.AgeOfDgpsData = double.Parse(ageValue, _invariantCulture); return true; + case "sat": + string satValue = _xmlReader.ReadElementContentAsString(); + metadata.SatellitesCount = int.Parse(satValue, _invariantCulture); return true; + case "dgpsid": + string dgpsidValue = _xmlReader.ReadElementContentAsString(); + metadata.DgpsId = int.Parse(dgpsidValue, _invariantCulture); return true; + case "fix": + string fixValue = _xmlReader.ReadElementContentAsString(); + metadata.Fix = GpxFixHelper.ParseGpsFix(fixValue); return true; } - /// - /// Releases the unmanaged resources used by the GpxReader and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + return false; + } + + /// + /// Releases the unmanaged resources used by the GpxReader and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) { - if (!this._disposed) + if (disposing) { - if (disposing) - { - _xmlReader.Dispose(); + _xmlReader.Dispose(); - if (_ownsInputStream) - { - _input.Dispose(); - } + if (_ownsInputStream) + { + _input.Dispose(); } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Gps/IO/GpxReaderSettings.cs b/src/SpatialLite.Gps/IO/GpxReaderSettings.cs index 5d12d77..1496ba8 100644 --- a/src/SpatialLite.Gps/IO/GpxReaderSettings.cs +++ b/src/SpatialLite.Gps/IO/GpxReaderSettings.cs @@ -1,46 +1,45 @@ using System; -namespace SpatialLite.Gps.IO +namespace SpatialLite.Gps.IO; + +/// +/// Contains settings that determine behaviour of GpxReader. +/// +public class GpxReaderSettings { + + bool _readMetadata = true; + /// - /// Contains settings that determine behaviour of GpxReader. + /// Initializes a new instance of the GpxReaderSettings class with default values. /// - public class GpxReaderSettings + public GpxReaderSettings() { + this.ReadMetadata = true; + } - bool _readMetadata = true; - - /// - /// Initializes a new instance of the GpxReaderSettings class with default values. - /// - public GpxReaderSettings() + /// + /// Gets a value indicating whether GpxReader should read and parse metadata. + /// + public bool ReadMetadata + { + get { - this.ReadMetadata = true; + return _readMetadata; } - - /// - /// Gets a value indicating whether GpxReader should read and parse metadata. - /// - public bool ReadMetadata + set { - get + if (this.IsReadOnly) { - return _readMetadata; + throw new InvalidOperationException("Cannot change the 'ReadMetadata' property GpxReaderSettings is read-only."); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'ReadMetadata' property GpxReaderSettings is read-only."); - } - _readMetadata = value; - } + _readMetadata = value; } - - /// - /// Gets or sets value indicating whether properties of the current GpxReaderSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } } + + /// + /// Gets or sets value indicating whether properties of the current GpxReaderSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } } diff --git a/src/SpatialLite.Gps/IO/GpxWriter.cs b/src/SpatialLite.Gps/IO/GpxWriter.cs index 461484c..e3beeea 100644 --- a/src/SpatialLite.Gps/IO/GpxWriter.cs +++ b/src/SpatialLite.Gps/IO/GpxWriter.cs @@ -4,304 +4,303 @@ using System.Xml; using SpatialLite.Gps.Geometries; -namespace SpatialLite.Gps.IO +namespace SpatialLite.Gps.IO; + +/// +/// Implements data writer that can write GPX data to streams and files. +/// +public class GpxWriter : IDisposable, IGpxWriter { + private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + + private XmlWriter _xmlWriter; + private StreamWriter _streamWriter; + private bool _disposed = false; + /// - /// Implements data writer that can write GPX data to streams and files. + /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified stream. /// - public class GpxWriter : IDisposable, IGpxWriter + /// The Stream to write GPX entities to. + /// The settings defining behaviour of the writer. + public GpxWriter(Stream stream, GpxWriterSettings settings) { - private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; - - private XmlWriter _xmlWriter; - private StreamWriter _streamWriter; - private bool _disposed = false; - - /// - /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified stream. - /// - /// The Stream to write GPX entities to. - /// The settings defining behaviour of the writer. - public GpxWriter(Stream stream, GpxWriterSettings settings) - { - this.Settings = settings; - settings.IsReadOnly = true; + this.Settings = settings; + settings.IsReadOnly = true; - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; - _streamWriter = new StreamWriter(stream, new UTF8Encoding(false)); - _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); + _streamWriter = new StreamWriter(stream, new UTF8Encoding(false)); + _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); - StartDocument(); - } + StartDocument(); + } - /// - /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified file. - /// - /// Path to the GPX file. - /// The settings defining behaviour of the writer. - /// If the file exists, it is overwritten, otherwise, a new file is created. - public GpxWriter(string path, GpxWriterSettings settings) - { - this.Settings = settings; - settings.IsReadOnly = true; + /// + /// Initializes a new instance of the GpxWriter class that writes GPX entities to the specified file. + /// + /// Path to the GPX file. + /// The settings defining behaviour of the writer. + /// If the file exists, it is overwritten, otherwise, a new file is created. + public GpxWriter(string path, GpxWriterSettings settings) + { + this.Settings = settings; + settings.IsReadOnly = true; - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; - var fileStream = new FileStream(path, FileMode.Create); - _streamWriter = new StreamWriter(fileStream, new UTF8Encoding(false)); - _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); + var fileStream = new FileStream(path, FileMode.Create); + _streamWriter = new StreamWriter(fileStream, new UTF8Encoding(false)); + _xmlWriter = XmlWriter.Create(_streamWriter, writerSetting); - StartDocument(); - } + StartDocument(); + } - /// - /// Creates root element in the output stream - /// - private void StartDocument() - { - _xmlWriter.WriteStartDocument(); - _xmlWriter.WriteStartElement("gpx", "http://www.topografix.com/GPX/1/1"); - _xmlWriter.WriteAttributeString("version", "1.1"); - _xmlWriter.WriteAttributeString("creator", this.Settings.GeneratorName ?? "SpatialLite"); - } + /// + /// Creates root element in the output stream + /// + private void StartDocument() + { + _xmlWriter.WriteStartDocument(); + _xmlWriter.WriteStartElement("gpx", "http://www.topografix.com/GPX/1/1"); + _xmlWriter.WriteAttributeString("version", "1.1"); + _xmlWriter.WriteAttributeString("creator", this.Settings.GeneratorName ?? "SpatialLite"); + } + + /// + /// Gets settings of the writer + /// + public GpxWriterSettings Settings { get; private set; } - /// - /// Gets settings of the writer - /// - public GpxWriterSettings Settings { get; private set; } + /// + /// Writes the given waypoint to the output stream + /// + /// The waypoint to write + public void Write(GpxPoint waypoint) + { + WritePoint(waypoint, "wpt"); + } - /// - /// Writes the given waypoint to the output stream - /// - /// The waypoint to write - public void Write(GpxPoint waypoint) + /// + /// Writes the given route to the output stream + /// + /// The route to write + public void Write(GpxRoute route) + { + _xmlWriter.WriteStartElement("rte"); + + for (int i = 0; i < route.Points.Count; i++) + { + WritePoint(route.Points[i], "rtept"); + } + if (this.Settings.WriteMetadata) { - WritePoint(waypoint, "wpt"); + this.WriteTrackMetadata(route.Metadata); } - /// - /// Writes the given route to the output stream - /// - /// The route to write - public void Write(GpxRoute route) + _xmlWriter.WriteEndElement(); + } + + /// + /// Writes the given track to the output stream + /// + /// The track to write + public void Write(GpxTrack track) + { + _xmlWriter.WriteStartElement("trk"); + + for (int i = 0; i < track.Geometries.Count; i++) { - _xmlWriter.WriteStartElement("rte"); + _xmlWriter.WriteStartElement("trkseg"); - for (int i = 0; i < route.Points.Count; i++) - { - WritePoint(route.Points[i], "rtept"); - } - if (this.Settings.WriteMetadata) + for (int ii = 0; ii < track.Geometries[i].Points.Count; ii++) { - this.WriteTrackMetadata(route.Metadata); + WritePoint(track.Geometries[i].Points[ii], "trkpt"); } _xmlWriter.WriteEndElement(); } - /// - /// Writes the given track to the output stream - /// - /// The track to write - public void Write(GpxTrack track) + if (this.Settings.WriteMetadata) { - _xmlWriter.WriteStartElement("trk"); + this.WriteTrackMetadata(track.Metadata); + } - for (int i = 0; i < track.Geometries.Count; i++) - { - _xmlWriter.WriteStartElement("trkseg"); + _xmlWriter.WriteEndElement(); + } - for (int ii = 0; ii < track.Geometries[i].Points.Count; ii++) - { - WritePoint(track.Geometries[i].Points[ii], "trkpt"); - } + /// + /// Releases all resources used by the GpxWriter. + /// + public void Dispose() + { + Dispose(true); - _xmlWriter.WriteEndElement(); - } + GC.SuppressFinalize(this); + } - if (this.Settings.WriteMetadata) - { - this.WriteTrackMetadata(track.Metadata); - } + /// + /// Writes the given point to the output stream + /// + /// The point to be written + /// The name of the XML element the point is to be written to + private void WritePoint(GpxPoint point, string pointElementName) + { + _xmlWriter.WriteStartElement(pointElementName); + _xmlWriter.WriteAttributeString("lat", point.Position.Y.ToString(_invariantCulture)); + _xmlWriter.WriteAttributeString("lon", point.Position.X.ToString(_invariantCulture)); - _xmlWriter.WriteEndElement(); + if (!double.IsNaN(point.Position.Z)) + { + _xmlWriter.WriteElementString("ele", point.Position.Z.ToString(_invariantCulture)); } - /// - /// Releases all resources used by the GpxWriter. - /// - public void Dispose() + if (point.Timestamp != null) { - Dispose(true); - - GC.SuppressFinalize(this); + _xmlWriter.WriteElementString("time", point.Timestamp.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture)); } - /// - /// Writes the given point to the output stream - /// - /// The point to be written - /// The name of the XML element the point is to be written to - private void WritePoint(GpxPoint point, string pointElementName) + if (this.Settings.WriteMetadata) { - _xmlWriter.WriteStartElement(pointElementName); - _xmlWriter.WriteAttributeString("lat", point.Position.Y.ToString(_invariantCulture)); - _xmlWriter.WriteAttributeString("lon", point.Position.X.ToString(_invariantCulture)); + this.WritePointMetadata(point.Metadata); + } + + _xmlWriter.WriteEndElement(); + } - if (!double.IsNaN(point.Position.Z)) + /// + /// Writes content of the GpxEntityDetails class to the current position of output stream + /// + /// A GpxEntityDetails object to be written + private void WriteTrackMetadata(GpxTrackMetadata metadata) + { + if (metadata != null) + { + if (metadata.Name != null) + _xmlWriter.WriteElementString("name", metadata.Name); + if (metadata.Comment != null) + _xmlWriter.WriteElementString("cmt", metadata.Comment); + if (metadata.Description != null) + _xmlWriter.WriteElementString("desc", metadata.Description); + if (metadata.Source != null) + _xmlWriter.WriteElementString("src", metadata.Source); + foreach (var link in metadata.Links) { - _xmlWriter.WriteElementString("ele", point.Position.Z.ToString(_invariantCulture)); + this.WriteLink(link); } + if (metadata.Comment != null) + _xmlWriter.WriteElementString("type", metadata.Type); + } + } - if (point.Timestamp != null) + /// + /// Writes content of the GpxPointDetails class to the current position of output stream + /// + /// A GpxEntityDetails object to be written + private void WritePointMetadata(GpxPointMetadata metadata) + { + if (metadata != null) + { + if (metadata.Name != null) { - _xmlWriter.WriteElementString("time", point.Timestamp.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture)); + _xmlWriter.WriteElementString("name", metadata.Name); } - - if (this.Settings.WriteMetadata) + if (metadata.Comment != null) { - this.WritePointMetadata(point.Metadata); + _xmlWriter.WriteElementString("cmt", metadata.Comment); + } + if (metadata.Description != null) + { + _xmlWriter.WriteElementString("desc", metadata.Description); + } + if (metadata.Source != null) + { + _xmlWriter.WriteElementString("src", metadata.Source); } - _xmlWriter.WriteEndElement(); - } - - /// - /// Writes content of the GpxEntityDetails class to the current position of output stream - /// - /// A GpxEntityDetails object to be written - private void WriteTrackMetadata(GpxTrackMetadata metadata) - { - if (metadata != null) + foreach (var link in metadata.Links) { - if (metadata.Name != null) - _xmlWriter.WriteElementString("name", metadata.Name); - if (metadata.Comment != null) - _xmlWriter.WriteElementString("cmt", metadata.Comment); - if (metadata.Description != null) - _xmlWriter.WriteElementString("desc", metadata.Description); - if (metadata.Source != null) - _xmlWriter.WriteElementString("src", metadata.Source); - foreach (var link in metadata.Links) - { - this.WriteLink(link); - } - if (metadata.Comment != null) - _xmlWriter.WriteElementString("type", metadata.Type); + this.WriteLink(link); } - } - /// - /// Writes content of the GpxPointDetails class to the current position of output stream - /// - /// A GpxEntityDetails object to be written - private void WritePointMetadata(GpxPointMetadata metadata) - { - if (metadata != null) + if (metadata.MagVar.HasValue) + { + _xmlWriter.WriteElementString("magvar", metadata.MagVar.Value.ToString(_invariantCulture)); + } + if (metadata.GeoidHeight.HasValue) + { + _xmlWriter.WriteElementString("geoidheight", (metadata.GeoidHeight ?? 0).ToString(_invariantCulture)); + } + if (metadata.Symbol != null) { - if (metadata.Name != null) - { - _xmlWriter.WriteElementString("name", metadata.Name); - } - if (metadata.Comment != null) - { - _xmlWriter.WriteElementString("cmt", metadata.Comment); - } - if (metadata.Description != null) - { - _xmlWriter.WriteElementString("desc", metadata.Description); - } - if (metadata.Source != null) - { - _xmlWriter.WriteElementString("src", metadata.Source); - } - - foreach (var link in metadata.Links) - { - this.WriteLink(link); - } - - if (metadata.MagVar.HasValue) - { - _xmlWriter.WriteElementString("magvar", metadata.MagVar.Value.ToString(_invariantCulture)); - } - if (metadata.GeoidHeight.HasValue) - { - _xmlWriter.WriteElementString("geoidheight", (metadata.GeoidHeight ?? 0).ToString(_invariantCulture)); - } - if (metadata.Symbol != null) - { - _xmlWriter.WriteElementString("sym", metadata.Symbol); - } - if (metadata.Fix.HasValue) - { - _xmlWriter.WriteElementString("fix", GpxFixHelper.GpsFixToString(metadata.Fix.Value)); - } - if (metadata.SatellitesCount.HasValue) - { - _xmlWriter.WriteElementString("sat", metadata.SatellitesCount.Value.ToString(_invariantCulture)); - } - if (metadata.Hdop.HasValue) - { - _xmlWriter.WriteElementString("hdop", metadata.Hdop.Value.ToString(_invariantCulture)); - } - if (metadata.Vdop.HasValue) - { - _xmlWriter.WriteElementString("vdop", metadata.Vdop.Value.ToString(_invariantCulture)); - } - if (metadata.Pdop.HasValue) - { - _xmlWriter.WriteElementString("pdop", metadata.Pdop.Value.ToString(_invariantCulture)); - } - if (metadata.AgeOfDgpsData.HasValue) - { - _xmlWriter.WriteElementString("ageofdgpsdata", metadata.AgeOfDgpsData.Value.ToString(_invariantCulture)); - } - if (metadata.DgpsId.HasValue) - { - _xmlWriter.WriteElementString("dgpsid", metadata.DgpsId.Value.ToString(_invariantCulture)); - } + _xmlWriter.WriteElementString("sym", metadata.Symbol); + } + if (metadata.Fix.HasValue) + { + _xmlWriter.WriteElementString("fix", GpxFixHelper.GpsFixToString(metadata.Fix.Value)); + } + if (metadata.SatellitesCount.HasValue) + { + _xmlWriter.WriteElementString("sat", metadata.SatellitesCount.Value.ToString(_invariantCulture)); + } + if (metadata.Hdop.HasValue) + { + _xmlWriter.WriteElementString("hdop", metadata.Hdop.Value.ToString(_invariantCulture)); + } + if (metadata.Vdop.HasValue) + { + _xmlWriter.WriteElementString("vdop", metadata.Vdop.Value.ToString(_invariantCulture)); + } + if (metadata.Pdop.HasValue) + { + _xmlWriter.WriteElementString("pdop", metadata.Pdop.Value.ToString(_invariantCulture)); + } + if (metadata.AgeOfDgpsData.HasValue) + { + _xmlWriter.WriteElementString("ageofdgpsdata", metadata.AgeOfDgpsData.Value.ToString(_invariantCulture)); + } + if (metadata.DgpsId.HasValue) + { + _xmlWriter.WriteElementString("dgpsid", metadata.DgpsId.Value.ToString(_invariantCulture)); } } + } - /// - /// Writes the given link to the output stream - /// - /// The link to be written - private void WriteLink(GpxLink link) - { - _xmlWriter.WriteStartElement("link"); - _xmlWriter.WriteAttributeString("href", link.Url.OriginalString); + /// + /// Writes the given link to the output stream + /// + /// The link to be written + private void WriteLink(GpxLink link) + { + _xmlWriter.WriteStartElement("link"); + _xmlWriter.WriteAttributeString("href", link.Url.OriginalString); - if (link.Text != null) - _xmlWriter.WriteElementString("text", link.Text); - if (link.Type != null) - _xmlWriter.WriteElementString("type", link.Type); + if (link.Text != null) + _xmlWriter.WriteElementString("text", link.Text); + if (link.Type != null) + _xmlWriter.WriteElementString("type", link.Type); - _xmlWriter.WriteEndElement(); - } + _xmlWriter.WriteEndElement(); + } - /// - /// Releases the unmanaged resources used by the GpxWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + /// + /// Releases the unmanaged resources used by the GpxWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) { - if (!this._disposed) + if (disposing) { - if (disposing) - { - _xmlWriter.Dispose(); - - if (_streamWriter != null) - _streamWriter.Dispose(); - } + _xmlWriter.Dispose(); - _disposed = true; + if (_streamWriter != null) + _streamWriter.Dispose(); } + + _disposed = true; } } } diff --git a/src/SpatialLite.Gps/IO/GpxWriterSettings.cs b/src/SpatialLite.Gps/IO/GpxWriterSettings.cs index 43a7e11..73c3b04 100644 --- a/src/SpatialLite.Gps/IO/GpxWriterSettings.cs +++ b/src/SpatialLite.Gps/IO/GpxWriterSettings.cs @@ -1,66 +1,65 @@ using System; -namespace SpatialLite.Gps.IO +namespace SpatialLite.Gps.IO; + +/// +/// Contains settings that determine behaviour of the GpxWriter. +/// +public class GpxWriterSettings { + + bool _writeMetadata = true; + string _generatorName; + /// - /// Contains settings that determine behaviour of the GpxWriter. + /// Initializes a new instance of the GpxWriterSettings class with default values. /// - public class GpxWriterSettings + public GpxWriterSettings() { + } - bool _writeMetadata = true; - string _generatorName; - - /// - /// Initializes a new instance of the GpxWriterSettings class with default values. - /// - public GpxWriterSettings() + /// + /// Gets or sets a value indicating whether GpxWriter should write entity metadata. + /// + public bool WriteMetadata + { + get { + return _writeMetadata; } - - /// - /// Gets or sets a value indicating whether GpxWriter should write entity metadata. - /// - public bool WriteMetadata + set { - get + if (this.IsReadOnly) { - return _writeMetadata; + throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - GpxWriterSettings is read-only."); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - GpxWriterSettings is read-only."); - } - _writeMetadata = value; - } + _writeMetadata = value; } + } - /// - /// Gets or sets the name of the program that will be save to the output file. - /// - public string GeneratorName + /// + /// Gets or sets the name of the program that will be save to the output file. + /// + public string GeneratorName + { + get { - get + return _generatorName; + } + set + { + if (this.IsReadOnly) { - return _generatorName; + throw new InvalidOperationException("Cannot change the 'GeneratorName' property - GpxWriterSettings is read-only."); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'GeneratorName' property - GpxWriterSettings is read-only."); - } - _generatorName = value; - } + _generatorName = value; } - - /// - /// Gets or sets value indicating whether properties of the current GpxWriterSettings instance can be changed. - /// - public bool IsReadOnly { get; internal set; } } + + /// + /// Gets or sets value indicating whether properties of the current GpxWriterSettings instance can be changed. + /// + public bool IsReadOnly { get; internal set; } } diff --git a/src/SpatialLite.Gps/IO/IGpxReader.cs b/src/SpatialLite.Gps/IO/IGpxReader.cs index a3342e4..dfd6c9e 100644 --- a/src/SpatialLite.Gps/IO/IGpxReader.cs +++ b/src/SpatialLite.Gps/IO/IGpxReader.cs @@ -1,13 +1,12 @@ -namespace SpatialLite.Gps.IO +namespace SpatialLite.Gps.IO; + +/// +/// Defines functions and properties for classes that can read GPX entities from a source. +/// +public interface IGpxReader { /// - /// Defines functions and properties for classes that can read GPX entities from a source. + /// Parses next element of the GPX file /// - public interface IGpxReader - { - /// - /// Parses next element of the GPX file - /// - IGpxGeometry Read(); - } + IGpxGeometry Read(); } diff --git a/src/SpatialLite.Gps/IO/IGpxWriter.cs b/src/SpatialLite.Gps/IO/IGpxWriter.cs index d47f928..c1de3df 100644 --- a/src/SpatialLite.Gps/IO/IGpxWriter.cs +++ b/src/SpatialLite.Gps/IO/IGpxWriter.cs @@ -1,28 +1,27 @@ using SpatialLite.Gps.Geometries; -namespace SpatialLite.Gps.IO +namespace SpatialLite.Gps.IO; + +/// +/// Defines functions and properties for classes that can writes GPX entities to a destination. +/// +public interface IGpxWriter { /// - /// Defines functions and properties for classes that can writes GPX entities to a destination. + /// Writes GpxWaypoint /// - public interface IGpxWriter - { - /// - /// Writes GpxWaypoint - /// - /// The waypoint to write. - void Write(GpxPoint waypoint); + /// The waypoint to write. + void Write(GpxPoint waypoint); - /// - /// Writes GpxRoute - /// - /// The route to write - void Write(GpxRoute route); + /// + /// Writes GpxRoute + /// + /// The route to write + void Write(GpxRoute route); - /// - /// Writes GpxTrack - /// - /// The track to write - void Write(GpxTrack track); - } + /// + /// Writes GpxTrack + /// + /// The track to write + void Write(GpxTrack track); } diff --git a/src/SpatialLite.Osm/EntityCollection.cs b/src/SpatialLite.Osm/EntityCollection.cs index d2c162b..0d38bd2 100644 --- a/src/SpatialLite.Osm/EntityCollection.cs +++ b/src/SpatialLite.Osm/EntityCollection.cs @@ -1,182 +1,181 @@ using System; using System.Collections.Generic; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents collection of the OSM entities that optimized for access speed. +/// +/// The type of the entities in the collection. +public class EntityCollection : ITypedEntityCollection where T : IOsmEntity { + + private Dictionary _storage = null; + /// - /// Represents collection of the OSM entities that optimized for access speed. + /// Initializes a new instance of the EntityCollection class that is empty. /// - /// The type of the entities in the collection. - public class EntityCollection : ITypedEntityCollection where T : IOsmEntity + public EntityCollection() { + _storage = new Dictionary(); + } - private Dictionary _storage = null; + /// + /// Initializes a new instance of the EntityCollection class with specified entities. + /// + /// Collection of entities to be populated into this EntityCollection. + public EntityCollection(IEnumerable entities) + { + _storage = new Dictionary(); - /// - /// Initializes a new instance of the EntityCollection class that is empty. - /// - public EntityCollection() + foreach (var entity in entities) { - _storage = new Dictionary(); + _storage.Add(entity.ID, entity); } + } - /// - /// Initializes a new instance of the EntityCollection class with specified entities. - /// - /// Collection of entities to be populated into this EntityCollection. - public EntityCollection(IEnumerable entities) + /// + /// Gets the number of entities in the collection. + /// + public int Count + { + get { - _storage = new Dictionary(); - - foreach (var entity in entities) - { - _storage.Add(entity.ID, entity); - } + return _storage.Count; } + } - /// - /// Gets the number of entities in the collection. - /// - public int Count + /// + /// Gets a value indicating whether the collection is read-only. + /// + public bool IsReadOnly + { + get { - get - { - return _storage.Count; - } + return false; } + } - /// - /// Gets a value indicating whether the collection is read-only. - /// - public bool IsReadOnly + /// + /// Gets an entity with specific ID from the collection. + /// + /// The ID of the entity to get. + /// entity with the specific ID or null if such entity is not present in the collection. + public T this[long id] + { + get { - get + if (_storage.TryGetValue(id, out T value)) { - return false; + return value; } - } - - /// - /// Gets an entity with specific ID from the collection. - /// - /// The ID of the entity to get. - /// entity with the specific ID or null if such entity is not present in the collection. - public T this[long id] - { - get - { - if (_storage.TryGetValue(id, out T value)) - { - return value; - } - return default(T); - } + return default(T); } + } - /// - /// Adds specific entity to the collection. - /// - /// The entity to add to the collection. - public void Add(T entity) + /// + /// Adds specific entity to the collection. + /// + /// The entity to add to the collection. + public void Add(T entity) + { + if (entity == null) { - if (entity == null) - { - throw new ArgumentNullException(nameof(entity), "Cannot add null to EntityCollection"); - } - - if (_storage.ContainsKey(entity.ID)) - { - throw new ArgumentException("An entity with the same ID has already been added."); - } - - _storage.Add(entity.ID, entity); + throw new ArgumentNullException(nameof(entity), "Cannot add null to EntityCollection"); } - /// - /// Removes all entities form the collection. - /// - public void Clear() + if (_storage.ContainsKey(entity.ID)) { - _storage.Clear(); + throw new ArgumentException("An entity with the same ID has already been added."); } - /// - /// Determines whether the EntityICollection contains a specific entity. - /// - /// The entity to locate in the EntityCollection - /// true if entity is found in the collection, otherwise false. - public bool Contains(T item) - { - if (item == null) - { - return false; - } + _storage.Add(entity.ID, entity); + } - return _storage.ContainsKey(item.ID); - } + /// + /// Removes all entities form the collection. + /// + public void Clear() + { + _storage.Clear(); + } - /// - /// Determines whether the EntityICollection contains an entity with specific ID. - /// - /// The ID of the entity to locate in the EntityCollection. - /// true if entity is found in the collection, otherwise false. - public bool Contains(long id) + /// + /// Determines whether the EntityICollection contains a specific entity. + /// + /// The entity to locate in the EntityCollection + /// true if entity is found in the collection, otherwise false. + public bool Contains(T item) + { + if (item == null) { - return _storage.ContainsKey(id); + return false; } - /// - /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. - /// The zero-based index in array at which copying begins. - public void CopyTo(T[] array, int arrayIndex) - { - _storage.Values.CopyTo(array, arrayIndex); - } + return _storage.ContainsKey(item.ID); + } - /// - /// Removes the specific entity from the collection. - /// - /// The entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(T entity) - { - if (entity == null) - { - return false; - } + /// + /// Determines whether the EntityICollection contains an entity with specific ID. + /// + /// The ID of the entity to locate in the EntityCollection. + /// true if entity is found in the collection, otherwise false. + public bool Contains(long id) + { + return _storage.ContainsKey(id); + } - return _storage.Remove(entity.ID); - } + /// + /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. + /// + /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. + /// The zero-based index in array at which copying begins. + public void CopyTo(T[] array, int arrayIndex) + { + _storage.Values.CopyTo(array, arrayIndex); + } - /// - /// Removes an entity with the specific ID from the collection. - /// - /// The ID of the entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(long id) + /// + /// Removes the specific entity from the collection. + /// + /// The entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(T entity) + { + if (entity == null) { - return _storage.Remove(id); + return false; } - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator<T> that can be used to iterate through the collection. - public IEnumerator GetEnumerator() - { - return _storage.Values.GetEnumerator(); - } + return _storage.Remove(entity.ID); + } - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } + /// + /// Removes an entity with the specific ID from the collection. + /// + /// The ID of the entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(long id) + { + return _storage.Remove(id); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator<T> that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return _storage.Values.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); } } diff --git a/src/SpatialLite.Osm/EntityMetadata.cs b/src/SpatialLite.Osm/EntityMetadata.cs index e9e6047..77eacf9 100644 --- a/src/SpatialLite.Osm/EntityMetadata.cs +++ b/src/SpatialLite.Osm/EntityMetadata.cs @@ -1,41 +1,40 @@ using System; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Contains additional information about OSM entities such as Author, Version, Timesptam of the last change and others. +/// +public class EntityMetadata { + + /// + /// Gets or sets version of the object. + /// + public int Version { get; set; } + + /// + /// Gets or sets date and time when the entity was modified. + /// + public DateTime Timestamp { get; set; } + + /// + /// Gets or sets if of the user who made last modification to the entity. + /// + public int Uid { get; set; } + + /// + /// Gets or sets username of the person who made last modification to the entity. + /// + public string User { get; set; } + + /// + /// Gets or sets changeset id. + /// + public int Changeset { get; set; } + /// - /// Contains additional information about OSM entities such as Author, Version, Timesptam of the last change and others. + /// Gets or sets visibility of this item. /// - public class EntityMetadata - { - - /// - /// Gets or sets version of the object. - /// - public int Version { get; set; } - - /// - /// Gets or sets date and time when the entity was modified. - /// - public DateTime Timestamp { get; set; } - - /// - /// Gets or sets if of the user who made last modification to the entity. - /// - public int Uid { get; set; } - - /// - /// Gets or sets username of the person who made last modification to the entity. - /// - public string User { get; set; } - - /// - /// Gets or sets changeset id. - /// - public int Changeset { get; set; } - - /// - /// Gets or sets visibility of this item. - /// - public bool Visible { get; set; } - } + public bool Visible { get; set; } } diff --git a/src/SpatialLite.Osm/EntityType.cs b/src/SpatialLite.Osm/EntityType.cs index 79a1a24..6944824 100644 --- a/src/SpatialLite.Osm/EntityType.cs +++ b/src/SpatialLite.Osm/EntityType.cs @@ -1,25 +1,24 @@ -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Defines possible type of object that IOsmGeometryInfo can represent. +/// +public enum EntityType { /// - /// Defines possible type of object that IOsmGeometryInfo can represent. + /// Unknown type of the entity. /// - public enum EntityType - { - /// - /// Unknown type of the entity. - /// - Unknown, - /// - /// Node - /// - Node, - /// - /// Way - /// - Way, - /// - /// Relation - /// - Relation - } + Unknown, + /// + /// Node + /// + Node, + /// + /// Way + /// + Way, + /// + /// Relation + /// + Relation } diff --git a/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs b/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs index 95f4d71..ce3749a 100644 --- a/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs +++ b/src/SpatialLite.Osm/Geometries/IOsmGeometry.cs @@ -1,11 +1,10 @@ using SpatialLite.Core.API; -namespace SpatialLite.Osm.Geometries +namespace SpatialLite.Osm.Geometries; + +/// +/// Represents OSM entity that implements IGeometry interface. +/// +public interface IOsmGeometry : IOsmEntity, IGeometry { - /// - /// Represents OSM entity that implements IGeometry interface. - /// - public interface IOsmGeometry : IOsmEntity, IGeometry - { - } } diff --git a/src/SpatialLite.Osm/Geometries/Node.cs b/src/SpatialLite.Osm/Geometries/Node.cs index 77fc39f..1f5714a 100644 --- a/src/SpatialLite.Osm/Geometries/Node.cs +++ b/src/SpatialLite.Osm/Geometries/Node.cs @@ -1,100 +1,99 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Osm.Geometries +namespace SpatialLite.Osm.Geometries; + +/// +/// Represents OSM node. +/// +public class Node : Point, IOsmGeometry { + /// - /// Represents OSM node. + /// Initializes a new instance of the Node class with specified ID. /// - public class Node : Point, IOsmGeometry + /// The ID of the node. + public Node(long id) + : this(id, Coordinate.Empty, new TagsCollection()) { + } - /// - /// Initializes a new instance of the Node class with specified ID. - /// - /// The ID of the node. - public Node(long id) - : this(id, Coordinate.Empty, new TagsCollection()) - { - } - - /// - /// Initializes a new instance of the Node class with specified ID, Longitude and Latitude. - /// - /// The ID of the node. - /// The longitude of the Node. - /// The latitude of the Node. - public Node(long id, double longitude, double latitude) - : this(id, new Coordinate(longitude, latitude), new TagsCollection()) - { - } + /// + /// Initializes a new instance of the Node class with specified ID, Longitude and Latitude. + /// + /// The ID of the node. + /// The longitude of the Node. + /// The latitude of the Node. + public Node(long id, double longitude, double latitude) + : this(id, new Coordinate(longitude, latitude), new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Node class with specified ID, Longitude, Latitude and Tags. - /// - /// The ID of the node. - /// The longitude of the Node. - /// The latitude of the Node. - /// The collection of tags associated with the Node. - public Node(long id, double longitude, double latitude, TagsCollection tags) - : this(id, new Coordinate(longitude, latitude), tags) - { - } + /// + /// Initializes a new instance of the Node class with specified ID, Longitude, Latitude and Tags. + /// + /// The ID of the node. + /// The longitude of the Node. + /// The latitude of the Node. + /// The collection of tags associated with the Node. + public Node(long id, double longitude, double latitude, TagsCollection tags) + : this(id, new Coordinate(longitude, latitude), tags) + { + } - /// - /// Initializes a new instance of the Node class with specified ID and Position. - /// - /// The ID of the node. - /// The position of the Node. - public Node(long id, Coordinate position) - : this(id, position, new TagsCollection()) - { - } + /// + /// Initializes a new instance of the Node class with specified ID and Position. + /// + /// The ID of the node. + /// The position of the Node. + public Node(long id, Coordinate position) + : this(id, position, new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Node class with specified ID, Position and Tags. - /// - /// The ID of the node. - /// The position of the Node. - /// The collection of tags associated with the Node. - public Node(long id, Coordinate position, TagsCollection tags) - : base(position) - { - this.ID = id; - this.Tags = tags; - } + /// + /// Initializes a new instance of the Node class with specified ID, Position and Tags. + /// + /// The ID of the node. + /// The position of the Node. + /// The collection of tags associated with the Node. + public Node(long id, Coordinate position, TagsCollection tags) + : base(position) + { + this.ID = id; + this.Tags = tags; + } - /// - /// Creates a new instance of the Node class with data from NodeInfo object - /// - /// NodeInfo object that contains data about node - /// Node object with data from specific NodeInfo object - public static Node FromNodeInfo(NodeInfo info) - { - return new Node(info.ID, info.Longitude, info.Latitude, info.Tags) { Metadata = info.Metadata }; - } + /// + /// Creates a new instance of the Node class with data from NodeInfo object + /// + /// NodeInfo object that contains data about node + /// Node object with data from specific NodeInfo object + public static Node FromNodeInfo(NodeInfo info) + { + return new Node(info.ID, info.Longitude, info.Latitude, info.Tags) { Metadata = info.Metadata }; + } - /// - /// Gets or sets ID of the Node. - /// - public long ID { get; set; } + /// + /// Gets or sets ID of the Node. + /// + public long ID { get; set; } - /// - /// Gets or sets the collection of tags associated with the Node. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets or sets the collection of tags associated with the Node. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets or sets metadata of the Node. - /// - public EntityMetadata Metadata { get; set; } + /// + /// Gets or sets metadata of the Node. + /// + public EntityMetadata Metadata { get; set; } - /// - /// Gets type of this entity. - /// - public EntityType EntityType - { - get { return EntityType.Node; } - } + /// + /// Gets type of this entity. + /// + public EntityType EntityType + { + get { return EntityType.Node; } } } diff --git a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs index 0d1c2a8..e8baf77 100644 --- a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs +++ b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs @@ -3,108 +3,107 @@ using SpatialLite.Osm.IO; -namespace SpatialLite.Osm.Geometries +namespace SpatialLite.Osm.Geometries; + +/// +/// Represents in-memory OSM entities database that contains entities as IOsmGeometry objects. +/// +public class OsmGeometryDatabase : OsmDatabase { + /// - /// Represents in-memory OSM entities database that contains entities as IOsmGeometry objects. + /// Initializes a new instance of the OsmGeometryDatabase class that is empty. /// - public class OsmGeometryDatabase : OsmDatabase + public OsmGeometryDatabase() + : base() { + } - /// - /// Initializes a new instance of the OsmGeometryDatabase class that is empty. - /// - public OsmGeometryDatabase() - : base() - { - } - - /// - /// Initializes a new instance of the OsmGeometryDatabase class with specific entities. - /// - /// Entities to add to the database. - public OsmGeometryDatabase(IEnumerable entities) - : base(entities) - { - } - - /// - /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. - /// - /// The IOsmReader to read data from. - /// A value indicatings whether Load function should skip geometries that reference miising geometries. - /// New instance of the OsmDatabase class with data loaded from specified reader. - public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferentialErrors) - { - OsmGeometryDatabase db = new OsmGeometryDatabase(); + /// + /// Initializes a new instance of the OsmGeometryDatabase class with specific entities. + /// + /// Entities to add to the database. + public OsmGeometryDatabase(IEnumerable entities) + : base(entities) + { + } - List relations = new List(); + /// + /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. + /// + /// The IOsmReader to read data from. + /// A value indicatings whether Load function should skip geometries that reference miising geometries. + /// New instance of the OsmDatabase class with data loaded from specified reader. + public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferentialErrors) + { + OsmGeometryDatabase db = new OsmGeometryDatabase(); - IEntityInfo entityInfo = null; - while ((entityInfo = reader.Read()) != null) - { - switch (entityInfo.EntityType) - { - case EntityType.Node: db.Nodes.Add(Node.FromNodeInfo(entityInfo as NodeInfo)); break; - case EntityType.Way: - Way toAdd = Way.FromWayInfo(entityInfo as WayInfo, db, !ignoreReferentialErrors); - if (toAdd == null) - { - if (!ignoreReferentialErrors) - { - throw new ArgumentException(string.Format("Way (ID = {0}) references missing node.", entityInfo.ID)); - } - } - else - { - db.Ways.Add(toAdd); - } + List relations = new List(); - break; - case EntityType.Relation: - RelationInfo ri = entityInfo as RelationInfo; - db.Relations.Add(new Relation(ri.ID) { Tags = ri.Tags, Metadata = ri.Metadata }); - relations.Add(ri); - break; - } - } - - foreach (var relationInfo in relations) + IEntityInfo entityInfo = null; + while ((entityInfo = reader.Read()) != null) + { + switch (entityInfo.EntityType) { - Relation relation = db.Relations[relationInfo.ID]; - - foreach (var memberInfo in relationInfo.Members) - { - RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, db, false); - if (member == null) + case EntityType.Node: db.Nodes.Add(Node.FromNodeInfo(entityInfo as NodeInfo)); break; + case EntityType.Way: + Way toAdd = Way.FromWayInfo(entityInfo as WayInfo, db, !ignoreReferentialErrors); + if (toAdd == null) { if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format("Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); + throw new ArgumentException(string.Format("Way (ID = {0}) references missing node.", entityInfo.ID)); } - - db.Relations.Remove(relation); } else { - relation.Geometries.Add(member); + db.Ways.Add(toAdd); } - } - } - return db; + break; + case EntityType.Relation: + RelationInfo ri = entityInfo as RelationInfo; + db.Relations.Add(new Relation(ri.ID) { Tags = ri.Tags, Metadata = ri.Metadata }); + relations.Add(ri); + break; + } } - /// - /// Saves entities from the database to the specific writer. - /// - /// The IOsmWriter to save entities to. - public override void Save(IOsmWriter writer) + foreach (var relationInfo in relations) { - foreach (var entity in this) + Relation relation = db.Relations[relationInfo.ID]; + + foreach (var memberInfo in relationInfo.Members) { - writer.Write(entity); + RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, db, false); + if (member == null) + { + if (!ignoreReferentialErrors) + { + throw new ArgumentException(string.Format("Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); + } + + db.Relations.Remove(relation); + } + else + { + relation.Geometries.Add(member); + } } } + + return db; + } + + /// + /// Saves entities from the database to the specific writer. + /// + /// The IOsmWriter to save entities to. + public override void Save(IOsmWriter writer) + { + foreach (var entity in this) + { + writer.Write(entity); + } } } diff --git a/src/SpatialLite.Osm/Geometries/Relation.cs b/src/SpatialLite.Osm/Geometries/Relation.cs index 990e9aa..ff54497 100644 --- a/src/SpatialLite.Osm/Geometries/Relation.cs +++ b/src/SpatialLite.Osm/Geometries/Relation.cs @@ -2,93 +2,92 @@ using SpatialLite.Core.Geometries; -namespace SpatialLite.Osm.Geometries +namespace SpatialLite.Osm.Geometries; + +/// +/// Represents OSM relation. +/// +public class Relation : GeometryCollection, IOsmGeometry { + /// - /// Represents OSM relation. + /// Initializes a new instance of the Relation class with the specified ID. /// - public class Relation : GeometryCollection, IOsmGeometry + /// The ID of the Relation. + public Relation(long id) + : this(id, new RelationMember[] { }, new TagsCollection()) { + } - /// - /// Initializes a new instance of the Relation class with the specified ID. - /// - /// The ID of the Relation. - public Relation(long id) - : this(id, new RelationMember[] { }, new TagsCollection()) - { - } + /// + /// Initializes a new instance of the Relation class with the specified ID and Members. + /// + /// The ID of the Relation. + /// The memberes of the relation. + public Relation(long id, IEnumerable members) + : this(id, members, new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Relation class with the specified ID and Members. - /// - /// The ID of the Relation. - /// The memberes of the relation. - public Relation(long id, IEnumerable members) - : this(id, members, new TagsCollection()) - { - } + /// + /// Initializes a new instance of the Relation class with the specified ID, Members and tags. + /// + /// The ID of the Relation. + /// The memberes of the relation. + /// The collectoin of tags associated with the relation. + public Relation(long id, IEnumerable members, TagsCollection tags) + : base(members) + { + this.ID = id; + this.Tags = tags; + } - /// - /// Initializes a new instance of the Relation class with the specified ID, Members and tags. - /// - /// The ID of the Relation. - /// The memberes of the relation. - /// The collectoin of tags associated with the relation. - public Relation(long id, IEnumerable members, TagsCollection tags) - : base(members) - { - this.ID = id; - this.Tags = tags; - } + /// + /// Gets or sets ID of the Relation. + /// + public long ID { get; set; } - /// - /// Gets or sets ID of the Relation. - /// - public long ID { get; set; } + /// + /// Gets or sets the collection of tags associated with the Relation. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets or sets the collection of tags associated with the Relation. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets or sets metadata of the Relation. + /// + public EntityMetadata Metadata { get; set; } - /// - /// Gets or sets metadata of the Relation. - /// - public EntityMetadata Metadata { get; set; } + /// + /// Gets type of this entity. + /// + public EntityType EntityType + { + get { return EntityType.Relation; } + } - /// - /// Gets type of this entity. - /// - public EntityType EntityType - { - get { return EntityType.Relation; } - } + /// + /// Creates a new instance of the Relation class with data from RelationInfo object. + /// + /// The RelationInfo object that contains data about relation. + /// The collection of entities that can be referenced by the relation. + /// bool value indicating whether references to the missing entities should cause exception. + /// The Relation object created from RelationInfo or null if referenced entity is missing. + public static Relation FromRelationInfo(RelationInfo info, IEntityCollection entities, bool throwOnMissing) + { + Relation result = new Relation(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; - /// - /// Creates a new instance of the Relation class with data from RelationInfo object. - /// - /// The RelationInfo object that contains data about relation. - /// The collection of entities that can be referenced by the relation. - /// bool value indicating whether references to the missing entities should cause exception. - /// The Relation object created from RelationInfo or null if referenced entity is missing. - public static Relation FromRelationInfo(RelationInfo info, IEntityCollection entities, bool throwOnMissing) + result.Geometries.Capacity = info.Members.Count; + foreach (var memberInfo in info.Members) { - Relation result = new Relation(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; - - result.Geometries.Capacity = info.Members.Count; - foreach (var memberInfo in info.Members) + RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, entities, throwOnMissing); + if (member == null) { - RelationMember member = RelationMember.FromRelationMemberInfo(memberInfo, entities, throwOnMissing); - if (member == null) - { - return null; - } - - result.Geometries.Add(member); + return null; } - return result; + result.Geometries.Add(member); } + + return result; } } diff --git a/src/SpatialLite.Osm/Geometries/RelationMember.cs b/src/SpatialLite.Osm/Geometries/RelationMember.cs index 2ff7cba..af9359b 100644 --- a/src/SpatialLite.Osm/Geometries/RelationMember.cs +++ b/src/SpatialLite.Osm/Geometries/RelationMember.cs @@ -4,147 +4,146 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Osm.Geometries +namespace SpatialLite.Osm.Geometries; + +/// +/// Ecapsules member of the OSM relation and it's role in the relation. +/// +public class RelationMember : Geometry { + /// - /// Ecapsules member of the OSM relation and it's role in the relation. + /// Initializes a new instance of the RelationMember class with empty Role and specified Member. /// - public class RelationMember : Geometry + /// The member of this RelatioinMember. + public RelationMember(IOsmGeometry member) + : this(member, null) { + } - /// - /// Initializes a new instance of the RelationMember class with empty Role and specified Member. - /// - /// The member of this RelatioinMember. - public RelationMember(IOsmGeometry member) - : this(member, null) + /// + /// Initializes a new instance of the RelationMember class with specified Role and Member. + /// + /// The member of this RelationMember. + /// The Role of this member in the relation. + public RelationMember(IOsmGeometry member, string role) + : base() + { + if (member == null) { + throw new ArgumentNullException(nameof(member)); } - /// - /// Initializes a new instance of the RelationMember class with specified Role and Member. - /// - /// The member of this RelationMember. - /// The Role of this member in the relation. - public RelationMember(IOsmGeometry member, string role) - : base() + this.Member = member; + this.Role = role; + + if (member is Node) { - if (member == null) - { - throw new ArgumentNullException(nameof(member)); - } + this.MemberType = EntityType.Node; + } + else if (member is Way) + { + this.MemberType = EntityType.Way; + } + else if (member is Relation) + { + this.MemberType = EntityType.Relation; + } + else + { + throw new ArgumentException("Unknown member type."); + } + } - this.Member = member; - this.Role = role; + /// + /// Gets the actual member. + /// + public IOsmGeometry Member { get; private set; } - if (member is Node) - { - this.MemberType = EntityType.Node; - } - else if (member is Way) - { - this.MemberType = EntityType.Way; - } - else if (member is Relation) - { - this.MemberType = EntityType.Relation; - } - else - { - throw new ArgumentException("Unknown member type."); - } - } + /// + /// Gets or sets role of the member in the relation. + /// + public string Role { get; set; } + + /// + /// Gets the type of the Member. + /// + public EntityType MemberType { get; private set; } - /// - /// Gets the actual member. - /// - public IOsmGeometry Member { get; private set; } - - /// - /// Gets or sets role of the member in the relation. - /// - public string Role { get; set; } - - /// - /// Gets the type of the Member. - /// - public EntityType MemberType { get; private set; } - - /// - /// Gets a value indicating whether this has Z coordinates. - /// - public override bool Is3D + /// + /// Gets a value indicating whether this has Z coordinates. + /// + public override bool Is3D + { + get { - get - { - return ((Geometry)this.Member).Is3D; - } + return ((Geometry)this.Member).Is3D; } + } - /// - /// Gets a value indicating whether this has M values. - /// - public override bool IsMeasured + /// + /// Gets a value indicating whether this has M values. + /// + public override bool IsMeasured + { + get { - get - { - return ((Geometry)this.Member).IsMeasured; - } + return ((Geometry)this.Member).IsMeasured; } + } - /// - /// Creates a new instance of the RelationMember class based on the data from RelationInfo object. - /// - /// The RelationMemberInfo object that contains data about member. - /// The entities that can be referenced by RelationMember. - /// bool value indicating whether references to the missing entity should cause exception. - /// The RelationMember object created from RelationMemberInfo or null if referenced node is missing. - public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEntityCollection entities, bool throwOnMissing) + /// + /// Creates a new instance of the RelationMember class based on the data from RelationInfo object. + /// + /// The RelationMemberInfo object that contains data about member. + /// The entities that can be referenced by RelationMember. + /// bool value indicating whether references to the missing entity should cause exception. + /// The RelationMember object created from RelationMemberInfo or null if referenced node is missing. + public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEntityCollection entities, bool throwOnMissing) + { + if (info.MemberType == EntityType.Unknown) { - if (info.MemberType == EntityType.Unknown) - { - throw new ArgumentException("info.MemberType cannot be EntityType.Unknown"); - } + throw new ArgumentException("info.MemberType cannot be EntityType.Unknown"); + } - if (entities.Contains(info.Reference, info.MemberType) == false) + if (entities.Contains(info.Reference, info.MemberType) == false) + { + if (throwOnMissing) { - if (throwOnMissing) - { - throw new ArgumentException(string.Format("Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); - } - else - { - return null; - } + throw new ArgumentException(string.Format("Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); } - - RelationMember result = new RelationMember(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; - if (result.Member.EntityType != info.MemberType) + else { - throw new ArgumentException("Type of the referenced entity doesn't match type of the entity in the collection."); + return null; } - - return result; } - /// - /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. - /// - /// - /// Returns an object that specifies the minimal bounding box of the Geometry object. - /// - public override Envelope GetEnvelope() + RelationMember result = new RelationMember(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; + if (result.Member.EntityType != info.MemberType) { - return ((Geometry)this.Member).GetEnvelope(); + throw new ArgumentException("Type of the referenced entity doesn't match type of the entity in the collection."); } - /// - /// Gets collection of all of this IGeometry object - /// - /// the collection of all of this object - public override IEnumerable GetCoordinates() - { - return this.Member.GetCoordinates(); - } + return result; + } + + /// + /// Computes envelope of the IGeometry object. The envelope is defined as a minimal bounding box for a geometry. + /// + /// + /// Returns an object that specifies the minimal bounding box of the Geometry object. + /// + public override Envelope GetEnvelope() + { + return ((Geometry)this.Member).GetEnvelope(); + } + + /// + /// Gets collection of all of this IGeometry object + /// + /// the collection of all of this object + public override IEnumerable GetCoordinates() + { + return this.Member.GetCoordinates(); } } diff --git a/src/SpatialLite.Osm/Geometries/Way.cs b/src/SpatialLite.Osm/Geometries/Way.cs index 92c4511..1814897 100644 --- a/src/SpatialLite.Osm/Geometries/Way.cs +++ b/src/SpatialLite.Osm/Geometries/Way.cs @@ -4,121 +4,120 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace SpatialLite.Osm.Geometries +namespace SpatialLite.Osm.Geometries; + +/// +/// Represents OSM way. +/// +public class Way : LineString, IOsmGeometry { + + private WayCoordinateList _coordinatesAdapter; + /// - /// Represents OSM way. + /// Initializes a new instance of the Way class with specified ID. /// - public class Way : LineString, IOsmGeometry + /// The ID of the Way. + public Way(long id) + : this(id, new Node[] { }, new TagsCollection()) { + } - private WayCoordinateList _coordinatesAdapter; + /// + /// Initializes a new instance of the Way class with specified ID and given Nodes. + /// + /// The ID of the Way. + /// The colection of Nodes to add to this Way. + public Way(long id, IEnumerable nodes) + : this(id, nodes, new TagsCollection()) + { + } - /// - /// Initializes a new instance of the Way class with specified ID. - /// - /// The ID of the Way. - public Way(long id) - : this(id, new Node[] { }, new TagsCollection()) - { - } + /// + /// Initializes a new instance of the Way class with specified ID, Nodes and collection of tags. + /// + /// The ID of the Way. + /// The colection of Nodes to add to this Way. + /// The collection of tags associated with the way. + public Way(long id, IEnumerable nodes, TagsCollection tags) + : base() + { + this.ID = id; + this.Tags = tags; + this.Nodes = new List(nodes); - /// - /// Initializes a new instance of the Way class with specified ID and given Nodes. - /// - /// The ID of the Way. - /// The colection of Nodes to add to this Way. - public Way(long id, IEnumerable nodes) - : this(id, nodes, new TagsCollection()) - { - } + _coordinatesAdapter = new WayCoordinateList(this.Nodes); + } - /// - /// Initializes a new instance of the Way class with specified ID, Nodes and collection of tags. - /// - /// The ID of the Way. - /// The colection of Nodes to add to this Way. - /// The collection of tags associated with the way. - public Way(long id, IEnumerable nodes, TagsCollection tags) - : base() - { - this.ID = id; - this.Tags = tags; - this.Nodes = new List(nodes); + /// + /// Gets or sets ID of the Node. + /// + public long ID { get; set; } - _coordinatesAdapter = new WayCoordinateList(this.Nodes); - } + /// + /// Gets or sets the collection of tags associated with the Node. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets or sets ID of the Node. - /// - public long ID { get; set; } - - /// - /// Gets or sets the collection of tags associated with the Node. - /// - public TagsCollection Tags { get; set; } - - /// - /// Gets or sets metadata of the Node. - /// - public EntityMetadata Metadata { get; set; } - - /// - /// Gets collection of Nodes of this Way. - /// - public List Nodes { get; private set; } - - /// - /// Gets the list of çoordinates of this Way. - /// - public override ICoordinateList Coordinates - { - get - { - return _coordinatesAdapter; - } - } + /// + /// Gets or sets metadata of the Node. + /// + public EntityMetadata Metadata { get; set; } - /// - /// Gets type of this entity. - /// - public EntityType EntityType + /// + /// Gets collection of Nodes of this Way. + /// + public List Nodes { get; private set; } + + /// + /// Gets the list of çoordinates of this Way. + /// + public override ICoordinateList Coordinates + { + get { - get { return EntityType.Way; } + return _coordinatesAdapter; } + } - /// - /// Creates a new instance of the Way class based on data from WayInfo object - /// - /// The WayInfo object that contains data about way - /// The entities that can be referenced by way - /// bool value indicating whether references to the missing nodes should cause exception - /// The Way object created from WayInfo or null if referenced node is missing - public static Way FromWayInfo(WayInfo info, IEntityCollection entities, bool throwOnMissing) - { - Way result = new Way(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; + /// + /// Gets type of this entity. + /// + public EntityType EntityType + { + get { return EntityType.Way; } + } + + /// + /// Creates a new instance of the Way class based on data from WayInfo object + /// + /// The WayInfo object that contains data about way + /// The entities that can be referenced by way + /// bool value indicating whether references to the missing nodes should cause exception + /// The Way object created from WayInfo or null if referenced node is missing + public static Way FromWayInfo(WayInfo info, IEntityCollection entities, bool throwOnMissing) + { + Way result = new Way(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; - result.Nodes.Capacity = info.Nodes.Count; - foreach (var nodeID in info.Nodes) + result.Nodes.Capacity = info.Nodes.Count; + foreach (var nodeID in info.Nodes) + { + Node node = entities[nodeID, EntityType.Node] as Node; + if (node != null) { - Node node = entities[nodeID, EntityType.Node] as Node; - if (node != null) + result.Nodes.Add(node); + } + else + { + if (throwOnMissing) { - result.Nodes.Add(node); + throw new ArgumentException(string.Format("Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); } - else - { - if (throwOnMissing) - { - throw new ArgumentException(string.Format("Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); - } - return null; - } + return null; } - - return result; } + + return result; } } diff --git a/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs b/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs index 0ebf435..bb2e694 100644 --- a/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs +++ b/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs @@ -4,121 +4,120 @@ using SpatialLite.Core.API; -namespace SpatialLite.Osm.Geometries +namespace SpatialLite.Osm.Geometries; + +/// +/// Provides a read-only wrapper around list of Nodes that implements ICoordinateList interface. +/// +internal class WayCoordinateList : ICoordinateList { + /// - /// Provides a read-only wrapper around list of Nodes that implements ICoordinateList interface. + /// Initializes a new instance of the WayCoordinateList class with specified source list fo nodes /// - internal class WayCoordinateList : ICoordinateList + /// The list of Nodes to be used as source for this WayCoordinateList + public WayCoordinateList(IList source) { + this.Source = source; + } - /// - /// Initializes a new instance of the WayCoordinateList class with specified source list fo nodes - /// - /// The list of Nodes to be used as source for this WayCoordinateList - public WayCoordinateList(IList source) - { - this.Source = source; - } - - /// - /// Gets number of Coordinates in the list. - /// - public int Count + /// + /// Gets number of Coordinates in the list. + /// + public int Count + { + get { - get - { - return this.Source.Count; - } + return this.Source.Count; } + } - /// - /// Gets the List of Nodes used as source for this WayCoordinateList. - /// - public IList Source { get; private set; } + /// + /// Gets the List of Nodes used as source for this WayCoordinateList. + /// + public IList Source { get; private set; } - /// - /// Gets or sets Coordinate at the given index. - /// - /// The zero-based index of the Coordinate to get or set. - /// The element at the specified index. - public Coordinate this[int index] + /// + /// Gets or sets Coordinate at the given index. + /// + /// The zero-based index of the Coordinate to get or set. + /// The element at the specified index. + public Coordinate this[int index] + { + get { - get - { - return this.Source[index].Position; - } - set - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + return this.Source[index].Position; } - - /// - /// Adds Coordinate to the end of the list. - /// - /// The Coordinate to add to the list. - public void Add(Coordinate coord) + set { throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); } + } - /// - /// Adds collection of coordinates to the end of the list. - /// - /// The collection of coordinates to add to the list. - public void Add(IEnumerable coords) - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Adds Coordinate to the end of the list. + /// + /// The Coordinate to add to the list. + public void Add(Coordinate coord) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Insertes Coordinate to the list at the specified index. - /// - /// The zero-based index at which coord should be inserted. - /// The Coordinate to insert into list. - /// If index equals the number of items in the list, then item is appended to the list. - public void Insert(int index, Coordinate coord) - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Adds collection of coordinates to the end of the list. + /// + /// The collection of coordinates to add to the list. + public void Add(IEnumerable coords) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Removes Coordinate at the specified index from the list. - /// - /// The zero-based index of the Coordinate to remove. - public void RemoveAt(int index) - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Insertes Coordinate to the list at the specified index. + /// + /// The zero-based index at which coord should be inserted. + /// The Coordinate to insert into list. + /// If index equals the number of items in the list, then item is appended to the list. + public void Insert(int index, Coordinate coord) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Removes all Coordinates from the collection. - /// - public void Clear() - { - throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); - } + /// + /// Removes Coordinate at the specified index from the list. + /// + /// The zero-based index of the Coordinate to remove. + public void RemoveAt(int index) + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - public IEnumerator GetEnumerator() - { - foreach (var node in this.Source) - { - yield return node.Position; - } - } + /// + /// Removes all Coordinates from the collection. + /// + public void Clear() + { + throw new NotSupportedException("This operation isn't supported - use Nodes property to modify coordinates."); + } - /// - /// Returns an enumerator that iterates through the CoordinateList - /// - /// The Enumerator for the CoordinateList - IEnumerator IEnumerable.GetEnumerator() + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + public IEnumerator GetEnumerator() + { + foreach (var node in this.Source) { - return this.GetEnumerator(); + yield return node.Position; } } + + /// + /// Returns an enumerator that iterates through the CoordinateList + /// + /// The Enumerator for the CoordinateList + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } } diff --git a/src/SpatialLite.Osm/IEntityCollection.cs b/src/SpatialLite.Osm/IEntityCollection.cs index 2e389cb..ec23a96 100644 --- a/src/SpatialLite.Osm/IEntityCollection.cs +++ b/src/SpatialLite.Osm/IEntityCollection.cs @@ -1,35 +1,34 @@ using System.Collections.Generic; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Defines methods and properties for collection of the OSM entities where entities can be accessed by their ID and type. +/// +/// The type of the entitie in the collection. +public interface IEntityCollection : ICollection where T : IOsmEntity { /// - /// Defines methods and properties for collection of the OSM entities where entities can be accessed by their ID and type. + /// Gets an entity with specific ID from the collection. /// - /// The type of the entitie in the collection. - public interface IEntityCollection : ICollection where T : IOsmEntity - { - /// - /// Gets an entity with specific ID from the collection. - /// - /// The ID of the entity to get. - /// The type of the entity to get. - /// entity with the specific ID or null if such entity is not present in the collection. - T this[long id, EntityType type] { get; } + /// The ID of the entity to get. + /// The type of the entity to get. + /// entity with the specific ID or null if such entity is not present in the collection. + T this[long id, EntityType type] { get; } - /// - /// Removes an entity with the specific ID from the collection. - /// - /// The ID of the entity to remove from the collection. - /// The type of the entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - bool Remove(long id, EntityType type); + /// + /// Removes an entity with the specific ID from the collection. + /// + /// The ID of the entity to remove from the collection. + /// The type of the entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + bool Remove(long id, EntityType type); - /// - /// Determines whether the EntityICollection contains an entity with specific ID. - /// - /// The ID of the entity to locate in the EntityCollection. - /// The type of the entity to locate in the EntityCollection - /// true if entity is found in the collection, otherwise false. - bool Contains(long id, EntityType type); - } + /// + /// Determines whether the EntityICollection contains an entity with specific ID. + /// + /// The ID of the entity to locate in the EntityCollection. + /// The type of the entity to locate in the EntityCollection + /// true if entity is found in the collection, otherwise false. + bool Contains(long id, EntityType type); } diff --git a/src/SpatialLite.Osm/IEntityInfo.cs b/src/SpatialLite.Osm/IEntityInfo.cs index 216baf8..216a5b0 100644 --- a/src/SpatialLite.Osm/IEntityInfo.cs +++ b/src/SpatialLite.Osm/IEntityInfo.cs @@ -1,9 +1,8 @@ -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Defines common properties for nodes, ways and relations in serialized form. +/// +public interface IEntityInfo : IOsmEntity { - /// - /// Defines common properties for nodes, ways and relations in serialized form. - /// - public interface IEntityInfo : IOsmEntity - { - } } diff --git a/src/SpatialLite.Osm/IO/CompressionMode.cs b/src/SpatialLite.Osm/IO/CompressionMode.cs index 87fb6e8..0bfd02c 100644 --- a/src/SpatialLite.Osm/IO/CompressionMode.cs +++ b/src/SpatialLite.Osm/IO/CompressionMode.cs @@ -1,18 +1,17 @@ -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Defines compressions that can be used in the PBF format. +/// +public enum CompressionMode { /// - /// Defines compressions that can be used in the PBF format. + /// No compresion is used. /// - public enum CompressionMode - { - /// - /// No compresion is used. - /// - None, + None, - /// - /// Zlib compression. - /// - ZlibDeflate - } + /// + /// Zlib compression. + /// + ZlibDeflate } diff --git a/src/SpatialLite.Osm/IO/IOsmReader.cs b/src/SpatialLite.Osm/IO/IOsmReader.cs index 82ac06b..e53e422 100644 --- a/src/SpatialLite.Osm/IO/IOsmReader.cs +++ b/src/SpatialLite.Osm/IO/IOsmReader.cs @@ -1,16 +1,15 @@ using System; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Defines functions and properties for classes that can read OSM entities from various sources. +/// +public interface IOsmReader : IDisposable { /// - /// Defines functions and properties for classes that can read OSM entities from various sources. + /// Reads the next Osm entity from a source. /// - public interface IOsmReader : IDisposable - { - /// - /// Reads the next Osm entity from a source. - /// - /// IEntityInfo object with information about entity, or null if no more entities are available. - IEntityInfo Read(); - } + /// IEntityInfo object with information about entity, or null if no more entities are available. + IEntityInfo Read(); } diff --git a/src/SpatialLite.Osm/IO/IOsmWriter.cs b/src/SpatialLite.Osm/IO/IOsmWriter.cs index e6d0cc3..fdab800 100644 --- a/src/SpatialLite.Osm/IO/IOsmWriter.cs +++ b/src/SpatialLite.Osm/IO/IOsmWriter.cs @@ -1,28 +1,27 @@ using System; using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Defines functions and properties for classes that can write OSM entities to various destinations. +/// +public interface IOsmWriter : IDisposable { /// - /// Defines functions and properties for classes that can write OSM entities to various destinations. + /// Writes entity to the destination. /// - public interface IOsmWriter : IDisposable - { - /// - /// Writes entity to the destination. - /// - /// The entity to write. - void Write(IOsmGeometry entity); + /// The entity to write. + void Write(IOsmGeometry entity); - /// - /// Writes entity info object to the target. - /// - /// The entity info object to wrirte. - void Write(IEntityInfo info); + /// + /// Writes entity info object to the target. + /// + /// The entity info object to wrirte. + void Write(IEntityInfo info); - /// - /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. - /// - void Flush(); - } + /// + /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. + /// + void Flush(); } diff --git a/src/SpatialLite.Osm/IO/OsmReaderSettings.cs b/src/SpatialLite.Osm/IO/OsmReaderSettings.cs index 5f6c547..2f33853 100644 --- a/src/SpatialLite.Osm/IO/OsmReaderSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmReaderSettings.cs @@ -1,46 +1,45 @@ using System; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Contains settings that determine behaviour of OsmReaders. +/// +public class OsmReaderSettings { + + bool _readMetadata = true; + /// - /// Contains settings that determine behaviour of OsmReaders. + /// Initializes a new instance of the OsmReaderSettings class with default values. /// - public class OsmReaderSettings + public OsmReaderSettings() { + this.ReadMetadata = true; + } - bool _readMetadata = true; - - /// - /// Initializes a new instance of the OsmReaderSettings class with default values. - /// - public OsmReaderSettings() + /// + /// Gets a value indicating whether OsmReader should read and parse entity metadata. + /// + public bool ReadMetadata + { + get { - this.ReadMetadata = true; + return _readMetadata; } - - /// - /// Gets a value indicating whether OsmReader should read and parse entity metadata. - /// - public bool ReadMetadata + set { - get + if (this.IsReadOnly) { - return _readMetadata; + throw new InvalidOperationException("Cannot change the 'ReadMetadata' property OsmReaderSettings is read-only."); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'ReadMetadata' property OsmReaderSettings is read-only."); - } - _readMetadata = value; - } + _readMetadata = value; } - - /// - /// Gets or sets value indicating whether properties of the current OsmReaderSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } } + + /// + /// Gets or sets value indicating whether properties of the current OsmReaderSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } } diff --git a/src/SpatialLite.Osm/IO/OsmWriterSettings.cs b/src/SpatialLite.Osm/IO/OsmWriterSettings.cs index 7dd04ad..c456108 100644 --- a/src/SpatialLite.Osm/IO/OsmWriterSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmWriterSettings.cs @@ -1,67 +1,66 @@ using System; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Contains settings that determine behaviour of the OsmWriterWriter. +/// +public class OsmWriterSettings { + + bool _writeMetadata = true; + string _programName = "SpatialLITE"; + /// - /// Contains settings that determine behaviour of the OsmWriterWriter. + /// Initializes a new instance of the OsmReaderSettings class with default values. /// - public class OsmWriterSettings + public OsmWriterSettings() { + this.WriteMetadata = true; + } - bool _writeMetadata = true; - string _programName = "SpatialLITE"; - - /// - /// Initializes a new instance of the OsmReaderSettings class with default values. - /// - public OsmWriterSettings() + /// + /// Gets or sets a value indicating whether OsmWriter should write entity metadata. + /// + public bool WriteMetadata + { + get { - this.WriteMetadata = true; + return _writeMetadata; } - - /// - /// Gets or sets a value indicating whether OsmWriter should write entity metadata. - /// - public bool WriteMetadata + set { - get + if (this.IsReadOnly) { - return _writeMetadata; + throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - OsmWriterSettings is read-only."); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - OsmWriterSettings is read-only."); - } - _writeMetadata = value; - } + _writeMetadata = value; } + } - /// - /// Gets or sets the name of the program that will be save to the output file. - /// - public string ProgramName + /// + /// Gets or sets the name of the program that will be save to the output file. + /// + public string ProgramName + { + get { - get + return _programName; + } + set + { + if (this.IsReadOnly) { - return _programName; + throw new InvalidOperationException("Cannot change the 'ProgramName' property - OsmWriterSettings is read-only."); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'ProgramName' property - OsmWriterSettings is read-only."); - } - _programName = value; - } + _programName = value; } - - /// - /// Gets or sets value indicating whether properties of the current OsmWriterSettings instance can be changed. - /// - protected internal bool IsReadOnly { get; internal set; } } + + /// + /// Gets or sets value indicating whether properties of the current OsmWriterSettings instance can be changed. + /// + protected internal bool IsReadOnly { get; internal set; } } diff --git a/src/SpatialLite.Osm/IO/OsmXmlReader.cs b/src/SpatialLite.Osm/IO/OsmXmlReader.cs index e56a08f..4b2c0c7 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReader.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReader.cs @@ -3,505 +3,504 @@ using System.IO; using Sys = System.Xml; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Represents a OsmReader, that can read OSM entities saved in the XML format. +/// +public class OsmXmlReader : IOsmReader { + + private bool _disposed = false; + private Sys.XmlReader _xmlReader; + /// - /// Represents a OsmReader, that can read OSM entities saved in the XML format. + /// Underlaying stream to read data from /// - public class OsmXmlReader : IOsmReader - { + private Stream _input; + private bool _ownsInputStream = false; - private bool _disposed = false; - private Sys.XmlReader _xmlReader; - - /// - /// Underlaying stream to read data from - /// - private Stream _input; - private bool _ownsInputStream = false; + /// + /// Contains bool value indicating whether XmlReader is inside osm element + /// + private bool _insideOsm; - /// - /// Contains bool value indicating whether XmlReader is inside osm element - /// - private bool _insideOsm; + /// + /// Initializes a new instance of the OsmXmlReader class that reads data from the specified file. + /// + /// Path to the .osm file. + /// The OsmReaderSettings object that determines behaviour of XmlReader. + public OsmXmlReader(string path, OsmXmlReaderSettings settings) + { + _input = new FileStream(path, FileMode.Open, FileAccess.Read); + _ownsInputStream = true; - /// - /// Initializes a new instance of the OsmXmlReader class that reads data from the specified file. - /// - /// Path to the .osm file. - /// The OsmReaderSettings object that determines behaviour of XmlReader. - public OsmXmlReader(string path, OsmXmlReaderSettings settings) - { - _input = new FileStream(path, FileMode.Open, FileAccess.Read); - _ownsInputStream = true; + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); - } + /// + /// Initializes a new instance of the OsmXmlReader class that reads data from the specified stream. + /// + /// The stream with osm xml data. + /// The OsmReaderSettings object that determines behaviour of XmlReader. + public OsmXmlReader(Stream stream, OsmXmlReaderSettings settings) + { + _input = stream; - /// - /// Initializes a new instance of the OsmXmlReader class that reads data from the specified stream. - /// - /// The stream with osm xml data. - /// The OsmReaderSettings object that determines behaviour of XmlReader. - public OsmXmlReader(Stream stream, OsmXmlReaderSettings settings) - { - _input = stream; + this.Settings = settings; + this.Settings.IsReadOnly = true; + this.InitializeReader(); + } - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); - } + /// + /// Gets OsmReaderSettings object that contains properties which determine behaviour of the reader. + /// + public OsmXmlReaderSettings Settings { get; private set; } - /// - /// Gets OsmReaderSettings object that contains properties which determine behaviour of the reader. - /// - public OsmXmlReaderSettings Settings { get; private set; } + /// + /// Reads the next OSM entity from the stream. + /// + /// IEntityInfo object with information about entity read from the stream, or null if no more entities are available. + public IEntityInfo Read() + { + IEntityInfo result = null; - /// - /// Reads the next OSM entity from the stream. - /// - /// IEntityInfo object with information about entity read from the stream, or null if no more entities are available. - public IEntityInfo Read() + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement && result == null) { - IEntityInfo result = null; - - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement && result == null) + switch (_xmlReader.Name) { - switch (_xmlReader.Name) - { - case "node": - result = this.ReadNode(); - break; - case "way": - result = this.ReadWay(); - break; - case "relation": - result = this.ReadRelation(); - break; - default: - _xmlReader.Read(); - break; - } + case "node": + result = this.ReadNode(); + break; + case "way": + result = this.ReadWay(); + break; + case "relation": + result = this.ReadRelation(); + break; + default: + _xmlReader.Read(); + break; } - - return result; } - /// - /// Releases all resources used by the OsmXmlReader. - /// - public void Dispose() + return result; + } + + /// + /// Releases all resources used by the OsmXmlReader. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Reads Node from the currnt element in the _xmlReader. + /// + /// Information about parsed node. + private NodeInfo ReadNode() + { + // id + string attId = _xmlReader.GetAttribute("id"); + if (attId == null) { - Dispose(true); - GC.SuppressFinalize(this); + throw new Sys.XmlException("Attribute 'id' is missing."); } - /// - /// Reads Node from the currnt element in the _xmlReader. - /// - /// Information about parsed node. - private NodeInfo ReadNode() + var nodeId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); + + // latitude + string attLat = _xmlReader.GetAttribute("lat"); + if (attLat == null) { - // id - string attId = _xmlReader.GetAttribute("id"); - if (attId == null) - { - throw new Sys.XmlException("Attribute 'id' is missing."); - } + throw new Sys.XmlException("Attribute 'lat' is missing."); + } - var nodeId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); + double nodeLat = double.Parse(attLat, System.Globalization.CultureInfo.InvariantCulture); - // latitude - string attLat = _xmlReader.GetAttribute("lat"); - if (attLat == null) - { - throw new Sys.XmlException("Attribute 'lat' is missing."); - } + // longitude + string attLon = _xmlReader.GetAttribute("lon"); + if (attLon == null) + { + throw new Sys.XmlException("Attribute 'lon'is missing."); + } - double nodeLat = double.Parse(attLat, System.Globalization.CultureInfo.InvariantCulture); + double nodeLon = double.Parse(attLon, System.Globalization.CultureInfo.InvariantCulture); - // longitude - string attLon = _xmlReader.GetAttribute("lon"); - if (attLon == null) - { - throw new Sys.XmlException("Attribute 'lon'is missing."); - } + EntityMetadata additionalInfo = null; + if (this.Settings.ReadMetadata) + { + additionalInfo = this.ReadMetadata(); + } - double nodeLon = double.Parse(attLon, System.Globalization.CultureInfo.InvariantCulture); + NodeInfo result = new NodeInfo(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); - EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) - { - additionalInfo = this.ReadMetadata(); - } - - NodeInfo result = new NodeInfo(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); - if (_xmlReader.IsEmptyElement == false) + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) { - _xmlReader.Read(); - - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + if (_xmlReader.NodeType == Sys.XmlNodeType.Element && _xmlReader.Name == "tag") { - if (_xmlReader.NodeType == Sys.XmlNodeType.Element && _xmlReader.Name == "tag") - { - result.Tags.Add(this.ReadTag()); - } - else - { - _xmlReader.Skip(); - } + result.Tags.Add(this.ReadTag()); + } + else + { + _xmlReader.Skip(); } } - - _xmlReader.Skip(); - return result; } - /// - /// Reads Way from the currnt element in the _xmlReader. - /// - /// Information about parsed way. - private WayInfo ReadWay() + _xmlReader.Skip(); + return result; + } + + /// + /// Reads Way from the currnt element in the _xmlReader. + /// + /// Information about parsed way. + private WayInfo ReadWay() + { + string attId = _xmlReader.GetAttribute("id"); + if (attId == null) { - string attId = _xmlReader.GetAttribute("id"); - if (attId == null) - { - throw new Sys.XmlException("Attribute 'id' is missing."); - } + throw new Sys.XmlException("Attribute 'id' is missing."); + } - var wayId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); + var wayId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); - EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) - { - additionalInfo = this.ReadMetadata(); - } + EntityMetadata additionalInfo = null; + if (this.Settings.ReadMetadata) + { + additionalInfo = this.ReadMetadata(); + } - WayInfo way = new WayInfo(wayId, new TagsCollection(), new List(), additionalInfo); + WayInfo way = new WayInfo(wayId, new TagsCollection(), new List(), additionalInfo); - if (_xmlReader.IsEmptyElement == false) - { - _xmlReader.Read(); + if (_xmlReader.IsEmptyElement == false) + { + _xmlReader.Read(); - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + { + switch (_xmlReader.NodeType) { - switch (_xmlReader.NodeType) - { - case Sys.XmlNodeType.Element: - switch (_xmlReader.Name) - { - case "nd": - way.Nodes.Add(this.ReadWayNd()); - continue; - case "tag": - way.Tags.Add(this.ReadTag()); - continue; - default: - _xmlReader.Skip(); - continue; - } - - default: - _xmlReader.Skip(); - break; - } + case Sys.XmlNodeType.Element: + switch (_xmlReader.Name) + { + case "nd": + way.Nodes.Add(this.ReadWayNd()); + continue; + case "tag": + way.Tags.Add(this.ReadTag()); + continue; + default: + _xmlReader.Skip(); + continue; + } + + default: + _xmlReader.Skip(); + break; } } - - _xmlReader.Skip(); - return way; } - /// - /// Reads Node reference from the currnt Way element in the _xmlReader. - /// - /// Reference to the node. - private long ReadWayNd() + _xmlReader.Skip(); + return way; + } + + /// + /// Reads Node reference from the currnt Way element in the _xmlReader. + /// + /// Reference to the node. + private long ReadWayNd() + { + string attRef = _xmlReader.GetAttribute("ref"); + if (string.IsNullOrEmpty(attRef)) { - string attRef = _xmlReader.GetAttribute("ref"); - if (string.IsNullOrEmpty(attRef)) - { - throw new Sys.XmlException("Attribute 'ref' is missing."); - } + throw new Sys.XmlException("Attribute 'ref' is missing."); + } - var nodeId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); + var nodeId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); - _xmlReader.Skip(); + _xmlReader.Skip(); - return nodeId; - } + return nodeId; + } - /// - /// Reads Relation from the currnt element in the _xmlReader. - /// - /// Information about parsed relation. - private RelationInfo ReadRelation() + /// + /// Reads Relation from the currnt element in the _xmlReader. + /// + /// Information about parsed relation. + private RelationInfo ReadRelation() + { + string attId = _xmlReader.GetAttribute("id"); + if (attId == null) { - string attId = _xmlReader.GetAttribute("id"); - if (attId == null) - { - throw new Sys.XmlException("Attribute 'id' is missing."); - } + throw new Sys.XmlException("Attribute 'id' is missing."); + } - var relationId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); + var relationId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); - EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) - { - additionalInfo = this.ReadMetadata(); - } + EntityMetadata additionalInfo = null; + if (this.Settings.ReadMetadata) + { + additionalInfo = this.ReadMetadata(); + } - RelationInfo relation = new RelationInfo(relationId, new TagsCollection(), new List(), additionalInfo); + RelationInfo relation = new RelationInfo(relationId, new TagsCollection(), new List(), additionalInfo); - if (false == _xmlReader.IsEmptyElement) - { - _xmlReader.Read(); + if (false == _xmlReader.IsEmptyElement) + { + _xmlReader.Read(); - while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + while (_xmlReader.NodeType != Sys.XmlNodeType.EndElement) + { + switch (_xmlReader.NodeType) { - switch (_xmlReader.NodeType) - { - case Sys.XmlNodeType.Element: - switch (_xmlReader.Name) - { - case "member": - relation.Members.Add(this.ReadRelationMember()); - continue; - case "tag": - relation.Tags.Add(this.ReadTag()); - continue; - default: - _xmlReader.Skip(); - continue; - } - - default: - _xmlReader.Skip(); - break; - } + case Sys.XmlNodeType.Element: + switch (_xmlReader.Name) + { + case "member": + relation.Members.Add(this.ReadRelationMember()); + continue; + case "tag": + relation.Tags.Add(this.ReadTag()); + continue; + default: + _xmlReader.Skip(); + continue; + } + + default: + _xmlReader.Skip(); + break; } } + } - _xmlReader.Skip(); + _xmlReader.Skip(); - return relation; + return relation; + } + + /// + /// Reads RelationMember from the current Relation in the _xmlReader. + /// + /// Information about parsed relation member + private RelationMemberInfo ReadRelationMember() + { + string attType = _xmlReader.GetAttribute("type"); + if (string.IsNullOrEmpty(attType)) + { + throw new Sys.XmlException("Attribute 'type' is missing."); } - /// - /// Reads RelationMember from the current Relation in the _xmlReader. - /// - /// Information about parsed relation member - private RelationMemberInfo ReadRelationMember() + string attRef = _xmlReader.GetAttribute("ref"); + if (string.IsNullOrEmpty(attRef)) { - string attType = _xmlReader.GetAttribute("type"); - if (string.IsNullOrEmpty(attType)) - { - throw new Sys.XmlException("Attribute 'type' is missing."); - } + throw new Sys.XmlException("Attribute 'ref' is missing."); + } - string attRef = _xmlReader.GetAttribute("ref"); - if (string.IsNullOrEmpty(attRef)) - { - throw new Sys.XmlException("Attribute 'ref' is missing."); - } + var refId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); - var refId = long.Parse(attRef, System.Globalization.CultureInfo.InvariantCulture); + string attRole = _xmlReader.GetAttribute("role"); - string attRole = _xmlReader.GetAttribute("role"); + EntityType memberType; + switch (attType) + { + case "node": + memberType = EntityType.Node; + break; + case "way": + memberType = EntityType.Way; + break; + case "relation": + memberType = EntityType.Relation; + break; + default: + throw new Sys.XmlException("Unknown relation member type"); + } - EntityType memberType; - switch (attType) - { - case "node": - memberType = EntityType.Node; - break; - case "way": - memberType = EntityType.Way; - break; - case "relation": - memberType = EntityType.Relation; - break; - default: - throw new Sys.XmlException("Unknown relation member type"); - } + _xmlReader.Skip(); - _xmlReader.Skip(); + return new RelationMemberInfo() { MemberType = memberType, Reference = refId, Role = attRole }; + } - return new RelationMemberInfo() { MemberType = memberType, Reference = refId, Role = attRole }; + /// + /// Reads Tag from the current element in the _xmlReader. + /// + /// the parsed Tag. + private Tag ReadTag() + { + string attK = _xmlReader.GetAttribute("k"); + if (attK == null) + { + throw new Sys.XmlException("Attribute 'k' is missing."); } - /// - /// Reads Tag from the current element in the _xmlReader. - /// - /// the parsed Tag. - private Tag ReadTag() + string attV = _xmlReader.GetAttribute("v"); + if (attV == null) { - string attK = _xmlReader.GetAttribute("k"); - if (attK == null) - { - throw new Sys.XmlException("Attribute 'k' is missing."); - } + throw new Sys.XmlException("Attribute 'v' is missing."); + } - string attV = _xmlReader.GetAttribute("v"); - if (attV == null) - { - throw new Sys.XmlException("Attribute 'v' is missing."); - } + _xmlReader.Skip(); - _xmlReader.Skip(); + return new Tag(attK, attV); + } - return new Tag(attK, attV); - } + /// + /// Reads metadata of the osm entity + /// + /// Metadata of the entity read from the reader. + private EntityMetadata ReadMetadata() + { + EntityMetadata result = new EntityMetadata(); - /// - /// Reads metadata of the osm entity - /// - /// Metadata of the entity read from the reader. - private EntityMetadata ReadMetadata() + // version + string attVersion = _xmlReader.GetAttribute("version"); + if (attVersion == null) { - EntityMetadata result = new EntityMetadata(); - - // version - string attVersion = _xmlReader.GetAttribute("version"); - if (attVersion == null) - { - if (this.Settings.StrictMode) - { - throw new Sys.XmlException("Attribute 'version' is missing."); - } - } - else + if (this.Settings.StrictMode) { - result.Version = int.Parse(attVersion, System.Globalization.CultureInfo.InvariantCulture); + throw new Sys.XmlException("Attribute 'version' is missing."); } + } + else + { + result.Version = int.Parse(attVersion, System.Globalization.CultureInfo.InvariantCulture); + } - // changeset - string attChangeset = _xmlReader.GetAttribute("changeset"); - if (attChangeset == null) - { - if (this.Settings.StrictMode) - { - throw new Sys.XmlException("Attribute 'changeset' is missing."); - } - } - else + // changeset + string attChangeset = _xmlReader.GetAttribute("changeset"); + if (attChangeset == null) + { + if (this.Settings.StrictMode) { - result.Changeset = int.Parse(attChangeset, System.Globalization.CultureInfo.InvariantCulture); + throw new Sys.XmlException("Attribute 'changeset' is missing."); } + } + else + { + result.Changeset = int.Parse(attChangeset, System.Globalization.CultureInfo.InvariantCulture); + } - // uid - string attUid = _xmlReader.GetAttribute("uid"); - if (attUid == null) - { - if (this.Settings.StrictMode) - { - throw new Sys.XmlException("Attribute 'uid' is missing."); - } - } - else + // uid + string attUid = _xmlReader.GetAttribute("uid"); + if (attUid == null) + { + if (this.Settings.StrictMode) { - result.Uid = int.Parse(attUid, System.Globalization.CultureInfo.InvariantCulture); + throw new Sys.XmlException("Attribute 'uid' is missing."); } + } + else + { + result.Uid = int.Parse(attUid, System.Globalization.CultureInfo.InvariantCulture); + } - // user - string attrUser = _xmlReader.GetAttribute("user"); - if (attrUser == null) - { - if (this.Settings.StrictMode) - { - throw new Sys.XmlException("Attribute 'user' is missing."); - } - } - else + // user + string attrUser = _xmlReader.GetAttribute("user"); + if (attrUser == null) + { + if (this.Settings.StrictMode) { - result.User = attrUser; + throw new Sys.XmlException("Attribute 'user' is missing."); } + } + else + { + result.User = attrUser; + } - // visible - string attVisible = _xmlReader.GetAttribute("visible"); - if (attVisible == null) - { - if (this.Settings.StrictMode) - { - result.Visible = true; - } - } - else + // visible + string attVisible = _xmlReader.GetAttribute("visible"); + if (attVisible == null) + { + if (this.Settings.StrictMode) { - result.Visible = bool.Parse(attVisible); + result.Visible = true; } + } + else + { + result.Visible = bool.Parse(attVisible); + } - // timestamp - string attTimestamp = _xmlReader.GetAttribute("timestamp"); - if (attTimestamp == null) - { - if (this.Settings.StrictMode) - { - throw new Sys.XmlException("Attribute 'timestamp' is missing."); - } - } - else + // timestamp + string attTimestamp = _xmlReader.GetAttribute("timestamp"); + if (attTimestamp == null) + { + if (this.Settings.StrictMode) { - result.Timestamp = DateTime.ParseExact(attTimestamp, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", System.Globalization.CultureInfo.InvariantCulture); + throw new Sys.XmlException("Attribute 'timestamp' is missing."); } - - return result; } - - /// - /// Initializes internal properties - /// - private void InitializeReader() + else { - Sys.XmlReaderSettings xmlReaderSettings = new Sys.XmlReaderSettings(); - xmlReaderSettings.IgnoreComments = true; - xmlReaderSettings.IgnoreProcessingInstructions = true; - xmlReaderSettings.IgnoreWhitespace = true; + result.Timestamp = DateTime.ParseExact(attTimestamp, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", System.Globalization.CultureInfo.InvariantCulture); + } - _xmlReader = Sys.XmlReader.Create(_input, xmlReaderSettings); + return result; + } - _xmlReader.Read(); - while (_xmlReader.EOF == false && _insideOsm == false) + /// + /// Initializes internal properties + /// + private void InitializeReader() + { + Sys.XmlReaderSettings xmlReaderSettings = new Sys.XmlReaderSettings(); + xmlReaderSettings.IgnoreComments = true; + xmlReaderSettings.IgnoreProcessingInstructions = true; + xmlReaderSettings.IgnoreWhitespace = true; + + _xmlReader = Sys.XmlReader.Create(_input, xmlReaderSettings); + + _xmlReader.Read(); + while (_xmlReader.EOF == false && _insideOsm == false) + { + switch (_xmlReader.NodeType) { - switch (_xmlReader.NodeType) - { - case Sys.XmlNodeType.Element: - if (_xmlReader.Name != "osm") - { - throw new Sys.XmlException("Invalid xml root element. Expected ."); - } + case Sys.XmlNodeType.Element: + if (_xmlReader.Name != "osm") + { + throw new Sys.XmlException("Invalid xml root element. Expected ."); + } - _insideOsm = true; - break; + _insideOsm = true; + break; - default: - _xmlReader.Read(); - break; - } + default: + _xmlReader.Read(); + break; } } + } - /// - /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + /// + /// Releases the unmanaged resources used by the ComponentLibrary and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) { - if (!this._disposed) + if (disposing) { - if (disposing) + if (_ownsInputStream) { - if (_ownsInputStream) - { - _input.Dispose(); - } + _input.Dispose(); } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs b/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs index 797901f..d221994 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs @@ -1,41 +1,40 @@ using System; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Contains settings that determine behaviour of the OsmXmlReader. +/// +public class OsmXmlReaderSettings : OsmReaderSettings { + + private bool _strictMode = true; + /// - /// Contains settings that determine behaviour of the OsmXmlReader. + /// Gets or sets a value indicating whether OsmXmlReader should run in strct mode. /// - public class OsmXmlReaderSettings : OsmReaderSettings + /// + /// + /// Default value is true. + /// + /// + /// In strict mode missing attributes for entity metadata causes OsmXmlReader to throw an exception. If strict mode is off and some metadata attributes are missing, missing attributes are set to their default values. + /// + /// + public bool StrictMode { - - private bool _strictMode = true; - - /// - /// Gets or sets a value indicating whether OsmXmlReader should run in strct mode. - /// - /// - /// - /// Default value is true. - /// - /// - /// In strict mode missing attributes for entity metadata causes OsmXmlReader to throw an exception. If strict mode is off and some metadata attributes are missing, missing attributes are set to their default values. - /// - /// - public bool StrictMode + get { - get + return _strictMode; + } + set + { + if (this.IsReadOnly) { - return _strictMode; + throw new InvalidOperationException("Cannot change the 'StrictMode' property - OsmXmlReaderSettings is read-only."); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'StrictMode' property - OsmXmlReaderSettings is read-only."); - } - _strictMode = value; - } + _strictMode = value; } } } diff --git a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs index e482bc2..b96df85 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs @@ -5,299 +5,298 @@ using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Represents an IOsmWriter, that can write OSM entities to XML format. +/// +public class OsmXmlWriter : IOsmWriter { + + private System.Globalization.CultureInfo _culture = System.Globalization.CultureInfo.InvariantCulture; + private Stream _output; + private bool _ownsOutputStream; + + private XmlWriter _writer; + private bool _isInsideOsm = false; + private bool _disposed = false; + + // underlaying stream writer for writing to files + private StreamWriter _streamWriter; + /// - /// Represents an IOsmWriter, that can write OSM entities to XML format. + /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified stream. /// - public class OsmXmlWriter : IOsmWriter + /// The Stream to write OSM entities to. + /// The settings defining behaviour of the writer. + public OsmXmlWriter(Stream stream, OsmWriterSettings settings) { + this.Settings = settings; + this.Settings.IsReadOnly = true; - private System.Globalization.CultureInfo _culture = System.Globalization.CultureInfo.InvariantCulture; - private Stream _output; - private bool _ownsOutputStream; - - private XmlWriter _writer; - private bool _isInsideOsm = false; - private bool _disposed = false; + _output = stream; + _ownsOutputStream = false; - // underlaying stream writer for writing to files - private StreamWriter _streamWriter; + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; - /// - /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified stream. - /// - /// The Stream to write OSM entities to. - /// The settings defining behaviour of the writer. - public OsmXmlWriter(Stream stream, OsmWriterSettings settings) - { - this.Settings = settings; - this.Settings.IsReadOnly = true; + _writer = XmlWriter.Create(stream, writerSetting); + } - _output = stream; - _ownsOutputStream = false; + /// + /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified file. + /// + /// Path to the OSM file. + /// The settings defining behaviour of the writer. + /// If the file exists, it is overwritten, otherwise, a new file is created. + public OsmXmlWriter(string path, OsmWriterSettings settings) + { + this.Settings = settings; + this.Settings.IsReadOnly = true; - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; + _output = new FileStream(path, FileMode.Create, FileAccess.Write); + _ownsOutputStream = true; - _writer = XmlWriter.Create(stream, writerSetting); - } + XmlWriterSettings writerSetting = new XmlWriterSettings(); + writerSetting.Indent = true; - /// - /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified file. - /// - /// Path to the OSM file. - /// The settings defining behaviour of the writer. - /// If the file exists, it is overwritten, otherwise, a new file is created. - public OsmXmlWriter(string path, OsmWriterSettings settings) - { - this.Settings = settings; - this.Settings.IsReadOnly = true; + _streamWriter = new StreamWriter(_output, new UTF8Encoding(false)); + _writer = XmlWriter.Create(_streamWriter, writerSetting); + } - _output = new FileStream(path, FileMode.Create, FileAccess.Write); - _ownsOutputStream = true; + /// + /// Gets settings used by this XmlWriter. + /// + public OsmWriterSettings Settings { get; private set; } - XmlWriterSettings writerSetting = new XmlWriterSettings(); - writerSetting.Indent = true; + /// + /// Releases all resources used by the OsmXmlWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - _streamWriter = new StreamWriter(_output, new UTF8Encoding(false)); - _writer = XmlWriter.Create(_streamWriter, writerSetting); + /// + /// Writes specified entity object in XML format to the underlaying stream. + /// + /// Entity to write. + public void Write(IOsmGeometry entity) + { + if (entity == null) + { + throw new ArgumentNullException(nameof(entity), "Entity cannot be null"); } - /// - /// Gets settings used by this XmlWriter. - /// - public OsmWriterSettings Settings { get; private set; } - - /// - /// Releases all resources used by the OsmXmlWriter. - /// - public void Dispose() + if (_isInsideOsm == false) { - Dispose(true); - GC.SuppressFinalize(this); + this.StartDocument(); } - /// - /// Writes specified entity object in XML format to the underlaying stream. - /// - /// Entity to write. - public void Write(IOsmGeometry entity) + switch (entity.EntityType) { - if (entity == null) - { - throw new ArgumentNullException(nameof(entity), "Entity cannot be null"); - } - - if (_isInsideOsm == false) - { - this.StartDocument(); - } - - switch (entity.EntityType) - { - case EntityType.Node: this.Write(new NodeInfo((Node)entity)); break; - case EntityType.Way: this.Write(new WayInfo((Way)entity)); break; - case EntityType.Relation: this.Write(new RelationInfo((Relation)entity)); break; - } + case EntityType.Node: this.Write(new NodeInfo((Node)entity)); break; + case EntityType.Way: this.Write(new WayInfo((Way)entity)); break; + case EntityType.Relation: this.Write(new RelationInfo((Relation)entity)); break; } + } - /// - /// Writes specified entity data-transfer object in XML format to the underlaying stream. - /// - /// Entity data-transfer object to write. - public void Write(IEntityInfo info) + /// + /// Writes specified entity data-transfer object in XML format to the underlaying stream. + /// + /// Entity data-transfer object to write. + public void Write(IEntityInfo info) + { + if (this.Settings.WriteMetadata) { - if (this.Settings.WriteMetadata) + if (info.Metadata == null) { - if (info.Metadata == null) - { - throw new ArgumentException("Entity doesn't contain metadata object, but writer was created with WriteMetadata setting."); - } - } - - if (_isInsideOsm == false) - { - this.StartDocument(); - } - - switch (info.EntityType) - { - case EntityType.Node: this.WriteNode((NodeInfo)info); break; - case EntityType.Way: this.WriteWay((WayInfo)info); break; - case EntityType.Relation: this.WriteRelation((RelationInfo)info); break; + throw new ArgumentException("Entity doesn't contain metadata object, but writer was created with WriteMetadata setting."); } } - /// - /// Causes any buffered data to be written to the underlaying storage. - /// - public void Flush() + if (_isInsideOsm == false) { - _writer.Flush(); + this.StartDocument(); } - /// - /// Writes <osm> start element to the output stream. - /// - private void StartDocument() + switch (info.EntityType) { - _writer.WriteStartElement("osm"); - if (string.IsNullOrEmpty(this.Settings.ProgramName) == false) - { - _writer.WriteAttributeString("generator", this.Settings.ProgramName); - } - - _isInsideOsm = true; + case EntityType.Node: this.WriteNode((NodeInfo)info); break; + case EntityType.Way: this.WriteWay((WayInfo)info); break; + case EntityType.Relation: this.WriteRelation((RelationInfo)info); break; } + } + + /// + /// Causes any buffered data to be written to the underlaying storage. + /// + public void Flush() + { + _writer.Flush(); + } - /// - /// Writes <osm> end element to the output stream. - /// - private void EndDocument() + /// + /// Writes <osm> start element to the output stream. + /// + private void StartDocument() + { + _writer.WriteStartElement("osm"); + if (string.IsNullOrEmpty(this.Settings.ProgramName) == false) { - _writer.WriteEndElement(); - _isInsideOsm = false; + _writer.WriteAttributeString("generator", this.Settings.ProgramName); } - /// - /// Writes node to the output streram. - /// - /// The Node to be written. - private void WriteNode(NodeInfo info) - { - _writer.WriteStartElement("node"); - _writer.WriteAttributeString("lon", info.Longitude.ToString(_culture)); - _writer.WriteAttributeString("lat", info.Latitude.ToString(_culture)); - _writer.WriteAttributeString("id", info.ID.ToString(_culture)); + _isInsideOsm = true; + } - if (this.Settings.WriteMetadata) - { - this.WriteMetadata(info.Metadata); - } + /// + /// Writes <osm> end element to the output stream. + /// + private void EndDocument() + { + _writer.WriteEndElement(); + _isInsideOsm = false; + } - this.WriteTags(info.Tags); + /// + /// Writes node to the output streram. + /// + /// The Node to be written. + private void WriteNode(NodeInfo info) + { + _writer.WriteStartElement("node"); + _writer.WriteAttributeString("lon", info.Longitude.ToString(_culture)); + _writer.WriteAttributeString("lat", info.Latitude.ToString(_culture)); + _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - _writer.WriteEndElement(); + if (this.Settings.WriteMetadata) + { + this.WriteMetadata(info.Metadata); } - /// - /// Writes way to the output stream - /// - /// The Way to be written - private void WriteWay(WayInfo info) - { - _writer.WriteStartElement("way"); - _writer.WriteAttributeString("id", info.ID.ToString(_culture)); + this.WriteTags(info.Tags); - if (this.Settings.WriteMetadata) - { - this.WriteMetadata(info.Metadata); - } + _writer.WriteEndElement(); + } + + /// + /// Writes way to the output stream + /// + /// The Way to be written + private void WriteWay(WayInfo info) + { + _writer.WriteStartElement("way"); + _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - this.WriteTags(info.Tags); + if (this.Settings.WriteMetadata) + { + this.WriteMetadata(info.Metadata); + } - for (int i = 0; i < info.Nodes.Count; i++) - { - _writer.WriteStartElement("nd"); - _writer.WriteAttributeString("ref", info.Nodes[i].ToString(_culture)); - _writer.WriteEndElement(); - } + this.WriteTags(info.Tags); + for (int i = 0; i < info.Nodes.Count; i++) + { + _writer.WriteStartElement("nd"); + _writer.WriteAttributeString("ref", info.Nodes[i].ToString(_culture)); _writer.WriteEndElement(); } - /// - /// Writes relation to the output stream. - /// - /// The relation to be written. - private void WriteRelation(RelationInfo info) - { - _writer.WriteStartElement("relation"); - _writer.WriteAttributeString("id", info.ID.ToString(_culture)); + _writer.WriteEndElement(); + } - if (this.Settings.WriteMetadata) - { - this.WriteMetadata(info.Metadata); - } + /// + /// Writes relation to the output stream. + /// + /// The relation to be written. + private void WriteRelation(RelationInfo info) + { + _writer.WriteStartElement("relation"); + _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - this.WriteTags(info.Tags); + if (this.Settings.WriteMetadata) + { + this.WriteMetadata(info.Metadata); + } - for (int i = 0; i < info.Members.Count; i++) - { - _writer.WriteStartElement("member"); - _writer.WriteAttributeString("ref", info.Members[i].Reference.ToString(_culture)); - _writer.WriteAttributeString("role", info.Members[i].Role); - _writer.WriteAttributeString("type", info.Members[i].MemberType.ToString().ToLower()); - _writer.WriteEndElement(); - } + this.WriteTags(info.Tags); + for (int i = 0; i < info.Members.Count; i++) + { + _writer.WriteStartElement("member"); + _writer.WriteAttributeString("ref", info.Members[i].Reference.ToString(_culture)); + _writer.WriteAttributeString("role", info.Members[i].Role); + _writer.WriteAttributeString("type", info.Members[i].MemberType.ToString().ToLower()); _writer.WriteEndElement(); } - /// - /// Writes collection of tags to the output stream. - /// - /// The collection of tags to write. - private void WriteTags(TagsCollection tags) + _writer.WriteEndElement(); + } + + /// + /// Writes collection of tags to the output stream. + /// + /// The collection of tags to write. + private void WriteTags(TagsCollection tags) + { + foreach (var tag in tags) { - foreach (var tag in tags) - { - _writer.WriteStartElement("tag"); - _writer.WriteAttributeString("k", tag.Key); - _writer.WriteAttributeString("v", tag.Value); - _writer.WriteEndElement(); - } + _writer.WriteStartElement("tag"); + _writer.WriteAttributeString("k", tag.Key); + _writer.WriteAttributeString("v", tag.Value); + _writer.WriteEndElement(); } + } + + /// + /// Writes detailed attributes of the OSM entity. + /// + /// The entity whose attributes to be written. + private void WriteMetadata(EntityMetadata medatata) + { + _writer.WriteAttributeString("version", medatata.Version.ToString(_culture)); + _writer.WriteAttributeString("changeset", medatata.Changeset.ToString(_culture)); - /// - /// Writes detailed attributes of the OSM entity. - /// - /// The entity whose attributes to be written. - private void WriteMetadata(EntityMetadata medatata) + //HACK ? write only valid user data + if (medatata.Uid > 0) { - _writer.WriteAttributeString("version", medatata.Version.ToString(_culture)); - _writer.WriteAttributeString("changeset", medatata.Changeset.ToString(_culture)); + _writer.WriteAttributeString("uid", medatata.Uid.ToString(_culture)); + _writer.WriteAttributeString("user", medatata.User); + } - //HACK ? write only valid user data - if (medatata.Uid > 0) + _writer.WriteAttributeString("visible", medatata.Visible.ToString().ToLower()); + _writer.WriteAttributeString("timestamp", medatata.Timestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'")); + } + + /// + /// Releases the unmanaged resources used by the OsmXmlWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) + { + if (_writer != null) { - _writer.WriteAttributeString("uid", medatata.Uid.ToString(_culture)); - _writer.WriteAttributeString("user", medatata.User); + _writer.Dispose(); } - _writer.WriteAttributeString("visible", medatata.Visible.ToString().ToLower()); - _writer.WriteAttributeString("timestamp", medatata.Timestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'")); - } - - /// - /// Releases the unmanaged resources used by the OsmXmlWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) - { - if (!this._disposed) + if (disposing) { - if (_writer != null) + if (_streamWriter != null) { - _writer.Dispose(); + _streamWriter.Dispose(); } - if (disposing) + if (_ownsOutputStream) { - if (_streamWriter != null) - { - _streamWriter.Dispose(); - } - - if (_ownsOutputStream) - { - _output.Dispose(); - } + _output.Dispose(); } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Osm/IO/Pbf/Blob.cs b/src/SpatialLite.Osm/IO/Pbf/Blob.cs index e9558bf..700e644 100644 --- a/src/SpatialLite.Osm/IO/Pbf/Blob.cs +++ b/src/SpatialLite.Osm/IO/Pbf/Blob.cs @@ -1,31 +1,30 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represents content of the file block. +/// +[ProtoContract] +internal class Blob { + /// - /// Represents content of the file block. + /// Gets or sets blob content if no compression is used. /// - [ProtoContract] - internal class Blob - { + [ProtoMember(1, IsRequired = false, Name = "raw")] + public byte[] Raw { get; set; } - /// - /// Gets or sets blob content if no compression is used. - /// - [ProtoMember(1, IsRequired = false, Name = "raw")] - public byte[] Raw { get; set; } - - /// - /// Gets or sets uncopressed size of the blob content if ZLIB compression is used. - /// - [ProtoMember(2, IsRequired = false, Name = "raw_size")] - public int? RawSize { get; set; } + /// + /// Gets or sets uncopressed size of the blob content if ZLIB compression is used. + /// + [ProtoMember(2, IsRequired = false, Name = "raw_size")] + public int? RawSize { get; set; } - /// - /// Gets or sets blob content if ZLIB compression is used. - /// - [ProtoMember(3, IsRequired = false, Name = "zlib_data")] - public byte[] ZlibData { get; set; } + /// + /// Gets or sets blob content if ZLIB compression is used. + /// + [ProtoMember(3, IsRequired = false, Name = "zlib_data")] + public byte[] ZlibData { get; set; } - } } diff --git a/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs b/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs index 7384d9f..9ee372a 100644 --- a/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs +++ b/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs @@ -1,34 +1,33 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represents header of the fileblock. +/// +[ProtoContract] +internal class BlobHeader { + /// - /// Represents header of the fileblock. + /// Gets or sets type of the fileblock. /// - [ProtoContract] - internal class BlobHeader - { + /// + /// Supported values are 'OSMHeader' and 'OSMData'. + /// S + [ProtoMember(1, IsRequired = true, Name = "type")] + public string Type { get; set; } - /// - /// Gets or sets type of the fileblock. - /// - /// - /// Supported values are 'OSMHeader' and 'OSMData'. - /// S - [ProtoMember(1, IsRequired = true, Name = "type")] - public string Type { get; set; } - - /// - /// Gets or sets an arbitrary blob that may include metadata about the following blob. For future use. - /// - [ProtoMember(2, IsRequired = false, Name = "indexdata")] - public byte[] IndexData { get; set; } + /// + /// Gets or sets an arbitrary blob that may include metadata about the following blob. For future use. + /// + [ProtoMember(2, IsRequired = false, Name = "indexdata")] + public byte[] IndexData { get; set; } - /// - /// Gets or sets size of the subsequent Blob message. - /// - [ProtoMember(3, IsRequired = true, Name = "datasize")] - public int DataSize { get; set; } + /// + /// Gets or sets size of the subsequent Blob message. + /// + [ProtoMember(3, IsRequired = true, Name = "datasize")] + public int DataSize { get; set; } - } } diff --git a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs index d3a7f47..7698524 100644 --- a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs +++ b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs @@ -1,174 +1,173 @@ using System.Collections.Generic; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Stores entities to be written to output PBF. +/// +/// The type of entities to store. +internal class EntityInfoBuffer : IStringTableBuilder, IEnumerable where T : class, IEntityInfo { + + private List _storage = null; + private Dictionary _stringTable; + + private int _stringTableSize = 0; + private int _estimatedEntityDataSize = 0; + private bool _writeMetadata; + /// - /// Stores entities to be written to output PBF. + /// Initializes a new instance of the EntityInfoBuffer class. /// - /// The type of entities to store. - internal class EntityInfoBuffer : IStringTableBuilder, IEnumerable where T : class, IEntityInfo + /// A value indicating whether writer is writing entity metadata (neccessary for size estimation). + public EntityInfoBuffer(bool writeMetadata) { + _storage = new List(10000); + _stringTable = new Dictionary(); - private List _storage = null; - private Dictionary _stringTable; + _stringTableSize = 0; + _estimatedEntityDataSize = 0; + + _writeMetadata = writeMetadata; + + //add dummy value to the string table to get rid of 0 index + this.GetStringIndex(string.Empty); + } - private int _stringTableSize = 0; - private int _estimatedEntityDataSize = 0; - private bool _writeMetadata; + /// + /// Get maximal estimated size of data in buffer. + /// + /// + /// Actual size of the data should be smaller because proto buffer library compresess data. + /// + public int EstimatedMaxSize + { + get + { + return _estimatedEntityDataSize + _stringTableSize; + } + } - /// - /// Initializes a new instance of the EntityInfoBuffer class. - /// - /// A value indicating whether writer is writing entity metadata (neccessary for size estimation). - public EntityInfoBuffer(bool writeMetadata) + /// + /// Gets number of entities in the buffer. + /// + public int Count + { + get { - _storage = new List(10000); - _stringTable = new Dictionary(); + return _storage.Count; + } + } - _stringTableSize = 0; - _estimatedEntityDataSize = 0; + /// + /// Adds specific entity to buffer + /// + /// The entity to add + public void Add(T item) + { + _storage.Add(item); - _writeMetadata = writeMetadata; + foreach (var tag in item.Tags) + { + this.GetStringIndex(tag.Key); + this.GetStringIndex(tag.Value); - //add dummy value to the string table to get rid of 0 index - this.GetStringIndex(string.Empty); + _estimatedEntityDataSize += 8; } - /// - /// Get maximal estimated size of data in buffer. - /// - /// - /// Actual size of the data should be smaller because proto buffer library compresess data. - /// - public int EstimatedMaxSize + if (item.EntityType == EntityType.Node) { - get - { - return _estimatedEntityDataSize + _stringTableSize; - } + _estimatedEntityDataSize += 3 * 8; } - - /// - /// Gets number of entities in the buffer. - /// - public int Count + else if (item.EntityType == EntityType.Way) { - get - { - return _storage.Count; - } + WayInfo wayItem = item as WayInfo; + _estimatedEntityDataSize += 8 + wayItem.Nodes.Count * 8; } - - /// - /// Adds specific entity to buffer - /// - /// The entity to add - public void Add(T item) + else if (item.EntityType == EntityType.Relation) { - _storage.Add(item); - - foreach (var tag in item.Tags) - { - this.GetStringIndex(tag.Key); - this.GetStringIndex(tag.Value); - - _estimatedEntityDataSize += 8; - } - - if (item.EntityType == EntityType.Node) - { - _estimatedEntityDataSize += 3 * 8; - } - else if (item.EntityType == EntityType.Way) - { - WayInfo wayItem = item as WayInfo; - _estimatedEntityDataSize += 8 + wayItem.Nodes.Count * 8; - } - else if (item.EntityType == EntityType.Relation) - { - RelationInfo relationItem = item as RelationInfo; - _estimatedEntityDataSize += 8 + relationItem.Members.Count * 12; - } - - if (_writeMetadata) - { - _estimatedEntityDataSize += 28; - } + RelationInfo relationItem = item as RelationInfo; + _estimatedEntityDataSize += 8 + relationItem.Members.Count * 12; } - /// - /// Remove all data from buffer. - /// - public void Clear() + if (_writeMetadata) { - _storage.Clear(); - _stringTable.Clear(); + _estimatedEntityDataSize += 28; + } + } - _estimatedEntityDataSize = 0; - _stringTableSize = 0; + /// + /// Remove all data from buffer. + /// + public void Clear() + { + _storage.Clear(); + _stringTable.Clear(); - //add dummy value to the string table to get rid of 0 index - this.GetStringIndex(string.Empty); - } + _estimatedEntityDataSize = 0; + _stringTableSize = 0; - /// - /// Gets index of the string in StringTable being constructed. - /// - /// The string to locate in StringTable. - /// Index of the string in the StringTable. - public uint GetStringIndex(string str) + //add dummy value to the string table to get rid of 0 index + this.GetStringIndex(string.Empty); + } + + /// + /// Gets index of the string in StringTable being constructed. + /// + /// The string to locate in StringTable. + /// Index of the string in the StringTable. + public uint GetStringIndex(string str) + { + if (_stringTable.TryGetValue(str, out uint value)) { - if (_stringTable.TryGetValue(str, out uint value)) - { - return value; - } - else - { - uint index = (uint)_stringTable.Count; - _stringTable.Add(str, index); - _stringTableSize += str.Length; - - return index; - } + return value; } - - /// - /// Creates a StringTable object with data from StringTable object. - /// - /// The StringTable object with data from the buffer. - public StringTable BuildStringTable() + else { - StringTable result = new StringTable(); - result.Storage = new List(_stringTable.Count); - for (int i = 0; i < _stringTable.Count; i++) - { - result.Storage.Add(new byte[0]); - } - - foreach (var item in _stringTable) - { - result[item.Value] = item.Key; - } - - return result; + uint index = (uint)_stringTable.Count; + _stringTable.Add(str, index); + _stringTableSize += str.Length; + + return index; } + } - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator<T> that can be used to iterate through the collection. - public IEnumerator GetEnumerator() + /// + /// Creates a StringTable object with data from StringTable object. + /// + /// The StringTable object with data from the buffer. + public StringTable BuildStringTable() + { + StringTable result = new StringTable(); + result.Storage = new List(_stringTable.Count); + for (int i = 0; i < _stringTable.Count; i++) { - return _storage.GetEnumerator(); + result.Storage.Add(new byte[0]); } - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + foreach (var item in _stringTable) { - return _storage.GetEnumerator(); + result[item.Value] = item.Key; } + + return result; + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator<T> that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return _storage.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return _storage.GetEnumerator(); } } diff --git a/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs b/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs index 177c262..a4c457f 100644 --- a/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs +++ b/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs @@ -1,37 +1,36 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represents rectangular envelope of data. +/// +[ProtoContract(Name = "HeaderBBox")] +internal class HeaderBBox { + /// - /// Represents rectangular envelope of data. + /// Gets or sets Bootom boundary of the BBox. /// - [ProtoContract(Name = "HeaderBBox")] - internal class HeaderBBox - { - - /// - /// Gets or sets Bootom boundary of the BBox. - /// - [ProtoMember(4, Name = "bottom", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Bottom { get; set; } + [ProtoMember(4, Name = "bottom", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Bottom { get; set; } - /// - /// Gets or sets Left boundary of the BBox. - /// - [ProtoMember(1, Name = "left", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Left { get; set; } + /// + /// Gets or sets Left boundary of the BBox. + /// + [ProtoMember(1, Name = "left", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Left { get; set; } - /// - /// Gets or sets Right boundary of the BBox. - /// - [ProtoMember(2, Name = "right", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Right { get; set; } + /// + /// Gets or sets Right boundary of the BBox. + /// + [ProtoMember(2, Name = "right", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Right { get; set; } - /// - /// Gets or sets Top boundary of the BBox. - /// - [ProtoMember(3, Name = "top", IsRequired = true, DataFormat = DataFormat.ZigZag)] - public long Top { get; set; } + /// + /// Gets or sets Top boundary of the BBox. + /// + [ProtoMember(3, Name = "top", IsRequired = true, DataFormat = DataFormat.ZigZag)] + public long Top { get; set; } - } } diff --git a/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs b/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs index 915e2e7..ab55331 100644 --- a/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs +++ b/src/SpatialLite.Osm/IO/Pbf/IStringTableBuilder.cs @@ -1,21 +1,20 @@ -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Defines function for object that can be used to build StringTables. +/// +internal interface IStringTableBuilder { /// - /// Defines function for object that can be used to build StringTables. + /// Gets index of the string in StringTable being constructed. /// - internal interface IStringTableBuilder - { - /// - /// Gets index of the string in StringTable being constructed. - /// - /// The string to locate in StringTable. - /// Index of the string in the StringTable. - uint GetStringIndex(string str); + /// The string to locate in StringTable. + /// Index of the string in the StringTable. + uint GetStringIndex(string str); - /// - /// Creates a StringTable object with data from StringTable object. - /// - /// The StringTable object with data from the IStringBuilder. - StringTable BuildStringTable(); - } + /// + /// Creates a StringTable object with data from StringTable object. + /// + /// The StringTable object with data from the IStringBuilder. + StringTable BuildStringTable(); } diff --git a/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs b/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs index ad6c74c..a7ff43d 100644 --- a/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs +++ b/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs @@ -2,53 +2,52 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represents header message of the PBF file. +/// +[ProtoContract(Name = "HeaderBlock")] +internal class OsmHeader { + private IList _optionalFeatures = new List(); + private IList _requiredFeatures = new List(); + + /// + /// Gets or sets bounding box of the data in the file + /// + [ProtoMember(1, Name = "bbox", IsRequired = false)] + public HeaderBBox BBox { get; set; } + + /// + /// Gets or sets collection of optional features that parser could take advantege of + /// + [ProtoMember(5, Name = "optional_features")] + public IList OptionalFeatures + { + get { return _optionalFeatures; } + set { _optionalFeatures = value; } + } + /// - /// Represents header message of the PBF file. + /// Gets or sets collection of required features that parser must suppor to process the file /// - [ProtoContract(Name = "HeaderBlock")] - internal class OsmHeader + [ProtoMember(4, Name = "required_features")] + public IList RequiredFeatures { - private IList _optionalFeatures = new List(); - private IList _requiredFeatures = new List(); - - /// - /// Gets or sets bounding box of the data in the file - /// - [ProtoMember(1, Name = "bbox", IsRequired = false)] - public HeaderBBox BBox { get; set; } - - /// - /// Gets or sets collection of optional features that parser could take advantege of - /// - [ProtoMember(5, Name = "optional_features")] - public IList OptionalFeatures - { - get { return _optionalFeatures; } - set { _optionalFeatures = value; } - } - - /// - /// Gets or sets collection of required features that parser must suppor to process the file - /// - [ProtoMember(4, Name = "required_features")] - public IList RequiredFeatures - { - get { return _requiredFeatures; } - set { _requiredFeatures = value; } - } - - /// - /// Gets or sets source of the data - /// - [ProtoMember(0x11, Name = "source", IsRequired = false)] - public string Source { get; set; } - - /// - /// Gets or sets identification of writing program - /// - [ProtoMember(0x10, Name = "writingprogram", IsRequired = false)] - public string WritingProgram { get; set; } + get { return _requiredFeatures; } + set { _requiredFeatures = value; } } + + /// + /// Gets or sets source of the data + /// + [ProtoMember(0x11, Name = "source", IsRequired = false)] + public string Source { get; set; } + + /// + /// Gets or sets identification of writing program + /// + [ProtoMember(0x10, Name = "writingprogram", IsRequired = false)] + public string WritingProgram { get; set; } } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs b/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs index fea8171..70ae85b 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs @@ -1,19 +1,18 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represetns data transfer object used by PBF serializer for changesets. +/// +[ProtoContract(Name = "ChangeSet")] +public class PbfChangeset { + /// - /// Represetns data transfer object used by PBF serializer for changesets. + /// Gets or sets id of the changeset. /// - [ProtoContract(Name = "ChangeSet")] - public class PbfChangeset - { - - /// - /// Gets or sets id of the changeset. - /// - [ProtoMember(1, IsRequired = true, Name = "id")] - public long ID { get; set; } + [ProtoMember(1, IsRequired = true, Name = "id")] + public long ID { get; set; } - } } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs b/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs index bfd9e74..ae01db8 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs @@ -2,109 +2,108 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represetns data transfer object used by PBF serializer for metadata in dense format. +/// +[ProtoContract(Name = "DenseInfo")] +internal class PbfDenseMetadata { + private IList _changeset = new List(); + private IList _timestamp = new List(); + private IList _userId = new List(); + private IList _userNameIndex = new List(); + private IList _version = new List(); + private IList _visible = new List(); + /// - /// Represetns data transfer object used by PBF serializer for metadata in dense format. + /// Initializes a new instance of the DenseInfo class with internal fields initialized to default capacity. /// - [ProtoContract(Name = "DenseInfo")] - internal class PbfDenseMetadata + public PbfDenseMetadata() { - private IList _changeset = new List(); - private IList _timestamp = new List(); - private IList _userId = new List(); - private IList _userNameIndex = new List(); - private IList _version = new List(); - private IList _visible = new List(); - - /// - /// Initializes a new instance of the DenseInfo class with internal fields initialized to default capacity. - /// - public PbfDenseMetadata() - { - _changeset = new List(); - _timestamp = new List(); - _userId = new List(); - _userNameIndex = new List(); - _version = new List(); - _visible = new List(); - } + _changeset = new List(); + _timestamp = new List(); + _userId = new List(); + _userNameIndex = new List(); + _version = new List(); + _visible = new List(); + } - /// - /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfDenseMetadata(int capacity) - { - _changeset = new List(capacity); - _timestamp = new List(capacity); - _userId = new List(capacity); - _userNameIndex = new List(capacity); - _version = new List(capacity); - _visible = new List(capacity); - } + /// + /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfDenseMetadata(int capacity) + { + _changeset = new List(capacity); + _timestamp = new List(capacity); + _userId = new List(capacity); + _userNameIndex = new List(capacity); + _version = new List(capacity); + _visible = new List(capacity); + } - /// - /// Gets or sets changeset id for corresponding node in DenseNodes. Property is delta encoded. - /// - [ProtoMember(3, Name = "changeset", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList Changeset - { - get { return _changeset; } - set { _changeset = value; } - } + /// + /// Gets or sets changeset id for corresponding node in DenseNodes. Property is delta encoded. + /// + [ProtoMember(3, Name = "changeset", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList Changeset + { + get { return _changeset; } + set { _changeset = value; } + } - /// - /// Gets or sets timestamp as number of DateGranularity from UNIX 1970 epoch for the corresponding node in DenseNodes. Property is delta encoded. - /// - /// - /// DateTime LastChange = _unixEpoch.AddMilliseconds(timestamp * block.DateGranularity). - /// - [ProtoMember(2, Name = "timestamp", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList Timestamp - { - get { return _timestamp; } - set { _timestamp = value; } - } + /// + /// Gets or sets timestamp as number of DateGranularity from UNIX 1970 epoch for the corresponding node in DenseNodes. Property is delta encoded. + /// + /// + /// DateTime LastChange = _unixEpoch.AddMilliseconds(timestamp * block.DateGranularity). + /// + [ProtoMember(2, Name = "timestamp", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList Timestamp + { + get { return _timestamp; } + set { _timestamp = value; } + } - /// - /// Gets or sets UserId for corresponding node in DenseNodes. Property is delta encoded. - /// - [ProtoMember(4, Name = "uid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList UserId - { - get { return _userId; } - set { _userId = value; } - } + /// + /// Gets or sets UserId for corresponding node in DenseNodes. Property is delta encoded. + /// + [ProtoMember(4, Name = "uid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList UserId + { + get { return _userId; } + set { _userId = value; } + } - /// - /// Gets or sets index of the UserName in StringTable for corresponding node in DenseNodes. Property is delta encoded. - /// - [ProtoMember(5, Name = "user_sid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList UserNameIndex - { - get { return _userNameIndex; } - set { _userNameIndex = value; } - } + /// + /// Gets or sets index of the UserName in StringTable for corresponding node in DenseNodes. Property is delta encoded. + /// + [ProtoMember(5, Name = "user_sid", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList UserNameIndex + { + get { return _userNameIndex; } + set { _userNameIndex = value; } + } - /// - /// Gets or sets version of the corresponding node in DenseNodes. - /// - [ProtoMember(1, Name = "version", Options = MemberSerializationOptions.Packed)] - public IList Version - { - get { return _version; } - set { _version = value; } - } + /// + /// Gets or sets version of the corresponding node in DenseNodes. + /// + [ProtoMember(1, Name = "version", Options = MemberSerializationOptions.Packed)] + public IList Version + { + get { return _version; } + set { _version = value; } + } - /// - /// Gets or sets visible attribute for corresponding node in DenseNodes. - /// - [ProtoMember(6, Name = "visible", Options = MemberSerializationOptions.Packed)] - public IList Visible - { - get { return _visible; } - set { _visible = value; } - } + /// + /// Gets or sets visible attribute for corresponding node in DenseNodes. + /// + [ProtoMember(6, Name = "visible", Options = MemberSerializationOptions.Packed)] + public IList Visible + { + get { return _visible; } + set { _visible = value; } } } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs b/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs index 8cb6c94..98c6b9c 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs @@ -2,96 +2,95 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represetns data transfer object used by PBF serializer for nodes saved in dense format. +/// +[ProtoContract(Name = "DenseNodes")] +internal class PbfDenseNodes { + + private IList _id = null; + private IList _latitude = null; + private IList _longitude = null; + private IList _keysVals = null; + /// - /// Represetns data transfer object used by PBF serializer for nodes saved in dense format. + /// Initializes a new instance of the DenseNodes class with internal fields initialized to default capacity. /// - [ProtoContract(Name = "DenseNodes")] - internal class PbfDenseNodes + public PbfDenseNodes() { + _id = new List(); + _latitude = new List(); + _longitude = new List(); + _keysVals = new List(); + } - private IList _id = null; - private IList _latitude = null; - private IList _longitude = null; - private IList _keysVals = null; - - /// - /// Initializes a new instance of the DenseNodes class with internal fields initialized to default capacity. - /// - public PbfDenseNodes() - { - _id = new List(); - _latitude = new List(); - _longitude = new List(); - _keysVals = new List(); - } - - /// - /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfDenseNodes(int capacity) - { - _id = new List(capacity); - _latitude = new List(capacity); - _longitude = new List(capacity); - _keysVals = new List(capacity); - } + /// + /// Initializes a new instance of the DenseInfo class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfDenseNodes(int capacity) + { + _id = new List(capacity); + _latitude = new List(capacity); + _longitude = new List(capacity); + _keysVals = new List(capacity); + } - /// - /// Gets or sets ids of the nodes. This property is delta encoded. - /// - [ProtoMember(1, Name = "id", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] - public IList Id - { - get { return _id; } - set { _id = value; } - } + /// + /// Gets or sets ids of the nodes. This property is delta encoded. + /// + [ProtoMember(1, Name = "id", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] + public IList Id + { + get { return _id; } + set { _id = value; } + } - /// - /// Gets or sets latitudes of the nodes as number of granularity steps from the LatOffset. This property is delta encoded. - /// - /// - /// double nodeLat = 1E-09 * (block.LatOffset + (block.Granularity * Latitude)); - /// - [ProtoMember(8, Name = "lat", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] - public IList Latitude - { - get { return _latitude; } - set { _latitude = value; } - } + /// + /// Gets or sets latitudes of the nodes as number of granularity steps from the LatOffset. This property is delta encoded. + /// + /// + /// double nodeLat = 1E-09 * (block.LatOffset + (block.Granularity * Latitude)); + /// + [ProtoMember(8, Name = "lat", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] + public IList Latitude + { + get { return _latitude; } + set { _latitude = value; } + } - /// - /// Gets or sets longitude of the nodes as number of granularity steps from the LonOffset. This property is delta encoded. - /// - /// - /// double nodeLon = 1E-09 * (block.LonOffset + (block.Granularity * Longitude)); - /// - [ProtoMember(9, Name = "lon", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] - public IList Longitude - { - get { return _longitude; } - set { _longitude = value; } - } + /// + /// Gets or sets longitude of the nodes as number of granularity steps from the LonOffset. This property is delta encoded. + /// + /// + /// double nodeLon = 1E-09 * (block.LonOffset + (block.Granularity * Longitude)); + /// + [ProtoMember(9, Name = "lon", IsRequired = true, DataFormat = DataFormat.ZigZag, Options = MemberSerializationOptions.Packed)] + public IList Longitude + { + get { return _longitude; } + set { _longitude = value; } + } - /// - /// Gets or sets entities metadata encoded in the DenseInfo object - /// - [ProtoMember(5, Name = "denseinfo", IsRequired = false)] - public PbfDenseMetadata DenseInfo { get; set; } + /// + /// Gets or sets entities metadata encoded in the DenseInfo object + /// + [ProtoMember(5, Name = "denseinfo", IsRequired = false)] + public PbfDenseMetadata DenseInfo { get; set; } - /// - /// Gets or sets tags for nodes. - /// - /// - /// Tags are saved as (KeyIndex, ValueIndex) pairs. Tags for concesutive nodes are seprated by 0. - /// - [ProtoMember(10, Name = "keys_vals", Options = MemberSerializationOptions.Packed)] - public IList KeysVals - { - get { return _keysVals; } - set { _keysVals = value; } - } + /// + /// Gets or sets tags for nodes. + /// + /// + /// Tags are saved as (KeyIndex, ValueIndex) pairs. Tags for concesutive nodes are seprated by 0. + /// + [ProtoMember(10, Name = "keys_vals", Options = MemberSerializationOptions.Packed)] + public IList KeysVals + { + get { return _keysVals; } + set { _keysVals = value; } } } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs b/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs index 8de0575..4f18fe7 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs @@ -1,43 +1,42 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represetns data transfer object used by PBF serializer for Entity metadata. +/// +[ProtoContract(Name = "Info")] +internal class PbfMetadata { + + /// + /// Gets or sets changeset ID. + /// + [ProtoMember(3, Name = "changeset", IsRequired = false)] + public long? Changeset { get; set; } + + /// + /// Gets or sets Timestamp. + /// + [ProtoMember(2, Name = "timestamp", IsRequired = false)] + public long? Timestamp { get; set; } + /// - /// Represetns data transfer object used by PBF serializer for Entity metadata. + /// Gets or sets UserID. /// - [ProtoContract(Name = "Info")] - internal class PbfMetadata - { - - /// - /// Gets or sets changeset ID. - /// - [ProtoMember(3, Name = "changeset", IsRequired = false)] - public long? Changeset { get; set; } - - /// - /// Gets or sets Timestamp. - /// - [ProtoMember(2, Name = "timestamp", IsRequired = false)] - public long? Timestamp { get; set; } - - /// - /// Gets or sets UserID. - /// - [ProtoMember(4, Name = "uid", IsRequired = false)] - public int? UserID { get; set; } - - /// - /// Gets or sets index of the username in string table. - /// - [ProtoMember(5, Name = "user_sid", IsRequired = false)] - public int? UserNameIndex { get; set; } - - /// - /// Gets or sets version of the entity. - /// - [ProtoMember(1, Name = "version", IsRequired = false)] - public int? Version { get; set; } - - } + [ProtoMember(4, Name = "uid", IsRequired = false)] + public int? UserID { get; set; } + + /// + /// Gets or sets index of the username in string table. + /// + [ProtoMember(5, Name = "user_sid", IsRequired = false)] + public int? UserNameIndex { get; set; } + + /// + /// Gets or sets version of the entity. + /// + [ProtoMember(1, Name = "version", IsRequired = false)] + public int? Version { get; set; } + } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs b/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs index c9697c5..f5eedd2 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs @@ -2,50 +2,49 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represetns data transfer object used by PBF serializer for nodes. +/// +[ProtoContract(Name = "Node")] +internal class PbfNode { + + /// + /// Gets or sets ID of the node. + /// + [ProtoMember(1, IsRequired = true, Name = "id", DataFormat = DataFormat.ZigZag)] + public long ID { get; set; } + + /// + /// Gets or sets indexes of tag's keys in string table. + /// + [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] + public List Keys { get; set; } + + /// + /// Gets or sets indexes of tag's values in string table. + /// + [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] + public List Values { get; set; } + + /// + /// Gets or sets entity metadata. + /// + [ProtoMember(4, IsRequired = false, Name = "info")] + public PbfMetadata Metadata { get; set; } + /// - /// Represetns data transfer object used by PBF serializer for nodes. + /// Gets or sets Latitude of the node as number of granularity steps from LatOffset. /// - [ProtoContract(Name = "Node")] - internal class PbfNode - { - - /// - /// Gets or sets ID of the node. - /// - [ProtoMember(1, IsRequired = true, Name = "id", DataFormat = DataFormat.ZigZag)] - public long ID { get; set; } - - /// - /// Gets or sets indexes of tag's keys in string table. - /// - [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] - public List Keys { get; set; } - - /// - /// Gets or sets indexes of tag's values in string table. - /// - [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] - public List Values { get; set; } - - /// - /// Gets or sets entity metadata. - /// - [ProtoMember(4, IsRequired = false, Name = "info")] - public PbfMetadata Metadata { get; set; } - - /// - /// Gets or sets Latitude of the node as number of granularity steps from LatOffset. - /// - [ProtoMember(8, IsRequired = true, Name = "lat", DataFormat = DataFormat.ZigZag)] - public long Latitude { get; set; } - - /// - /// Gets or sets Longitude of the node as number of granularity steps from LonOffset. - /// - [ProtoMember(9, IsRequired = true, Name = "lon", DataFormat = DataFormat.ZigZag)] - public long Longitude { get; set; } - - } + [ProtoMember(8, IsRequired = true, Name = "lat", DataFormat = DataFormat.ZigZag)] + public long Latitude { get; set; } + + /// + /// Gets or sets Longitude of the node as number of granularity steps from LonOffset. + /// + [ProtoMember(9, IsRequired = true, Name = "lon", DataFormat = DataFormat.ZigZag)] + public long Longitude { get; set; } + } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs b/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs index 4d7085a..25040d1 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs @@ -2,92 +2,91 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represetns data transfer object used by PBF serializer for relations. +/// +[ProtoContract(Name = "Relation")] +internal class PbfRelation { + + private IList _memberIds = null; + private IList _rolesIndexes = null; + private IList _types = null; + /// - /// Represetns data transfer object used by PBF serializer for relations. + /// Initializes a new instance of the PbfRelation class with internal fields initialized to default capacity. /// - [ProtoContract(Name = "Relation")] - internal class PbfRelation + public PbfRelation() { + _memberIds = new List(); + _rolesIndexes = new List(); + _types = new List(); + } - private IList _memberIds = null; - private IList _rolesIndexes = null; - private IList _types = null; - - /// - /// Initializes a new instance of the PbfRelation class with internal fields initialized to default capacity. - /// - public PbfRelation() - { - _memberIds = new List(); - _rolesIndexes = new List(); - _types = new List(); - } - - /// - /// Initializes a new instance of the PbfRelation class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfRelation(int capacity) - { - _memberIds = new List(capacity); - _rolesIndexes = new List(capacity); - _types = new List(capacity); - } + /// + /// Initializes a new instance of the PbfRelation class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfRelation(int capacity) + { + _memberIds = new List(capacity); + _rolesIndexes = new List(capacity); + _types = new List(capacity); + } - /// - /// Gets or sets ID of the relation. - /// - [ProtoMember(1, Name = "id", IsRequired = true)] - public long ID { get; set; } + /// + /// Gets or sets ID of the relation. + /// + [ProtoMember(1, Name = "id", IsRequired = true)] + public long ID { get; set; } - /// - /// Gets or sets relation metadata. - /// - [ProtoMember(4, Name = "info", IsRequired = false)] - public PbfMetadata Metadata { get; set; } + /// + /// Gets or sets relation metadata. + /// + [ProtoMember(4, Name = "info", IsRequired = false)] + public PbfMetadata Metadata { get; set; } - /// - /// Gets or sets indexes of tag's keys in string table. - /// - [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] - public IList Keys { get; set; } + /// + /// Gets or sets indexes of tag's keys in string table. + /// + [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] + public IList Keys { get; set; } - /// - /// Gets or sets indexes of tag's values in string table. - /// - [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] - public IList Values { get; set; } + /// + /// Gets or sets indexes of tag's values in string table. + /// + [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] + public IList Values { get; set; } - /// - /// Gets or sets IDs of the relation members. This propeerty is delta encoded. - /// - [ProtoMember(9, Name = "memids", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList MemberIds - { - get { return _memberIds; } - set { _memberIds = value; } - } + /// + /// Gets or sets IDs of the relation members. This propeerty is delta encoded. + /// + [ProtoMember(9, Name = "memids", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList MemberIds + { + get { return _memberIds; } + set { _memberIds = value; } + } - /// - /// Gets or sets index of the role in string table for appropriate members. - /// - [ProtoMember(8, Name = "roles_sid", Options = MemberSerializationOptions.Packed)] - public IList RolesIndexes - { - get { return _rolesIndexes; } - set { _rolesIndexes = value; } - } + /// + /// Gets or sets index of the role in string table for appropriate members. + /// + [ProtoMember(8, Name = "roles_sid", Options = MemberSerializationOptions.Packed)] + public IList RolesIndexes + { + get { return _rolesIndexes; } + set { _rolesIndexes = value; } + } - /// - /// Gets or sets type of the relation members. - /// - [ProtoMember(10, Name = "types", Options = MemberSerializationOptions.Packed)] - public IList Types - { - get { return _types; } - set { _types = value; } - } + /// + /// Gets or sets type of the relation members. + /// + [ProtoMember(10, Name = "types", Options = MemberSerializationOptions.Packed)] + public IList Types + { + get { return _types; } + set { _types = value; } } } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs b/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs index eafe4f1..653988d 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfRelationMemberType.cs @@ -1,21 +1,20 @@ -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Defines possible types of the relation member. +/// +public enum PbfRelationMemberType { /// - /// Defines possible types of the relation member. + /// Relation member is Node. /// - public enum PbfRelationMemberType - { - /// - /// Relation member is Node. - /// - Node, - /// - /// Relation member is Way. - /// - Way, - /// - /// Relation member is Relation. - /// - Relation - } + Node, + /// + /// Relation member is Way. + /// + Way, + /// + /// Relation member is Relation. + /// + Relation } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs b/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs index eebe3fe..bb3c19a 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs @@ -2,66 +2,65 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represetns data transfer object used by PBF serializer for Ways. +/// +[ProtoContract(Name = "Way")] +internal class PbfWay { + + private IList _refs = null; + /// - /// Represetns data transfer object used by PBF serializer for Ways. + /// Initializes a new instance of the PbfWay class with internal fields initialized to default capacity. /// - [ProtoContract(Name = "Way")] - internal class PbfWay + public PbfWay() { + _refs = new List(); + } - private IList _refs = null; - - /// - /// Initializes a new instance of the PbfWay class with internal fields initialized to default capacity. - /// - public PbfWay() - { - _refs = new List(); - } - - /// - /// Initializes a new instance of the PbfWay class with internal fields initialized to specified capacity. - /// - /// The desired capacity of internal fields. - public PbfWay(int capacity) - { - _refs = new List(capacity); - } + /// + /// Initializes a new instance of the PbfWay class with internal fields initialized to specified capacity. + /// + /// The desired capacity of internal fields. + public PbfWay(int capacity) + { + _refs = new List(capacity); + } - /// - /// Gets or sets ID of the way. - /// - [ProtoMember(1, Name = "id", IsRequired = true)] - public long ID { get; set; } + /// + /// Gets or sets ID of the way. + /// + [ProtoMember(1, Name = "id", IsRequired = true)] + public long ID { get; set; } - /// - /// Gets or sets indexes of tag's keys in string table. - /// - [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] - public IList Keys { get; set; } + /// + /// Gets or sets indexes of tag's keys in string table. + /// + [ProtoMember(2, Name = "keys", Options = MemberSerializationOptions.Packed)] + public IList Keys { get; set; } - /// - /// Gets or sets indexes of tag's values in string table. - /// - [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] - public IList Values { get; set; } + /// + /// Gets or sets indexes of tag's values in string table. + /// + [ProtoMember(3, Name = "vals", Options = MemberSerializationOptions.Packed)] + public IList Values { get; set; } - /// - /// Gets or sets entity metadata . - /// - [ProtoMember(4, Name = "info", IsRequired = false)] - public PbfMetadata Metadata { get; set; } + /// + /// Gets or sets entity metadata . + /// + [ProtoMember(4, Name = "info", IsRequired = false)] + public PbfMetadata Metadata { get; set; } - /// - /// Gets or sets IDs of nodes referenced by the way. This property is delta encoded. - /// - [ProtoMember(8, Name = "refs", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] - public IList Refs - { - get { return _refs; } - set { _refs = value; } - } + /// + /// Gets or sets IDs of nodes referenced by the way. This property is delta encoded. + /// + [ProtoMember(8, Name = "refs", Options = MemberSerializationOptions.Packed, DataFormat = DataFormat.ZigZag)] + public IList Refs + { + get { return _refs; } + set { _refs = value; } } } diff --git a/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs b/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs index d7fea79..73f44bb 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs @@ -2,60 +2,59 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represents content of the fileblock's data stream. +/// +[ProtoContract(Name = "PrimitiveBlock")] +internal class PrimitiveBlock { + + private int _granularity = 100; + private int _date_granularity = 1000; + + /// + /// Gets or sets StringTable with all strings used in the block. + /// + [ProtoMember(1, IsRequired = true, Name = "stringtable")] + public StringTable StringTable { get; set; } + /// - /// Represents content of the fileblock's data stream. + /// Gets or sets PrimitiveGroup object with OSM entities. /// - [ProtoContract(Name = "PrimitiveBlock")] - internal class PrimitiveBlock + [ProtoMember(2, Name = "primitivegroup")] + public List PrimitiveGroup { get; set; } + + /// + /// Gets or sets granularity of the position data. Default value is 1000. + /// + [ProtoMember(16, IsRequired = false, Name = "granularity")] + public int Granularity { + get { return _granularity; } + set { _granularity = value; } + } - private int _granularity = 100; - private int _date_granularity = 1000; - - /// - /// Gets or sets StringTable with all strings used in the block. - /// - [ProtoMember(1, IsRequired = true, Name = "stringtable")] - public StringTable StringTable { get; set; } - - /// - /// Gets or sets PrimitiveGroup object with OSM entities. - /// - [ProtoMember(2, Name = "primitivegroup")] - public List PrimitiveGroup { get; set; } - - /// - /// Gets or sets granularity of the position data. Default value is 1000. - /// - [ProtoMember(16, IsRequired = false, Name = "granularity")] - public int Granularity - { - get { return _granularity; } - set { _granularity = value; } - } - - /// - /// Gets or sets latitude offset. - /// - [ProtoMember(19, IsRequired = false, Name = "lat_offset")] - public long LatOffset { get; set; } - - /// - /// Gets or sets longitude offset. - /// - [ProtoMember(20, IsRequired = false, Name = "lon_offset")] - public long LonOffset { get; set; } - - /// - /// Gets or sets granularity of the DateTime data. Default value is 100. - /// - [ProtoMember(18, IsRequired = false, Name = "date_granularity")] - public int DateGranularity - { - get { return _date_granularity; } - set { _date_granularity = value; } - } + /// + /// Gets or sets latitude offset. + /// + [ProtoMember(19, IsRequired = false, Name = "lat_offset")] + public long LatOffset { get; set; } + + /// + /// Gets or sets longitude offset. + /// + [ProtoMember(20, IsRequired = false, Name = "lon_offset")] + public long LonOffset { get; set; } + + /// + /// Gets or sets granularity of the DateTime data. Default value is 100. + /// + [ProtoMember(18, IsRequired = false, Name = "date_granularity")] + public int DateGranularity + { + get { return _date_granularity; } + set { _date_granularity = value; } } } diff --git a/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs b/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs index 191c663..c0cd23c 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs @@ -2,44 +2,43 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Represents container for PBF data transfer objects for OSM entities. +/// +[ProtoContract(Name = "PrimitiveGroup")] +internal class PrimitiveGroup { + + /// + /// Gets or sets collection of nodes. + /// + [ProtoMember(1, Name = "nodes")] + public List Nodes { get; set; } + + /// + /// Gets or sets collection of nodes serialized in dense format. + /// + [ProtoMember(2, IsRequired = false, Name = "dense")] + public PbfDenseNodes DenseNodes { get; set; } + /// - /// Represents container for PBF data transfer objects for OSM entities. + /// Gets or sets collection of way. /// - [ProtoContract(Name = "PrimitiveGroup")] - internal class PrimitiveGroup - { - - /// - /// Gets or sets collection of nodes. - /// - [ProtoMember(1, Name = "nodes")] - public List Nodes { get; set; } - - /// - /// Gets or sets collection of nodes serialized in dense format. - /// - [ProtoMember(2, IsRequired = false, Name = "dense")] - public PbfDenseNodes DenseNodes { get; set; } - - /// - /// Gets or sets collection of way. - /// - [ProtoMember(3, Name = "ways")] - public List Ways { get; set; } - - /// - /// Gets or sets collection of relations. - /// - [ProtoMember(4, Name = "relations")] - public List Relations { get; set; } - - /// - /// Gets or sets collection of changesets. - /// - [ProtoMember(5, Name = "changesets")] - public List Changesets { get; set; } - - } + [ProtoMember(3, Name = "ways")] + public List Ways { get; set; } + + /// + /// Gets or sets collection of relations. + /// + [ProtoMember(4, Name = "relations")] + public List Relations { get; set; } + + /// + /// Gets or sets collection of changesets. + /// + [ProtoMember(5, Name = "changesets")] + public List Changesets { get; set; } + } diff --git a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs index 406ea12..6e35567 100644 --- a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs +++ b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs @@ -4,71 +4,70 @@ using ProtoBuf; -namespace SpatialLite.Osm.IO.Pbf +namespace SpatialLite.Osm.IO.Pbf; + +/// +/// Stores all strings for Primitive block. +/// +[ProtoContract(Name = "StringTable")] +public class StringTable { + + private List _s = new List(); + /// - /// Stores all strings for Primitive block. + /// Gets or sets collection of strings serialized as byte array. /// - [ProtoContract(Name = "StringTable")] - public class StringTable + [ProtoMember(1, Name = "s", DataFormat = DataFormat.Default)] + public List Storage { + get { return _s; } + set { _s = value; } + } - private List _s = new List(); - - /// - /// Gets or sets collection of strings serialized as byte array. - /// - [ProtoMember(1, Name = "s", DataFormat = DataFormat.Default)] - public List Storage + /// + /// Gets or sets string at specified position. + /// + /// The index of the string. + /// string at specified position. + [ProtoIgnore] + public string this[int index] + { + get { - get { return _s; } - set { _s = value; } - } + if (index >= this.Storage.Count) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } - /// - /// Gets or sets string at specified position. - /// - /// The index of the string. - /// string at specified position. - [ProtoIgnore] - public string this[int index] + return Encoding.UTF8.GetString(this.Storage[index], 0, this.Storage[index].Length); + } + set { - get + if (index >= this.Storage.Count) { - if (index >= this.Storage.Count) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - - return Encoding.UTF8.GetString(this.Storage[index], 0, this.Storage[index].Length); + throw new ArgumentOutOfRangeException(nameof(index)); } - set - { - if (index >= this.Storage.Count) - { - throw new ArgumentOutOfRangeException(nameof(index)); - } - this.Storage[index] = Encoding.UTF8.GetBytes(value); - } + this.Storage[index] = Encoding.UTF8.GetBytes(value); } + } - /// - /// Gets or sets string at specified position. - /// - /// The index of the string. - /// string at specified position. - [ProtoIgnore] - public string this[uint index] + /// + /// Gets or sets string at specified position. + /// + /// The index of the string. + /// string at specified position. + [ProtoIgnore] + public string this[uint index] + { + get { - get - { - return this[(int)index]; - } - set - { - this[(int)index] = value; - } + return this[(int)index]; + } + set + { + this[(int)index] = value; } } } diff --git a/src/SpatialLite.Osm/IO/PbfReader.cs b/src/SpatialLite.Osm/IO/PbfReader.cs index 08e64b4..32c96dc 100644 --- a/src/SpatialLite.Osm/IO/PbfReader.cs +++ b/src/SpatialLite.Osm/IO/PbfReader.cs @@ -5,526 +5,525 @@ using ProtoBuf; using SpatialLite.Osm.IO.Pbf; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Represents IOsmReader that can read OSM entities from PBF format. +/// +public class PbfReader : IOsmReader { + /// - /// Represents IOsmReader that can read OSM entities from PBF format. + /// Defines maximal allowed size of uncompressed OsmData block. Larger blocks are considered invalid. /// - public class PbfReader : IOsmReader - { + public const int MaxDataBlockSize = 32 * 1024 * 1024; - /// - /// Defines maximal allowed size of uncompressed OsmData block. Larger blocks are considered invalid. - /// - public const int MaxDataBlockSize = 32 * 1024 * 1024; - - /// - /// Defines maximal allowed size of uncopressed OsmHeader block. Larger blocks are considered invalid. - /// - public const int MaxHeaderBlockSize = 64 * 1024; - - private bool _disposed = false; - private Stream _input; - private Queue _cache; - private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); - - /// - /// Initializes a new instance of the PbfReader class that read data form specified stream. - /// - /// The input stream. - /// The OsmReaderSettings object that determines behaviour of PbfReader. - public PbfReader(Stream input, OsmReaderSettings settings) - { - _input = input; - _cache = new Queue(); + /// + /// Defines maximal allowed size of uncopressed OsmHeader block. Larger blocks are considered invalid. + /// + public const int MaxHeaderBlockSize = 64 * 1024; - this.Settings = settings; - this.Settings.IsReadOnly = true; + private bool _disposed = false; + private Stream _input; + private Queue _cache; + private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); - BlobHeader blobHeader = null; - while ((blobHeader = this.ReadBlobHeader()) != null) + /// + /// Initializes a new instance of the PbfReader class that read data form specified stream. + /// + /// The input stream. + /// The OsmReaderSettings object that determines behaviour of PbfReader. + public PbfReader(Stream input, OsmReaderSettings settings) + { + _input = input; + _cache = new Queue(); + + this.Settings = settings; + this.Settings.IsReadOnly = true; + + BlobHeader blobHeader = null; + while ((blobHeader = this.ReadBlobHeader()) != null) + { + try { - try + if (blobHeader.Type == "OSMHeader") { - if (blobHeader.Type == "OSMHeader") - { - OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); - this.ProcessOsmHeader(osmHeader); - return; - } - else if (blobHeader.Type == "OSMData") - { - throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block before 'OSMData' block."); - } - else - { - _input.Seek(blobHeader.DataSize, SeekOrigin.Current); - } + OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); + this.ProcessOsmHeader(osmHeader); + return; } - catch (ProtoException ex) + else if (blobHeader.Type == "OSMData") { - throw new InvalidDataException("Input stream contains unsupported data", ex); + throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block before 'OSMData' block."); + } + else + { + _input.Seek(blobHeader.DataSize, SeekOrigin.Current); } } - - throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block."); + catch (ProtoException ex) + { + throw new InvalidDataException("Input stream contains unsupported data", ex); + } } - /// - /// Initializes a new instance of the PbfReader class that read data form specified file. - /// - /// The path to the input file. - /// The OsmReaderSettings object that determines behaviour of PbfReader. - public PbfReader(string path, OsmReaderSettings settings) - { - _input = new FileStream(path, FileMode.Open, FileAccess.Read); - _cache = new Queue(); + throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block."); + } - this.Settings = settings; - this.Settings.IsReadOnly = true; + /// + /// Initializes a new instance of the PbfReader class that read data form specified file. + /// + /// The path to the input file. + /// The OsmReaderSettings object that determines behaviour of PbfReader. + public PbfReader(string path, OsmReaderSettings settings) + { + _input = new FileStream(path, FileMode.Open, FileAccess.Read); + _cache = new Queue(); - BlobHeader blobHeader = null; - while ((blobHeader = this.ReadBlobHeader()) != null) + this.Settings = settings; + this.Settings.IsReadOnly = true; + + BlobHeader blobHeader = null; + while ((blobHeader = this.ReadBlobHeader()) != null) + { + try { - try + if (blobHeader.Type == "OSMHeader") { - if (blobHeader.Type == "OSMHeader") - { - OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); - this.ProcessOsmHeader(osmHeader); - return; - } - else if (blobHeader.Type == "OSMData") - { - throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block before 'OSMData' block."); - } - else - { - _input.Seek(blobHeader.DataSize, SeekOrigin.Current); - } + OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); + this.ProcessOsmHeader(osmHeader); + return; + } + else if (blobHeader.Type == "OSMData") + { + throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block before 'OSMData' block."); } - catch (ProtoException ex) + else { - throw new InvalidDataException("Input stream contains unsupported data", ex); + _input.Seek(blobHeader.DataSize, SeekOrigin.Current); } } - - throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block."); + catch (ProtoException ex) + { + throw new InvalidDataException("Input stream contains unsupported data", ex); + } } - /// - /// Gets OsmReaderSettings object that contains properties which determine behaviour of the OSM reader. - /// - public OsmReaderSettings Settings { get; private set; } + throw new InvalidDataException("Input stream doesn't contain an 'OSMHeader' block."); + } + + /// + /// Gets OsmReaderSettings object that contains properties which determine behaviour of the OSM reader. + /// + public OsmReaderSettings Settings { get; private set; } - /// - /// Reads next OSM entity from the stream. - /// - /// Parsed OSM entity from the stream or null if no other entity is available. - public IEntityInfo Read() + /// + /// Reads next OSM entity from the stream. + /// + /// Parsed OSM entity from the stream or null if no other entity is available. + public IEntityInfo Read() + { + if (_cache.Count > 0) { - if (_cache.Count > 0) - { - return _cache.Dequeue(); - } - else + return _cache.Dequeue(); + } + else + { + BlobHeader blobHeader = null; + while (_cache.Count == 0 && (blobHeader = this.ReadBlobHeader()) != null) { - BlobHeader blobHeader = null; - while (_cache.Count == 0 && (blobHeader = this.ReadBlobHeader()) != null) + PrimitiveBlock data = this.ReadBlob(blobHeader) as PrimitiveBlock; + if (data != null) { - PrimitiveBlock data = this.ReadBlob(blobHeader) as PrimitiveBlock; - if (data != null) + foreach (PrimitiveGroup group in data.PrimitiveGroup) { - foreach (PrimitiveGroup group in data.PrimitiveGroup) - { - this.ProcessPrimitiveGroup(data, group); - } + this.ProcessPrimitiveGroup(data, group); } } } - - if (_cache.Count > 0) - { - return _cache.Dequeue(); - } - else - { - return null; - } } - /// - /// Releases all resources used by the PbfReader. - /// - public void Dispose() + if (_cache.Count > 0) { - Dispose(true); - - GC.SuppressFinalize(this); + return _cache.Dequeue(); } - - /// - /// Reads and deserializes a BlobHeader from input stream. - /// - /// Deserialized BlobHeader object or null if end of the stream is reached. - private BlobHeader ReadBlobHeader() + else { - if (_input.Position < _input.Length) - { - return Serializer.DeserializeWithLengthPrefix(_input, PrefixStyle.Fixed32BigEndian); - } - return null; } + } + + /// + /// Releases all resources used by the PbfReader. + /// + public void Dispose() + { + Dispose(true); + + GC.SuppressFinalize(this); + } - /// - /// Read blob and deserializes its content. - /// - /// Header of the blob. - /// Deserialized content of the read blob or null if blob contains unknown data. - private object ReadBlob(BlobHeader header) + /// + /// Reads and deserializes a BlobHeader from input stream. + /// + /// Deserialized BlobHeader object or null if end of the stream is reached. + private BlobHeader ReadBlobHeader() + { + if (_input.Position < _input.Length) { - byte[] buffer = new byte[header.DataSize]; - _input.Read(buffer, 0, header.DataSize); - Blob blob = Serializer.Deserialize(new MemoryStream(buffer)); + return Serializer.DeserializeWithLengthPrefix(_input, PrefixStyle.Fixed32BigEndian); + } - Stream blobContentStream; - if (blob.Raw != null) - { - blobContentStream = new MemoryStream(blob.Raw); - } - else if (blob.ZlibData != null) - { - MemoryStream deflateStreamData = new MemoryStream(blob.ZlibData); + return null; + } - //skip ZLIB header - deflateStreamData.Seek(2, SeekOrigin.Begin); + /// + /// Read blob and deserializes its content. + /// + /// Header of the blob. + /// Deserialized content of the read blob or null if blob contains unknown data. + private object ReadBlob(BlobHeader header) + { + byte[] buffer = new byte[header.DataSize]; + _input.Read(buffer, 0, header.DataSize); + Blob blob = Serializer.Deserialize(new MemoryStream(buffer)); - blobContentStream = new System.IO.Compression.DeflateStream(deflateStreamData, System.IO.Compression.CompressionMode.Decompress); - } - else + Stream blobContentStream; + if (blob.Raw != null) + { + blobContentStream = new MemoryStream(blob.Raw); + } + else if (blob.ZlibData != null) + { + MemoryStream deflateStreamData = new MemoryStream(blob.ZlibData); + + //skip ZLIB header + deflateStreamData.Seek(2, SeekOrigin.Begin); + + blobContentStream = new System.IO.Compression.DeflateStream(deflateStreamData, System.IO.Compression.CompressionMode.Decompress); + } + else + { + throw new NotSupportedException(); + } + + if (header.Type.Equals("OSMData", StringComparison.OrdinalIgnoreCase)) + { + if ((blob.RawSize.HasValue && blob.RawSize > MaxDataBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxDataBlockSize)) { - throw new NotSupportedException(); + throw new InvalidDataException("Invalid OSMData block"); } - if (header.Type.Equals("OSMData", StringComparison.OrdinalIgnoreCase)) + return Serializer.Deserialize(blobContentStream); + } + else if (header.Type.Equals("OSMHeader", StringComparison.OrdinalIgnoreCase)) + { + if ((blob.RawSize.HasValue && blob.RawSize > MaxHeaderBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxHeaderBlockSize)) { - if ((blob.RawSize.HasValue && blob.RawSize > MaxDataBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxDataBlockSize)) - { - throw new InvalidDataException("Invalid OSMData block"); - } - - return Serializer.Deserialize(blobContentStream); + throw new InvalidDataException("Invalid OSMHeader block"); } - else if (header.Type.Equals("OSMHeader", StringComparison.OrdinalIgnoreCase)) - { - if ((blob.RawSize.HasValue && blob.RawSize > MaxHeaderBlockSize) || (blob.RawSize.HasValue == false && blobContentStream.Length > MaxHeaderBlockSize)) - { - throw new InvalidDataException("Invalid OSMHeader block"); - } - try - { - return Serializer.Deserialize(blobContentStream); - } - catch (ProtoException ex) - { - throw new InvalidDataException("Invalid OSMData block", ex); - } + try + { + return Serializer.Deserialize(blobContentStream); } - else + catch (ProtoException ex) { - return null; + throw new InvalidDataException("Invalid OSMData block", ex); } } + else + { + return null; + } + } - /// - /// Checks OsmHeader required features and if any of required features isn't supported, NotSupportedException is thrown. - /// - /// OsmHeader object to process. - private void ProcessOsmHeader(OsmHeader header) + /// + /// Checks OsmHeader required features and if any of required features isn't supported, NotSupportedException is thrown. + /// + /// OsmHeader object to process. + private void ProcessOsmHeader(OsmHeader header) + { + string[] supportedFeatures = new string[] { "OsmSchema-V0.6", "DenseNodes" }; + foreach (var required in header.RequiredFeatures) { - string[] supportedFeatures = new string[] { "OsmSchema-V0.6", "DenseNodes" }; - foreach (var required in header.RequiredFeatures) + if (supportedFeatures.Contains(required) == false) { - if (supportedFeatures.Contains(required) == false) - { - throw new NotSupportedException(string.Format("Processing specified PBF file requires '{0}' feature which isn't supported by PbfReader.", required)); - } + throw new NotSupportedException(string.Format("Processing specified PBF file requires '{0}' feature which isn't supported by PbfReader.", required)); } } + } - /// - /// Processes OSM entities in Primitive group. - /// - /// The PrimitiveBlock that contains specified PrimitiveGroup. - /// The PrimitiveGroup to process. - private void ProcessPrimitiveGroup(PrimitiveBlock block, PrimitiveGroup group) + /// + /// Processes OSM entities in Primitive group. + /// + /// The PrimitiveBlock that contains specified PrimitiveGroup. + /// The PrimitiveGroup to process. + private void ProcessPrimitiveGroup(PrimitiveBlock block, PrimitiveGroup group) + { + this.ProcessNodes(block, group); + this.ProcessDenseNodes(block, group); + this.ProcessWays(block, group); + this.ProcessRelations(block, group); + } + + /// + /// Processes all nodes in non-dense format from the PrimitiveGroup and adds them to the output queue. + /// + /// The PrimitiveBlock that contains specified PrimitiveGroup. + /// The PrimitiveGroup with nodes to process. + private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.Nodes == null) { - this.ProcessNodes(block, group); - this.ProcessDenseNodes(block, group); - this.ProcessWays(block, group); - this.ProcessRelations(block, group); + return; } - /// - /// Processes all nodes in non-dense format from the PrimitiveGroup and adds them to the output queue. - /// - /// The PrimitiveBlock that contains specified PrimitiveGroup. - /// The PrimitiveGroup with nodes to process. - private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) + foreach (PbfNode node in group.Nodes) { - if (group.Nodes == null) - { - return; - } + double lat = 1E-09 * (block.LatOffset + (block.Granularity * node.Latitude)); + double lon = 1E-09 * (block.LonOffset + (block.Granularity * node.Longitude)); - foreach (PbfNode node in group.Nodes) + List tags = new List(); + if (node.Keys != null) { - double lat = 1E-09 * (block.LatOffset + (block.Granularity * node.Latitude)); - double lon = 1E-09 * (block.LonOffset + (block.Granularity * node.Longitude)); - - List tags = new List(); - if (node.Keys != null) + for (int i = 0; i < node.Keys.Count; i++) { - for (int i = 0; i < node.Keys.Count; i++) - { - tags.Add(new Tag(block.StringTable[node.Keys[i]], block.StringTable[node.Values[i]])); - } + tags.Add(new Tag(block.StringTable[node.Keys[i]], block.StringTable[node.Values[i]])); } + } - EntityMetadata metadata = this.ProcessMetadata(node.Metadata, block); + EntityMetadata metadata = this.ProcessMetadata(node.Metadata, block); - NodeInfo parsed = new NodeInfo((long)node.ID, lat, lon, new TagsCollection(tags), metadata); - _cache.Enqueue(parsed); - } + NodeInfo parsed = new NodeInfo((long)node.ID, lat, lon, new TagsCollection(tags), metadata); + _cache.Enqueue(parsed); } + } - /// - /// Processes all nodes in dense format from the PrimitiveGroup and adds them to the output queue. - /// - /// The PrimitiveBlock that contains specified PrimitiveGroup. - /// The PrimitiveGroup with nodes to process. - private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) + /// + /// Processes all nodes in dense format from the PrimitiveGroup and adds them to the output queue. + /// + /// The PrimitiveBlock that contains specified PrimitiveGroup. + /// The PrimitiveGroup with nodes to process. + private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.DenseNodes == null) { - if (group.DenseNodes == null) - { - return; - } + return; + } - long idStore = 0; - long latStore = 0; - long lonStore = 0; + long idStore = 0; + long latStore = 0; + long lonStore = 0; - int keyValueIndex = 0; + int keyValueIndex = 0; - long timestampStore = 0; - long changesetStore = 0; - int userIdStore = 0; - int usernameIdStore = 0; + long timestampStore = 0; + long changesetStore = 0; + int userIdStore = 0; + int usernameIdStore = 0; - for (int i = 0; i < group.DenseNodes.Id.Count; i++) - { - idStore += group.DenseNodes.Id[i]; - lonStore += group.DenseNodes.Longitude[i]; - latStore += group.DenseNodes.Latitude[i]; + for (int i = 0; i < group.DenseNodes.Id.Count; i++) + { + idStore += group.DenseNodes.Id[i]; + lonStore += group.DenseNodes.Longitude[i]; + latStore += group.DenseNodes.Latitude[i]; - double lat = 1E-09 * (block.LatOffset + (block.Granularity * latStore)); - double lon = 1E-09 * (block.LonOffset + (block.Granularity * lonStore)); + double lat = 1E-09 * (block.LatOffset + (block.Granularity * latStore)); + double lon = 1E-09 * (block.LonOffset + (block.Granularity * lonStore)); - List tags = new List(); - if (group.DenseNodes.KeysVals.Count > 0) + List tags = new List(); + if (group.DenseNodes.KeysVals.Count > 0) + { + while (group.DenseNodes.KeysVals[keyValueIndex] != 0) { - while (group.DenseNodes.KeysVals[keyValueIndex] != 0) - { - string key = block.StringTable[group.DenseNodes.KeysVals[keyValueIndex++]]; - string value = block.StringTable[group.DenseNodes.KeysVals[keyValueIndex++]]; - - tags.Add(new Tag(key, value)); - } + string key = block.StringTable[group.DenseNodes.KeysVals[keyValueIndex++]]; + string value = block.StringTable[group.DenseNodes.KeysVals[keyValueIndex++]]; - //Skip '0' used as delimiter - keyValueIndex++; + tags.Add(new Tag(key, value)); } - EntityMetadata metadata = null; - if (this.Settings.ReadMetadata && group.DenseNodes.DenseInfo != null) - { - timestampStore += group.DenseNodes.DenseInfo.Timestamp[i]; - changesetStore += group.DenseNodes.DenseInfo.Changeset[i]; - userIdStore += group.DenseNodes.DenseInfo.UserId[i]; - usernameIdStore += group.DenseNodes.DenseInfo.UserNameIndex[i]; + //Skip '0' used as delimiter + keyValueIndex++; + } - metadata = new EntityMetadata() - { - Changeset = (int)changesetStore, - Timestamp = _unixEpoch.AddMilliseconds(timestampStore * block.DateGranularity), - Uid = userIdStore, - User = block.StringTable[usernameIdStore], - Version = group.DenseNodes.DenseInfo.Version[i], - Visible = true - }; - - if (group.DenseNodes.DenseInfo.Visible.Count > 0) - { - metadata.Visible = group.DenseNodes.DenseInfo.Visible[i]; - } - } + EntityMetadata metadata = null; + if (this.Settings.ReadMetadata && group.DenseNodes.DenseInfo != null) + { + timestampStore += group.DenseNodes.DenseInfo.Timestamp[i]; + changesetStore += group.DenseNodes.DenseInfo.Changeset[i]; + userIdStore += group.DenseNodes.DenseInfo.UserId[i]; + usernameIdStore += group.DenseNodes.DenseInfo.UserNameIndex[i]; - NodeInfo parsed = new NodeInfo((long)idStore, lat, lon, new TagsCollection(tags), metadata); - _cache.Enqueue(parsed); + metadata = new EntityMetadata() + { + Changeset = (int)changesetStore, + Timestamp = _unixEpoch.AddMilliseconds(timestampStore * block.DateGranularity), + Uid = userIdStore, + User = block.StringTable[usernameIdStore], + Version = group.DenseNodes.DenseInfo.Version[i], + Visible = true + }; + + if (group.DenseNodes.DenseInfo.Visible.Count > 0) + { + metadata.Visible = group.DenseNodes.DenseInfo.Visible[i]; + } } + + NodeInfo parsed = new NodeInfo((long)idStore, lat, lon, new TagsCollection(tags), metadata); + _cache.Enqueue(parsed); + } + } + + /// + /// Processes all ways from the PrimitiveGroup and adds them to the output queue. + /// + /// The PrimitiveBlock that contains specified PrimitiveGroup. + /// The PrimitiveGroup with nodes to process. + private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.Ways == null) + { + return; } - /// - /// Processes all ways from the PrimitiveGroup and adds them to the output queue. - /// - /// The PrimitiveBlock that contains specified PrimitiveGroup. - /// The PrimitiveGroup with nodes to process. - private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) + foreach (var way in group.Ways) { - if (group.Ways == null) + long refStore = 0; + List refs = new List(way.Refs.Count); + + for (int i = 0; i < way.Refs.Count; i++) { - return; + refStore += (long)way.Refs[i]; + refs.Add(refStore); } - foreach (var way in group.Ways) + List tags = new List(); + if (way.Keys != null) { - long refStore = 0; - List refs = new List(way.Refs.Count); - - for (int i = 0; i < way.Refs.Count; i++) + for (int i = 0; i < way.Keys.Count; i++) { - refStore += (long)way.Refs[i]; - refs.Add(refStore); + tags.Add(new Tag(block.StringTable[way.Keys[i]], block.StringTable[way.Values[i]])); } + } - List tags = new List(); - if (way.Keys != null) - { - for (int i = 0; i < way.Keys.Count; i++) - { - tags.Add(new Tag(block.StringTable[way.Keys[i]], block.StringTable[way.Values[i]])); - } - } + EntityMetadata metadata = this.ProcessMetadata(way.Metadata, block); - EntityMetadata metadata = this.ProcessMetadata(way.Metadata, block); + WayInfo parsed = new WayInfo((long)way.ID, new TagsCollection(tags), refs, metadata); + _cache.Enqueue(parsed); + } + } - WayInfo parsed = new WayInfo((long)way.ID, new TagsCollection(tags), refs, metadata); - _cache.Enqueue(parsed); - } + /// + /// Processes all relations from the PrimitiveGroup and adds them to the output queue. + /// + /// The PrimitiveBlock that contains specified PrimitiveGroup. + /// The PrimitiveGroup with nodes to process. + private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) + { + if (group.Relations == null) + { + return; } - /// - /// Processes all relations from the PrimitiveGroup and adds them to the output queue. - /// - /// The PrimitiveBlock that contains specified PrimitiveGroup. - /// The PrimitiveGroup with nodes to process. - private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) + foreach (var relation in group.Relations) { - if (group.Relations == null) - { - return; - } + long memberRefStore = 0; - foreach (var relation in group.Relations) + List members = new List(); + for (int i = 0; i < relation.MemberIds.Count; i++) { - long memberRefStore = 0; + memberRefStore += (long)relation.MemberIds[i]; + string role = block.StringTable[relation.RolesIndexes[i]]; - List members = new List(); - for (int i = 0; i < relation.MemberIds.Count; i++) + EntityType memberType = 0; + switch (relation.Types[i]) { - memberRefStore += (long)relation.MemberIds[i]; - string role = block.StringTable[relation.RolesIndexes[i]]; - - EntityType memberType = 0; - switch (relation.Types[i]) - { - case PbfRelationMemberType.Node: memberType = EntityType.Node; break; - case PbfRelationMemberType.Way: memberType = EntityType.Way; break; - case PbfRelationMemberType.Relation: memberType = EntityType.Relation; break; - } - - members.Add(new RelationMemberInfo() { MemberType = memberType, Reference = memberRefStore, Role = role }); + case PbfRelationMemberType.Node: memberType = EntityType.Node; break; + case PbfRelationMemberType.Way: memberType = EntityType.Way; break; + case PbfRelationMemberType.Relation: memberType = EntityType.Relation; break; } - List tags = new List(); - if (relation.Keys != null) + members.Add(new RelationMemberInfo() { MemberType = memberType, Reference = memberRefStore, Role = role }); + } + + List tags = new List(); + if (relation.Keys != null) + { + for (int i = 0; i < relation.Keys.Count; i++) { - for (int i = 0; i < relation.Keys.Count; i++) - { - tags.Add(new Tag(block.StringTable[relation.Keys[i]], block.StringTable[relation.Values[i]])); - } + tags.Add(new Tag(block.StringTable[relation.Keys[i]], block.StringTable[relation.Values[i]])); } + } - EntityMetadata metadata = this.ProcessMetadata(relation.Metadata, block); + EntityMetadata metadata = this.ProcessMetadata(relation.Metadata, block); - RelationInfo parsed = new RelationInfo((long)relation.ID, new TagsCollection(tags), members, metadata); - _cache.Enqueue(parsed); - } + RelationInfo parsed = new RelationInfo((long)relation.ID, new TagsCollection(tags), members, metadata); + _cache.Enqueue(parsed); } + } - /// - /// Processes entity metadata. - /// - /// Serilized metadata. - /// PrimitiveBlock that contains metadata being processed. - /// Parsed metadata. - private EntityMetadata ProcessMetadata(PbfMetadata serializedMetadata, PrimitiveBlock block) - { - EntityMetadata metadata = null; + /// + /// Processes entity metadata. + /// + /// Serilized metadata. + /// PrimitiveBlock that contains metadata being processed. + /// Parsed metadata. + private EntityMetadata ProcessMetadata(PbfMetadata serializedMetadata, PrimitiveBlock block) + { + EntityMetadata metadata = null; - if (this.Settings.ReadMetadata && serializedMetadata != null) + if (this.Settings.ReadMetadata && serializedMetadata != null) + { + //PBF has no field for 'visible' property, true is default value for OSM entity read from PBF file + metadata = new EntityMetadata() { Visible = true }; + if (serializedMetadata.Changeset.HasValue) { - //PBF has no field for 'visible' property, true is default value for OSM entity read from PBF file - metadata = new EntityMetadata() { Visible = true }; - if (serializedMetadata.Changeset.HasValue) - { - metadata.Changeset = (int)serializedMetadata.Changeset.Value; - } - - if (serializedMetadata.Timestamp.HasValue) - { - metadata.Timestamp = _unixEpoch.AddMilliseconds(serializedMetadata.Timestamp.Value * block.DateGranularity); - } + metadata.Changeset = (int)serializedMetadata.Changeset.Value; + } - if (serializedMetadata.UserID.HasValue) - { - metadata.Uid = serializedMetadata.UserID.Value; - } + if (serializedMetadata.Timestamp.HasValue) + { + metadata.Timestamp = _unixEpoch.AddMilliseconds(serializedMetadata.Timestamp.Value * block.DateGranularity); + } - if (serializedMetadata.UserNameIndex.HasValue) - { - metadata.User = block.StringTable[serializedMetadata.UserNameIndex.Value]; - } + if (serializedMetadata.UserID.HasValue) + { + metadata.Uid = serializedMetadata.UserID.Value; + } - if (serializedMetadata.Version.HasValue) - { - metadata.Version = serializedMetadata.Version.Value; - } + if (serializedMetadata.UserNameIndex.HasValue) + { + metadata.User = block.StringTable[serializedMetadata.UserNameIndex.Value]; } - return metadata; + if (serializedMetadata.Version.HasValue) + { + metadata.Version = serializedMetadata.Version.Value; + } } - /// - /// Releases the unmanaged resources used by the PbfReader and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + return metadata; + } + + /// + /// Releases the unmanaged resources used by the PbfReader and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!this._disposed) { - if (!this._disposed) + if (disposing) { - if (disposing) + if (_input != null) { - if (_input != null) - { - _input.Dispose(); - } + _input.Dispose(); } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Osm/IO/PbfWriter.cs b/src/SpatialLite.Osm/IO/PbfWriter.cs index d690db7..f227005 100644 --- a/src/SpatialLite.Osm/IO/PbfWriter.cs +++ b/src/SpatialLite.Osm/IO/PbfWriter.cs @@ -6,634 +6,633 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm.IO.Pbf; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Represents IOsmWriter that writes OSM entities to Pbf format. +/// +public class PbfWriter : IOsmWriter { + /// - /// Represents IOsmWriter that writes OSM entities to Pbf format. + /// Defines maximal allowed size of uncompressed OsmData block. Larger blocks are considered invalid. /// - public class PbfWriter : IOsmWriter - { + public const int MaxDataBlockSize = 16 * 1024 * 1024; - /// - /// Defines maximal allowed size of uncompressed OsmData block. Larger blocks are considered invalid. - /// - public const int MaxDataBlockSize = 16 * 1024 * 1024; + private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); - private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); + private bool _disposed = false; + private Stream _output; + private bool _ownsOutputStream; - private bool _disposed = false; - private Stream _output; - private bool _ownsOutputStream; + private EntityInfoBuffer _nodesBuffer; + private EntityInfoBuffer _wayBuffer; + private EntityInfoBuffer _relationBuffer; - private EntityInfoBuffer _nodesBuffer; - private EntityInfoBuffer _wayBuffer; - private EntityInfoBuffer _relationBuffer; + /// + /// Initializes a new instance of the PbfWriter class that writes entities to specified stream with given settings. + /// + /// The stream to write entities to. + /// The settings defining behaviour of the writer. + public PbfWriter(Stream stream, PbfWriterSettings settings) + { + this.Settings = settings; + this.Settings.IsReadOnly = true; + _output = stream; + _ownsOutputStream = false; - /// - /// Initializes a new instance of the PbfWriter class that writes entities to specified stream with given settings. - /// - /// The stream to write entities to. - /// The settings defining behaviour of the writer. - public PbfWriter(Stream stream, PbfWriterSettings settings) - { - this.Settings = settings; - this.Settings.IsReadOnly = true; - _output = stream; - _ownsOutputStream = false; + this.InitializeBuffers(); + this.WriteHeader(); + } - this.InitializeBuffers(); - this.WriteHeader(); - } + /// + /// Initializes a new instance of the PbfWriter class that writes entities to specified file with given settings. + /// + /// Path to the file to write entities to. + /// The settings defining behaviour of the writer. + public PbfWriter(string filename, PbfWriterSettings settings) + { + this.Settings = settings; + this.Settings.IsReadOnly = true; + _output = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite); + _ownsOutputStream = true; - /// - /// Initializes a new instance of the PbfWriter class that writes entities to specified file with given settings. - /// - /// Path to the file to write entities to. - /// The settings defining behaviour of the writer. - public PbfWriter(string filename, PbfWriterSettings settings) - { - this.Settings = settings; - this.Settings.IsReadOnly = true; - _output = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite); - _ownsOutputStream = true; + this.InitializeBuffers(); + this.WriteHeader(); + } - this.InitializeBuffers(); - this.WriteHeader(); - } + /// + /// Gets settings used by this PbfWriter. + /// + public PbfWriterSettings Settings { get; private set; } - /// - /// Gets settings used by this PbfWriter. - /// - public PbfWriterSettings Settings { get; private set; } - - /// - /// Writes specified entity in PBF format to the underlaying stream. - /// - /// Entity to write. - /// - /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. - /// - public void Write(IEntityInfo entity) + /// + /// Writes specified entity in PBF format to the underlaying stream. + /// + /// Entity to write. + /// + /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. + /// + public void Write(IEntityInfo entity) + { + if (this.Settings.WriteMetadata) { - if (this.Settings.WriteMetadata) - { - if (entity.Metadata == null) - { - throw new ArgumentException("Entity doesn't contain metadata obejct, but writer was created with WriteMetadata setting."); - } - - if (entity.Metadata.User == null) - { - throw new ArgumentNullException("Entity.Metadata.User cannot be null."); - } - } - - switch (entity.EntityType) - { - case EntityType.Node: _nodesBuffer.Add(entity as NodeInfo); break; - case EntityType.Way: _wayBuffer.Add(entity as WayInfo); break; - case EntityType.Relation: _relationBuffer.Add(entity as RelationInfo); break; - } - - if (_nodesBuffer.EstimatedMaxSize > MaxDataBlockSize) - { - this.Flush(EntityType.Node); - } - - if (_wayBuffer.EstimatedMaxSize > MaxDataBlockSize) + if (entity.Metadata == null) { - this.Flush(EntityType.Way); + throw new ArgumentException("Entity doesn't contain metadata obejct, but writer was created with WriteMetadata setting."); } - if (_relationBuffer.EstimatedMaxSize > MaxDataBlockSize) + if (entity.Metadata.User == null) { - this.Flush(EntityType.Relation); + throw new ArgumentNullException("Entity.Metadata.User cannot be null."); } } - /// - /// Writes specific IOsmGeometry in PBF format to the underlaying stream. - /// - /// Entity to write. - /// - /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. - /// - public void Write(IOsmGeometry entity) + switch (entity.EntityType) { - if (entity == null) - { - throw new ArgumentNullException(nameof(entity), "Entity cannot be null"); - } - - switch (entity.EntityType) - { - case EntityType.Node: this.Write(new NodeInfo((Geometries.Node)entity)); break; - case EntityType.Way: this.Write(new WayInfo((Geometries.Way)entity)); break; - case EntityType.Relation: this.Write(new RelationInfo((Geometries.Relation)entity)); break; - } + case EntityType.Node: _nodesBuffer.Add(entity as NodeInfo); break; + case EntityType.Way: _wayBuffer.Add(entity as WayInfo); break; + case EntityType.Relation: _relationBuffer.Add(entity as RelationInfo); break; } - /// - /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. - /// - public void Flush() + if (_nodesBuffer.EstimatedMaxSize > MaxDataBlockSize) { this.Flush(EntityType.Node); + } + + if (_wayBuffer.EstimatedMaxSize > MaxDataBlockSize) + { this.Flush(EntityType.Way); - this.Flush(EntityType.Relation); } - /// - /// Releases all resources used by the PbfWriter. - /// - public void Dispose() + if (_relationBuffer.EstimatedMaxSize > MaxDataBlockSize) { - Dispose(true); - GC.SuppressFinalize(this); + this.Flush(EntityType.Relation); } + } - /// - /// Creates internal buffers and initializes them to default capacity. - /// - private void InitializeBuffers() + /// + /// Writes specific IOsmGeometry in PBF format to the underlaying stream. + /// + /// Entity to write. + /// + /// PbfWriter uses internal buffers and writes entities to the output stream in blocks. To force PbfWriter to clear internal buffers and write data to the underlaying stream use Flush() function. + /// + public void Write(IOsmGeometry entity) + { + if (entity == null) { - _nodesBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); - _wayBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); - _relationBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + throw new ArgumentNullException(nameof(entity), "Entity cannot be null"); } - /// - /// Clears internal buffer for specified EntityType and writes all buffered data the underlaying storage. - /// - /// The type of entity to process - private void Flush(EntityType entityType) + switch (entity.EntityType) { - PrimitiveBlock primitiveBlock = this.BuildPrimitiveBlock(entityType); - if (primitiveBlock == null) - { - return; - } + case EntityType.Node: this.Write(new NodeInfo((Geometries.Node)entity)); break; + case EntityType.Way: this.Write(new WayInfo((Geometries.Way)entity)); break; + case EntityType.Relation: this.Write(new RelationInfo((Geometries.Relation)entity)); break; + } + } - MemoryStream primitiveBlockStream = new MemoryStream(); - Serializer.Serialize(primitiveBlockStream, primitiveBlock); + /// + /// Clears internal buffers and causes any buffered data to be written to the unerlaying storage. + /// + public void Flush() + { + this.Flush(EntityType.Node); + this.Flush(EntityType.Way); + this.Flush(EntityType.Relation); + } - //byte[] buffer = new byte[primitiveBlockStream.Length]; - //Array.Copy(primitiveBlockStream.GetBuffer(), buffer, primitiveBlockStream.Length); + /// + /// Releases all resources used by the PbfWriter. + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - this.WriteBlob("OSMData", primitiveBlockStream.ToArray()); - } + /// + /// Creates internal buffers and initializes them to default capacity. + /// + private void InitializeBuffers() + { + _nodesBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + _wayBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + _relationBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + } - /// - /// Writes PBF file header to the underlaying stream. - /// - private void WriteHeader() + /// + /// Clears internal buffer for specified EntityType and writes all buffered data the underlaying storage. + /// + /// The type of entity to process + private void Flush(EntityType entityType) + { + PrimitiveBlock primitiveBlock = this.BuildPrimitiveBlock(entityType); + if (primitiveBlock == null) { - OsmHeader header = new OsmHeader(); - header.RequiredFeatures.Add("OsmSchema-V0.6"); + return; + } - if (this.Settings.UseDenseFormat) - { - header.RequiredFeatures.Add("DenseNodes"); - } + MemoryStream primitiveBlockStream = new MemoryStream(); + Serializer.Serialize(primitiveBlockStream, primitiveBlock); - if (this.Settings.WriteMetadata) - { - header.OptionalFeatures.Add("Has_Metadata"); - } + //byte[] buffer = new byte[primitiveBlockStream.Length]; + //Array.Copy(primitiveBlockStream.GetBuffer(), buffer, primitiveBlockStream.Length); - using (MemoryStream stream = new MemoryStream()) - { - Serializer.Serialize(stream, header); + this.WriteBlob("OSMData", primitiveBlockStream.ToArray()); + } - //byte[] buffer = new byte[stream.Length]; - //Array.Copy(stream.GetBuffer(), buffer, stream.Length); + /// + /// Writes PBF file header to the underlaying stream. + /// + private void WriteHeader() + { + OsmHeader header = new OsmHeader(); + header.RequiredFeatures.Add("OsmSchema-V0.6"); - this.WriteBlob("OSMHeader", stream.ToArray()); - } + if (this.Settings.UseDenseFormat) + { + header.RequiredFeatures.Add("DenseNodes"); } - /// - /// Writes blob and it's header to the underlaying stream. - /// - /// The type of the blob. - /// The pbf serialized content of the blob. - private void WriteBlob(string blobType, byte[] blobContent) + if (this.Settings.WriteMetadata) { - Blob blob = new Blob(); - if (this.Settings.Compression == CompressionMode.None) - { - blob.Raw = blobContent; - } - else if (this.Settings.Compression == CompressionMode.ZlibDeflate) - { - MemoryStream zlibStream = new MemoryStream(); - - //ZLIB header - zlibStream.WriteByte(120); - zlibStream.WriteByte(156); - - using (System.IO.Compression.DeflateStream deflateSteram = new System.IO.Compression.DeflateStream(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) - { - deflateSteram.Write(blobContent, 0, blobContent.Length); - } - - blob.RawSize = (int)blobContent.Length; - blob.ZlibData = zlibStream.ToArray(); - } + header.OptionalFeatures.Add("Has_Metadata"); + } - MemoryStream blobStream = new MemoryStream(); - Serializer.Serialize(blobStream, blob); + using (MemoryStream stream = new MemoryStream()) + { + Serializer.Serialize(stream, header); - BlobHeader header = new BlobHeader(); - header.Type = blobType; - header.DataSize = (int)blobStream.Length; - Serializer.SerializeWithLengthPrefix(_output, header, PrefixStyle.Fixed32BigEndian); + //byte[] buffer = new byte[stream.Length]; + //Array.Copy(stream.GetBuffer(), buffer, stream.Length); - blobStream.WriteTo(_output); + this.WriteBlob("OSMHeader", stream.ToArray()); } + } - /// - /// Creates a PrimitiveBlock with entities of specified type from data in tokens. - /// - /// The type of entity to include in PrimitiveBlock. - /// PrimitiveBlock with entities of specified type or null if tokens doesn't contain any entities of specified type. - private PrimitiveBlock BuildPrimitiveBlock(EntityType entityType) + /// + /// Writes blob and it's header to the underlaying stream. + /// + /// The type of the blob. + /// The pbf serialized content of the blob. + private void WriteBlob(string blobType, byte[] blobContent) + { + Blob blob = new Blob(); + if (this.Settings.Compression == CompressionMode.None) + { + blob.Raw = blobContent; + } + else if (this.Settings.Compression == CompressionMode.ZlibDeflate) { - PrimitiveBlock result = new PrimitiveBlock(); + MemoryStream zlibStream = new MemoryStream(); - result.PrimitiveGroup = new List(); - PrimitiveGroup entityGroup = null; - switch (entityType) - { - case EntityType.Node: - entityGroup = this.BuildNodesPrimitiveGroup(result.DateGranularity, result.Granularity, result.LatOffset, result.LonOffset); - result.StringTable = _nodesBuffer.BuildStringTable(); - _nodesBuffer.Clear(); - break; - case EntityType.Way: - entityGroup = this.BuildWaysPrimitiveGroup(result.DateGranularity); - result.StringTable = _wayBuffer.BuildStringTable(); - _wayBuffer.Clear(); - break; - case EntityType.Relation: - entityGroup = this.BuildRelationsPrimitiveGroup(result.DateGranularity); - result.StringTable = _relationBuffer.BuildStringTable(); - _relationBuffer.Clear(); - break; - } + //ZLIB header + zlibStream.WriteByte(120); + zlibStream.WriteByte(156); - if (entityGroup == null) + using (System.IO.Compression.DeflateStream deflateSteram = new System.IO.Compression.DeflateStream(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) { - return null; + deflateSteram.Write(blobContent, 0, blobContent.Length); } - result.PrimitiveGroup.Add(entityGroup); - - return result; + blob.RawSize = (int)blobContent.Length; + blob.ZlibData = zlibStream.ToArray(); } - /// - /// Creates a PrimitiveGroup with serialized nodes from tokens. - /// - /// Timestamp granularity defined in PrimitiveBlock. - /// Granularity defined in PrimitiveBlock. - /// Latitude offset defined in PrimitiveBlock. - /// Longitude offset defined in PrimitiveBlock. - /// PrimitiveGroup with nodes from tokens or null if tokens is empty. - private PrimitiveGroup BuildNodesPrimitiveGroup(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) - { - PrimitiveGroup result = null; + MemoryStream blobStream = new MemoryStream(); + Serializer.Serialize(blobStream, blob); - if (_nodesBuffer.Count > 0) - { - result = new PrimitiveGroup(); + BlobHeader header = new BlobHeader(); + header.Type = blobType; + header.DataSize = (int)blobStream.Length; + Serializer.SerializeWithLengthPrefix(_output, header, PrefixStyle.Fixed32BigEndian); - if (this.Settings.UseDenseFormat) - { - result.DenseNodes = this.BuildDenseNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); - } - else - { - result.Nodes = this.BuildNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); - } - } + blobStream.WriteTo(_output); + } - return result; + /// + /// Creates a PrimitiveBlock with entities of specified type from data in tokens. + /// + /// The type of entity to include in PrimitiveBlock. + /// PrimitiveBlock with entities of specified type or null if tokens doesn't contain any entities of specified type. + private PrimitiveBlock BuildPrimitiveBlock(EntityType entityType) + { + PrimitiveBlock result = new PrimitiveBlock(); + + result.PrimitiveGroup = new List(); + PrimitiveGroup entityGroup = null; + switch (entityType) + { + case EntityType.Node: + entityGroup = this.BuildNodesPrimitiveGroup(result.DateGranularity, result.Granularity, result.LatOffset, result.LonOffset); + result.StringTable = _nodesBuffer.BuildStringTable(); + _nodesBuffer.Clear(); + break; + case EntityType.Way: + entityGroup = this.BuildWaysPrimitiveGroup(result.DateGranularity); + result.StringTable = _wayBuffer.BuildStringTable(); + _wayBuffer.Clear(); + break; + case EntityType.Relation: + entityGroup = this.BuildRelationsPrimitiveGroup(result.DateGranularity); + result.StringTable = _relationBuffer.BuildStringTable(); + _relationBuffer.Clear(); + break; } - /// - /// Creates a PrimitiveGroup with serialized ways from tokens. - /// - /// Timestamp granularity defined in PrimitiveBlock. - /// PrimitiveGroup with ways from tokens or null if tokens is empty. - private PrimitiveGroup BuildWaysPrimitiveGroup(int timestampGranularity) + if (entityGroup == null) { - PrimitiveGroup result = null; + return null; + } - if (_wayBuffer.Count > 0) - { - result = new PrimitiveGroup(); + result.PrimitiveGroup.Add(entityGroup); - result.Ways = this.BuildWays(timestampGranularity); - } + return result; + } - return result; - } + /// + /// Creates a PrimitiveGroup with serialized nodes from tokens. + /// + /// Timestamp granularity defined in PrimitiveBlock. + /// Granularity defined in PrimitiveBlock. + /// Latitude offset defined in PrimitiveBlock. + /// Longitude offset defined in PrimitiveBlock. + /// PrimitiveGroup with nodes from tokens or null if tokens is empty. + private PrimitiveGroup BuildNodesPrimitiveGroup(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) + { + PrimitiveGroup result = null; - /// - /// Creates a PrimitiveGroup with serialized relations objects from relation tokens. - /// - /// Timestamp granularity defined in PrimitiveBlock. - /// PrimitiveGroup with relations from tokens or null if tokens is empty. - private PrimitiveGroup BuildRelationsPrimitiveGroup(int timestampGranularity) + if (_nodesBuffer.Count > 0) { - PrimitiveGroup result = null; + result = new PrimitiveGroup(); - if (_relationBuffer.Count > 0) + if (this.Settings.UseDenseFormat) { - result = new PrimitiveGroup(); - - result.Relations = this.BuildRelations(timestampGranularity); + result.DenseNodes = this.BuildDenseNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); + } + else + { + result.Nodes = this.BuildNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); } - - return result; } - /// - /// Creates a collection of Node objects from nodes in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// Granularity as defined in PrimitiveBlock. - /// Latitude offset as defined in PrimitiveBlock. - /// Longitude offset as defined in PrimitiveBlock. - /// The DenseNode obejct with data from nodes in tokens. - private List BuildNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) - { - List result = new List(_nodesBuffer.Count); - foreach (var node in _nodesBuffer) - { - PbfNode toAdd = new PbfNode(); + return result; + } - toAdd.ID = node.ID; - toAdd.Latitude = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); - toAdd.Longitude = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); + /// + /// Creates a PrimitiveGroup with serialized ways from tokens. + /// + /// Timestamp granularity defined in PrimitiveBlock. + /// PrimitiveGroup with ways from tokens or null if tokens is empty. + private PrimitiveGroup BuildWaysPrimitiveGroup(int timestampGranularity) + { + PrimitiveGroup result = null; - if (node.Tags.Count > 0) - { - toAdd.Keys = new List(); - toAdd.Values = new List(); + if (_wayBuffer.Count > 0) + { + result = new PrimitiveGroup(); - foreach (var tag in node.Tags) - { - toAdd.Keys.Add(_nodesBuffer.GetStringIndex(tag.Key)); - toAdd.Values.Add(_nodesBuffer.GetStringIndex(tag.Value)); - } - } + result.Ways = this.BuildWays(timestampGranularity); + } - if (node.Metadata != null && this.Settings.WriteMetadata) - { - toAdd.Metadata = this.BuildInfo(node.Metadata, timestampGranularity, _nodesBuffer); - } + return result; + } - result.Add(toAdd); - } + /// + /// Creates a PrimitiveGroup with serialized relations objects from relation tokens. + /// + /// Timestamp granularity defined in PrimitiveBlock. + /// PrimitiveGroup with relations from tokens or null if tokens is empty. + private PrimitiveGroup BuildRelationsPrimitiveGroup(int timestampGranularity) + { + PrimitiveGroup result = null; + + if (_relationBuffer.Count > 0) + { + result = new PrimitiveGroup(); - return result; + result.Relations = this.BuildRelations(timestampGranularity); } - /// - /// Creates DenseNode obejcet from nodes in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// Granularity as defined in PrimitiveBlock. - /// Latitude offset as defined in PrimitiveBlock. - /// Longitude offset as defined in PrimitiveBlock. - /// The DenseNode obejct with data from nodes in tokens. - private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) + return result; + } + + /// + /// Creates a collection of Node objects from nodes in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// Granularity as defined in PrimitiveBlock. + /// Latitude offset as defined in PrimitiveBlock. + /// Longitude offset as defined in PrimitiveBlock. + /// The DenseNode obejct with data from nodes in tokens. + private List BuildNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) + { + List result = new List(_nodesBuffer.Count); + foreach (var node in _nodesBuffer) { - PbfDenseNodes result = new PbfDenseNodes(_nodesBuffer.Count); + PbfNode toAdd = new PbfNode(); - long lastID = 0; - long lastLat = 0; - long lastLon = 0; + toAdd.ID = node.ID; + toAdd.Latitude = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); + toAdd.Longitude = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); - foreach (var node in _nodesBuffer) + if (node.Tags.Count > 0) { - result.Id.Add(node.ID - lastID); - lastID = node.ID; - - long latValue = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); - result.Latitude.Add(latValue - lastLat); - lastLat = latValue; - - long lonValue = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); - result.Longitude.Add(lonValue - lastLon); - lastLon = lonValue; + toAdd.Keys = new List(); + toAdd.Values = new List(); foreach (var tag in node.Tags) { - result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Key)); - result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Value)); + toAdd.Keys.Add(_nodesBuffer.GetStringIndex(tag.Key)); + toAdd.Values.Add(_nodesBuffer.GetStringIndex(tag.Value)); } - - result.KeysVals.Add(0); } - if (this.Settings.WriteMetadata) + if (node.Metadata != null && this.Settings.WriteMetadata) { - result.DenseInfo = this.BuildDenseInfo(timestampGranularity); + toAdd.Metadata = this.BuildInfo(node.Metadata, timestampGranularity, _nodesBuffer); } - return result; + result.Add(toAdd); } - /// - /// Creates collection of PbfWay objects from ways in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// The collection of PbfWay objects created from relations in tokens. - private List BuildWays(int timestampGranularity) + return result; + } + + /// + /// Creates DenseNode obejcet from nodes in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// Granularity as defined in PrimitiveBlock. + /// Latitude offset as defined in PrimitiveBlock. + /// Longitude offset as defined in PrimitiveBlock. + /// The DenseNode obejct with data from nodes in tokens. + private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) + { + PbfDenseNodes result = new PbfDenseNodes(_nodesBuffer.Count); + + long lastID = 0; + long lastLat = 0; + long lastLon = 0; + + foreach (var node in _nodesBuffer) { - List result = new List(); + result.Id.Add(node.ID - lastID); + lastID = node.ID; + + long latValue = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); + result.Latitude.Add(latValue - lastLat); + lastLat = latValue; - foreach (var way in _wayBuffer) + long lonValue = (long)Math.Round(((node.Longitude / 1E-09) - lonOffset) / positionGranularity); + result.Longitude.Add(lonValue - lastLon); + lastLon = lonValue; + + foreach (var tag in node.Tags) { - long lastRef = 0; + result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Key)); + result.KeysVals.Add((int)_nodesBuffer.GetStringIndex(tag.Value)); + } - PbfWay toAdd = new PbfWay(); + result.KeysVals.Add(0); + } - toAdd.ID = way.ID; + if (this.Settings.WriteMetadata) + { + result.DenseInfo = this.BuildDenseInfo(timestampGranularity); + } - if (way.Nodes.Count > 0) - { - toAdd.Refs = new List(way.Nodes.Count); + return result; + } - for (int i = 0; i < way.Nodes.Count; i++) - { - toAdd.Refs.Add(way.Nodes[i] - lastRef); - lastRef = way.Nodes[i]; - } - } + /// + /// Creates collection of PbfWay objects from ways in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// The collection of PbfWay objects created from relations in tokens. + private List BuildWays(int timestampGranularity) + { + List result = new List(); - if (way.Tags.Count > 0) - { - toAdd.Keys = new List(); - toAdd.Values = new List(); + foreach (var way in _wayBuffer) + { + long lastRef = 0; - foreach (var tag in way.Tags) - { - toAdd.Keys.Add(_wayBuffer.GetStringIndex(tag.Key)); - toAdd.Values.Add(_wayBuffer.GetStringIndex(tag.Value)); - } + PbfWay toAdd = new PbfWay(); + + toAdd.ID = way.ID; + + if (way.Nodes.Count > 0) + { + toAdd.Refs = new List(way.Nodes.Count); + + for (int i = 0; i < way.Nodes.Count; i++) + { + toAdd.Refs.Add(way.Nodes[i] - lastRef); + lastRef = way.Nodes[i]; } + } + + if (way.Tags.Count > 0) + { + toAdd.Keys = new List(); + toAdd.Values = new List(); - if (way.Metadata != null && this.Settings.WriteMetadata) + foreach (var tag in way.Tags) { - toAdd.Metadata = this.BuildInfo(way.Metadata, timestampGranularity, _wayBuffer); + toAdd.Keys.Add(_wayBuffer.GetStringIndex(tag.Key)); + toAdd.Values.Add(_wayBuffer.GetStringIndex(tag.Value)); } + } - result.Add(toAdd); + if (way.Metadata != null && this.Settings.WriteMetadata) + { + toAdd.Metadata = this.BuildInfo(way.Metadata, timestampGranularity, _wayBuffer); } - return result; + result.Add(toAdd); } - /// - /// Creates collection of PbfRelation objects from relations in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// The collection of PbfRelation objects created from relations in tokens. - private List BuildRelations(int timestampGranularity) + return result; + } + + /// + /// Creates collection of PbfRelation objects from relations in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// The collection of PbfRelation objects created from relations in tokens. + private List BuildRelations(int timestampGranularity) + { + List result = new List(); + + foreach (var relation in _relationBuffer) { - List result = new List(); + PbfRelation toAdd = new PbfRelation(); + toAdd.ID = relation.ID; - foreach (var relation in _relationBuffer) + long lastRef = 0; + foreach (var member in relation.Members) { - PbfRelation toAdd = new PbfRelation(); - toAdd.ID = relation.ID; + toAdd.MemberIds.Add(member.Reference - lastRef); + lastRef = member.Reference; - long lastRef = 0; - foreach (var member in relation.Members) + toAdd.RolesIndexes.Add((int)_relationBuffer.GetStringIndex(member.Role ?? string.Empty)); + PbfRelationMemberType memberType = 0; + switch (member.MemberType) { - toAdd.MemberIds.Add(member.Reference - lastRef); - lastRef = member.Reference; - - toAdd.RolesIndexes.Add((int)_relationBuffer.GetStringIndex(member.Role ?? string.Empty)); - PbfRelationMemberType memberType = 0; - switch (member.MemberType) - { - case EntityType.Node: memberType = PbfRelationMemberType.Node; break; - case EntityType.Way: memberType = PbfRelationMemberType.Way; break; - case EntityType.Relation: memberType = PbfRelationMemberType.Relation; break; - } - - toAdd.Types.Add(memberType); + case EntityType.Node: memberType = PbfRelationMemberType.Node; break; + case EntityType.Way: memberType = PbfRelationMemberType.Way; break; + case EntityType.Relation: memberType = PbfRelationMemberType.Relation; break; } - toAdd.Keys = new List(relation.Tags.Count); - toAdd.Values = new List(relation.Tags.Count); + toAdd.Types.Add(memberType); + } - if (relation.Tags.Count > 0) - { - foreach (var tag in relation.Tags) - { - toAdd.Keys.Add(_relationBuffer.GetStringIndex(tag.Key)); - toAdd.Values.Add(_relationBuffer.GetStringIndex(tag.Value)); - } - } + toAdd.Keys = new List(relation.Tags.Count); + toAdd.Values = new List(relation.Tags.Count); - if (relation.Metadata != null && this.Settings.WriteMetadata) + if (relation.Tags.Count > 0) + { + foreach (var tag in relation.Tags) { - toAdd.Metadata = this.BuildInfo(relation.Metadata, timestampGranularity, _relationBuffer); + toAdd.Keys.Add(_relationBuffer.GetStringIndex(tag.Key)); + toAdd.Values.Add(_relationBuffer.GetStringIndex(tag.Value)); } + } - result.Add(toAdd); + if (relation.Metadata != null && this.Settings.WriteMetadata) + { + toAdd.Metadata = this.BuildInfo(relation.Metadata, timestampGranularity, _relationBuffer); } - return result; + result.Add(toAdd); } - /// - /// Creates a DenseInfo object with metadata for nodes in tokens. - /// - /// Timestamp granularity as defined in PrimitiveBlock. - /// DenseInfo object with metadata for noes in tokens. - private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) - { - PbfDenseMetadata result = new PbfDenseMetadata(_nodesBuffer.Count); + return result; + } - long lastChangeset = 0; - long lastTimestamp = 0; - int lastUid = 0; - int lastUserNameIndex = 0; + /// + /// Creates a DenseInfo object with metadata for nodes in tokens. + /// + /// Timestamp granularity as defined in PrimitiveBlock. + /// DenseInfo object with metadata for noes in tokens. + private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) + { + PbfDenseMetadata result = new PbfDenseMetadata(_nodesBuffer.Count); - foreach (var node in _nodesBuffer) - { - EntityMetadata metadata = node.Metadata ?? new EntityMetadata(); + long lastChangeset = 0; + long lastTimestamp = 0; + int lastUid = 0; + int lastUserNameIndex = 0; - result.Changeset.Add(metadata.Changeset - lastChangeset); - lastChangeset = metadata.Changeset; + foreach (var node in _nodesBuffer) + { + EntityMetadata metadata = node.Metadata ?? new EntityMetadata(); - long timestampValue = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); - result.Timestamp.Add(timestampValue - lastTimestamp); - lastTimestamp = timestampValue; + result.Changeset.Add(metadata.Changeset - lastChangeset); + lastChangeset = metadata.Changeset; - result.UserId.Add(metadata.Uid - lastUid); - lastUid = metadata.Uid; + long timestampValue = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); + result.Timestamp.Add(timestampValue - lastTimestamp); + lastTimestamp = timestampValue; - int userNameIndex = (int)_nodesBuffer.GetStringIndex(metadata.User); - result.UserNameIndex.Add(userNameIndex - lastUserNameIndex); - lastUserNameIndex = userNameIndex; + result.UserId.Add(metadata.Uid - lastUid); + lastUid = metadata.Uid; - result.Version.Add(metadata.Version); - result.Visible.Add(metadata.Visible); - } + int userNameIndex = (int)_nodesBuffer.GetStringIndex(metadata.User); + result.UserNameIndex.Add(userNameIndex - lastUserNameIndex); + lastUserNameIndex = userNameIndex; - return result; + result.Version.Add(metadata.Version); + result.Visible.Add(metadata.Visible); } - /// - /// Creates an PbfMetadata obejct from given Metadata. - /// - /// Metadata obejct to be used as source of data. - /// Timestamp granularity as defined in PrimitiveBlock. - /// IStrignTable object to save string values to. - /// PbfMetadata obejct with data from specified metadata object. - private PbfMetadata BuildInfo(EntityMetadata metadata, int timestampGranularity, IStringTableBuilder stringTableBuilder) - { - PbfMetadata result = new PbfMetadata(); - result.Changeset = metadata.Changeset; - result.Timestamp = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); - result.UserID = metadata.Uid; - result.UserNameIndex = (int)stringTableBuilder.GetStringIndex(metadata.User); - result.Version = metadata.Version; - - return result; - } + return result; + } + + /// + /// Creates an PbfMetadata obejct from given Metadata. + /// + /// Metadata obejct to be used as source of data. + /// Timestamp granularity as defined in PrimitiveBlock. + /// IStrignTable object to save string values to. + /// PbfMetadata obejct with data from specified metadata object. + private PbfMetadata BuildInfo(EntityMetadata metadata, int timestampGranularity, IStringTableBuilder stringTableBuilder) + { + PbfMetadata result = new PbfMetadata(); + result.Changeset = metadata.Changeset; + result.Timestamp = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); + result.UserID = metadata.Uid; + result.UserNameIndex = (int)stringTableBuilder.GetStringIndex(metadata.User); + result.Version = metadata.Version; + + return result; + } - /// - /// Releases the unmanaged resources used by the PbfWriter and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - private void Dispose(bool disposing) + /// + /// Releases the unmanaged resources used by the PbfWriter and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + private void Dispose(bool disposing) + { + if (!_disposed) { - if (!_disposed) + if (disposing) { - if (disposing) - { - this.Flush(); + this.Flush(); - if (_output != null) + if (_output != null) + { + if (_ownsOutputStream) { - if (_ownsOutputStream) - { - _output.Dispose(); - } + _output.Dispose(); } } - - _disposed = true; } + + _disposed = true; } } } diff --git a/src/SpatialLite.Osm/IO/PbfWriterSettings.cs b/src/SpatialLite.Osm/IO/PbfWriterSettings.cs index 9b35e7f..f10d235 100644 --- a/src/SpatialLite.Osm/IO/PbfWriterSettings.cs +++ b/src/SpatialLite.Osm/IO/PbfWriterSettings.cs @@ -1,64 +1,63 @@ using System; -namespace SpatialLite.Osm.IO +namespace SpatialLite.Osm.IO; + +/// +/// Contains settings that determine behaviour of the PbfWriter. +/// +public class PbfWriterSettings : OsmWriterSettings { + + private bool _useDenseFormat; + private CompressionMode _compression; + /// - /// Contains settings that determine behaviour of the PbfWriter. + /// Initializes a new instance of the PbfWriterSettings class with default values. /// - public class PbfWriterSettings : OsmWriterSettings + public PbfWriterSettings() + : base() { + this.UseDenseFormat = true; + this.Compression = CompressionMode.ZlibDeflate; + } - private bool _useDenseFormat; - private CompressionMode _compression; - - /// - /// Initializes a new instance of the PbfWriterSettings class with default values. - /// - public PbfWriterSettings() - : base() + /// + /// Gets or sets a value indicating whether PbfWriter should use dense format for serializing nodes. + /// + public bool UseDenseFormat + { + get { - this.UseDenseFormat = true; - this.Compression = CompressionMode.ZlibDeflate; + return _useDenseFormat; } - - /// - /// Gets or sets a value indicating whether PbfWriter should use dense format for serializing nodes. - /// - public bool UseDenseFormat + set { - get + if (this.IsReadOnly) { - return _useDenseFormat; + throw new InvalidOperationException("Cannot change the 'UseDenseFromat' property - PbfReaderSettings is read-only"); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'UseDenseFromat' property - PbfReaderSettings is read-only"); - } - _useDenseFormat = value; - } + _useDenseFormat = value; } + } - /// - /// Gets or sets a compression to be used by PbfWriter. - /// - public CompressionMode Compression + /// + /// Gets or sets a compression to be used by PbfWriter. + /// + public CompressionMode Compression + { + get { - get + return _compression; + } + set + { + if (this.IsReadOnly) { - return _compression; + throw new InvalidOperationException("Cannot change the 'Compression' property - PbfReaderSettings is read-only"); } - set - { - if (this.IsReadOnly) - { - throw new InvalidOperationException("Cannot change the 'Compression' property - PbfReaderSettings is read-only"); - } - _compression = value; - } + _compression = value; } } } diff --git a/src/SpatialLite.Osm/IOsmEntity.cs b/src/SpatialLite.Osm/IOsmEntity.cs index 155f051..8204710 100644 --- a/src/SpatialLite.Osm/IOsmEntity.cs +++ b/src/SpatialLite.Osm/IOsmEntity.cs @@ -1,30 +1,29 @@ -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Defines properties for all OSM entities. +/// +public interface IOsmEntity { + /// - /// Defines properties for all OSM entities. + /// Gets or sets ID of the object. /// - public interface IOsmEntity - { - - /// - /// Gets or sets ID of the object. - /// - long ID { get; set; } + long ID { get; set; } - /// - /// Gets or sets the collection of tags associated with the IOsmGeometry. - /// - TagsCollection Tags { get; set; } + /// + /// Gets or sets the collection of tags associated with the IOsmGeometry. + /// + TagsCollection Tags { get; set; } - /// - /// Gets or sets detailed information about OSM entity. - /// - EntityMetadata Metadata { get; set; } + /// + /// Gets or sets detailed information about OSM entity. + /// + EntityMetadata Metadata { get; set; } - /// - /// Gets type of the entity. - /// - EntityType EntityType { get; } + /// + /// Gets type of the entity. + /// + EntityType EntityType { get; } - } } diff --git a/src/SpatialLite.Osm/ITypedEntityCollection.cs b/src/SpatialLite.Osm/ITypedEntityCollection.cs index 31de979..0d9358b 100644 --- a/src/SpatialLite.Osm/ITypedEntityCollection.cs +++ b/src/SpatialLite.Osm/ITypedEntityCollection.cs @@ -1,32 +1,31 @@ using System.Collections.Generic; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Defines methods and properties for collection of the OSM entities of single where entities can be accessed by their ID. +/// +/// The type of the entitie in the collection. +public interface ITypedEntityCollection : ICollection where T : IOsmEntity { /// - /// Defines methods and properties for collection of the OSM entities of single where entities can be accessed by their ID. + /// Gets an entity with specific ID from the collection. /// - /// The type of the entitie in the collection. - public interface ITypedEntityCollection : ICollection where T : IOsmEntity - { - /// - /// Gets an entity with specific ID from the collection. - /// - /// The ID of the entity to get. - /// entity with the specific ID or null if such entity is not present in the collection. - T this[long id] { get; } + /// The ID of the entity to get. + /// entity with the specific ID or null if such entity is not present in the collection. + T this[long id] { get; } - /// - /// Removes an entity with the specific ID from the collection. - /// - /// The ID of the entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - bool Remove(long id); + /// + /// Removes an entity with the specific ID from the collection. + /// + /// The ID of the entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + bool Remove(long id); - /// - /// Determines whether the EntityICollection contains an entity with specific ID. - /// - /// The ID of the entity to locate in the EntityCollection. - /// true if entity is found in the collection, otherwise false. - bool Contains(long id); - } + /// + /// Determines whether the EntityICollection contains an entity with specific ID. + /// + /// The ID of the entity to locate in the EntityCollection. + /// true if entity is found in the collection, otherwise false. + bool Contains(long id); } diff --git a/src/SpatialLite.Osm/NodeInfo.cs b/src/SpatialLite.Osm/NodeInfo.cs index cac73a0..f63fa7b 100644 --- a/src/SpatialLite.Osm/NodeInfo.cs +++ b/src/SpatialLite.Osm/NodeInfo.cs @@ -2,83 +2,82 @@ using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents information about node. +/// +public class NodeInfo : IEntityInfo { + /// - /// Represents information about node. + /// Initializes a new instance of the NodeInfo class with specified ID, latitude, longitude, collection of tags and optionally EntityMetadata. /// - public class NodeInfo : IEntityInfo + /// The id of the node. + /// The latitude of the node. + /// The longitude of the node. + /// The collection of thag associated with the node. + /// The EntityMetadata structure with additinal properties. Default value is null. + public NodeInfo(long id, double latitude, double longitude, TagsCollection tags, EntityMetadata additionalInfo = null) { + this.ID = id; + this.Latitude = latitude; + this.Longitude = longitude; + this.Tags = tags; + this.Metadata = additionalInfo; + } - /// - /// Initializes a new instance of the NodeInfo class with specified ID, latitude, longitude, collection of tags and optionally EntityMetadata. - /// - /// The id of the node. - /// The latitude of the node. - /// The longitude of the node. - /// The collection of thag associated with the node. - /// The EntityMetadata structure with additinal properties. Default value is null. - public NodeInfo(long id, double latitude, double longitude, TagsCollection tags, EntityMetadata additionalInfo = null) + /// + /// Initializes a new instance of the NodeInfo class with data from Node. + /// + /// The Node obejct to take data from. + public NodeInfo(Node node) + { + if (node == null) { - this.ID = id; - this.Latitude = latitude; - this.Longitude = longitude; - this.Tags = tags; - this.Metadata = additionalInfo; + throw new ArgumentNullException(nameof(node), "Node parameter cannot be null"); } - /// - /// Initializes a new instance of the NodeInfo class with data from Node. - /// - /// The Node obejct to take data from. - public NodeInfo(Node node) - { - if (node == null) - { - throw new ArgumentNullException(nameof(node), "Node parameter cannot be null"); - } - - this.ID = node.ID; - this.Longitude = node.Position.X; - this.Latitude = node.Position.Y; - this.Tags = node.Tags; - this.Metadata = node.Metadata; - } + this.ID = node.ID; + this.Longitude = node.Position.X; + this.Latitude = node.Position.Y; + this.Tags = node.Tags; + this.Metadata = node.Metadata; + } - /// - /// Gets type of the object that is represented by this IOsmGeometryInfo. - /// - public EntityType EntityType + /// + /// Gets type of the object that is represented by this IOsmGeometryInfo. + /// + public EntityType EntityType + { + get { - get - { - return EntityType.Node; - } + return EntityType.Node; } + } - /// - /// Gets ID of the object. - /// - public long ID { get; set; } + /// + /// Gets ID of the object. + /// + public long ID { get; set; } - /// - /// Gets the collection of tags associated with this node. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets the collection of tags associated with this node. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets the latitude of the node. - /// - public double Latitude { get; set; } + /// + /// Gets the latitude of the node. + /// + public double Latitude { get; set; } - /// - /// Gets the longitude of the node. - /// - public double Longitude { get; set; } + /// + /// Gets the longitude of the node. + /// + public double Longitude { get; set; } - /// - /// Gets or sets metadata of this Node. - /// - public EntityMetadata Metadata { get; set; } - } + /// + /// Gets or sets metadata of this Node. + /// + public EntityMetadata Metadata { get; set; } } diff --git a/src/SpatialLite.Osm/OsmDatabase.cs b/src/SpatialLite.Osm/OsmDatabase.cs index 293394c..c2f3959 100644 --- a/src/SpatialLite.Osm/OsmDatabase.cs +++ b/src/SpatialLite.Osm/OsmDatabase.cs @@ -2,265 +2,264 @@ using System.Collections.Generic; using SpatialLite.Osm.IO; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents in-memory database of OSM entities. +/// +/// Generic type that relresents all nodes, ways and relations +/// The type of Nodes +/// The type of Ways +/// The type of Relations +public class OsmDatabase : IEntityCollection where T : IOsmEntity where N : T where W : T where R : T { + /// - /// Represents in-memory database of OSM entities. + /// Initializes a new instance of the OsmDatabase class that is empty. /// - /// Generic type that relresents all nodes, ways and relations - /// The type of Nodes - /// The type of Ways - /// The type of Relations - public class OsmDatabase : IEntityCollection where T : IOsmEntity where N : T where W : T where R : T + internal OsmDatabase() { + this.Nodes = new EntityCollection(); + this.Ways = new EntityCollection(); + this.Relations = new EntityCollection(); + } - /// - /// Initializes a new instance of the OsmDatabase class that is empty. - /// - internal OsmDatabase() + /// + /// Initializes a new instance of the OsmDatabase class with specific entities. + /// + /// Entities to add to the database. + internal OsmDatabase(IEnumerable entities) + : this() + { + foreach (var entity in entities) { - this.Nodes = new EntityCollection(); - this.Ways = new EntityCollection(); - this.Relations = new EntityCollection(); + this.Add(entity); } + } - /// - /// Initializes a new instance of the OsmDatabase class with specific entities. - /// - /// Entities to add to the database. - internal OsmDatabase(IEnumerable entities) - : this() - { - foreach (var entity in entities) - { - this.Add(entity); - } - } + /// + /// Gets collection of nodes in the database. + /// + public ITypedEntityCollection Nodes { get; private set; } - /// - /// Gets collection of nodes in the database. - /// - public ITypedEntityCollection Nodes { get; private set; } - - /// - /// Gets collection of ways in the database. - /// - public ITypedEntityCollection Ways { get; private set; } - - /// - /// Gets collection of relations in the database. - /// - public ITypedEntityCollection Relations { get; private set; } - - /// - /// Gets the number of entities in the collection. - /// - public int Count - { - get - { - return this.Nodes.Count + this.Ways.Count + this.Relations.Count; - } - } + /// + /// Gets collection of ways in the database. + /// + public ITypedEntityCollection Ways { get; private set; } - /// - /// Gets a value indicating whether the collection is read-only. - /// - public bool IsReadOnly - { - get - { - return false; - } - } + /// + /// Gets collection of relations in the database. + /// + public ITypedEntityCollection Relations { get; private set; } - /// - /// Gets an entity with specific ID from the collection. - /// - /// The ID of the entity to get. - /// The type of the entity to get. - /// entity with the specific ID or null if such entity is not present in the collection. - public T this[long id, EntityType type] + /// + /// Gets the number of entities in the collection. + /// + public int Count + { + get { - get - { - if (type == EntityType.Node && this.Nodes.Contains(id)) - { - return (T)this.Nodes[id]; - } - - if (type == EntityType.Way && this.Ways.Contains(id)) - { - return (T)this.Ways[id]; - } - - if (type == EntityType.Relation && this.Relations.Contains(id)) - { - return (T)this.Relations[id]; - } - - return default(T); - } + return this.Nodes.Count + this.Ways.Count + this.Relations.Count; } + } - /// - /// When overridden in derived class, saves entities from the database to specific writer. - /// - /// IOsmWriter to save entities to. - public virtual void Save(IOsmWriter writer) + /// + /// Gets a value indicating whether the collection is read-only. + /// + public bool IsReadOnly + { + get { + return false; } + } - /// - /// Removes an entity with the specific ID from the collection. - /// - /// The ID of the entity to remove from the collection. - /// The type of the entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(long id, EntityType type) + /// + /// Gets an entity with specific ID from the collection. + /// + /// The ID of the entity to get. + /// The type of the entity to get. + /// entity with the specific ID or null if such entity is not present in the collection. + public T this[long id, EntityType type] + { + get { - if (this.Nodes.Contains(id)) + if (type == EntityType.Node && this.Nodes.Contains(id)) { - return this.Nodes.Remove(id); + return (T)this.Nodes[id]; } - if (this.Ways.Contains(id)) + if (type == EntityType.Way && this.Ways.Contains(id)) { - return this.Ways.Remove(id); + return (T)this.Ways[id]; } - if (this.Relations.Contains(id)) + if (type == EntityType.Relation && this.Relations.Contains(id)) { - return this.Relations.Remove(id); + return (T)this.Relations[id]; } - return false; + return default(T); } + } + + /// + /// When overridden in derived class, saves entities from the database to specific writer. + /// + /// IOsmWriter to save entities to. + public virtual void Save(IOsmWriter writer) + { + } - /// - /// Determines whether the EntityICollection contains an entity with specific ID. - /// - /// The ID of the entity to locate in the EntityCollection. - /// The type of the entity to locate in the EntityCollection - /// true if entity is found in the collection, otherwise false. - public bool Contains(long id, EntityType type) + /// + /// Removes an entity with the specific ID from the collection. + /// + /// The ID of the entity to remove from the collection. + /// The type of the entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(long id, EntityType type) + { + if (this.Nodes.Contains(id)) { - switch (type) - { - case EntityType.Node: return this.Nodes.Contains(id); - case EntityType.Way: return this.Ways.Contains(id); - case EntityType.Relation: return this.Relations.Contains(id); - } + return this.Nodes.Remove(id); + } - throw new NotImplementedException(); + if (this.Ways.Contains(id)) + { + return this.Ways.Remove(id); } - /// - /// Adds specified entity to the collection. - /// - /// The entity to add to the collection. - public void Add(T entity) + if (this.Relations.Contains(id)) { - if (entity == null) - { - throw new ArgumentNullException(nameof(entity), "Cannot add null to EntityCollection"); - } + return this.Relations.Remove(id); + } - if (this.Contains(entity.ID, entity.EntityType)) - { - throw new ArgumentException("An entity with the same ID has already been added."); - } + return false; + } - switch (entity.EntityType) - { - case EntityType.Node: this.Nodes.Add((N)entity); break; - case EntityType.Way: this.Ways.Add((W)entity); break; - case EntityType.Relation: this.Relations.Add((R)entity); break; - } + /// + /// Determines whether the EntityICollection contains an entity with specific ID. + /// + /// The ID of the entity to locate in the EntityCollection. + /// The type of the entity to locate in the EntityCollection + /// true if entity is found in the collection, otherwise false. + public bool Contains(long id, EntityType type) + { + switch (type) + { + case EntityType.Node: return this.Nodes.Contains(id); + case EntityType.Way: return this.Ways.Contains(id); + case EntityType.Relation: return this.Relations.Contains(id); } - /// - /// Removes all entities form the collection. - /// - public void Clear() + throw new NotImplementedException(); + } + + /// + /// Adds specified entity to the collection. + /// + /// The entity to add to the collection. + public void Add(T entity) + { + if (entity == null) { - this.Nodes.Clear(); - this.Ways.Clear(); - this.Relations.Clear(); + throw new ArgumentNullException(nameof(entity), "Cannot add null to EntityCollection"); } - /// - /// Determines whether the EntityICollection contains a specific entity. - /// - /// The entity to locate in the EntityCollection. - /// true if entity is found in the collection, otherwise false. - public bool Contains(T item) + if (this.Contains(entity.ID, entity.EntityType)) { - if (item == null) - { - return false; - } - - return this.Contains(item.ID, item.EntityType); + throw new ArgumentException("An entity with the same ID has already been added."); } - /// - /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. - /// The zero-based index in array at which copying begins. - public void CopyTo(T[] array, int arrayIndex) + switch (entity.EntityType) { - foreach (var entity in this) - { - array[arrayIndex++] = entity; - } + case EntityType.Node: this.Nodes.Add((N)entity); break; + case EntityType.Way: this.Ways.Add((W)entity); break; + case EntityType.Relation: this.Relations.Add((R)entity); break; } + } + + /// + /// Removes all entities form the collection. + /// + public void Clear() + { + this.Nodes.Clear(); + this.Ways.Clear(); + this.Relations.Clear(); + } - /// - /// Removes the specific entity from the collection. - /// - /// The entity to remove from the collection. - /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. - public bool Remove(T entity) + /// + /// Determines whether the EntityICollection contains a specific entity. + /// + /// The entity to locate in the EntityCollection. + /// true if entity is found in the collection, otherwise false. + public bool Contains(T item) + { + if (item == null) { - if (entity == null) - { - return false; - } + return false; + } + + return this.Contains(item.ID, item.EntityType); + } - return this.Remove(entity.ID, entity.EntityType); + /// + /// Copies the entire EntityCollection to a compatible one-dimensional Array, starting at the specified index of the target array. + /// + /// The one-dimensional Array that is the destination of the elements copied from EntityCollection. + /// The zero-based index in array at which copying begins. + public void CopyTo(T[] array, int arrayIndex) + { + foreach (var entity in this) + { + array[arrayIndex++] = entity; } + } - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator<T> that can be used to iterate through the collection. - public IEnumerator GetEnumerator() + /// + /// Removes the specific entity from the collection. + /// + /// The entity to remove from the collection. + /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. + public bool Remove(T entity) + { + if (entity == null) { - foreach (var node in this.Nodes) - { - yield return node; - } + return false; + } - foreach (var way in this.Ways) - { - yield return way; - } + return this.Remove(entity.ID, entity.EntityType); + } - foreach (var relation in this.Relations) - { - yield return relation; - } + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator<T> that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + foreach (var node in this.Nodes) + { + yield return node; + } + + foreach (var way in this.Ways) + { + yield return way; } - /// - /// Returns an enumerator that iterates through a collection. - /// - /// A IEnumerator that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + foreach (var relation in this.Relations) { - return this.GetEnumerator(); + yield return relation; } } + + /// + /// Returns an enumerator that iterates through a collection. + /// + /// A IEnumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } } diff --git a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs index c08d158..17bbff0 100644 --- a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs +++ b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs @@ -2,64 +2,63 @@ using SpatialLite.Osm.IO; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents in-memory OSM entities database that contains entities as IEntityInfo objects. +/// +public class OsmEntityInfoDatabase : OsmDatabase { + /// - /// Represents in-memory OSM entities database that contains entities as IEntityInfo objects. + /// Initializes a new instance of the OsmEntityInfoDatabase class that is empty. /// - public class OsmEntityInfoDatabase : OsmDatabase + public OsmEntityInfoDatabase() + : base() { + } - /// - /// Initializes a new instance of the OsmEntityInfoDatabase class that is empty. - /// - public OsmEntityInfoDatabase() - : base() - { - } + /// + /// Initializes a new instance of the OsmEntityInfoDatabase class with specific entities. + /// + /// Entities to add to the database. + public OsmEntityInfoDatabase(IEnumerable entities) + : base(entities) + { + } - /// - /// Initializes a new instance of the OsmEntityInfoDatabase class with specific entities. - /// - /// Entities to add to the database. - public OsmEntityInfoDatabase(IEnumerable entities) - : base(entities) - { - } + /// + /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. + /// + /// The IOsmReader to read data from. + /// New instance of the OsmDAtabase class with data loaded from specified reader. + public static OsmEntityInfoDatabase Load(IOsmReader reader) + { + OsmEntityInfoDatabase db = new OsmEntityInfoDatabase(); - /// - /// Creates a new instaance of the OsmDatabase class and loads data from specific IOsmReader into it. - /// - /// The IOsmReader to read data from. - /// New instance of the OsmDAtabase class with data loaded from specified reader. - public static OsmEntityInfoDatabase Load(IOsmReader reader) + IEntityInfo entityInfo = null; + while ((entityInfo = reader.Read()) != null) { - OsmEntityInfoDatabase db = new OsmEntityInfoDatabase(); - - IEntityInfo entityInfo = null; - while ((entityInfo = reader.Read()) != null) + switch (entityInfo.EntityType) { - switch (entityInfo.EntityType) - { - case EntityType.Node: db.Nodes.Add((NodeInfo)entityInfo); break; - case EntityType.Way: db.Ways.Add((WayInfo)entityInfo); break; - case EntityType.Relation: db.Relations.Add((RelationInfo)entityInfo); break; - } + case EntityType.Node: db.Nodes.Add((NodeInfo)entityInfo); break; + case EntityType.Way: db.Ways.Add((WayInfo)entityInfo); break; + case EntityType.Relation: db.Relations.Add((RelationInfo)entityInfo); break; } - - return db; } - /// - /// Saves entities from the database to specific writer. - /// - /// IOsmWriter to save entities to. - public override void Save(IOsmWriter writer) + return db; + } + + /// + /// Saves entities from the database to specific writer. + /// + /// IOsmWriter to save entities to. + public override void Save(IOsmWriter writer) + { + foreach (var entity in this) { - foreach (var entity in this) - { - writer.Write(entity); - } + writer.Write(entity); } } } diff --git a/src/SpatialLite.Osm/RelationInfo.cs b/src/SpatialLite.Osm/RelationInfo.cs index 89f9ec0..8e49667 100644 --- a/src/SpatialLite.Osm/RelationInfo.cs +++ b/src/SpatialLite.Osm/RelationInfo.cs @@ -2,80 +2,79 @@ using System.Collections.Generic; using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents information about relation. +/// +public class RelationInfo : IEntityInfo { + /// - /// Represents information about relation. + /// Initializes a new instance of the RelationInfo class with specified ID, Tags, Member and optionally EntityMetadata. /// - public class RelationInfo : IEntityInfo + /// The id of the relation. + /// The collection of tags associated with the relation. + /// The members of the relation. + /// The EntityMetadata structure with additinal properties. Default value is null. + public RelationInfo(long id, TagsCollection tags, IList members, EntityMetadata additionalInfo = null) { + this.ID = id; + this.Tags = tags; + this.Members = members; + this.Metadata = additionalInfo; + } - /// - /// Initializes a new instance of the RelationInfo class with specified ID, Tags, Member and optionally EntityMetadata. - /// - /// The id of the relation. - /// The collection of tags associated with the relation. - /// The members of the relation. - /// The EntityMetadata structure with additinal properties. Default value is null. - public RelationInfo(long id, TagsCollection tags, IList members, EntityMetadata additionalInfo = null) + /// + /// Initializes a new instance of the RelationInfo class with data from specific Relation. + /// + /// The Relation object to copy data from. + public RelationInfo(Relation source) + { + if (source == null) { - this.ID = id; - this.Tags = tags; - this.Members = members; - this.Metadata = additionalInfo; + throw new ArgumentNullException(nameof(source), "Source relation cannot be null"); } - /// - /// Initializes a new instance of the RelationInfo class with data from specific Relation. - /// - /// The Relation object to copy data from. - public RelationInfo(Relation source) - { - if (source == null) - { - throw new ArgumentNullException(nameof(source), "Source relation cannot be null"); - } - - this.ID = source.ID; - this.Tags = source.Tags; - this.Metadata = source.Metadata; + this.ID = source.ID; + this.Tags = source.Tags; + this.Metadata = source.Metadata; - this.Members = new List(source.Geometries.Count); - foreach (var member in source.Geometries) - { - this.Members.Add(new RelationMemberInfo(member)); - } + this.Members = new List(source.Geometries.Count); + foreach (var member in source.Geometries) + { + this.Members.Add(new RelationMemberInfo(member)); } + } - /// - /// Gets type of the object that is represented by this IOsmGeometryInfo. - /// - public EntityType EntityType + /// + /// Gets type of the object that is represented by this IOsmGeometryInfo. + /// + public EntityType EntityType + { + get { - get - { - return EntityType.Relation; - } + return EntityType.Relation; } + } - /// - /// Gets ID of the relation. - /// - public long ID { get; set; } + /// + /// Gets ID of the relation. + /// + public long ID { get; set; } - /// - /// Gets the collection of tags associated with the relation. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets the collection of tags associated with the relation. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets list of members of the relation. - /// - public IList Members { get; set; } + /// + /// Gets list of members of the relation. + /// + public IList Members { get; set; } - /// - /// Gets additional information about this RelationInfo. - /// - public EntityMetadata Metadata { get; set; } - } + /// + /// Gets additional information about this RelationInfo. + /// + public EntityMetadata Metadata { get; set; } } diff --git a/src/SpatialLite.Osm/RelationMemberInfo.cs b/src/SpatialLite.Osm/RelationMemberInfo.cs index c4e818b..db5593c 100644 --- a/src/SpatialLite.Osm/RelationMemberInfo.cs +++ b/src/SpatialLite.Osm/RelationMemberInfo.cs @@ -1,38 +1,37 @@ using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents information about relation member. +/// +public struct RelationMemberInfo { + /// - /// Represents information about relation member. + /// The type of the member (node, way, relation) /// - public struct RelationMemberInfo - { - - /// - /// The type of the member (node, way, relation) - /// - public EntityType MemberType; + public EntityType MemberType; - /// - /// The role of the member in relation - /// - public string Role; - - /// - /// The ID of the member entity - /// - public long Reference; + /// + /// The role of the member in relation + /// + public string Role; - /// - /// Initializes a new instance of the RelationMemberInfo structure with values from specific RelationMember. - /// - /// The RelationMember object to copy valyes from. - public RelationMemberInfo(RelationMember source) - { - this.Reference = source.Member.ID; - this.MemberType = source.MemberType; - this.Role = source.Role; - } + /// + /// The ID of the member entity + /// + public long Reference; + /// + /// Initializes a new instance of the RelationMemberInfo structure with values from specific RelationMember. + /// + /// The RelationMember object to copy valyes from. + public RelationMemberInfo(RelationMember source) + { + this.Reference = source.Member.ID; + this.MemberType = source.MemberType; + this.Role = source.Role; } + } diff --git a/src/SpatialLite.Osm/Tag.cs b/src/SpatialLite.Osm/Tag.cs index 47c185c..9a1c7a8 100644 --- a/src/SpatialLite.Osm/Tag.cs +++ b/src/SpatialLite.Osm/Tag.cs @@ -1,109 +1,108 @@ using System; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents OSM tag and it's value. +/// +public class Tag { + + private string _key; + private string _value; + /// - /// Represents OSM tag and it's value. + /// Initializes a new instance of the Tag class with specified key and value. /// - public class Tag + /// The key of the Tag. + /// The value of the Tag. + public Tag(string key, string value) { + if (key == null) + { + throw new ArgumentNullException("Parameter 'key' can't be null."); + } - private string _key; - private string _value; - - /// - /// Initializes a new instance of the Tag class with specified key and value. - /// - /// The key of the Tag. - /// The value of the Tag. - public Tag(string key, string value) + if (key == string.Empty) { - if (key == null) - { - throw new ArgumentNullException("Parameter 'key' can't be null."); - } + throw new ArgumentException("Parameter 'key' can't be empty string."); + } - if (key == string.Empty) - { - throw new ArgumentException("Parameter 'key' can't be empty string."); - } + if (value == null) + { + throw new ArgumentNullException("Parameter 'value' can't be null."); + } - if (value == null) - { - throw new ArgumentNullException("Parameter 'value' can't be null."); - } + _key = key; + _value = value; + } - _key = key; - _value = value; + /// + /// Gets the key of the tag. + /// + public string Key + { + get + { + return _key; } + } - /// - /// Gets the key of the tag. - /// - public string Key + /// + /// Gets the value of the tag. + /// + public string Value + { + get { - get - { - return _key; - } + return _value; } + } - /// - /// Gets the value of the tag. - /// - public string Value + /// + /// Compares the current Tag object with the specified object for equivalence. + /// + /// The object to test for equivalence with the current Tag object. + /// true if the objects are equal, otherwise returns false. + public override bool Equals(object obj) + { + if (obj == null) { - get - { - return _value; - } + return false; } - /// - /// Compares the current Tag object with the specified object for equivalence. - /// - /// The object to test for equivalence with the current Tag object. - /// true if the objects are equal, otherwise returns false. - public override bool Equals(object obj) + Tag other = obj as Tag; + if (other != null) { - if (obj == null) - { - return false; - } - - Tag other = obj as Tag; - if (other != null) - { - return Equals(other); - } - else - { - return false; - } + return Equals(other); } - - /// - /// Compares the current Tag object with the specified Tag. - /// - /// The Tag to test for equivalence with the current Tag object. - /// true if the objects are equal, otherwise returns false. - public bool Equals(Tag other) + else { - if (other == null) - { - return false; - } - - return _key.Equals(other._key) && _value.Equals(other._value); + return false; } + } - /// - /// Returns the hash code for the current object. - /// - /// An integer hash code. - public override int GetHashCode() + /// + /// Compares the current Tag object with the specified Tag. + /// + /// The Tag to test for equivalence with the current Tag object. + /// true if the objects are equal, otherwise returns false. + public bool Equals(Tag other) + { + if (other == null) { - return unchecked(_key.GetHashCode() * 83 + _value.GetHashCode()); + return false; } + + return _key.Equals(other._key) && _value.Equals(other._value); + } + + /// + /// Returns the hash code for the current object. + /// + /// An integer hash code. + public override int GetHashCode() + { + return unchecked(_key.GetHashCode() * 83 + _value.GetHashCode()); } } diff --git a/src/SpatialLite.Osm/TagsCollection.cs b/src/SpatialLite.Osm/TagsCollection.cs index f7e9eb6..feb34bc 100644 --- a/src/SpatialLite.Osm/TagsCollection.cs +++ b/src/SpatialLite.Osm/TagsCollection.cs @@ -2,265 +2,264 @@ using System.Collections.Generic; using System.Linq; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents collection of Tags that are accesible by their key. +/// +public class TagsCollection : ICollection { + + private List _tags; + /// - /// Represents collection of Tags that are accesible by their key. + /// Initializes a new instance of the TagsCollection class. /// - public class TagsCollection : ICollection + public TagsCollection() { + } - private List _tags; + /// + /// Initializes a new instance of the TagsCollection class with specified tags. + /// + /// Collection of tags. + public TagsCollection(IEnumerable tags) + { + _tags = new List(tags.Count()); - /// - /// Initializes a new instance of the TagsCollection class. - /// - public TagsCollection() + foreach (var tag in tags) { + this.Add(tag); } + } - /// - /// Initializes a new instance of the TagsCollection class with specified tags. - /// - /// Collection of tags. - public TagsCollection(IEnumerable tags) + /// + /// Gets the number of Tags in the TagsCollection. + /// + public int Count + { + get { - _tags = new List(tags.Count()); - - foreach (var tag in tags) + if (_tags == null) { - this.Add(tag); + return 0; } - } - - /// - /// Gets the number of Tags in the TagsCollection. - /// - public int Count - { - get + else { - if (_tags == null) - { - return 0; - } - else - { - return _tags.Count; - } + return _tags.Count; } } + } - /// - /// Gets a value indicating whether the TagsCollection is read-only. - /// - public bool IsReadOnly + /// + /// Gets a value indicating whether the TagsCollection is read-only. + /// + public bool IsReadOnly + { + get { return false; } + } + + /// + /// Gets or sets value of the Tag with given key. + /// + /// The string key of Tag. + /// The value of the Tag or null if Tag isn't found. + public string this[string key] + { + get { - get { return false; } + Tag tag = this.GetTag(key); + return tag.Value; } - - /// - /// Gets or sets value of the Tag with given key. - /// - /// The string key of Tag. - /// The value of the Tag or null if Tag isn't found. - public string this[string key] + set { - get + if (this.Contains(key)) { - Tag tag = this.GetTag(key); - return tag.Value; + this.Remove(key); + this.Add(new Tag(key, value)); } - set + else { - if (this.Contains(key)) - { - this.Remove(key); - this.Add(new Tag(key, value)); - } - else - { - this.Add(new Tag(key, value)); - } + this.Add(new Tag(key, value)); } } + } - /// - /// Adds Tag to the TagsCollection. - /// - /// The Tag to add to the TagsCollection. - public void Add(Tag tag) + /// + /// Adds Tag to the TagsCollection. + /// + /// The Tag to add to the TagsCollection. + public void Add(Tag tag) + { + if (_tags == null) { - if (_tags == null) - { - _tags = new List(); - } - - if (this.Contains(tag.Key)) - { - throw new ArgumentException(string.Format("Tag with key '{0}' is already present in the collection.", tag.Key)); - } - - _tags.Add(tag); + _tags = new List(); } - /// - /// Removes all items from the TagsCollection. - /// - public void Clear() + if (this.Contains(tag.Key)) { - if (_tags != null) - { - _tags.Clear(); - } + throw new ArgumentException(string.Format("Tag with key '{0}' is already present in the collection.", tag.Key)); } - /// - /// Determines whether the TagsCollection contains a specific value. - /// - /// The Tag to locate in the TagsCollection. - /// true if item is found in the TagsCollection; otherwise, false. - public bool Contains(Tag item) - { - if (_tags == null) - { - return false; - } + _tags.Add(tag); + } - return _tags.Contains(item); + /// + /// Removes all items from the TagsCollection. + /// + public void Clear() + { + if (_tags != null) + { + _tags.Clear(); } + } - /// - /// Determines whether the TagsCollection contains a Tag with specified key. - /// - /// The key of a Tag to locate in the TagsCollection. - /// true if item is found in the TagsCollection; otherwise, false. - public bool Contains(string key) + /// + /// Determines whether the TagsCollection contains a specific value. + /// + /// The Tag to locate in the TagsCollection. + /// true if item is found in the TagsCollection; otherwise, false. + public bool Contains(Tag item) + { + if (_tags == null) { - if (_tags == null) - { - return false; - } + return false; + } - for (int i = 0; i < _tags.Count; i++) - { - if (_tags[i].Key == key) - { - return true; - } - } + return _tags.Contains(item); + } + /// + /// Determines whether the TagsCollection contains a Tag with specified key. + /// + /// The key of a Tag to locate in the TagsCollection. + /// true if item is found in the TagsCollection; otherwise, false. + public bool Contains(string key) + { + if (_tags == null) + { return false; } - /// - /// opies the entire TagCollection to a compatible one-dimensional Array, starting at the specified index of the target array. - /// - /// The one-dimensional Array that is the destination of the elements copied from TagCollection. - /// The zero-based index in array at which copying begins. - public void CopyTo(Tag[] array, int arrayIndex) + for (int i = 0; i < _tags.Count; i++) { - if (_tags != null) + if (_tags[i].Key == key) { - _tags.CopyTo(array, arrayIndex); + return true; } } - /// - /// Gets Tag with the specified key from the collection. - /// - /// The key of the Tag. - /// Tag with specified Key or null, if the Tag is not found in the TagsCollection. - public Tag GetTag(string key) - { - if (_tags == null) - { - throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); - } + return false; + } - for (int i = 0; i < _tags.Count; i++) - { - if (_tags[i].Key == key) - { - return _tags[i]; - } - } + /// + /// opies the entire TagCollection to a compatible one-dimensional Array, starting at the specified index of the target array. + /// + /// The one-dimensional Array that is the destination of the elements copied from TagCollection. + /// The zero-based index in array at which copying begins. + public void CopyTo(Tag[] array, int arrayIndex) + { + if (_tags != null) + { + _tags.CopyTo(array, arrayIndex); + } + } + /// + /// Gets Tag with the specified key from the collection. + /// + /// The key of the Tag. + /// Tag with specified Key or null, if the Tag is not found in the TagsCollection. + public Tag GetTag(string key) + { + if (_tags == null) + { throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); } - /// - /// Removes the specific Tag from the TagsCollection. - /// - /// The Tag to remove from the TagsCollection. - /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. - public bool Remove(Tag item) + for (int i = 0; i < _tags.Count; i++) { - if (_tags == null) + if (_tags[i].Key == key) { - return false; + return _tags[i]; } - - return _tags.Remove(item); } - /// - /// Removes the Tag with specified key from the TagsCollection. - /// - /// The Key of the Tag to remove from the TagsCollection. - /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. - public bool Remove(string key) + throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); + } + + /// + /// Removes the specific Tag from the TagsCollection. + /// + /// The Tag to remove from the TagsCollection. + /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. + public bool Remove(Tag item) + { + if (_tags == null) { - if (this.Contains(key)) - { - Tag tag = this.GetTag(key); - return this.Remove(tag); - } - else - { - return false; - } + return false; } - /// - /// Returns an generic enumerator that iterates through a collection. - /// - /// An generic IEnumerator object that can be used to iterate through the collection. - public IEnumerator GetEnumerator() + return _tags.Remove(item); + } + + /// + /// Removes the Tag with specified key from the TagsCollection. + /// + /// The Key of the Tag to remove from the TagsCollection. + /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. + public bool Remove(string key) + { + if (this.Contains(key)) { - if (_tags == null) - { - return this.GetEmptyEnumerator(); - } - else - { - return _tags.GetEnumerator(); - } + Tag tag = this.GetTag(key); + return this.Remove(tag); } + else + { + return false; + } + } - /// - /// Returns an enumerator that iterates through a collection. - /// - /// An IEnumerator object that can be used to iterate through the collection. - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + /// + /// Returns an generic enumerator that iterates through a collection. + /// + /// An generic IEnumerator object that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + if (_tags == null) { - if (_tags == null) - { - return this.GetEmptyEnumerator(); - } - else - { - return _tags.GetEnumerator(); - } + return this.GetEmptyEnumerator(); + } + else + { + return _tags.GetEnumerator(); } + } - /// - /// Returns Enumerator for empty collection. - /// - /// Enumerator that returns no items. - private IEnumerator GetEmptyEnumerator() + /// + /// Returns an enumerator that iterates through a collection. + /// + /// An IEnumerator object that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + if (_tags == null) + { + return this.GetEmptyEnumerator(); + } + else { - yield break; + return _tags.GetEnumerator(); } } + + /// + /// Returns Enumerator for empty collection. + /// + /// Enumerator that returns no items. + private IEnumerator GetEmptyEnumerator() + { + yield break; + } } diff --git a/src/SpatialLite.Osm/WayInfo.cs b/src/SpatialLite.Osm/WayInfo.cs index 375cc7d..680b0a3 100644 --- a/src/SpatialLite.Osm/WayInfo.cs +++ b/src/SpatialLite.Osm/WayInfo.cs @@ -3,83 +3,82 @@ using SpatialLite.Osm.Geometries; -namespace SpatialLite.Osm +namespace SpatialLite.Osm; + +/// +/// Represents information about way. +/// +/// +/// Nodes are represented with their id's only. +/// +public class WayInfo : IEntityInfo { + /// - /// Represents information about way. + /// Initializes a new instance of the WayInfo class with specified ID, Nodes, collection of tags and optionaly EntityMetadata. /// - /// - /// Nodes are represented with their id's only. - /// - public class WayInfo : IEntityInfo + /// The Id of the way. + /// The collection of tags associated with the way. + /// The nodes of the way. + /// The EntityMetadata structure with additinal properties. Default value is null. + public WayInfo(long id, TagsCollection tags, IList nodes, EntityMetadata additionalInfo = null) { + this.ID = id; + this.Tags = tags; + this.Nodes = nodes; + this.Metadata = additionalInfo; + } - /// - /// Initializes a new instance of the WayInfo class with specified ID, Nodes, collection of tags and optionaly EntityMetadata. - /// - /// The Id of the way. - /// The collection of tags associated with the way. - /// The nodes of the way. - /// The EntityMetadata structure with additinal properties. Default value is null. - public WayInfo(long id, TagsCollection tags, IList nodes, EntityMetadata additionalInfo = null) - { - this.ID = id; - this.Tags = tags; - this.Nodes = nodes; - this.Metadata = additionalInfo; - } - - /// - /// Initializes a new instance of the WayInfo class with data from specific Way - /// - /// The way to get data from + /// + /// Initializes a new instance of the WayInfo class with data from specific Way + /// + /// The way to get data from public WayInfo(Way way) + { + if (way == null) { - if (way == null) - { - throw new ArgumentNullException(nameof(way), "Way parameter cannot be null"); - } + throw new ArgumentNullException(nameof(way), "Way parameter cannot be null"); + } - this.ID = way.ID; - this.Tags = way.Tags; - this.Metadata = way.Metadata; + this.ID = way.ID; + this.Tags = way.Tags; + this.Metadata = way.Metadata; - this.Nodes = new List(way.Nodes.Count); - foreach (var node in way.Nodes) - { - this.Nodes.Add(node.ID); - } + this.Nodes = new List(way.Nodes.Count); + foreach (var node in way.Nodes) + { + this.Nodes.Add(node.ID); } + } - /// - /// Gets type of the object that is represented by this WayInfo. - /// - public EntityType EntityType + /// + /// Gets type of the object that is represented by this WayInfo. + /// + public EntityType EntityType + { + get { - get - { - return EntityType.Way; - } + return EntityType.Way; } + } - /// - /// Gets ID of the object. - /// - public long ID { get; set; } + /// + /// Gets ID of the object. + /// + public long ID { get; set; } - /// - /// Gets the collection of tags associated with this WayInfo. - /// - public TagsCollection Tags { get; set; } + /// + /// Gets the collection of tags associated with this WayInfo. + /// + public TagsCollection Tags { get; set; } - /// - /// Gets the list of id's of this way nodes. - /// - public IList Nodes { get; private set; } + /// + /// Gets the list of id's of this way nodes. + /// + public IList Nodes { get; private set; } - /// - /// Gets additional information about this IOsmGeometryInfo. - /// - public EntityMetadata Metadata { get; set; } - } + /// + /// Gets additional information about this IOsmGeometryInfo. + /// + public EntityMetadata Metadata { get; set; } } diff --git a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs index 1a8a68b..9b0eb3e 100644 --- a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs +++ b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs @@ -8,213 +8,212 @@ using SpatialLite.Core.API; -namespace Tests.SpatialLite.Core.API +namespace Tests.SpatialLite.Core.API; + +public class CoordinateTests { - public class CoordinateTests - { - double xCoordinate = 3.5; - double yCoordinate = 4.2; - double zCoordinate = 10.5; - double mValue = 100.4; - - [Fact] - public void Constructor_XY_SetsXYValuesAndZMNaN() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); - - Assert.Equal(xCoordinate, target.X); - Assert.Equal(yCoordinate, target.Y); - Assert.Equal(double.NaN, target.Z); - Assert.Equal(double.NaN, target.M); - } - - [Fact] - public void Constructor_XYZ_SetsXYZValuesAndMNaN() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); - - Assert.Equal(xCoordinate, target.X); - Assert.Equal(yCoordinate, target.Y); - Assert.Equal(zCoordinate, target.Z); - Assert.Equal(double.NaN, target.M); - } - - [Fact] - public void Constructor_XYZM_SetsXYZMValues() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.Equal(xCoordinate, target.X); - Assert.Equal(yCoordinate, target.Y); - Assert.Equal(zCoordinate, target.Z); - Assert.Equal(mValue, target.M); - } - - [Fact] - public void Is3D_ReturnsFalseForNaNZCoordinate() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); - - Assert.False(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsTrueFor3D() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); - - Assert.True(target.Is3D); - } - - [Fact] - public void IsMeasured_ReturnsFalseForNaNMCoordinate() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredCoordinate() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target.IsMeasured); - } - - [Fact] - public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsTrueForNaNCoordinates() - { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.True(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForNull() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - object other = null; - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForOtherObjectType() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - object other = "string"; - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target.Equals2D(other)); - } - - [Fact] - public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); - - Assert.True(target.Equals2D(other)); - } - - [Fact] - public void Equals2D_ReturnsTrueForNaNCoordinates() - { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.True(target.Equals2D(other)); - } - - [Fact] - public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); - - Assert.False(target.Equals2D(other)); - } - - [Fact] - public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.True(target == other); - } - - [Fact] - public void EqualsOperator_ReturnsTrueForNaNCoordinates() - { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.True(target == other); - } - - [Fact] - public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); - - Assert.False(target == other); - } - - [Fact] - public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - - Assert.False(target != other); - } - - [Fact] - public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() - { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - - Assert.False(target != other); - } - - [Fact] - public void NotEqualsOperator_ReturnsTrueForCoordinateWithDifferentOrdinates() - { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); - - Assert.True(target != other); - } + double xCoordinate = 3.5; + double yCoordinate = 4.2; + double zCoordinate = 10.5; + double mValue = 100.4; + + [Fact] + public void Constructor_XY_SetsXYValuesAndZMNaN() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate); + + Assert.Equal(xCoordinate, target.X); + Assert.Equal(yCoordinate, target.Y); + Assert.Equal(double.NaN, target.Z); + Assert.Equal(double.NaN, target.M); + } + + [Fact] + public void Constructor_XYZ_SetsXYZValuesAndMNaN() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); + + Assert.Equal(xCoordinate, target.X); + Assert.Equal(yCoordinate, target.Y); + Assert.Equal(zCoordinate, target.Z); + Assert.Equal(double.NaN, target.M); + } + + [Fact] + public void Constructor_XYZM_SetsXYZMValues() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.Equal(xCoordinate, target.X); + Assert.Equal(yCoordinate, target.Y); + Assert.Equal(zCoordinate, target.Z); + Assert.Equal(mValue, target.M); + } + + [Fact] + public void Is3D_ReturnsFalseForNaNZCoordinate() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate); + + Assert.False(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsTrueFor3D() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); + + Assert.True(target.Is3D); + } + + [Fact] + public void IsMeasured_ReturnsFalseForNaNMCoordinate() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredCoordinate() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target.IsMeasured); + } + + [Fact] + public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsTrueForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.True(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForNull() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + object other = null; + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForOtherObjectType() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + object other = "string"; + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target.Equals2D(other)); + } + + [Fact] + public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); + + Assert.True(target.Equals2D(other)); + } + + [Fact] + public void Equals2D_ReturnsTrueForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.True(target.Equals2D(other)); + } + + [Fact] + public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); + + Assert.False(target.Equals2D(other)); + } + + [Fact] + public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.True(target == other); + } + + [Fact] + public void EqualsOperator_ReturnsTrueForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.True(target == other); + } + + [Fact] + public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + + Assert.False(target == other); + } + + [Fact] + public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + + Assert.False(target != other); + } + + [Fact] + public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() + { + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + + Assert.False(target != other); + } + + [Fact] + public void NotEqualsOperator_ReturnsTrueForCoordinateWithDifferentOrdinates() + { + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + + Assert.True(target != other); } } diff --git a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs index 889e97f..c13b099 100644 --- a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs +++ b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs @@ -9,254 +9,253 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace Tests.SpatialLite.Core.API +namespace Tests.SpatialLite.Core.API; + +public class EnvelopeTests { - public class EnvelopeTests - { - Coordinate[] _coordinates = new Coordinate[] { - new Coordinate(1, 10, 100, 1000), - new Coordinate(0, 0, 0, 0), - new Coordinate(-1, -10, -100, -1000) - }; + Coordinate[] _coordinates = new Coordinate[] { + new Coordinate(1, 10, 100, 1000), + new Coordinate(0, 0, 0, 0), + new Coordinate(-1, -10, -100, -1000) + }; - Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); - Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); - Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); + Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); + Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); + Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); - double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; + double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; - static public IEnumerable _XYZEnvelopeDifferentBounds + static public IEnumerable _XYZEnvelopeDifferentBounds + { + get { - get - { - yield return new object[] { new Coordinate[] { new Coordinate(1 + 1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2 + 1, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100 + 1, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000 + 1), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5 + 1, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6 + 1, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200 + 1, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000 + 1) } }; - } + yield return new object[] { new Coordinate[] { new Coordinate(1 + 1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2 + 1, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100 + 1, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000 + 1), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5 + 1, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6 + 1, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200 + 1, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000 + 1) } }; } + } - internal void CheckBoundaries(Envelope target, double minX, double maxX, double minY, double maxY, double minZ, double maxZ, double minM, double maxM) - { - Assert.Equal(minX, target.MinX); - Assert.Equal(maxX, target.MaxX); - Assert.Equal(minY, target.MinY); - Assert.Equal(maxY, target.MaxY); - Assert.Equal(minZ, target.MinZ); - Assert.Equal(maxZ, target.MaxZ); - Assert.Equal(minM, target.MinM); - Assert.Equal(maxM, target.MaxM); - } + internal void CheckBoundaries(Envelope target, double minX, double maxX, double minY, double maxY, double minZ, double maxZ, double minM, double maxM) + { + Assert.Equal(minX, target.MinX); + Assert.Equal(maxX, target.MaxX); + Assert.Equal(minY, target.MinY); + Assert.Equal(maxY, target.MaxY); + Assert.Equal(minZ, target.MinZ); + Assert.Equal(maxZ, target.MaxZ); + Assert.Equal(minM, target.MinM); + Assert.Equal(maxM, target.MaxM); + } - [Fact] - public void Constructor__InitializesBoundsToNaNValues() - { - Envelope target = new Envelope(); - - Assert.Equal(double.NaN, target.MinX); - Assert.Equal(double.NaN, target.MaxX); - Assert.Equal(double.NaN, target.MinY); - Assert.Equal(double.NaN, target.MaxY); - Assert.Equal(double.NaN, target.MinZ); - Assert.Equal(double.NaN, target.MaxZ); - Assert.Equal(double.NaN, target.MinM); - Assert.Equal(double.NaN, target.MaxM); - } + [Fact] + public void Constructor__InitializesBoundsToNaNValues() + { + Envelope target = new Envelope(); + + Assert.Equal(double.NaN, target.MinX); + Assert.Equal(double.NaN, target.MaxX); + Assert.Equal(double.NaN, target.MinY); + Assert.Equal(double.NaN, target.MaxY); + Assert.Equal(double.NaN, target.MinZ); + Assert.Equal(double.NaN, target.MaxZ); + Assert.Equal(double.NaN, target.MinM); + Assert.Equal(double.NaN, target.MaxM); + } - [Fact] - public void Constructor_Coordinate_InitializesXYZProperties() - { - Envelope target = new Envelope(_coordinates[0]); + [Fact] + public void Constructor_Coordinate_InitializesXYZProperties() + { + Envelope target = new Envelope(_coordinates[0]); - CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); - } + CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); + } - [Fact] - public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() - { - Envelope source = new Envelope(_coordinates); + [Fact] + public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() + { + Envelope source = new Envelope(_coordinates); - Envelope target = new Envelope(source); + Envelope target = new Envelope(source); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Constructor_Envelope_CopiesMinMaxValues() - { - Envelope source = new Envelope(_coordinates); + [Fact] + public void Constructor_Envelope_CopiesMinMaxValues() + { + Envelope source = new Envelope(_coordinates); - Envelope target = new Envelope(source); + Envelope target = new Envelope(source); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() - { - Envelope target = new Envelope(); - target.Extend(_coordinates[0]); + [Fact] + public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() + { + Envelope target = new Envelope(); + target.Extend(_coordinates[0]); - CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, - _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); - } + CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, + _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); + } - [Fact] - public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() + { + Envelope target = new Envelope(_coordinates); - target.Extend(Coordinate.Empty); + target.Extend(Coordinate.Empty); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() + { + Envelope target = new Envelope(_coordinates); - target.Extend(_lowerValues); + target.Extend(_lowerValues); - CheckBoundaries(target, _lowerValues.X, _expectedBounds[1], _lowerValues.Y, _expectedBounds[3], _lowerValues.Z, _expectedBounds[5], _lowerValues.M, _expectedBounds[7]); - } + CheckBoundaries(target, _lowerValues.X, _expectedBounds[1], _lowerValues.Y, _expectedBounds[3], _lowerValues.Z, _expectedBounds[5], _lowerValues.M, _expectedBounds[7]); + } - [Fact] - public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() + { + Envelope target = new Envelope(_coordinates); - target.Extend(_higherValues); + target.Extend(_higherValues); - CheckBoundaries(target, _expectedBounds[0], _higherValues.X, _expectedBounds[2], _higherValues.Y, _expectedBounds[4], _higherValues.Z, _expectedBounds[6], _higherValues.M); - } + CheckBoundaries(target, _expectedBounds[0], _higherValues.X, _expectedBounds[2], _higherValues.Y, _expectedBounds[4], _higherValues.Z, _expectedBounds[6], _higherValues.M); + } - [Fact] - public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() + { + Envelope target = new Envelope(_coordinates); - target.Extend(_insideCoordinate); + target.Extend(_insideCoordinate); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() - { - Envelope target = new Envelope(); + [Fact] + public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() + { + Envelope target = new Envelope(); - target.Extend(_coordinates); + target.Extend(_coordinates); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() + { + Envelope target = new Envelope(_coordinates); - target.Extend(new Coordinate[] { }); + target.Extend(new Coordinate[] { }); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Extend_IEnumerableCoordinate_ExtendsEnvelope() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_IEnumerableCoordinate_ExtendsEnvelope() + { + Envelope target = new Envelope(_coordinates); - target.Extend(new Coordinate[] { _lowerValues, _higherValues }); + target.Extend(new Coordinate[] { _lowerValues, _higherValues }); - CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); - } + CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); + } - [Fact] - public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() - { - Envelope target = new Envelope(); + [Fact] + public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() + { + Envelope target = new Envelope(); - target.Extend(new Envelope(_coordinates)); + target.Extend(new Envelope(_coordinates)); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() + { + Envelope target = new Envelope(_coordinates); - target.Extend(new Envelope(_coordinates[1])); + target.Extend(new Envelope(_coordinates[1])); - CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], - _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); - } + CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], + _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); + } - [Fact] - public void Extend_Envelope_ExtendsEnvelope() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Extend_Envelope_ExtendsEnvelope() + { + Envelope target = new Envelope(_coordinates); - target.Extend(new Envelope(new Coordinate[] { _lowerValues, _higherValues })); + target.Extend(new Envelope(new Coordinate[] { _lowerValues, _higherValues })); - CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); - } + CheckBoundaries(target, _lowerValues.X, _higherValues.X, _lowerValues.Y, _higherValues.Y, _lowerValues.Z, _higherValues.Z, _lowerValues.M, _higherValues.M); + } - [Fact] - public void Equals_ReturnsTrueForSameObjectInstance() - { - Envelope target = new Envelope(_coordinates); + [Fact] + public void Equals_ReturnsTrueForSameObjectInstance() + { + Envelope target = new Envelope(_coordinates); - Assert.True(target.Equals(target)); - } + Assert.True(target.Equals(target)); + } - [Fact] - public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() - { - Envelope target = new Envelope(_coordinates); - Envelope other = new Envelope(target); + [Fact] + public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() + { + Envelope target = new Envelope(_coordinates); + Envelope other = new Envelope(target); - Assert.True(target.Equals(other)); - } + Assert.True(target.Equals(other)); + } - [Fact] - public void Equals_ReturnsFalseForNull() - { - Envelope target = new Envelope(_coordinates); - object other = null; + [Fact] + public void Equals_ReturnsFalseForNull() + { + Envelope target = new Envelope(_coordinates); + object other = null; - Assert.False(target.Equals(other)); - } + Assert.False(target.Equals(other)); + } - [Fact] - public void Equals_ReturnsFalseForOtherObjectType() - { - Envelope target = new Envelope(_coordinates); - object other = "string"; + [Fact] + public void Equals_ReturnsFalseForOtherObjectType() + { + Envelope target = new Envelope(_coordinates); + object other = "string"; - Assert.False(target.Equals(other)); - } + Assert.False(target.Equals(other)); + } - [Theory] - [MemberData(nameof(_XYZEnvelopeDifferentBounds))] - public void Equals_ReturnsFalseForTheEnvelopeWithDifferentBounds(Coordinate[] corners) - { - Envelope target = new Envelope(_coordinates); - Envelope other = new Envelope(corners); + [Theory] + [MemberData(nameof(_XYZEnvelopeDifferentBounds))] + public void Equals_ReturnsFalseForTheEnvelopeWithDifferentBounds(Coordinate[] corners) + { + Envelope target = new Envelope(_coordinates); + Envelope other = new Envelope(corners); - Assert.False(target.Equals(other)); - } + Assert.False(target.Equals(other)); } } diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs index 972adf4..13cd7d8 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs @@ -10,251 +10,250 @@ using SpatialLite.Core.API; using SpatialLite.Core.Algorithms; -namespace Tests.SpatialLite.Core.Algorithms +namespace Tests.SpatialLite.Core.Algorithms; + +public class Euclidean2DCalculatorTests { - public class Euclidean2DCalculatorTests + public static IEnumerable CoordinatesSameXYOrdinates { - public static IEnumerable CoordinatesSameXYOrdinates + get { - get - { - yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2) }; - yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1) }; - yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1, 1) }; - } + yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2) }; + yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1) }; + yield return new object[] { new Coordinate(10.1, 100.2), new Coordinate(10.1, 100.2, 1, 1) }; } + } - [Theory] - [MemberData(nameof(CoordinatesSameXYOrdinates))] - public void ComputeDistance_CoordinateCoordinate_ReturnsZeroForPointsWithSameXYCoordinates(Coordinate c1, Coordinate c2) - { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Theory] + [MemberData(nameof(CoordinatesSameXYOrdinates))] + public void ComputeDistance_CoordinateCoordinate_ReturnsZeroForPointsWithSameXYCoordinates(Coordinate c1, Coordinate c2) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c1, c2); + double distance = target.CalculateDistance(c1, c2); - Assert.Equal(0, distance); - } + Assert.Equal(0, distance); + } - public static IEnumerable CoordinatesDistanceTestData + public static IEnumerable CoordinatesDistanceTestData + { + get { - get - { - yield return new object[] { new Coordinate(-1, 0), new Coordinate(1, 0), 2 }; - yield return new object[] { new Coordinate(0, -1), new Coordinate(0, 1), 2 }; - yield return new object[] { new Coordinate(2, 1), new Coordinate(-1, -3), 5 }; - } + yield return new object[] { new Coordinate(-1, 0), new Coordinate(1, 0), 2 }; + yield return new object[] { new Coordinate(0, -1), new Coordinate(0, 1), 2 }; + yield return new object[] { new Coordinate(2, 1), new Coordinate(-1, -3), 5 }; } + } - [Theory] - [MemberData(nameof(CoordinatesDistanceTestData))] - public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinates(Coordinate c1, Coordinate c2, double expectedDistance) - { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Theory] + [MemberData(nameof(CoordinatesDistanceTestData))] + public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinates(Coordinate c1, Coordinate c2, double expectedDistance) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c1, c2); + double distance = target.CalculateDistance(c1, c2); - Assert.Equal(expectedDistance, distance); - } + Assert.Equal(expectedDistance, distance); + } - [Fact] - public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() - { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Fact] + public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(new Coordinate(-1, 0, 100), new Coordinate(1, 0, -100)); + double distance = target.CalculateDistance(new Coordinate(-1, 0, 100), new Coordinate(1, 0, -100)); - Assert.Equal(2, distance); - } + Assert.Equal(2, distance); + } - [Fact] - public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsDistanceToEndPointsIfPointsProjectionLiesOutsideSegment() - { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(-1, -1); - Coordinate c1 = new Coordinate(1, 2); - Coordinate c2 = new Coordinate(-1, -2); + [Fact] + public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsDistanceToEndPointsIfPointsProjectionLiesOutsideSegment() + { + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(-1, -1); + Coordinate c1 = new Coordinate(1, 2); + Coordinate c2 = new Coordinate(-1, -2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distanceC1 = target.CalculateDistance(c1, A, B, LineMode.LineSegment); - Assert.Equal(1, distanceC1); + double distanceC1 = target.CalculateDistance(c1, A, B, LineMode.LineSegment); + Assert.Equal(1, distanceC1); - double distanceC2 = target.CalculateDistance(c2, A, B, LineMode.LineSegment); - Assert.Equal(1, distanceC2); - } + double distanceC2 = target.CalculateDistance(c2, A, B, LineMode.LineSegment); + Assert.Equal(1, distanceC2); + } - public static IEnumerable LineSegmentDistanceTestData + public static IEnumerable LineSegmentDistanceTestData + { + get { - get - { - yield return new object[] { new Coordinate(0.5, 1), new Coordinate(-1, 0), new Coordinate(1, 0), 1 }; - yield return new object[] { new Coordinate(1, 0.5), new Coordinate(0, -1), new Coordinate(0, 1), 1 }; - yield return new object[] { new Coordinate(-1, 1), new Coordinate(-5, -5), new Coordinate(5, 5), Math.Sqrt(2) }; - } + yield return new object[] { new Coordinate(0.5, 1), new Coordinate(-1, 0), new Coordinate(1, 0), 1 }; + yield return new object[] { new Coordinate(1, 0.5), new Coordinate(0, -1), new Coordinate(0, 1), 1 }; + yield return new object[] { new Coordinate(-1, 1), new Coordinate(-5, -5), new Coordinate(5, 5), Math.Sqrt(2) }; } + } - [Theory] - [MemberData(nameof(LineSegmentDistanceTestData))] - public void ComputeDistance_CoordinateLineLineSegmentMode_ComputesPerpendicularDistanceToLineIfPointsProjectionLiesInside(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) - { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Theory] + [MemberData(nameof(LineSegmentDistanceTestData))] + public void ComputeDistance_CoordinateLineLineSegmentMode_ComputesPerpendicularDistanceToLineIfPointsProjectionLiesInside(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); - Assert.Equal(expectedDistance, distance); - } + double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); + Assert.Equal(expectedDistance, distance); + } - public static IEnumerable LineSegmentDistanceZeroDistanceTestData + public static IEnumerable LineSegmentDistanceZeroDistanceTestData + { + get { - get - { - yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, 0), new Coordinate(1, 0) }; - yield return new object[] { new Coordinate(0, -1), new Coordinate(0, -1), new Coordinate(0, 1) }; - yield return new object[] { new Coordinate(0, 0), new Coordinate(0, -1), new Coordinate(0, 1) }; - } + yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, 0), new Coordinate(1, 0) }; + yield return new object[] { new Coordinate(0, -1), new Coordinate(0, -1), new Coordinate(0, 1) }; + yield return new object[] { new Coordinate(0, 0), new Coordinate(0, -1), new Coordinate(0, 1) }; } + } - [Theory] - [MemberData(nameof(LineSegmentDistanceZeroDistanceTestData))] - public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLiesOnLineSegment(Coordinate c, Coordinate A, Coordinate B) - { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Theory] + [MemberData(nameof(LineSegmentDistanceZeroDistanceTestData))] + public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLiesOnLineSegment(Coordinate c, Coordinate A, Coordinate B) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); - Assert.Equal(0, distance); - } + double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); + Assert.Equal(0, distance); + } - [Fact] - public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIfABAreEquals() - { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(1, 1); - Coordinate c = new Coordinate(1, 2); + [Fact] + public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIfABAreEquals() + { + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(1, 1); + Coordinate c = new Coordinate(1, 2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); - Assert.Equal(1, distance); - } + double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); + Assert.Equal(1, distance); + } - [Fact] - public void ComputeDistance_CoordinateLineLineMode_ReturnsPointDistanceIfABAreEquals() - { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(1, 1); - Coordinate c = new Coordinate(1, 2); + [Fact] + public void ComputeDistance_CoordinateLineLineMode_ReturnsPointDistanceIfABAreEquals() + { + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(1, 1); + Coordinate c = new Coordinate(1, 2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c, A, B, LineMode.Line); - Assert.Equal(1, distance); - } + double distance = target.CalculateDistance(c, A, B, LineMode.Line); + Assert.Equal(1, distance); + } - public static IEnumerable LineDistanceZeroDistanceTestData + public static IEnumerable LineDistanceZeroDistanceTestData + { + get { - get - { - yield return new object[] { new Coordinate(-2, -2), new Coordinate(-1, -1), new Coordinate(1, 1) }; - yield return new object[] { new Coordinate(2, 2), new Coordinate(-1, -1), new Coordinate(1, 1) }; - yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, -1), new Coordinate(1, 1) }; - } + yield return new object[] { new Coordinate(-2, -2), new Coordinate(-1, -1), new Coordinate(1, 1) }; + yield return new object[] { new Coordinate(2, 2), new Coordinate(-1, -1), new Coordinate(1, 1) }; + yield return new object[] { new Coordinate(0, 0), new Coordinate(-1, -1), new Coordinate(1, 1) }; } + } - [Theory] - [MemberData(nameof(LineDistanceZeroDistanceTestData))] - public void ComputeDistance_CoordinateLineLineMode_ReturnsZeroIfPointLiesOnLine(Coordinate c, Coordinate A, Coordinate B) - { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Theory] + [MemberData(nameof(LineDistanceZeroDistanceTestData))] + public void ComputeDistance_CoordinateLineLineMode_ReturnsZeroIfPointLiesOnLine(Coordinate c, Coordinate A, Coordinate B) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c, A, B, LineMode.Line); - Assert.Equal(0, distance); - } + double distance = target.CalculateDistance(c, A, B, LineMode.Line); + Assert.Equal(0, distance); + } - public static IEnumerable LineDistanceTestData + public static IEnumerable LineDistanceTestData + { + get { - get - { - yield return new object[] { new Coordinate(-3, -1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; - yield return new object[] { new Coordinate(-1, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; - yield return new object[] { new Coordinate(3, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; - } + yield return new object[] { new Coordinate(-3, -1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; + yield return new object[] { new Coordinate(-1, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; + yield return new object[] { new Coordinate(3, 1), new Coordinate(-1, -1), new Coordinate(1, 1), Math.Sqrt(2) }; } + } - [Theory] - [MemberData(nameof(LineDistanceTestData))] - public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistanceToLine(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) - { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Theory] + [MemberData(nameof(LineDistanceTestData))] + public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistanceToLine(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) + { + Euclidean2DCalculator target = new Euclidean2DCalculator(); - double distance = target.CalculateDistance(c, A, B, LineMode.Line); - Assert.Equal(expectedDistance, distance); - } + double distance = target.CalculateDistance(c, A, B, LineMode.Line); + Assert.Equal(expectedDistance, distance); + } - [Fact] - public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() - { - Mock listM = new Mock(); - listM.SetupGet(l => l.Count).Returns(2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + [Fact] + public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() + { + Mock listM = new Mock(); + listM.SetupGet(l => l.Count).Returns(2); + Euclidean2DCalculator target = new Euclidean2DCalculator(); - Assert.Throws(() => target.CalculateArea(listM.Object)); - } + Assert.Throws(() => target.CalculateArea(listM.Object)); + } - [Fact] - public void ComputeArea_ReturnsAreaOfConvexPolygon() - { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; - double expectedArea = 2.5; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(5); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[3]); - listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.Equal(expectedArea, area); - } + [Fact] + public void ComputeArea_ReturnsAreaOfConvexPolygon() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; + double expectedArea = 2.5; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(5); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[3]); + listM.Setup(list => list[4]).Returns(coordinates[4]); + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.Equal(expectedArea, area); + } - [Fact] - public void ComputeArea_ReturnsAreaOfConcavePolygon() - { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; - double expectedArea = 1.5; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(5); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[3]); - listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.Equal(expectedArea, area); - } + [Fact] + public void ComputeArea_ReturnsAreaOfConcavePolygon() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; + double expectedArea = 1.5; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(5); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[3]); + listM.Setup(list => list[4]).Returns(coordinates[4]); + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.Equal(expectedArea, area); + } - [Fact] - public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() - { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2), new Coordinate(1, 1) }; - double expectedArea = 2.5; - - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(6); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[3]); - listM.Setup(list => list[4]).Returns(coordinates[4]); - listM.Setup(list => list[5]).Returns(coordinates[5]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); - - double area = target.CalculateArea(listM.Object); - Assert.Equal(expectedArea, area); - } + [Fact] + public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2), new Coordinate(1, 1) }; + double expectedArea = 2.5; + + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(6); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[3]); + listM.Setup(list => list[4]).Returns(coordinates[4]); + listM.Setup(list => list[5]).Returns(coordinates[5]); + Euclidean2DCalculator target = new Euclidean2DCalculator(); + + double area = target.CalculateArea(listM.Object); + Assert.Equal(expectedArea, area); } } diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs index fc39ccc..3682b72 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs @@ -11,290 +11,289 @@ using SpatialLite.Core.Geometries; using SpatialLite.Core.IO; -namespace Tests.SpatialLite.Core.Algorithms +namespace Tests.SpatialLite.Core.Algorithms; + +public class Euclidean2DLocatorTests { - public class Euclidean2DLocatorTests - { - [Fact] - public void IsOnLine_ReturnsTrueIfPointIsOnAorB() - { - Coordinate a = new Coordinate(-10, 0); - Coordinate b = new Coordinate(3, 2); - Euclidean2DLocator target = new Euclidean2DLocator(); + [Fact] + public void IsOnLine_ReturnsTrueIfPointIsOnAorB() + { + Coordinate a = new Coordinate(-10, 0); + Coordinate b = new Coordinate(3, 2); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.IsOnLine(a, a, b, LineMode.Line)); - Assert.True(target.IsOnLine(b, a, b, LineMode.Line)); - } + Assert.True(target.IsOnLine(a, a, b, LineMode.Line)); + Assert.True(target.IsOnLine(b, a, b, LineMode.Line)); + } - public static IEnumerable PointsBetweenAB + public static IEnumerable PointsBetweenAB + { + get { - get - { - yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; - yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; - } + yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; + yield return new object[] { new Coordinate(1, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; } + } - [Theory] - [MemberData(nameof(PointsBetweenAB))] - public void IsOnLine_ReturnsTrueIfPointLiesBetweenAAndB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) - { - Euclidean2DLocator target = new Euclidean2DLocator(); + [Theory] + [MemberData(nameof(PointsBetweenAB))] + public void IsOnLine_ReturnsTrueIfPointLiesBetweenAAndB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.IsOnLine(c, a, b, mode)); - } + Assert.True(target.IsOnLine(c, a, b, mode)); + } - public static IEnumerable PointsOnAB + public static IEnumerable PointsOnAB + { + get { - get - { - yield return new object[] { new Coordinate(-11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; - yield return new object[] { new Coordinate(11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; - } + yield return new object[] { new Coordinate(-11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; + yield return new object[] { new Coordinate(11, 1), new Coordinate(-10, 1), new Coordinate(10, 1) }; } + } - [Theory] - [MemberData(nameof(PointsOnAB))] - public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coordinate a, Coordinate b) - { - Euclidean2DLocator target = new Euclidean2DLocator(); + [Theory] + [MemberData(nameof(PointsOnAB))] + public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coordinate a, Coordinate b) + { + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.IsOnLine(c, a, b, LineMode.Line)); - } + Assert.True(target.IsOnLine(c, a, b, LineMode.Line)); + } - [Theory] - [MemberData(nameof(PointsOnAB))] - public void IsOnLine_ReturnsFalseIfPointLiesOnABAndModeIsLineSegment(Coordinate c, Coordinate a, Coordinate b) - { - Euclidean2DLocator target = new Euclidean2DLocator(); + [Theory] + [MemberData(nameof(PointsOnAB))] + public void IsOnLine_ReturnsFalseIfPointLiesOnABAndModeIsLineSegment(Coordinate c, Coordinate a, Coordinate b) + { + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.IsOnLine(c, a, b, LineMode.LineSegment)); - } + Assert.False(target.IsOnLine(c, a, b, LineMode.LineSegment)); + } - public static IEnumerable PointsNotOnAB + public static IEnumerable PointsNotOnAB + { + get { - get - { - yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; - yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; - yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; - yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; - yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; - yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; - } + yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.Line }; + yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.Line }; + yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.Line }; + yield return new object[] { new Coordinate(1, 2), new Coordinate(-10, 1), new Coordinate(10, 1), LineMode.LineSegment }; + yield return new object[] { new Coordinate(2, 1), new Coordinate(1, 10), new Coordinate(1, -10), LineMode.LineSegment }; + yield return new object[] { new Coordinate(0, 1), new Coordinate(2, 2), new Coordinate(-1, -1), LineMode.LineSegment }; } + } - [Theory] - [MemberData(nameof(PointsNotOnAB))] - public void IsOnLine_ReturnsFalseIfPointDoEsNotLieOnAB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) - { - Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.IsOnLine(c, a, b, mode)); - } + [Theory] + [MemberData(nameof(PointsNotOnAB))] + public void IsOnLine_ReturnsFalseIfPointDoEsNotLieOnAB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) + { + Euclidean2DLocator target = new Euclidean2DLocator(); + Assert.False(target.IsOnLine(c, a, b, mode)); + } - [Fact] - public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() - { - Coordinate c = new Coordinate(0, 0); - CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + [Fact] + public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() + { + Coordinate c = new Coordinate(0, 0); + CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0) }); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.Throws(() => target.IsInRing(c, ring)); - } + Assert.Throws(() => target.IsInRing(c, ring)); + } - [Fact] - public void IsInRing_ThrowsArgumentExceptionIfCoordinateListDoesNotRepresentRing() - { - Coordinate c = new Coordinate(0, 0); - CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 2) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + [Fact] + public void IsInRing_ThrowsArgumentExceptionIfCoordinateListDoesNotRepresentRing() + { + Coordinate c = new Coordinate(0, 0); + CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 2) }); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.Throws(() => target.IsInRing(c, ring)); - } + Assert.Throws(() => target.IsInRing(c, ring)); + } - [Fact] - public void IsInRing_ReturnsTrueIfPointIsInSimpleRing() - { - string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); + [Fact] + public void IsInRing_ReturnsTrueIfPointIsInSimpleRing() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(0.5, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new Coordinate(0.5, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.IsInRing(c, ring.Coordinates)); - } + Assert.True(target.IsInRing(c, ring.Coordinates)); + } - [Fact] - public void IsInRing_ReturnsTrueIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() - { - string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); + [Fact] + public void IsInRing_ReturnsTrueIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(0.5, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new Coordinate(0.5, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.IsInRing(c, ring.Coordinates)); - } + Assert.True(target.IsInRing(c, ring.Coordinates)); + } - [Fact] - public void IsInRing_ReturnsTrueIfPointIsInConcaveRing() - { - string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; - LineString ring = WktReader.Parse(wktRing); + [Fact] + public void IsInRing_ReturnsTrueIfPointIsInConcaveRing() + { + string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; + LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(1, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new Coordinate(1, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.IsInRing(c, ring.Coordinates)); - } + Assert.True(target.IsInRing(c, ring.Coordinates)); + } - [Fact] - public void IsInRing_ReturnsFalseIfPointIsOutsideSimpleRing() - { - string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); + [Fact] + public void IsInRing_ReturnsFalseIfPointIsOutsideSimpleRing() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(2, 2); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new Coordinate(2, 2); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.IsInRing(c, ring.Coordinates)); - } + Assert.False(target.IsInRing(c, ring.Coordinates)); + } - [Fact] - public void IsInRing_ReturnsFalseIfPointIsOutsideRing() - { - string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; - LineString ring = WktReader.Parse(wktRing); + [Fact] + public void IsInRing_ReturnsFalseIfPointIsOutsideRing() + { + string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; + LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(3, 0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new Coordinate(3, 0); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.IsInRing(c, ring.Coordinates)); - } + Assert.False(target.IsInRing(c, ring.Coordinates)); + } - [Fact] - public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() - { - string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; - LineString ring = WktReader.Parse(wktRing); + [Fact] + public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoordinate() + { + string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; + LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(-2, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new Coordinate(-2, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.IsInRing(c, ring.Coordinates)); - } + Assert.False(target.IsInRing(c, ring.Coordinates)); + } - [Fact] - public void Intersects_ReturnsFalseForParallelLines() - { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 2.0); + [Fact] + public void Intersects_ReturnsFalseForParallelLines() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 2.0); - Coordinate A2 = new Coordinate(2.0, 1.0); - Coordinate B2 = new Coordinate(3.0, 2.0); + Coordinate A2 = new Coordinate(2.0, 1.0); + Coordinate B2 = new Coordinate(3.0, 2.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); - } + Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); + } - [Fact] - public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() - { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + [Fact] + public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); - } + Assert.True(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); + } - [Fact] - public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment1() - { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + [Fact] + public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment1() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.Line)); - } + Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.Line)); + } - [Fact] - public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment2() - { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + [Fact] + public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment2() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 0.5); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.LineSegment)); - } + Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.LineSegment)); + } - [Fact] - public void Intersects_ReturnsFalseForNonIntersectingLineSegments() - { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + [Fact] + public void Intersects_ReturnsFalseForNonIntersectingLineSegments() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); - } + Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); + } - [Fact] - public void Intersects_ReturnsTrueForIntersectingLineSegments() - { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(3.0, 1.0); + [Fact] + public void Intersects_ReturnsTrueForIntersectingLineSegments() + { + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(3.0, 1.0); - Coordinate A2 = new Coordinate(1.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 2.0); + Coordinate A2 = new Coordinate(1.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 2.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); - } + Assert.True(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); + } - [Fact] - public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() - { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(2.0, 0.0), new Coordinate(2.0, -1.0) }); + [Fact] + public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() + { + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(2.0, 0.0), new Coordinate(2.0, -1.0) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.False(target.Intersects(line1, line2)); - } + Assert.False(target.Intersects(line1, line2)); + } - [Fact] - public void Intersects_LineLine_ReturnsaTrueForIntersectingLines() - { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(1.5, 2.0), new Coordinate(2.0, -1.0) }); + [Fact] + public void Intersects_LineLine_ReturnsaTrueForIntersectingLines() + { + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(1.5, 2.0), new Coordinate(2.0, -1.0) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new Euclidean2DLocator(); - Assert.True(target.Intersects(line1, line2)); - } + Assert.True(target.Intersects(line1, line2)); } } diff --git a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs index 84e107b..43c3ee1 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs @@ -9,159 +9,158 @@ using Xunit; using Moq; -namespace Tests.SpatialLite.Core.Algorithms +namespace Tests.SpatialLite.Core.Algorithms; + +public class Sphere2DCalculatorTests { - public class Sphere2DCalculatorTests - { - [Fact] - public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() - { - Coordinate c = new Coordinate(10.1, 100.2); - Sphere2DCalculator target = new Sphere2DCalculator(); + [Fact] + public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() + { + Coordinate c = new Coordinate(10.1, 100.2); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c, c); + double distance = target.CalculateDistance(c, c); - Assert.Equal(0, distance); - } + Assert.Equal(0, distance); + } - //TODO more test cases - [Fact] - public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() - { - Coordinate c1 = new Coordinate(0, 0); - Coordinate c2 = new Coordinate(0, 90); - Sphere2DCalculator target = new Sphere2DCalculator(); + //TODO more test cases + [Fact] + public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() + { + Coordinate c1 = new Coordinate(0, 0); + Coordinate c2 = new Coordinate(0, 90); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c1, c2); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; + double distance = target.CalculateDistance(c1, c2); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } - [Fact] - public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegBoundary() - { - Coordinate c1 = new Coordinate(-45, 0); - Coordinate c2 = new Coordinate(45, 0); - Sphere2DCalculator target = new Sphere2DCalculator(); + [Fact] + public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegBoundary() + { + Coordinate c1 = new Coordinate(-45, 0); + Coordinate c2 = new Coordinate(45, 0); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c1, c2); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; + double distance = target.CalculateDistance(c1, c2); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } - [Fact] - public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180DegBoundary() - { - Coordinate c1 = new Coordinate(-135, 0); - Coordinate c2 = new Coordinate(135, 0); - Sphere2DCalculator target = new Sphere2DCalculator(); + [Fact] + public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180DegBoundary() + { + Coordinate c1 = new Coordinate(-135, 0); + Coordinate c2 = new Coordinate(135, 0); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c1, c2); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; + double distance = target.CalculateDistance(c1, c2); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() - { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(120, 45); + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(120, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c, a, b, LineMode.Line); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; + double distance = target.CalculateDistance(c, a, b, LineMode.Line); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() - { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(45, 45); + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(45, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); - double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; + double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); + double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment() - { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(95, 45); + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(95, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); - double expectedDistance = target.CalculateDistance(b, c); + double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); + double expectedDistance = target.CalculateDistance(b, c); - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } - [Fact] - public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment2() - { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(5, 45); + [Fact] + public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment2() + { + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(5, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new Sphere2DCalculator(); - double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); - double expectedDistance = target.CalculateDistance(a, c); + double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); + double expectedDistance = target.CalculateDistance(a, c); - Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); - } + Assert.InRange(distance, expectedDistance * 0.995, expectedDistance * 1.005); + } - [Fact] - public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast() - { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; + [Fact] + public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(3); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(3); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); - double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; + double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new Sphere2DCalculator(); - double area = target.CalculateArea(listM.Object); - Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); - } + double area = target.CalculateArea(listM.Object); + Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); + } - [Fact] - public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() - { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; + [Fact] + public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() + { + Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; - Mock listM = new Mock(); - listM.SetupGet(list => list.Count).Returns(4); - listM.Setup(list => list[0]).Returns(coordinates[0]); - listM.Setup(list => list[1]).Returns(coordinates[1]); - listM.Setup(list => list[2]).Returns(coordinates[2]); - listM.Setup(list => list[3]).Returns(coordinates[0]); + Mock listM = new Mock(); + listM.SetupGet(list => list.Count).Returns(4); + listM.Setup(list => list[0]).Returns(coordinates[0]); + listM.Setup(list => list[1]).Returns(coordinates[1]); + listM.Setup(list => list[2]).Returns(coordinates[2]); + listM.Setup(list => list[3]).Returns(coordinates[0]); - double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; + double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new Sphere2DCalculator(); - double area = target.CalculateArea(listM.Object); - Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); - } + double area = target.CalculateArea(listM.Object); + Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); } } diff --git a/src/Tests.SpatialLite.Core/Data/TestDataReader.cs b/src/Tests.SpatialLite.Core/Data/TestDataReader.cs index 4357cb0..746544e 100644 --- a/src/Tests.SpatialLite.Core/Data/TestDataReader.cs +++ b/src/Tests.SpatialLite.Core/Data/TestDataReader.cs @@ -5,24 +5,23 @@ using System.Reflection; using System.Threading.Tasks; -namespace Tests.SpatialLite.Core.Data +namespace Tests.SpatialLite.Core.Data; + +public static class TestDataReader { - public static class TestDataReader + public static Stream Open(string name) { - public static Stream Open(string name) - { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name); - } + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name); + } - public static byte[] Read(string name) - { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + public static byte[] Read(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - var stream = new MemoryStream(); - assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name).CopyTo(stream); + var stream = new MemoryStream(); + assembly.GetManifestResourceStream("Tests.SpatialLite.Core.Data.IO." + name).CopyTo(stream); - return stream.ToArray(); - } + return stream.ToArray(); } } diff --git a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs index f01e42e..3c97781 100644 --- a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs @@ -8,161 +8,160 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class CoordinateListTests { - public class CoordinateListTests - { - Coordinate _coordinate = new Coordinate(-10, -20, -200); + Coordinate _coordinate = new Coordinate(-10, -20, -200); - Coordinate[] _coordinates = new Coordinate[] { - new Coordinate(12,10,100), - new Coordinate(22,20,200), - new Coordinate(32,30,300) - }; + Coordinate[] _coordinates = new Coordinate[] { + new Coordinate(12,10,100), + new Coordinate(22,20,200), + new Coordinate(32,30,300) + }; - [Fact] - public void Constructor__CreatesEmptyList() - { - CoordinateList target = new CoordinateList(); + [Fact] + public void Constructor__CreatesEmptyList() + { + CoordinateList target = new CoordinateList(); - Assert.Empty(target); - } + Assert.Empty(target); + } - [Fact] - public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() - { - CoordinateList target = new CoordinateList(_coordinates); + [Fact] + public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() + { + CoordinateList target = new CoordinateList(_coordinates); - for (int i = 0; i < _coordinates.Length; i++) - { - Assert.Equal(_coordinates[i], target[i]); - } + for (int i = 0; i < _coordinates.Length; i++) + { + Assert.Equal(_coordinates[i], target[i]); } + } - [Fact] - public void Indexer_GetsAndSetsValues() - { - CoordinateList target = new CoordinateList(_coordinates); + [Fact] + public void Indexer_GetsAndSetsValues() + { + CoordinateList target = new CoordinateList(_coordinates); - Assert.Equal(_coordinates[1], target[1]); + Assert.Equal(_coordinates[1], target[1]); - target[1] = _coordinate; - Assert.Equal(_coordinate, target[1]); - } + target[1] = _coordinate; + Assert.Equal(_coordinate, target[1]); + } - [Fact] - public void Count_Returns0ForEmptyList() - { - CoordinateList target = new CoordinateList(); + [Fact] + public void Count_Returns0ForEmptyList() + { + CoordinateList target = new CoordinateList(); - Assert.Equal(0, target.Count); - } + Assert.Equal(0, target.Count); + } - [Fact] - public void Count_ReturnsNumberOfCoordinates() - { - CoordinateList target = new CoordinateList(_coordinates); + [Fact] + public void Count_ReturnsNumberOfCoordinates() + { + CoordinateList target = new CoordinateList(_coordinates); - Assert.Equal(_coordinates.Length, target.Count); - } + Assert.Equal(_coordinates.Length, target.Count); + } - [Fact] - public void Add_AppendsCoordinateToTheEndOfList() - { - CoordinateList target = new CoordinateList(_coordinates); - target.Add(_coordinate); + [Fact] + public void Add_AppendsCoordinateToTheEndOfList() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Add(_coordinate); - Assert.Equal(_coordinate, target.Last()); - } + Assert.Equal(_coordinate, target.Last()); + } - [Fact] - public void Add_IncresesCount() - { - CoordinateList target = new CoordinateList(_coordinates); - target.Add(_coordinate); + [Fact] + public void Add_IncresesCount() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Add(_coordinate); - Assert.Equal(_coordinates.Length + 1, target.Count); - } + Assert.Equal(_coordinates.Length + 1, target.Count); + } - [Fact] - public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() - { - CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); - target.Add(_coordinates); + [Fact] + public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() + { + CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); + target.Add(_coordinates); - for (int i = 0; i < _coordinates.Length; i++) - { - Assert.Equal(_coordinates[i], target[i + 1]); - } + for (int i = 0; i < _coordinates.Length; i++) + { + Assert.Equal(_coordinates[i], target[i + 1]); } + } - [Fact] - public void Add_IncresesCount2() - { - CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); - target.Add(_coordinates); + [Fact] + public void Add_IncresesCount2() + { + CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); + target.Add(_coordinates); - Assert.Equal(_coordinates.Length + 1, target.Count); - } + Assert.Equal(_coordinates.Length + 1, target.Count); + } - [Fact] - public void Insert_InsertsCoordinateToSpecifiedIndex() - { - int index = 1; - CoordinateList target = new CoordinateList(_coordinates); - target.Insert(index, _coordinate); + [Fact] + public void Insert_InsertsCoordinateToSpecifiedIndex() + { + int index = 1; + CoordinateList target = new CoordinateList(_coordinates); + target.Insert(index, _coordinate); - Assert.Equal(_coordinate, target[index]); - } + Assert.Equal(_coordinate, target[index]); + } - [Fact] - public void Insert_IncresesCount() - { - int index = 1; - CoordinateList target = new CoordinateList(_coordinates); - target.Insert(index, _coordinate); + [Fact] + public void Insert_IncresesCount() + { + int index = 1; + CoordinateList target = new CoordinateList(_coordinates); + target.Insert(index, _coordinate); - Assert.Equal(_coordinates.Length + 1, target.Count); - } + Assert.Equal(_coordinates.Length + 1, target.Count); + } - [Fact] - public void Insert_AppendsCoordinateToListIfIndexEqulasCount() - { - CoordinateList target = new CoordinateList(_coordinates); - target.Insert(target.Count, _coordinate); + [Fact] + public void Insert_AppendsCoordinateToListIfIndexEqulasCount() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Insert(target.Count, _coordinate); - Assert.Equal(_coordinate, target.Last()); - Assert.Equal(_coordinates.Length + 1, target.Count); - } + Assert.Equal(_coordinate, target.Last()); + Assert.Equal(_coordinates.Length + 1, target.Count); + } - [Fact] - public void RemoveAt_RemovesCoordinateAtIndex() - { - CoordinateList target = new CoordinateList(_coordinates); - target.RemoveAt(1); + [Fact] + public void RemoveAt_RemovesCoordinateAtIndex() + { + CoordinateList target = new CoordinateList(_coordinates); + target.RemoveAt(1); - Assert.Equal(_coordinates[0], target[0]); - Assert.Equal(_coordinates[2], target[1]); - } + Assert.Equal(_coordinates[0], target[0]); + Assert.Equal(_coordinates[2], target[1]); + } - [Fact] - public void RemoveAt_DecreasesCount() - { - CoordinateList target = new CoordinateList(_coordinates); - target.RemoveAt(1); + [Fact] + public void RemoveAt_DecreasesCount() + { + CoordinateList target = new CoordinateList(_coordinates); + target.RemoveAt(1); - Assert.Equal(_coordinates.Length - 1, target.Count); - } + Assert.Equal(_coordinates.Length - 1, target.Count); + } - [Fact] - public void Clear_RemovesAllCoordinatesFromList() - { - CoordinateList target = new CoordinateList(_coordinates); - target.Clear(); + [Fact] + public void Clear_RemovesAllCoordinatesFromList() + { + CoordinateList target = new CoordinateList(_coordinates); + target.Clear(); - Assert.Empty(target.ToArray()); - Assert.Equal(0, target.Count); - } + Assert.Empty(target.ToArray()); + Assert.Equal(0, target.Count); } } diff --git a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs index c7db366..1b60b0d 100644 --- a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs @@ -9,119 +9,118 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class GeometryCollectionTests { - public class GeometryCollectionTests - { - Point[] _geometries; + Point[] _geometries; - Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(12,10,100, 1000), - new Coordinate(22,20,200, 2000), - new Coordinate(32,30,300, 3000) - }; + Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(12,10,100, 1000), + new Coordinate(22,20,200, 2000), + new Coordinate(32,30,300, 3000) + }; - public GeometryCollectionTests() - { - _geometries = new Point[3]; - _geometries[0] = new Point(1, 2, 3); - _geometries[1] = new Point(1.1, 2.1, 3.1); - _geometries[2] = new Point(1.2, 2.2, 3.2); - } + public GeometryCollectionTests() + { + _geometries = new Point[3]; + _geometries[0] = new Point(1, 2, 3); + _geometries[1] = new Point(1.1, 2.1, 3.1); + _geometries[2] = new Point(1.2, 2.2, 3.2); + } - private void CheckGeometries(GeometryCollection target, Geometry[] geometries) - { - Assert.Equal(geometries.Length, target.Geometries.Count); + private void CheckGeometries(GeometryCollection target, Geometry[] geometries) + { + Assert.Equal(geometries.Length, target.Geometries.Count); - for (int i = 0; i < geometries.Length; i++) - { - Assert.Same(geometries[i], target.Geometries[i]); - } + for (int i = 0; i < geometries.Length; i++) + { + Assert.Same(geometries[i], target.Geometries[i]); } + } - [Fact] - public void Constructor__CreatesNewEmptyCollection() - { - GeometryCollection target = new GeometryCollection(); + [Fact] + public void Constructor__CreatesNewEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); - Assert.NotNull(target.Geometries); - Assert.Empty(target.Geometries); - } + Assert.NotNull(target.Geometries); + Assert.Empty(target.Geometries); + } - [Fact] - public void Constructor_IEnumerable_CreateNewCollectionWithData() - { - GeometryCollection target = new GeometryCollection(_geometries); + [Fact] + public void Constructor_IEnumerable_CreateNewCollectionWithData() + { + GeometryCollection target = new GeometryCollection(_geometries); - CheckGeometries(target, _geometries); - } + CheckGeometries(target, _geometries); + } - [Fact] - public void Is3D_ReturnsFalseForEmptyCollection() - { - GeometryCollection target = new GeometryCollection(); + [Fact] + public void Is3D_ReturnsFalseForEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); - Assert.False(target.Is3D); - } + Assert.False(target.Is3D); + } - [Fact] - public void Is3D_ReturnsFalseForCollectionOf2DObjects() - { - var members2d = new Geometry[] { new Point(1, 2), new Point(2, 3) }; - GeometryCollection target = new GeometryCollection(members2d); + [Fact] + public void Is3D_ReturnsFalseForCollectionOf2DObjects() + { + var members2d = new Geometry[] { new Point(1, 2), new Point(2, 3) }; + GeometryCollection target = new GeometryCollection(members2d); - Assert.False(target.Is3D); - } + Assert.False(target.Is3D); + } - [Fact] - public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() - { - GeometryCollection target = new GeometryCollection(_geometries); + [Fact] + public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() + { + GeometryCollection target = new GeometryCollection(_geometries); - Assert.True(target.Is3D); - } + Assert.True(target.Is3D); + } - [Fact] - public void IsMeasured_ReturnsFalseForEmptyCollection() - { - GeometryCollection target = new GeometryCollection(); + [Fact] + public void IsMeasured_ReturnsFalseForEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); - Assert.False(target.IsMeasured); - } + Assert.False(target.IsMeasured); + } - [Fact] - public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() - { - GeometryCollection target = new GeometryCollection(_geometries); + [Fact] + public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() + { + GeometryCollection target = new GeometryCollection(_geometries); - Assert.False(target.IsMeasured); - } + Assert.False(target.IsMeasured); + } - [Fact] - public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() - { - var members = new Geometry[] { new Point(1, 2), new Point(2, 3, 4, 5) }; - GeometryCollection target = new GeometryCollection(members); + [Fact] + public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() + { + var members = new Geometry[] { new Point(1, 2), new Point(2, 3, 4, 5) }; + GeometryCollection target = new GeometryCollection(members); - Assert.True(target.IsMeasured); - } + Assert.True(target.IsMeasured); + } - [Fact] - public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() - { - GeometryCollection target = new GeometryCollection(); + [Fact] + public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() + { + GeometryCollection target = new GeometryCollection(); - Assert.Equal(Envelope.Empty, target.GetEnvelope()); - } + Assert.Equal(Envelope.Empty, target.GetEnvelope()); + } - [Fact] - public void GetEnvelopeReturnsUnionOfMembersEnvelopes() - { - GeometryCollection target = new GeometryCollection(_geometries); - Envelope expected = new Envelope(new Coordinate[] { _geometries[0].Position, _geometries[1].Position, _geometries[2].Position }); + [Fact] + public void GetEnvelopeReturnsUnionOfMembersEnvelopes() + { + GeometryCollection target = new GeometryCollection(_geometries); + Envelope expected = new Envelope(new Coordinate[] { _geometries[0].Position, _geometries[1].Position, _geometries[2].Position }); - Assert.Equal(expected, target.GetEnvelope()); - } + Assert.Equal(expected, target.GetEnvelope()); } } diff --git a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs index 4f208ed..34bb3af 100644 --- a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs @@ -9,177 +9,176 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class LineStringTests { - public class LineStringTests - { - Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(12,10), - new Coordinate(22,20), - new Coordinate(32,30) - }; + Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(12,10), + new Coordinate(22,20), + new Coordinate(32,30) + }; - Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(12,10,100), - new Coordinate(22,20,200), - new Coordinate(32,30,300) - }; + Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(12,10,100), + new Coordinate(22,20,200), + new Coordinate(32,30,300) + }; - Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(12,10,100, 1000), - new Coordinate(22,20,200, 2000), - new Coordinate(32,30,300, 3000) - }; + Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(12,10,100, 1000), + new Coordinate(22,20,200, 2000), + new Coordinate(32,30,300, 3000) + }; - private void CheckCoordinates(LineString target, Coordinate[] expectedPoints) - { - Assert.Equal(expectedPoints.Length, target.Coordinates.Count); + private void CheckCoordinates(LineString target, Coordinate[] expectedPoints) + { + Assert.Equal(expectedPoints.Length, target.Coordinates.Count); - for (int i = 0; i < expectedPoints.Length; i++) - { - Assert.Equal(expectedPoints[i], target.Coordinates[i]); - } + for (int i = 0; i < expectedPoints.Length; i++) + { + Assert.Equal(expectedPoints[i], target.Coordinates[i]); } + } - [Fact] - public void Constructor__CreatesEmptyLineString() - { - LineString target = new LineString(); + [Fact] + public void Constructor__CreatesEmptyLineString() + { + LineString target = new LineString(); - Assert.Equal(0, target.Coordinates.Count); - } + Assert.Equal(0, target.Coordinates.Count); + } - [Fact] - public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() - { - LineString target = new LineString(_coordinatesXYZ); + [Fact] + public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() + { + LineString target = new LineString(_coordinatesXYZ); - CheckCoordinates(target, _coordinatesXYZ); - } + CheckCoordinates(target, _coordinatesXYZ); + } - [Fact] - public void Is3D_ReturnsFalseForEmptyLineString() - { - LineString target = new LineString(); + [Fact] + public void Is3D_ReturnsFalseForEmptyLineString() + { + LineString target = new LineString(); - Assert.False(target.Is3D); - } + Assert.False(target.Is3D); + } - [Fact] - public void Is3D_ReturnsFalseForAll2DCoords() - { - LineString target = new LineString(_coordinatesXY); + [Fact] + public void Is3D_ReturnsFalseForAll2DCoords() + { + LineString target = new LineString(_coordinatesXY); - Assert.False(target.Is3D); - } + Assert.False(target.Is3D); + } - [Fact] - public void Is3D_ReturnsTrueForAll3DCoords() - { - LineString target = new LineString(_coordinatesXYZ); + [Fact] + public void Is3D_ReturnsTrueForAll3DCoords() + { + LineString target = new LineString(_coordinatesXYZ); - Assert.True(target.Is3D); - } + Assert.True(target.Is3D); + } - [Fact] - public void IsMeasured_ReturnsFalseForEmptyLineString() - { - LineString target = new LineString(); + [Fact] + public void IsMeasured_ReturnsFalseForEmptyLineString() + { + LineString target = new LineString(); - Assert.False(target.IsMeasured); - } + Assert.False(target.IsMeasured); + } - [Fact] - public void IsMeasured_ReturnsFalseForNonMeasuredCoords() - { - LineString target = new LineString(_coordinatesXYZ); + [Fact] + public void IsMeasured_ReturnsFalseForNonMeasuredCoords() + { + LineString target = new LineString(_coordinatesXYZ); - Assert.False(target.IsMeasured); - } + Assert.False(target.IsMeasured); + } - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredCoords() - { - LineString target = new LineString(_coordinatesXYZM); + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredCoords() + { + LineString target = new LineString(_coordinatesXYZM); - Assert.True(target.IsMeasured); - } + Assert.True(target.IsMeasured); + } - [Fact] - public void Start_ReturnsEmptyCoordinateForEmptyLineString() - { - LineString target = new LineString(); + [Fact] + public void Start_ReturnsEmptyCoordinateForEmptyLineString() + { + LineString target = new LineString(); - Assert.Equal(Coordinate.Empty, target.Start); - } + Assert.Equal(Coordinate.Empty, target.Start); + } - [Fact] - public void Start_ReturnsFirstCoordinate() - { - LineString target = new LineString(_coordinatesXYZ); + [Fact] + public void Start_ReturnsFirstCoordinate() + { + LineString target = new LineString(_coordinatesXYZ); - Assert.Equal(_coordinatesXYZ.First(), target.Start); - } + Assert.Equal(_coordinatesXYZ.First(), target.Start); + } - [Fact] - public void End_ReturnsEmptyCoordinateForEmptyLineString() - { - LineString target = new LineString(); + [Fact] + public void End_ReturnsEmptyCoordinateForEmptyLineString() + { + LineString target = new LineString(); - Assert.Equal(Coordinate.Empty, target.End); - } + Assert.Equal(Coordinate.Empty, target.End); + } - [Fact] - public void End_ReturnsLastCoordinate() - { - LineString target = new LineString(_coordinatesXYZ); + [Fact] + public void End_ReturnsLastCoordinate() + { + LineString target = new LineString(_coordinatesXYZ); - Assert.Equal(_coordinatesXYZ.Last(), target.End); - } + Assert.Equal(_coordinatesXYZ.Last(), target.End); + } - [Fact] - public void IsClosed_ReturnsTrueForClosedLineString() - { - LineString target = new LineString(_coordinatesXYZ); - target.Coordinates.Add(target.Coordinates[0]); + [Fact] + public void IsClosed_ReturnsTrueForClosedLineString() + { + LineString target = new LineString(_coordinatesXYZ); + target.Coordinates.Add(target.Coordinates[0]); - Assert.True(target.IsClosed); - } + Assert.True(target.IsClosed); + } - [Fact] - public void IsClosed_ReturnsFalseForOpenLineString() - { - LineString target = new LineString(_coordinatesXYZ); + [Fact] + public void IsClosed_ReturnsFalseForOpenLineString() + { + LineString target = new LineString(_coordinatesXYZ); - Assert.False(target.IsClosed); - } + Assert.False(target.IsClosed); + } - [Fact] - public void IsClosed_ReturnsFalseForEmptyLineString() - { - LineString target = new LineString(); + [Fact] + public void IsClosed_ReturnsFalseForEmptyLineString() + { + LineString target = new LineString(); - Assert.False(target.IsClosed); - } + Assert.False(target.IsClosed); + } - [Fact] - public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() - { - LineString target = new LineString(); - Envelope envelope = target.GetEnvelope(); + [Fact] + public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() + { + LineString target = new LineString(); + Envelope envelope = target.GetEnvelope(); - Assert.Equal(Envelope.Empty, envelope); - } + Assert.Equal(Envelope.Empty, envelope); + } - [Fact] - public void GetEnvelope_ReturnsEnvelopeOfLineString() - { - LineString target = new LineString(_coordinatesXYZ); - Envelope expected = new Envelope(_coordinatesXYZ); + [Fact] + public void GetEnvelope_ReturnsEnvelopeOfLineString() + { + LineString target = new LineString(_coordinatesXYZ); + Envelope expected = new Envelope(_coordinatesXYZ); - Assert.Equal(expected, target.GetEnvelope()); - } + Assert.Equal(expected, target.GetEnvelope()); } } diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs index 2bc4d0c..74d3307 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs @@ -3,10 +3,9 @@ using System.Linq; using System.Text; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class MultiLineStringTests { - public class MultiLineStringTests - { - //The current implementation of MultiLineString just calls parents constructors, so nothing worth testing - } + //The current implementation of MultiLineString just calls parents constructors, so nothing worth testing } diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs index 0810afa..a311b60 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs @@ -3,10 +3,9 @@ using System.Linq; using System.Text; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class MultiPointTests { - public class MultiPointTests - { - //The current implementation of MultiPoint just calls parent constructors, so nothing worth testing - } + //The current implementation of MultiPoint just calls parent constructors, so nothing worth testing } diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs index f8b1285..4fc5138 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs @@ -3,10 +3,9 @@ using System.Linq; using System.Text; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class MultiPolygonTests { - public class MultiPolygonTests - { - //The current implementation of MultiPolygon just calls parents constructors, so nothing worth testing - } + //The current implementation of MultiPolygon just calls parents constructors, so nothing worth testing } diff --git a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs index 38cd3fe..da68202 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs @@ -9,132 +9,131 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class PointTests { - public class PointTests + + double _xOrdinate = 3.5; + double _yOrdinate = 4.2; + double _zOrdinate = 10.5; + double _mValue = 100.4; + + Coordinate _coordinate; + public PointTests() + { + _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); + } + + private void ChenckPosition(Point target, double x, double y, double z, double m) + { + Assert.Equal(x, target.Position.X); + Assert.Equal(y, target.Position.Y); + Assert.Equal(z, target.Position.Z); + Assert.Equal(m, target.Position.M); + } + + [Fact] + public void Constructor__CreatesPointWithEmptyPosition() + { + Point target = new Point(); + + Assert.Equal(Coordinate.Empty, target.Position); + } + + [Fact] + public void Constructor_XY_SetsCoordinates() + { + Point target = new Point(_xOrdinate, _yOrdinate); + + ChenckPosition(target, _xOrdinate, _yOrdinate, double.NaN, double.NaN); + } + + [Fact] + public void Constructor_XYZ_SetsCoordinates() + { + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); + + ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, double.NaN); + } + + [Fact] + public void Constructor_XYZM_SetsCoordinates() { + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - double _mValue = 100.4; - - Coordinate _coordinate; - public PointTests() - { - _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); - } - - private void ChenckPosition(Point target, double x, double y, double z, double m) - { - Assert.Equal(x, target.Position.X); - Assert.Equal(y, target.Position.Y); - Assert.Equal(z, target.Position.Z); - Assert.Equal(m, target.Position.M); - } - - [Fact] - public void Constructor__CreatesPointWithEmptyPosition() - { - Point target = new Point(); - - Assert.Equal(Coordinate.Empty, target.Position); - } - - [Fact] - public void Constructor_XY_SetsCoordinates() - { - Point target = new Point(_xOrdinate, _yOrdinate); - - ChenckPosition(target, _xOrdinate, _yOrdinate, double.NaN, double.NaN); - } - - [Fact] - public void Constructor_XYZ_SetsCoordinates() - { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); - - ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, double.NaN); - } - - [Fact] - public void Constructor_XYZM_SetsCoordinates() - { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); - - ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, _mValue); - } - - [Fact] - public void Constructor_Coordinate_SetsCoordinates() - { - Point target = new Point(_coordinate); - - Assert.Equal(_coordinate, target.Position); - } - - [Fact] - public void Is3D_ReturnsTrueFor3DPoint() - { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); - - Assert.True(target.Is3D); - } - - [Fact] - public void Is3D_ReturnsFalseFor2DPoint() - { - Point target = new Point(_xOrdinate, _yOrdinate); - - Assert.False(target.Is3D); - } - - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredPoint() - { - Point target = new Point(_xOrdinate, _yOrdinate, double.NaN, _mValue); - - Assert.True(target.IsMeasured); - } - - [Fact] - public void IsMeasured_ReturnsFalseForNonMeasuredPoint() - { - Point target = new Point(_xOrdinate, _yOrdinate); - - Assert.False(target.IsMeasured); - } - - [Fact] - public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() - { - Point target = new Point(); - Envelope envelope = target.GetEnvelope(); - - Assert.Equal(double.NaN, envelope.MinX); - Assert.Equal(double.NaN, envelope.MaxX); - Assert.Equal(double.NaN, envelope.MinY); - Assert.Equal(double.NaN, envelope.MaxY); - Assert.Equal(double.NaN, envelope.MinZ); - Assert.Equal(double.NaN, envelope.MaxZ); - Assert.Equal(double.NaN, envelope.MinM); - Assert.Equal(double.NaN, envelope.MaxM); - } - - [Fact] - public void GetEnvelope_ReturnsEnvelopeThatCoversOnePoint() - { - Point target = new Point(_coordinate); - Envelope envelope = target.GetEnvelope(); - - Assert.Equal(_coordinate.X, envelope.MinX); - Assert.Equal(_coordinate.X, envelope.MaxX); - Assert.Equal(_coordinate.Y, envelope.MinY); - Assert.Equal(_coordinate.Y, envelope.MaxY); - Assert.Equal(_coordinate.Z, envelope.MinZ); - Assert.Equal(_coordinate.Z, envelope.MaxZ); - Assert.Equal(_coordinate.M, envelope.MinM); - Assert.Equal(_coordinate.M, envelope.MaxM); - } + ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, _mValue); + } + + [Fact] + public void Constructor_Coordinate_SetsCoordinates() + { + Point target = new Point(_coordinate); + + Assert.Equal(_coordinate, target.Position); + } + + [Fact] + public void Is3D_ReturnsTrueFor3DPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); + + Assert.True(target.Is3D); + } + + [Fact] + public void Is3D_ReturnsFalseFor2DPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate); + + Assert.False(target.Is3D); + } + + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate, double.NaN, _mValue); + + Assert.True(target.IsMeasured); + } + + [Fact] + public void IsMeasured_ReturnsFalseForNonMeasuredPoint() + { + Point target = new Point(_xOrdinate, _yOrdinate); + + Assert.False(target.IsMeasured); + } + + [Fact] + public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() + { + Point target = new Point(); + Envelope envelope = target.GetEnvelope(); + + Assert.Equal(double.NaN, envelope.MinX); + Assert.Equal(double.NaN, envelope.MaxX); + Assert.Equal(double.NaN, envelope.MinY); + Assert.Equal(double.NaN, envelope.MaxY); + Assert.Equal(double.NaN, envelope.MinZ); + Assert.Equal(double.NaN, envelope.MaxZ); + Assert.Equal(double.NaN, envelope.MinM); + Assert.Equal(double.NaN, envelope.MaxM); + } + + [Fact] + public void GetEnvelope_ReturnsEnvelopeThatCoversOnePoint() + { + Point target = new Point(_coordinate); + Envelope envelope = target.GetEnvelope(); + + Assert.Equal(_coordinate.X, envelope.MinX); + Assert.Equal(_coordinate.X, envelope.MaxX); + Assert.Equal(_coordinate.Y, envelope.MinY); + Assert.Equal(_coordinate.Y, envelope.MaxY); + Assert.Equal(_coordinate.Z, envelope.MinZ); + Assert.Equal(_coordinate.Z, envelope.MaxZ); + Assert.Equal(_coordinate.M, envelope.MinM); + Assert.Equal(_coordinate.M, envelope.MaxM); } } diff --git a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs index fe92ad3..5f52c66 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs @@ -9,133 +9,132 @@ using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class PolygonTests { - public class PolygonTests - { - Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(1, 2), new Coordinate(1.1, 2.1), new Coordinate(1.2, 2.2), new Coordinate(1.3, 2.3) - }; + Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(1, 2), new Coordinate(1.1, 2.1), new Coordinate(1.2, 2.2), new Coordinate(1.3, 2.3) + }; - Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(1, 2, 3), new Coordinate(1.1, 2.1, 3.1), new Coordinate(1.2, 2.2, 3.2), new Coordinate(1.3, 2.3, 3.3) - }; + Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(1, 2, 3), new Coordinate(1.1, 2.1, 3.1), new Coordinate(1.2, 2.2, 3.2), new Coordinate(1.3, 2.3, 3.3) + }; - Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(1, 2, 3, 10), new Coordinate(1.1, 2.1, 3.1, 20), new Coordinate(1.2, 2.2, 3.2, 30), new Coordinate(1.3, 2.3, 3.3, 40) - }; + Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(1, 2, 3, 10), new Coordinate(1.1, 2.1, 3.1, 20), new Coordinate(1.2, 2.2, 3.2, 30), new Coordinate(1.3, 2.3, 3.3, 40) + }; - CoordinateList _exteriorRing3D; - CoordinateList[] _interiorRings3D; + CoordinateList _exteriorRing3D; + CoordinateList[] _interiorRings3D; - public PolygonTests() - { - _exteriorRing3D = new CoordinateList(_coordinatesXYZ); + public PolygonTests() + { + _exteriorRing3D = new CoordinateList(_coordinatesXYZ); - _interiorRings3D = new CoordinateList[2]; - _interiorRings3D[0] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[0], _coordinatesXYZ[1], _coordinatesXYZ[0] }); - _interiorRings3D[1] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[1], _coordinatesXYZ[2], _coordinatesXYZ[1] }); - } + _interiorRings3D = new CoordinateList[2]; + _interiorRings3D[0] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[0], _coordinatesXYZ[1], _coordinatesXYZ[0] }); + _interiorRings3D[1] = new CoordinateList(new Coordinate[] { _coordinatesXYZ[1], _coordinatesXYZ[2], _coordinatesXYZ[1] }); + } - private void CheckInteriorRings(Polygon target, CoordinateList[] expected) + private void CheckInteriorRings(Polygon target, CoordinateList[] expected) + { + Assert.Equal(expected.Length, target.InteriorRings.Count); + for (int i = 0; i < expected.Length; i++) { - Assert.Equal(expected.Length, target.InteriorRings.Count); - for (int i = 0; i < expected.Length; i++) - { - Assert.Same(expected[i], target.InteriorRings[i]); - } + Assert.Same(expected[i], target.InteriorRings[i]); } + } - [Fact] - public void Constructor__CreatesEmptyPolygonAndInitializesProperties() - { - Polygon target = new Polygon(); + [Fact] + public void Constructor__CreatesEmptyPolygonAndInitializesProperties() + { + Polygon target = new Polygon(); - Assert.NotNull(target.ExteriorRing); - Assert.Empty(target.ExteriorRing); + Assert.NotNull(target.ExteriorRing); + Assert.Empty(target.ExteriorRing); - Assert.NotNull(target.InteriorRings); - Assert.Empty(target.InteriorRings); - } + Assert.NotNull(target.InteriorRings); + Assert.Empty(target.InteriorRings); + } - [Fact] - public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() - { - Polygon target = new Polygon(_exteriorRing3D); + [Fact] + public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() + { + Polygon target = new Polygon(_exteriorRing3D); - Assert.Same(_exteriorRing3D, target.ExteriorRing); + Assert.Same(_exteriorRing3D, target.ExteriorRing); - Assert.NotNull(target.InteriorRings); - Assert.Empty(target.InteriorRings); - } + Assert.NotNull(target.InteriorRings); + Assert.Empty(target.InteriorRings); + } - [Fact] - public void Is3D_ReturnsTrueFor3DExteriorRing() - { - Polygon target = new Polygon(_exteriorRing3D); + [Fact] + public void Is3D_ReturnsTrueFor3DExteriorRing() + { + Polygon target = new Polygon(_exteriorRing3D); - Assert.True(target.Is3D); - } + Assert.True(target.Is3D); + } - [Fact] - public void Is3D_ReturnsFalseForEmptyPolygon() - { - Polygon target = new Polygon(); + [Fact] + public void Is3D_ReturnsFalseForEmptyPolygon() + { + Polygon target = new Polygon(); - Assert.False(target.Is3D); - } + Assert.False(target.Is3D); + } - [Fact] - public void Is3D_ReturnsFalseFor2DExteriorRing() - { - Polygon target = new Polygon(new CoordinateList(_coordinatesXY)); + [Fact] + public void Is3D_ReturnsFalseFor2DExteriorRing() + { + Polygon target = new Polygon(new CoordinateList(_coordinatesXY)); - Assert.False(target.Is3D); - } + Assert.False(target.Is3D); + } - [Fact] - public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() - { - Polygon target = new Polygon(new CoordinateList(_coordinatesXYZM)); + [Fact] + public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() + { + Polygon target = new Polygon(new CoordinateList(_coordinatesXYZM)); - Assert.True(target.IsMeasured); - } + Assert.True(target.IsMeasured); + } - [Fact] - public void IsMeasured_ReturnsFalseForEmptyPolygon() - { - Polygon target = new Polygon(); + [Fact] + public void IsMeasured_ReturnsFalseForEmptyPolygon() + { + Polygon target = new Polygon(); - Assert.False(target.IsMeasured); - } + Assert.False(target.IsMeasured); + } - [Fact] - public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() - { - Polygon target = new Polygon(new CoordinateList(_coordinatesXYZ)); + [Fact] + public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() + { + Polygon target = new Polygon(new CoordinateList(_coordinatesXYZ)); - Assert.False(target.IsMeasured); - } + Assert.False(target.IsMeasured); + } - [Fact] - public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() - { - Polygon target = new Polygon(); - Envelope envelope = target.GetEnvelope(); + [Fact] + public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() + { + Polygon target = new Polygon(); + Envelope envelope = target.GetEnvelope(); - Assert.Equal(Envelope.Empty, envelope); - } + Assert.Equal(Envelope.Empty, envelope); + } - [Fact] - public void GetEnvelopeReturnsEnvelopeOfLineString() - { - Envelope expectedEnvelope = new Envelope(_coordinatesXYZ); + [Fact] + public void GetEnvelopeReturnsEnvelopeOfLineString() + { + Envelope expectedEnvelope = new Envelope(_coordinatesXYZ); - Polygon target = new Polygon(_exteriorRing3D); - Envelope envelope = target.GetEnvelope(); + Polygon target = new Polygon(_exteriorRing3D); + Envelope envelope = target.GetEnvelope(); - Assert.Equal(expectedEnvelope, envelope); - } + Assert.Equal(expectedEnvelope, envelope); } } diff --git a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs index 9faeb47..32c02c5 100644 --- a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs @@ -8,89 +8,88 @@ using SpatialLite.Core.Geometries; using SpatialLite.Core.API; -namespace Tests.SpatialLite.Core.Geometries +namespace Tests.SpatialLite.Core.Geometries; + +public class ReadOnlyCoordinateListTests { - public class ReadOnlyCoordinateListTests - { - List _points = new List(new Point[] { - new Point(5, 1.1, 2.2), - new Point(6, 10.1, -20.2), - new Point(7, -30.1, 40.2) }); + List _points = new List(new Point[] { + new Point(5, 1.1, 2.2), + new Point(6, 10.1, -20.2), + new Point(7, -30.1, 40.2) }); - [Fact] - public void Constructor_Source_SetsSource() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Constructor_Source_SetsSource() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Same(_points, target.Source); - } + Assert.Same(_points, target.Source); + } - [Fact] - public void Indexer_Get_ReturnsCoordinatesFromSourceList() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Indexer_Get_ReturnsCoordinatesFromSourceList() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - for (int i = 0; i < _points.Count; i++) - { - Assert.Equal(_points[i].Position, target[i]); - } + for (int i = 0; i < _points.Count; i++) + { + Assert.Equal(_points[i].Position, target[i]); } + } - [Fact] - public void Indexer_Set_ThrowsNotSupportedException() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Indexer_Set_ThrowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); - } + Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); + } - [Fact] - public void Count_GetsNumberOfItemsInSourceCollection() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Count_GetsNumberOfItemsInSourceCollection() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Equal(_points.Count, target.Count); - } + Assert.Equal(_points.Count, target.Count); + } - [Fact] - public void Add_Coordinate_ThowsNotSupportedException() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Add_Coordinate_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Throws(() => target.Add(Coordinate.Empty)); - } + Assert.Throws(() => target.Add(Coordinate.Empty)); + } - [Fact] - public void Add_Coordinates_ThowsNotSupportedException() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Add_Coordinates_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); - } + Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); + } - [Fact] - public void Insert_Index_Coordinate_ThowsNotSupportedException() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Insert_Index_Coordinate_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Throws(() => target.Insert(0, Coordinate.Empty)); - } + Assert.Throws(() => target.Insert(0, Coordinate.Empty)); + } - [Fact] - public void RemoveAt_Index_ThowsNotSupportedException() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void RemoveAt_Index_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Throws(() => target.RemoveAt(0)); - } + Assert.Throws(() => target.RemoveAt(0)); + } - [Fact] - public void Clear_ThowsNotSupportedException() - { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + [Fact] + public void Clear_ThowsNotSupportedException() + { + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Throws(() => target.Clear()); - } + Assert.Throws(() => target.Clear()); } } diff --git a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs index e314a51..05397c6 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs @@ -11,686 +11,685 @@ using SpatialLite.Core.Geometries; using SpatialLite.Core.IO; -namespace Tests.SpatialLite.Core.IO +namespace Tests.SpatialLite.Core.IO; + +public class WkbReaderTests { - public class WkbReaderTests + [Fact] + public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() { - [Fact] - public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() - { - Stream stream = null; - Assert.Throws(() => new WkbReader(stream)); - } + Stream stream = null; + Assert.Throws(() => new WkbReader(stream)); + } - [Fact] - public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() - { - Assert.Throws(() => new WkbReader("non-existing-file.wkb")); - } + [Fact] + public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() + { + Assert.Throws(() => new WkbReader("non-existing-file.wkb")); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = "../../../Data/IO/point-3DM.wkb"; + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/IO/point-3DM.wkb"; - WkbReader target = new WkbReader(filename); - target.Dispose(); + WkbReader target = new WkbReader(filename); + target.Dispose(); - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() - { - var stream = TestDataReader.Open("point-3DM.wkb"); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + var stream = TestDataReader.Open("point-3DM.wkb"); - WkbReader target = new WkbReader(stream); - target.Dispose(); + WkbReader target = new WkbReader(stream); + target.Dispose(); - Assert.False(stream.CanRead); - } + Assert.False(stream.CanRead); + } - [Fact] - public void Read_ReturnsNullIfStreamIsEmpty() - { - MemoryStream stream = new MemoryStream(); + [Fact] + public void Read_ReturnsNullIfStreamIsEmpty() + { + MemoryStream stream = new MemoryStream(); - WkbReader target = new WkbReader(stream); - Geometry read = target.Read(); + WkbReader target = new WkbReader(stream); + Geometry read = target.Read(); - Assert.Null(read); - } + Assert.Null(read); + } - [Fact] - public void Read_ReadsGeometry() - { - Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + [Fact] + public void Read_ReadsGeometry() + { + Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - Point parsed = (Point)target.Read(); + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + Point parsed = (Point)target.Read(); - this.ComparePoints(parsed, expected); - } + this.ComparePoints(parsed, expected); + } - [Fact] - public void Read_ReadsMultipleGeometries() - { - Point expected1 = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - Point expected2 = (Point)this.ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); + [Fact] + public void Read_ReadsMultipleGeometries() + { + Point expected1 = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + Point expected2 = (Point)this.ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); - WkbReader target = new WkbReader(TestDataReader.Open("two-points-3DM.wkb")); + WkbReader target = new WkbReader(TestDataReader.Open("two-points-3DM.wkb")); - Point parsed1 = (Point)target.Read(); - this.ComparePoints(parsed1, expected1); + Point parsed1 = (Point)target.Read(); + this.ComparePoints(parsed1, expected1); - Point parsed2 = (Point)target.Read(); - this.ComparePoints(parsed2, expected2); - } + Point parsed2 = (Point)target.Read(); + this.ComparePoints(parsed2, expected2); + } - [Fact] - public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() - { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + [Fact] + public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() + { + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - target.Read(); - Geometry parsed = target.Read(); + target.Read(); + Geometry parsed = target.Read(); - Assert.Null(parsed); - } + Assert.Null(parsed); + } - [Fact] - public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + [Fact] + public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + { + byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; + using (MemoryStream ms = new MemoryStream(wkb)) { - byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new MemoryStream(wkb)) - { - WkbReader target = new WkbReader(ms); + WkbReader target = new WkbReader(ms); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); } + } - [Fact] - public void ReadT_ReturnsNullIfStreamIsEmpty() - { - MemoryStream stream = new MemoryStream(); + [Fact] + public void ReadT_ReturnsNullIfStreamIsEmpty() + { + MemoryStream stream = new MemoryStream(); - WkbReader target = new WkbReader(stream); - Geometry read = target.Read(); + WkbReader target = new WkbReader(stream); + Geometry read = target.Read(); - Assert.Null(read); - } + Assert.Null(read); + } - [Fact] - public void ReadT_ReadsGeometry() - { - Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + [Fact] + public void ReadT_ReadsGeometry() + { + Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - Point parsed = target.Read(); + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + Point parsed = target.Read(); - this.ComparePoints(parsed, expected); - } + this.ComparePoints(parsed, expected); + } - [Fact] - public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() - { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + [Fact] + public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() + { + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - target.Read(); - Geometry parsed = target.Read(); + target.Read(); + Geometry parsed = target.Read(); - Assert.Null(parsed); - } + Assert.Null(parsed); + } - [Fact] - public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + [Fact] + public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + { + byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; + using (MemoryStream ms = new MemoryStream(wkb)) { - byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new MemoryStream(wkb)) - { - WkbReader target = new WkbReader(ms); + WkbReader target = new WkbReader(ms); - Assert.Throws(() => target.Read()); - } - } - - [Fact] - public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiecGeometryType() - { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - Assert.Throws(() => target.Read()); + Assert.Throws(() => target.Read()); } + } - [Fact] - public void Parse_ThrowsExceptionIfWKBDoesNotRepresentGeometry() - { - byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; + [Fact] + public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiecGeometryType() + { + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + Assert.Throws(() => target.Read()); + } - Assert.Throws(() => WkbReader.Parse(wkb)); - } + [Fact] + public void Parse_ThrowsExceptionIfWKBDoesNotRepresentGeometry() + { + byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - [Fact] - public void Parse_ReturnsNullForEmptyInput() - { - byte[] wkb = new byte[0]; + Assert.Throws(() => WkbReader.Parse(wkb)); + } - Assert.Null(WkbReader.Parse(wkb)); - } + [Fact] + public void Parse_ReturnsNullForEmptyInput() + { + byte[] wkb = new byte[0]; - [Fact] - public void Parse_ThrowsArgumentNullExceptionIfDataIsNull() - { - Assert.Throws(() => WkbReader.Parse(null)); - } + Assert.Null(WkbReader.Parse(wkb)); + } - [Fact] - public void Parse_ReturnsParsedGeometry() - { - string wkt = "point m (-10.1 15.5 1000.5)"; - Point expected = (Point)this.ParseWKT(wkt); - Point parsed = (Point)WkbReader.Parse(TestDataReader.Read("point-2DM.wkb")); + [Fact] + public void Parse_ThrowsArgumentNullExceptionIfDataIsNull() + { + Assert.Throws(() => WkbReader.Parse(null)); + } - this.ComparePoints(parsed, expected); - } + [Fact] + public void Parse_ReturnsParsedGeometry() + { + string wkt = "point m (-10.1 15.5 1000.5)"; + Point expected = (Point)this.ParseWKT(wkt); + Point parsed = (Point)WkbReader.Parse(TestDataReader.Read("point-2DM.wkb")); - [Fact] - public void ParseT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiedType() - { - byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); + this.ComparePoints(parsed, expected); + } - Assert.Throws(() => WkbReader.Parse(wkb)); - } + [Fact] + public void ParseT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiedType() + { + byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); - [Fact] - public void ParseT_ReturnsNullForEmptyInput() - { - byte[] wkb = new byte[0]; + Assert.Throws(() => WkbReader.Parse(wkb)); + } - Assert.Null(WkbReader.Parse(wkb)); - } + [Fact] + public void ParseT_ReturnsNullForEmptyInput() + { + byte[] wkb = new byte[0]; - [Fact] - public void ParseT_ThrowsArgumentNullExceptionIfDataIsNull() - { - Assert.Throws(() => WkbReader.Parse(null)); - } + Assert.Null(WkbReader.Parse(wkb)); + } - [Fact] - public void ParsePoint_Parses2DPoint() - { - string wkt = "point (-10.1 15.5)"; - byte[] wkb = TestDataReader.Read("point-2D.wkb"); + [Fact] + public void ParseT_ThrowsArgumentNullExceptionIfDataIsNull() + { + Assert.Throws(() => WkbReader.Parse(null)); + } - this.TestParsePoint(wkb, wkt); - } + [Fact] + public void ParsePoint_Parses2DPoint() + { + string wkt = "point (-10.1 15.5)"; + byte[] wkb = TestDataReader.Read("point-2D.wkb"); - [Fact] - public void ParsePoint_Parses2DMeasuredPoint() - { - string wkt = "point m (-10.1 15.5 1000.5)"; - byte[] wkb = TestDataReader.Read("point-2DM.wkb"); + this.TestParsePoint(wkb, wkt); + } - this.TestParsePoint(wkb, wkt); - } + [Fact] + public void ParsePoint_Parses2DMeasuredPoint() + { + string wkt = "point m (-10.1 15.5 1000.5)"; + byte[] wkb = TestDataReader.Read("point-2DM.wkb"); - [Fact] - public void ParsePoint_Parses3DPoint() - { - string wkt = "point z (-10.1 15.5 100.5)"; - byte[] wkb = TestDataReader.Read("point-3D.wkb"); + this.TestParsePoint(wkb, wkt); + } - this.TestParsePoint(wkb, wkt); - } + [Fact] + public void ParsePoint_Parses3DPoint() + { + string wkt = "point z (-10.1 15.5 100.5)"; + byte[] wkb = TestDataReader.Read("point-3D.wkb"); - [Fact] - public void ParsePoint_Parses3DMeasuredPoint() - { - string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; - byte[] wkb = TestDataReader.Read("point-3DM.wkb"); + this.TestParsePoint(wkb, wkt); + } - this.TestParsePoint(wkb, wkt); - } + [Fact] + public void ParsePoint_Parses3DMeasuredPoint() + { + string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; + byte[] wkb = TestDataReader.Read("point-3DM.wkb"); - [Fact] - public void Parse_ParsesEmptyLineString() - { - string wkt = "linestring empty"; - byte[] wkb = TestDataReader.Read("linestring-empty.wkb"); + this.TestParsePoint(wkb, wkt); + } - this.TestParseLineString(wkb, wkt); - } + [Fact] + public void Parse_ParsesEmptyLineString() + { + string wkt = "linestring empty"; + byte[] wkb = TestDataReader.Read("linestring-empty.wkb"); - [Fact] - public void Parse_Parses2DLineString() - { - string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; - byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); + this.TestParseLineString(wkb, wkt); + } - this.TestParseLineString(wkb, wkt); - } + [Fact] + public void Parse_Parses2DLineString() + { + string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; + byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); - [Fact] - public void Parse_Parses2DMeasuredLineString() - { - string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; - byte[] wkb = TestDataReader.Read("linestring-2DM.wkb"); + this.TestParseLineString(wkb, wkt); + } - this.TestParseLineString(wkb, wkt); - } + [Fact] + public void Parse_Parses2DMeasuredLineString() + { + string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; + byte[] wkb = TestDataReader.Read("linestring-2DM.wkb"); - [Fact] - public void Parse_Parses3DLineString() - { - string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; - byte[] wkb = TestDataReader.Read("linestring-3D.wkb"); - this.TestParseLineString(wkb, wkt); - } + this.TestParseLineString(wkb, wkt); + } - [Fact] - public void Parse_Parses3DMeasuredLineString() - { - string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; - byte[] wkb = TestDataReader.Read("linestring-3DM.wkb"); + [Fact] + public void Parse_Parses3DLineString() + { + string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; + byte[] wkb = TestDataReader.Read("linestring-3D.wkb"); + this.TestParseLineString(wkb, wkt); + } - this.TestParseLineString(wkb, wkt); - } + [Fact] + public void Parse_Parses3DMeasuredLineString() + { + string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; + byte[] wkb = TestDataReader.Read("linestring-3DM.wkb"); - [Fact] - public void Parse_ParsesEmptyPolygon() - { - string wkt = "polygon empty"; - byte[] wkb = TestDataReader.Read("polygon-empty.wkb"); + this.TestParseLineString(wkb, wkt); + } - this.TestParsePolygon(wkb, wkt); - } + [Fact] + public void Parse_ParsesEmptyPolygon() + { + string wkt = "polygon empty"; + byte[] wkb = TestDataReader.Read("polygon-empty.wkb"); - [Fact] - public void Parse_Parses2DPolygonOnlyExteriorRing() - { - string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-2D.wkb"); + this.TestParsePolygon(wkb, wkt); + } - this.TestParsePolygon(wkb, wkt); - } + [Fact] + public void Parse_Parses2DPolygonOnlyExteriorRing() + { + string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-2D.wkb"); - [Fact] - public void Parse_Parses2DMeasuredPolygonOnlyExteriorRing() - { - string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-2DM.wkb"); + this.TestParsePolygon(wkb, wkt); + } - this.TestParsePolygon(wkb, wkt); - } + [Fact] + public void Parse_Parses2DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-2DM.wkb"); - [Fact] - public void Parse_Parses3DPolygonOnlyExteriorRing() - { - string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-3D.wkb"); + this.TestParsePolygon(wkb, wkt); + } - this.TestParsePolygon(wkb, wkt); - } + [Fact] + public void Parse_Parses3DPolygonOnlyExteriorRing() + { + string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-3D.wkb"); - [Fact] - public void Parse_Parses3DMeasuredPolygonOnlyExteriorRing() - { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("polygon-ext-3DM.wkb"); + this.TestParsePolygon(wkb, wkt); + } - this.TestParsePolygon(wkb, wkt); - } + [Fact] + public void Parse_Parses3DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("polygon-ext-3DM.wkb"); - [Fact] - public void Parse_Parses3DMeasuredPolygon() - { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - byte[] wkb = TestDataReader.Read("polygon-3DM.wkb"); + this.TestParsePolygon(wkb, wkt); + } - this.TestParsePolygon(wkb, wkt); - } + [Fact] + public void Parse_Parses3DMeasuredPolygon() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + byte[] wkb = TestDataReader.Read("polygon-3DM.wkb"); - [Fact] - public void ParseMultiPoint_ParsesEmptyMultipoint() - { - string wkt = "multipoint empty"; - byte[] wkb = TestDataReader.Read("multipoint-empty.wkb"); + this.TestParsePolygon(wkb, wkt); + } - this.TestParseMultiPoint(wkb, wkt); - } + [Fact] + public void ParseMultiPoint_ParsesEmptyMultipoint() + { + string wkt = "multipoint empty"; + byte[] wkb = TestDataReader.Read("multipoint-empty.wkb"); - [Fact] - public void ParseMultiPoint_Parses2DMultiPoint() - { - string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; - byte[] wkb = TestDataReader.Read("multipoint-2D.wkb"); + this.TestParseMultiPoint(wkb, wkt); + } - this.TestParseMultiPoint(wkb, wkt); - } + [Fact] + public void ParseMultiPoint_Parses2DMultiPoint() + { + string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; + byte[] wkb = TestDataReader.Read("multipoint-2D.wkb"); - [Fact] - public void ParseMultiPoint_Parses2DMeasuredMultiPoint() - { - string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; - byte[] wkb = TestDataReader.Read("multipoint-2DM.wkb"); + this.TestParseMultiPoint(wkb, wkt); + } - this.TestParseMultiPoint(wkb, wkt); - } + [Fact] + public void ParseMultiPoint_Parses2DMeasuredMultiPoint() + { + string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; + byte[] wkb = TestDataReader.Read("multipoint-2DM.wkb"); - [Fact] - public void ParseMultiPoint_Parses3DMultiPoint() - { - string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; - byte[] wkb = TestDataReader.Read("multipoint-3D.wkb"); + this.TestParseMultiPoint(wkb, wkt); + } - this.TestParseMultiPoint(wkb, wkt); - } + [Fact] + public void ParseMultiPoint_Parses3DMultiPoint() + { + string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; + byte[] wkb = TestDataReader.Read("multipoint-3D.wkb"); - [Fact] - public void ParseMultiPoint_Parses3DMeasuredMultiPoint() - { - string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; - byte[] wkb = TestDataReader.Read("multipoint-3DM.wkb"); + this.TestParseMultiPoint(wkb, wkt); + } - this.TestParseMultiPoint(wkb, wkt); - } + [Fact] + public void ParseMultiPoint_Parses3DMeasuredMultiPoint() + { + string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; + byte[] wkb = TestDataReader.Read("multipoint-3DM.wkb"); - [Fact] - public void ParseMultiLineString_ParsesEmptyMultiLineString() - { - string wkt = "multilinestring empty"; - byte[] wkb = TestDataReader.Read("multilinestring-empty.wkb"); + this.TestParseMultiPoint(wkb, wkt); + } - this.TestParseMultiLineString(wkb, wkt); - } + [Fact] + public void ParseMultiLineString_ParsesEmptyMultiLineString() + { + string wkt = "multilinestring empty"; + byte[] wkb = TestDataReader.Read("multilinestring-empty.wkb"); - [Fact] - public void ParseMultiLineString_Parses2DMultiLineString() - { - string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-2D.wkb"); + this.TestParseMultiLineString(wkb, wkt); + } - this.TestParseMultiLineString(wkb, wkt); - } + [Fact] + public void ParseMultiLineString_Parses2DMultiLineString() + { + string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-2D.wkb"); - [Fact] - public void ParseMultiLineString_Parses2DMeasuredMultiLineString() - { - string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-2DM.wkb"); + this.TestParseMultiLineString(wkb, wkt); + } - this.TestParseMultiLineString(wkb, wkt); - } + [Fact] + public void ParseMultiLineString_Parses2DMeasuredMultiLineString() + { + string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-2DM.wkb"); - [Fact] - public void ParseMultiLineString_Parses3DMultiLineString() - { - string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-3D.wkb"); + this.TestParseMultiLineString(wkb, wkt); + } - this.TestParseMultiLineString(wkb, wkt); - } + [Fact] + public void ParseMultiLineString_Parses3DMultiLineString() + { + string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-3D.wkb"); - [Fact] - public void ParseMultiLineString_Parses3DMeasuredMultiLineString() - { - string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - byte[] wkb = TestDataReader.Read("multilinestring-3DM.wkb"); + this.TestParseMultiLineString(wkb, wkt); + } - this.TestParseMultiLineString(wkb, wkt); - } + [Fact] + public void ParseMultiLineString_Parses3DMeasuredMultiLineString() + { + string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + byte[] wkb = TestDataReader.Read("multilinestring-3DM.wkb"); - [Fact] - public void ParseMultiPolygon_ParsesEmptyMultiPolygon() - { - string wkt = "multipolygon empty"; - byte[] wkb = TestDataReader.Read("multipolygon-empty.wkb"); + this.TestParseMultiLineString(wkb, wkt); + } - this.TestParseMultiPolygon(wkb, wkt); - } + [Fact] + public void ParseMultiPolygon_ParsesEmptyMultiPolygon() + { + string wkt = "multipolygon empty"; + byte[] wkb = TestDataReader.Read("multipolygon-empty.wkb"); - [Fact] - public void ParseMultiPolygon_Parses2DMultiPolygon() - { - string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-2D.wkb"); + this.TestParseMultiPolygon(wkb, wkt); + } - this.TestParseMultiPolygon(wkb, wkt); - } + [Fact] + public void ParseMultiPolygon_Parses2DMultiPolygon() + { + string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-2D.wkb"); - [Fact] - public void ParseMultiPolygon_Parses2DMeasuredMultiPolygon() - { - string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-2DM.wkb"); + this.TestParseMultiPolygon(wkb, wkt); + } - this.TestParseMultiPolygon(wkb, wkt); - } + [Fact] + public void ParseMultiPolygon_Parses2DMeasuredMultiPolygon() + { + string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-2DM.wkb"); - [Fact] - public void ParseMultiPolygon_Parses3DMultiPolygon() - { - string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-3D.wkb"); + this.TestParseMultiPolygon(wkb, wkt); + } - this.TestParseMultiPolygon(wkb, wkt); - } + [Fact] + public void ParseMultiPolygon_Parses3DMultiPolygon() + { + string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-3D.wkb"); - [Fact] - public void ParseMultiPolygon_Parses3DMeasuredMultiPolygon() - { - string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; - byte[] wkb = TestDataReader.Read("multipolygon-3DM.wkb"); + this.TestParseMultiPolygon(wkb, wkt); + } - this.TestParseMultiPolygon(wkb, wkt); - } + [Fact] + public void ParseMultiPolygon_Parses3DMeasuredMultiPolygon() + { + string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; + byte[] wkb = TestDataReader.Read("multipolygon-3DM.wkb"); - [Fact] - public void ParseGeometryCollection_ParsesEmptyGeometryCollection() - { - string wkt = "geometrycollection empty"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-empty.wkb")); + this.TestParseMultiPolygon(wkb, wkt); + } - Assert.Empty(parsed.Geometries); - } + [Fact] + public void ParseGeometryCollection_ParsesEmptyGeometryCollection() + { + string wkt = "geometrycollection empty"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-empty.wkb")); - [Fact] - public void ParseGeometryCollection_Parses2DGeometryCollection() - { - string wkt = "geometrycollection (point (-10.1 15.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2D.wkb")); + Assert.Empty(parsed.Geometries); + } - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } + [Fact] + public void ParseGeometryCollection_Parses2DGeometryCollection() + { + string wkt = "geometrycollection (point (-10.1 15.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2D.wkb")); - [Fact] - public void ParseGeometryCollection_Parses2DMeasuredGeometryCollection() - { - string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2DM.wkb")); + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } + [Fact] + public void ParseGeometryCollection_Parses2DMeasuredGeometryCollection() + { + string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2DM.wkb")); - [Fact] - public void ParseGeometryCollection_Parses3DGeometryCollection() - { - string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3D.wkb")); + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } + [Fact] + public void ParseGeometryCollection_Parses3DGeometryCollection() + { + string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3D.wkb")); - [Fact] - public void ParseGeometryCollection_Parses3DMeasuredGeometryCollection() - { - string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3DM.wkb")); + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - } + [Fact] + public void ParseGeometryCollection_Parses3DMeasuredGeometryCollection() + { + string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3DM.wkb")); - [Fact] - public void ParseGeometryCollection_ParsesCollectionWithPointLineStringAndPolygon() - { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-pt-ls-poly.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - this.CompareLineStrings((LineString)parsed.Geometries[1], (LineString)expected.Geometries[1]); - this.ComparePolygons((Polygon)parsed.Geometries[2], (Polygon)expected.Geometries[2]); - } + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + } - [Fact] - public void ParseGeometryCollection_ParsesCollectionWithMultiGeometries() - { - string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-multi.wkb")); - - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.CompareMultiPoints((MultiPoint)parsed.Geometries[0], (MultiPoint)expected.Geometries[0]); - this.CompareMultiLineStrings((MultiLineString)parsed.Geometries[1], (MultiLineString)expected.Geometries[1]); - this.CompareMultiPolygons((MultiPolygon)parsed.Geometries[2], (MultiPolygon)expected.Geometries[2]); - } + [Fact] + public void ParseGeometryCollection_ParsesCollectionWithPointLineStringAndPolygon() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-pt-ls-poly.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + this.CompareLineStrings((LineString)parsed.Geometries[1], (LineString)expected.Geometries[1]); + this.ComparePolygons((Polygon)parsed.Geometries[2], (Polygon)expected.Geometries[2]); + } - [Fact] - public void ParseGeometryCollection_ParsesNestedCollection() - { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); - GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-nested.wkb")); + [Fact] + public void ParseGeometryCollection_ParsesCollectionWithMultiGeometries() + { + string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-multi.wkb")); + + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + this.CompareMultiPoints((MultiPoint)parsed.Geometries[0], (MultiPoint)expected.Geometries[0]); + this.CompareMultiLineStrings((MultiLineString)parsed.Geometries[1], (MultiLineString)expected.Geometries[1]); + this.CompareMultiPolygons((MultiPolygon)parsed.Geometries[2], (MultiPolygon)expected.Geometries[2]); + } - Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - Assert.Equal(((GeometryCollection)expected.Geometries[0]).Geometries.Count, ((GeometryCollection)parsed.Geometries[0]).Geometries.Count); - this.ComparePoints((Point)((GeometryCollection)parsed.Geometries[0]).Geometries[0], (Point)((GeometryCollection)expected.Geometries[0]).Geometries[0]); - } + [Fact] + public void ParseGeometryCollection_ParsesNestedCollection() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-nested.wkb")); - private void TestParsePoint(byte[] wkb, string expectedAsWkt) - { - Point expected = (Point)this.ParseWKT(expectedAsWkt); - Point parsed = WkbReader.Parse(wkb); + Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); + Assert.Equal(((GeometryCollection)expected.Geometries[0]).Geometries.Count, ((GeometryCollection)parsed.Geometries[0]).Geometries.Count); + this.ComparePoints((Point)((GeometryCollection)parsed.Geometries[0]).Geometries[0], (Point)((GeometryCollection)expected.Geometries[0]).Geometries[0]); + } - this.ComparePoints(parsed, expected); - } + private void TestParsePoint(byte[] wkb, string expectedAsWkt) + { + Point expected = (Point)this.ParseWKT(expectedAsWkt); + Point parsed = WkbReader.Parse(wkb); - private void TestParseLineString(byte[] wkb, string expectedAsWkt) - { - LineString expected = (LineString)this.ParseWKT(expectedAsWkt); - LineString parsed = WkbReader.Parse(wkb); + this.ComparePoints(parsed, expected); + } - this.CompareLineStrings(parsed, expected); - } + private void TestParseLineString(byte[] wkb, string expectedAsWkt) + { + LineString expected = (LineString)this.ParseWKT(expectedAsWkt); + LineString parsed = WkbReader.Parse(wkb); - private void TestParsePolygon(byte[] wkb, string expectedAsWkt) - { - Polygon expected = (Polygon)this.ParseWKT(expectedAsWkt); - Polygon parsed = WkbReader.Parse(wkb); + this.CompareLineStrings(parsed, expected); + } - this.ComparePolygons(parsed, expected); - } + private void TestParsePolygon(byte[] wkb, string expectedAsWkt) + { + Polygon expected = (Polygon)this.ParseWKT(expectedAsWkt); + Polygon parsed = WkbReader.Parse(wkb); - private void TestParseMultiPoint(byte[] wkb, string expectedAsWkt) - { - MultiPoint expected = (MultiPoint)this.ParseWKT(expectedAsWkt); - MultiPoint parsed = WkbReader.Parse(wkb); + this.ComparePolygons(parsed, expected); + } - this.CompareMultiPoints(parsed, expected); - } + private void TestParseMultiPoint(byte[] wkb, string expectedAsWkt) + { + MultiPoint expected = (MultiPoint)this.ParseWKT(expectedAsWkt); + MultiPoint parsed = WkbReader.Parse(wkb); - private void TestParseMultiLineString(byte[] wkb, string expectedAsWkt) - { - MultiLineString expected = (MultiLineString)this.ParseWKT(expectedAsWkt); - MultiLineString parsed = WkbReader.Parse(wkb); + this.CompareMultiPoints(parsed, expected); + } - this.CompareMultiLineStrings(parsed, expected); - } + private void TestParseMultiLineString(byte[] wkb, string expectedAsWkt) + { + MultiLineString expected = (MultiLineString)this.ParseWKT(expectedAsWkt); + MultiLineString parsed = WkbReader.Parse(wkb); - private void TestParseMultiPolygon(byte[] wkb, string expectedAsWkt) - { - MultiPolygon expected = (MultiPolygon)this.ParseWKT(expectedAsWkt); - MultiPolygon parsed = WkbReader.Parse(wkb); + this.CompareMultiLineStrings(parsed, expected); + } - this.CompareMultiPolygons(parsed, expected); - } + private void TestParseMultiPolygon(byte[] wkb, string expectedAsWkt) + { + MultiPolygon expected = (MultiPolygon)this.ParseWKT(expectedAsWkt); + MultiPolygon parsed = WkbReader.Parse(wkb); - private void ComparePoints(Point point, Point expected) - { - Assert.Equal(expected.Position, point.Position); - } + this.CompareMultiPolygons(parsed, expected); + } - private void CompareCoordinateLists(ICoordinateList list, ICoordinateList expected) - { - Assert.Equal(expected.Count, list.Count); - for (int i = 0; i < expected.Count; i++) - { - Assert.Equal(expected[i], list[i]); - } - } + private void ComparePoints(Point point, Point expected) + { + Assert.Equal(expected.Position, point.Position); + } - private void CompareLineStrings(LineString linestring, LineString expected) + private void CompareCoordinateLists(ICoordinateList list, ICoordinateList expected) + { + Assert.Equal(expected.Count, list.Count); + for (int i = 0; i < expected.Count; i++) { - this.CompareCoordinateLists(linestring.Coordinates, expected.Coordinates); + Assert.Equal(expected[i], list[i]); } + } - private void ComparePolygons(Polygon polygon, Polygon expected) - { - this.CompareCoordinateLists(polygon.ExteriorRing, expected.ExteriorRing); + private void CompareLineStrings(LineString linestring, LineString expected) + { + this.CompareCoordinateLists(linestring.Coordinates, expected.Coordinates); + } - Assert.Equal(expected.InteriorRings.Count, polygon.InteriorRings.Count); - for (int i = 0; i < expected.InteriorRings.Count; i++) - { - this.CompareCoordinateLists(polygon.InteriorRings[i], expected.InteriorRings[i]); - } - } + private void ComparePolygons(Polygon polygon, Polygon expected) + { + this.CompareCoordinateLists(polygon.ExteriorRing, expected.ExteriorRing); - private void CompareMultiPoints(MultiPoint multipoint, MultiPoint expected) + Assert.Equal(expected.InteriorRings.Count, polygon.InteriorRings.Count); + for (int i = 0; i < expected.InteriorRings.Count; i++) { - Assert.Equal(expected.Geometries.Count, multipoint.Geometries.Count); - - for (int i = 0; i < expected.Geometries.Count; i++) - { - this.ComparePoints(multipoint.Geometries[i], expected.Geometries[i]); - } + this.CompareCoordinateLists(polygon.InteriorRings[i], expected.InteriorRings[i]); } + } - private void CompareMultiLineStrings(MultiLineString multilinestring, MultiLineString expected) - { - Assert.Equal(expected.Geometries.Count, multilinestring.Geometries.Count); + private void CompareMultiPoints(MultiPoint multipoint, MultiPoint expected) + { + Assert.Equal(expected.Geometries.Count, multipoint.Geometries.Count); - for (int i = 0; i < expected.Geometries.Count; i++) - { - this.CompareLineStrings(multilinestring.Geometries[i], expected.Geometries[i]); - } + for (int i = 0; i < expected.Geometries.Count; i++) + { + this.ComparePoints(multipoint.Geometries[i], expected.Geometries[i]); } + } - private void CompareMultiPolygons(MultiPolygon multipolygon, MultiPolygon expected) - { - Assert.Equal(expected.Geometries.Count, multipolygon.Geometries.Count); + private void CompareMultiLineStrings(MultiLineString multilinestring, MultiLineString expected) + { + Assert.Equal(expected.Geometries.Count, multilinestring.Geometries.Count); - for (int i = 0; i < expected.Geometries.Count; i++) - { - this.ComparePolygons(multipolygon.Geometries[i], expected.Geometries[i]); - } + for (int i = 0; i < expected.Geometries.Count; i++) + { + this.CompareLineStrings(multilinestring.Geometries[i], expected.Geometries[i]); } + } + private void CompareMultiPolygons(MultiPolygon multipolygon, MultiPolygon expected) + { + Assert.Equal(expected.Geometries.Count, multipolygon.Geometries.Count); - private Geometry ParseWKT(string wkt) + for (int i = 0; i < expected.Geometries.Count; i++) { - return WktReader.Parse(wkt); + this.ComparePolygons(multipolygon.Geometries[i], expected.Geometries[i]); } } + + + private Geometry ParseWKT(string wkt) + { + return WktReader.Parse(wkt); + } } diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs index d221292..334404d 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs @@ -7,26 +7,25 @@ using SpatialLite.Core.IO; -namespace Tests.SpatialLite.Core.IO +namespace Tests.SpatialLite.Core.IO; + +public class WkbWriterSettingsTests { - public class WkbWriterSettingsTests - { - [Fact] - public void Constructor__SetsDefaultValues() - { - WkbWriterSettings target = new WkbWriterSettings(); + [Fact] + public void Constructor__SetsDefaultValues() + { + WkbWriterSettings target = new WkbWriterSettings(); - Assert.Equal(BinaryEncoding.LittleEndian, target.Encoding); - } + Assert.Equal(BinaryEncoding.LittleEndian, target.Encoding); + } - [Fact] - public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - WkbWriterSettings target = new WkbWriterSettings(); - target.IsReadOnly = true; + [Fact] + public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + WkbWriterSettings target = new WkbWriterSettings(); + target.IsReadOnly = true; - Assert.Throws(() => target.Encoding = BinaryEncoding.BigEndian); - } + Assert.Throws(() => target.Encoding = BinaryEncoding.BigEndian); } } diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs index 5e33e3c..1091397 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs @@ -14,749 +14,748 @@ using SpatialLite.Core.IO; -namespace Tests.SpatialLite.Core.IO +namespace Tests.SpatialLite.Core.IO; + +public class WkbWriterTests { - public class WkbWriterTests - { - [Fact] - public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + [Fact] + public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + { + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) { - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() - { - Stream stream = null; - Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings())); - } + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + Stream stream = null; + Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings())); + } - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() - { - Assert.Throws(() => new WkbWriter(new MemoryStream(), null)); - } + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + Assert.Throws(() => new WkbWriter(new MemoryStream(), null)); + } - [Fact] - public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() + [Fact] + public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() + { + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) { - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_PathSettings_CreatesOutputFile() - { - string filename = PathHelper.GetTempFilePath("wkbwriter-constructor-creates-output-test.bin"); - - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(filename, settings)) - { - ; - } - - Assert.True(File.Exists(filename)); - } + [Fact] + public void Constructor_PathSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("wkbwriter-constructor-creates-output-test.bin"); - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(filename, settings)) { - string path = null; - Assert.Throws(() => new WkbWriter(path, new WkbWriterSettings())); + ; } - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() - { - string path = PathHelper.GetTempFilePath("wkbwriter-constructor-test.bin"); + Assert.True(File.Exists(filename)); + } - Assert.Throws(() => new WkbWriter(path, null)); - } + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + string path = null; + Assert.Throws(() => new WkbWriter(path, new WkbWriterSettings())); + } - [Fact] - public void Constructor_ThrowsExceptionIfEncodingIsSetToBingEndian() - { - MemoryStream stream = new MemoryStream(); - Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.BigEndian })); - } + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + string path = PathHelper.GetTempFilePath("wkbwriter-constructor-test.bin"); - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = PathHelper.GetTempFilePath("wkbwriter-closes-output-filestream-test.bin"); + Assert.Throws(() => new WkbWriter(path, null)); + } - WkbWriterSettings settings = new WkbWriterSettings(); - WkbWriter target = new WkbWriter(filename, settings); - target.Dispose(); + [Fact] + public void Constructor_ThrowsExceptionIfEncodingIsSetToBingEndian() + { + MemoryStream stream = new MemoryStream(); + Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.BigEndian })); + } - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = PathHelper.GetTempFilePath("wkbwriter-closes-output-filestream-test.bin"); - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() - { - MemoryStream stream = new MemoryStream(); + WkbWriterSettings settings = new WkbWriterSettings(); + WkbWriter target = new WkbWriter(filename, settings); + target.Dispose(); - WkbWriter target = new WkbWriter(stream, new WkbWriterSettings()); - target.Dispose(); + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - Assert.False(stream.CanRead); - } + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void WkbWriter_Write_WritesLittleEndianEncodingByte() - { - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) - { - target.Write(new Point()); + WkbWriter target = new WkbWriter(stream, new WkbWriterSettings()); + target.Dispose(); - CompareBytes(stream.ToArray(), 0, new byte[] { (byte)BinaryEncoding.LittleEndian }); - } - } + Assert.False(stream.CanRead); + } - [Fact] - public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() + [Fact] + public void WkbWriter_Write_WritesLittleEndianEncodingByte() + { + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) { - string wkt = "point empty"; - Point point = (Point)this.ParseWKT(wkt); - - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(point); + target.Write(new Point()); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); - } + CompareBytes(stream.ToArray(), 0, new byte[] { (byte)BinaryEncoding.LittleEndian }); } + } - [Fact] - public void Write_Writes2DPoint() - { - string wkt = "point (-10.1 15.5)"; - Point point = (Point)this.ParseWKT(wkt); + [Fact] + public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() + { + string wkt = "point empty"; + Point point = (Point)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(point); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); } + } - [Fact] - public void Write_Writes2DMeasuredPoint() - { - string wkt = "point m (-10.1 15.5 1000.5)"; - Point point = (Point)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DPoint() + { + string wkt = "point (-10.1 15.5)"; + Point point = (Point)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(point); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2D.wkb")); } + } - [Fact] - public void Write_Writes3DPoint() - { - string wkt = "point z (-10.1 15.5 100.5)"; - Point point = (Point)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMeasuredPoint() + { + string wkt = "point m (-10.1 15.5 1000.5)"; + Point point = (Point)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(point); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2DM.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredPoint() - { - string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; - Point point = (Point)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DPoint() + { + string wkt = "point z (-10.1 15.5 100.5)"; + Point point = (Point)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(point); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3D.wkb")); } + } - [Fact] - public void Write_WritesEmptyLineString() - { - string wkt = "linestring empty"; - LineString linestring = (LineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredPoint() + { + string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; + Point point = (Point)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(linestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-empty.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3DM.wkb")); } + } - [Fact] - public void Write_Writes2DLineString() - { - string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + [Fact] + public void Write_WritesEmptyLineString() + { + string wkt = "linestring empty"; + LineString linestring = (LineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(linestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-empty.wkb")); } + } - [Fact] - public void Write_Writes2DMeasuredLineString() - { - string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DLineString() + { + string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(linestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2D.wkb")); } + } - [Fact] - public void Write_Writes3DLineString() - { - string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMeasuredLineString() + { + string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(linestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2DM.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredLineString() - { - string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DLineString() + { + string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(linestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3D.wkb")); } + } - [Fact] - public void Write_WritesEmptyPolygon() - { - string wkt = "polygon empty"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredLineString() + { + string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; + LineString linestring = (LineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(polygon); + MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-empty.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3DM.wkb")); } + } - [Fact] - public void Write_Writes2DPolygonOnlyExteriorRing() - { - string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + [Fact] + public void Write_WritesEmptyPolygon() + { + string wkt = "polygon empty"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(polygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-empty.wkb")); } + } - [Fact] - public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() - { - string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DPolygonOnlyExteriorRing() + { + string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(polygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2D.wkb")); } + } - [Fact] - public void Write_Writes3DPolygonOnlyExteriorRing() - { - string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(polygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2DM.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() - { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DPolygonOnlyExteriorRing() + { + string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(polygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3D.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredPolygon() - { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(polygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3DM.wkb")); } + } - [Fact] - public void Write_WritesEmptyMultipoint() - { - string wkt = "multipoint empty"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredPolygon() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + Polygon polygon = (Polygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipoint); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-empty.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-3DM.wkb")); } + } - [Fact] - public void Write_Writes2DMultiPoint() - { - string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + [Fact] + public void Write_WritesEmptyMultipoint() + { + string wkt = "multipoint empty"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipoint); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-empty.wkb")); } + } - [Fact] - public void Write_Writes2DMeasuredMultiPoint() - { - string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMultiPoint() + { + string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipoint); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2D.wkb")); } + } - [Fact] - public void Write_Writes3DMultiPoint() - { - string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMeasuredMultiPoint() + { + string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipoint); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2DM.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredMultiPoint() - { - string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMultiPoint() + { + string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipoint); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3D.wkb")); } + } - [Fact] - public void Write_WritesEmptyMultiLineString() - { - string wkt = "multilinestring empty"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredMultiPoint() + { + string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; + MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multilinestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-empty.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3DM.wkb")); } + } - [Fact] - public void Write_Writes2DMultiLineString() - { - string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + [Fact] + public void Write_WritesEmptyMultiLineString() + { + string wkt = "multilinestring empty"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multilinestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-empty.wkb")); } + } - [Fact] - public void Write_Writes2DMeasuredMultiLineString() - { - string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMultiLineString() + { + string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multilinestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2D.wkb")); } + } - [Fact] - public void Write_Writes3DMultiLineString() - { - string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMeasuredMultiLineString() + { + string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multilinestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2DM.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredMultiLineString() - { - string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMultiLineString() + { + string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multilinestring); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3D.wkb")); } + } - [Fact] - public void Write_WritesEmptyMultiPolygon() - { - string wkt = "multipolygon empty"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredMultiLineString() + { + string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipolygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-empty.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3DM.wkb")); } + } - [Fact] - public void Write_Writes2DMultiPolygon() - { - string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + [Fact] + public void Write_WritesEmptyMultiPolygon() + { + string wkt = "multipolygon empty"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipolygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-empty.wkb")); } + } - [Fact] - public void Write_Writes2DMeasuredMultiPolygon() - { - string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMultiPolygon() + { + string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipolygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2D.wkb")); } + } - [Fact] - public void Write_Writes3DMultiPolygon() - { - string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMeasuredMultiPolygon() + { + string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipolygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2DM.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredMultiPolygon() - { - string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMultiPolygon() + { + string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(multipolygon); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3D.wkb")); } + } - [Fact] - public void Write_WritesEmptyGeometryCollection() - { - string wkt = "geometrycollection empty"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredMultiPolygon() + { + string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; + MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3DM.wkb")); } + } - [Fact] - public void Write_Writes2DGeometryCollection() - { - string wkt = "geometrycollection (point (-10.1 15.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_WritesEmptyGeometryCollection() + { + string wkt = "geometrycollection empty"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); } + } - [Fact] - public void Write_Writes2DMeasuredGeometryCollection() - { - string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DGeometryCollection() + { + string wkt = "geometrycollection (point (-10.1 15.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2D.wkb")); } + } - [Fact] - public void Write_Writes3DGeometryCollection() - { - string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_Writes2DMeasuredGeometryCollection() + { + string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3D.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2DM.wkb")); } + } - [Fact] - public void Write_Writes3DMeasuredGeometryCollection() - { - string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DGeometryCollection() + { + string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3DM.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3D.wkb")); } + } - [Fact] - public void Write_WritesCollectionWithPointLineStringAndPolygon() - { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_Writes3DMeasuredGeometryCollection() + { + string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-pt-ls-poly.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3DM.wkb")); } + } - [Fact] - public void Write_WritesCollectionWithMultiGeometries() - { - string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_WritesCollectionWithPointLineStringAndPolygon() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-multi.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-pt-ls-poly.wkb")); } + } - [Fact] - public void Write_WritesNestedCollection() - { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + [Fact] + public void Write_WritesCollectionWithMultiGeometries() + { + string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) - { - target.Write(collection); + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + { + target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-nested.wkb")); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-multi.wkb")); } + } - public static IEnumerable WriteToArrayTestData + [Fact] + public void Write_WritesNestedCollection() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { - get - { - yield return new object[] { "point zm (-10.1 15.5 100.5 1000.5)", TestDataReader.Read("point-3DM.wkb") }; - yield return new object[] { "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)", TestDataReader.Read("linestring-3DM.wkb") }; - yield return new object[] { "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))", TestDataReader.Read("polygon-3DM.wkb") }; - yield return new object[] { "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))", TestDataReader.Read("multipoint-3DM.wkb") }; - yield return new object[] { "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))", TestDataReader.Read("multilinestring-3DM.wkb") }; - yield return new object[] { "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))", TestDataReader.Read("multipolygon-3DM.wkb") }; - yield return new object[] { "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))", TestDataReader.Read("collection-3DM.wkb") }; + target.Write(collection); - } + this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-nested.wkb")); } + } - [Theory] - [MemberData(nameof(WriteToArrayTestData))] - public void WriteToArray_WritesAllGeometryTypes(string wkt, byte[] expectedWkb) + public static IEnumerable WriteToArrayTestData + { + get { - IGeometry geometry = this.ParseWKT(wkt); + yield return new object[] { "point zm (-10.1 15.5 100.5 1000.5)", TestDataReader.Read("point-3DM.wkb") }; + yield return new object[] { "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)", TestDataReader.Read("linestring-3DM.wkb") }; + yield return new object[] { "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))", TestDataReader.Read("polygon-3DM.wkb") }; + yield return new object[] { "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))", TestDataReader.Read("multipoint-3DM.wkb") }; + yield return new object[] { "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))", TestDataReader.Read("multilinestring-3DM.wkb") }; + yield return new object[] { "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))", TestDataReader.Read("multipolygon-3DM.wkb") }; + yield return new object[] { "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))", TestDataReader.Read("collection-3DM.wkb") }; - byte[] wkb = WkbWriter.WriteToArray(geometry); - this.CompareBytes(wkb, expectedWkb); } + } - private void CompareBytes(byte[] array, byte[] expected) - { - Assert.Equal(array.Length, expected.Length); + [Theory] + [MemberData(nameof(WriteToArrayTestData))] + public void WriteToArray_WritesAllGeometryTypes(string wkt, byte[] expectedWkb) + { + IGeometry geometry = this.ParseWKT(wkt); - for (int i = 0; i < expected.Length; i++) - { - Assert.Equal(expected[i], array[i]); - } - } + byte[] wkb = WkbWriter.WriteToArray(geometry); + this.CompareBytes(wkb, expectedWkb); + } - private void CompareBytes(byte[] array, int offset, byte[] expected) + private void CompareBytes(byte[] array, byte[] expected) + { + Assert.Equal(array.Length, expected.Length); + + for (int i = 0; i < expected.Length; i++) { - for (int i = 0; i < expected.Length; i++) - { - Assert.Equal(expected[i], array[i + offset]); - } + Assert.Equal(expected[i], array[i]); } + } - private Geometry ParseWKT(string wkt) + private void CompareBytes(byte[] array, int offset, byte[] expected) + { + for (int i = 0; i < expected.Length; i++) { - return WktReader.Parse(wkt); + Assert.Equal(expected[i], array[i + offset]); } } + + private Geometry ParseWKT(string wkt) + { + return WktReader.Parse(wkt); + } } diff --git a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs index 1e0f9cc..a44a7e2 100644 --- a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs @@ -12,798 +12,797 @@ using SpatialLite.Core.IO; using Tests.SpatialLite.Core.Data; -namespace Tests.SpatialLite.Core.IO -{ +namespace Tests.SpatialLite.Core.IO; - public class WktReaderTests - { - private Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) - }; +public class WktReaderTests +{ - private Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) - }; + private Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) + }; - private Coordinate[] _coordinatesXYM = new Coordinate[] { - new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) - }; + private Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) + }; - private Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) - }; + private Coordinate[] _coordinatesXYM = new Coordinate[] { + new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) + }; - private Coordinate[] _coordinates2XYZM = new Coordinate[] { - new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) - }; + private Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) + }; - [Fact] - public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() - { - Stream stream = null; - Assert.Throws(() => new WktReader(stream)); - } + private Coordinate[] _coordinates2XYZM = new Coordinate[] { + new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) + }; - [Fact] - public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() - { - Assert.Throws(() => new WktReader("non-existing-file.wkb")); - } + [Fact] + public void Constructor_Stream_ThrowsAgrumentNullExceptioIfStreamIsNull() + { + Stream stream = null; + Assert.Throws(() => new WktReader(stream)); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = "../../../Data/IO/wkt-point-3DM.wkt"; + [Fact] + public void Constructor_Path_ThrowsFileNotFoundExceptioIfFileDoesNotExists() + { + Assert.Throws(() => new WktReader("non-existing-file.wkb")); + } - WktReader target = new WktReader(filename); - target.Dispose(); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/IO/wkt-point-3DM.wkt"; - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + WktReader target = new WktReader(filename); + target.Dispose(); - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() - { - var stream = TestDataReader.Open("wkt-point-3DM.wkt"); + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - WktReader target = new WktReader(stream); - target.Dispose(); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + var stream = TestDataReader.Open("wkt-point-3DM.wkt"); - Assert.False(stream.CanRead); - } - public static IEnumerable Read_ReadsAllGeometryTypesTestData + WktReader target = new WktReader(stream); + target.Dispose(); + + Assert.False(stream.CanRead); + } + public static IEnumerable Read_ReadsAllGeometryTypesTestData + { + get { - get - { - yield return new object[] { TestDataReader.Read("wkt-point-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-linestring-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-polygon-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-multipoint-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-multilinestring-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-multipolygon-3DM.wkt") }; - yield return new object[] { TestDataReader.Read("wkt-geometry-collection-3DM.wkt") }; - } + yield return new object[] { TestDataReader.Read("wkt-point-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-linestring-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-polygon-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-multipoint-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-multilinestring-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-multipolygon-3DM.wkt") }; + yield return new object[] { TestDataReader.Read("wkt-geometry-collection-3DM.wkt") }; } + } - [Theory] - [MemberData(nameof(Read_ReadsAllGeometryTypesTestData))] - public void Read_ReadsAllGeometryTypes(byte[] data) + [Theory] + [MemberData(nameof(Read_ReadsAllGeometryTypesTestData))] + public void Read_ReadsAllGeometryTypes(byte[] data) + { + using (WktReader target = new WktReader(new MemoryStream(data))) { - using (WktReader target = new WktReader(new MemoryStream(data))) - { - IGeometry readGeometry = target.Read(); - Assert.NotNull(readGeometry); - } + IGeometry readGeometry = target.Read(); + Assert.NotNull(readGeometry); } + } - [Fact] - public void Read_ReturnsNullIfStreamIsEmpty() + [Fact] + public void Read_ReturnsNullIfStreamIsEmpty() + { + using (WktReader target = new WktReader(new MemoryStream())) { - using (WktReader target = new WktReader(new MemoryStream())) - { - IGeometry readGeometry = target.Read(); + IGeometry readGeometry = target.Read(); - Assert.Null(readGeometry); - } + Assert.Null(readGeometry); } + } - [Fact] - public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() + [Fact] + public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) - { - target.Read(); - IGeometry readGeometry = target.Read(); + target.Read(); + IGeometry readGeometry = target.Read(); - Assert.Null(readGeometry); - } + Assert.Null(readGeometry); } + } - [Fact] - public void Read_ReadsMultipleGeometries() + [Fact] + public void Read_ReadsMultipleGeometries() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) - { - IGeometry readGeometry = target.Read(); - Assert.True(readGeometry is Point); - - readGeometry = target.Read(); - Assert.True(readGeometry is LineString); - } + IGeometry readGeometry = target.Read(); + Assert.True(readGeometry is Point); + + readGeometry = target.Read(); + Assert.True(readGeometry is LineString); } + } - [Fact] - public void ReadT_ReadsGeometry() + [Fact] + public void ReadT_ReadsGeometry() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) - { - Point read = target.Read(); - Assert.NotNull(read); - } + Point read = target.Read(); + Assert.NotNull(read); } + } - [Fact] - public void ReadT_ReturnsNullIfStreamIsEmpty() + [Fact] + public void ReadT_ReturnsNullIfStreamIsEmpty() + { + using (WktReader target = new WktReader(new MemoryStream())) { - using (WktReader target = new WktReader(new MemoryStream())) - { - IGeometry readGeometry = target.Read(); + IGeometry readGeometry = target.Read(); - Assert.Null(readGeometry); - } + Assert.Null(readGeometry); } + } - [Fact] - public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() + [Fact] + public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() + { + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) - { - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); } + } - [Fact] - public void Parse_ParsesPoint() - { - string wkt = "point empty"; + [Fact] + public void Parse_ParsesPoint() + { + string wkt = "point empty"; - Point parsed = (Point)WktReader.Parse(wkt); - this.CompareCoordinate(Coordinate.Empty, parsed.Position); - } + Point parsed = (Point)WktReader.Parse(wkt); + this.CompareCoordinate(Coordinate.Empty, parsed.Position); + } - [Fact] - public void Parse_ParsesLineString() - { - string wkt = "linestring empty"; + [Fact] + public void Parse_ParsesLineString() + { + string wkt = "linestring empty"; - LineString parsed = (LineString)WktReader.Parse(wkt); + LineString parsed = (LineString)WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Coordinates); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Coordinates); + } - [Fact] - public void Parse_ParsesPolygon() - { - string wkt = "polygon empty"; + [Fact] + public void Parse_ParsesPolygon() + { + string wkt = "polygon empty"; - Polygon parsed = (Polygon)WktReader.Parse(wkt); + Polygon parsed = (Polygon)WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.ExteriorRing); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.ExteriorRing); + } - [Fact] - public void Parse_ParsesGeometryCollection() - { - string wkt = "geometrycollection empty"; + [Fact] + public void Parse_ParsesGeometryCollection() + { + string wkt = "geometrycollection empty"; - GeometryCollection parsed = (GeometryCollection)WktReader.Parse(wkt); + GeometryCollection parsed = (GeometryCollection)WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_ParsesMultiPoint() - { - string wkt = "multipoint empty"; + [Fact] + public void Parse_ParsesMultiPoint() + { + string wkt = "multipoint empty"; - MultiPoint parsed = (MultiPoint)WktReader.Parse(wkt); + MultiPoint parsed = (MultiPoint)WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_ParsesMultiLineString() - { - string wkt = "multilinestring empty"; + [Fact] + public void Parse_ParsesMultiLineString() + { + string wkt = "multilinestring empty"; - MultiLineString parsed = (MultiLineString)WktReader.Parse(wkt); + MultiLineString parsed = (MultiLineString)WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_ParsesMultiPolygon() - { - string wkt = "multipolygon empty"; + [Fact] + public void Parse_ParsesMultiPolygon() + { + string wkt = "multipolygon empty"; - MultiPolygon parsed = (MultiPolygon)WktReader.Parse(wkt); + MultiPolygon parsed = (MultiPolygon)WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometry() - { - string wkt = "invalid string"; + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometry() + { + string wkt = "invalid string"; - Assert.Throws(() => WktReader.Parse(wkt)); - } + Assert.Throws(() => WktReader.Parse(wkt)); + } - [Theory] - [InlineData("point zm \t(-10.1 15.5 100.5 \n1000.5)")] - [InlineData("\n\rlinestring (-10.1 15.5, 20.2 -25.5, \t30.3 35.5)")] - [InlineData("polygon\n\r m\t ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))")] - [InlineData("multipoint\t\r z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))")] - [InlineData("\nmultilinestring \tempty")] - [InlineData("multipolygon\n\r (((-10.1\t 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))")] - [InlineData("geometrycollection \t\n\r(point (-10.1 15.5))")] - public void Parse_ParsesGeometriesWithMultipleWhitespacesInsteadOneSpace(string wkt) - { - WktReader.Parse(wkt); - } + [Theory] + [InlineData("point zm \t(-10.1 15.5 100.5 \n1000.5)")] + [InlineData("\n\rlinestring (-10.1 15.5, 20.2 -25.5, \t30.3 35.5)")] + [InlineData("polygon\n\r m\t ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))")] + [InlineData("multipoint\t\r z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))")] + [InlineData("\nmultilinestring \tempty")] + [InlineData("multipolygon\n\r (((-10.1\t 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))")] + [InlineData("geometrycollection \t\n\r(point (-10.1 15.5))")] + public void Parse_ParsesGeometriesWithMultipleWhitespacesInsteadOneSpace(string wkt) + { + WktReader.Parse(wkt); + } - [Theory] - [InlineData("point zm ( -10.1 15.5 100.5 1000.5 )")] - [InlineData("linestring ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 )")] - [InlineData("polygon m ( ( -10.1 15.5 1000.5 , 20.2 -25.5 2000.5, 30.3 35.5 -3000.5 ) )")] - [InlineData("multipoint z ( ( -10.1 15.5 100.5 ) , ( 20.2 -25.5 200.5 ) )")] - [InlineData("multilinestring ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) , ( -10.1 15.5, 20.2 -25.5, 30.3 35.5 ) ) ")] - [InlineData("multipolygon ( ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) , ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) )")] - [InlineData("geometrycollection ( point ( -10.1 15.5 ) )")] - public void Parse_ParsesGeometriesWithWhitespacesAtPlacesWhereTheyAreNotExpected(string wkt) - { - WktReader.Parse(wkt); - } + [Theory] + [InlineData("point zm ( -10.1 15.5 100.5 1000.5 )")] + [InlineData("linestring ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 )")] + [InlineData("polygon m ( ( -10.1 15.5 1000.5 , 20.2 -25.5 2000.5, 30.3 35.5 -3000.5 ) )")] + [InlineData("multipoint z ( ( -10.1 15.5 100.5 ) , ( 20.2 -25.5 200.5 ) )")] + [InlineData("multilinestring ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) , ( -10.1 15.5, 20.2 -25.5, 30.3 35.5 ) ) ")] + [InlineData("multipolygon ( ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) , ( ( -10.1 15.5 , 20.2 -25.5 , 30.3 35.5 ) ) )")] + [InlineData("geometrycollection ( point ( -10.1 15.5 ) )")] + public void Parse_ParsesGeometriesWithWhitespacesAtPlacesWhereTheyAreNotExpected(string wkt) + { + WktReader.Parse(wkt); + } - [Fact] - public void Parse_ParsesEmptyPoint() - { - string wkt = "point empty"; + [Fact] + public void Parse_ParsesEmptyPoint() + { + string wkt = "point empty"; - Point parsed = WktReader.Parse(wkt); + Point parsed = WktReader.Parse(wkt); - this.CompareCoordinate(Coordinate.Empty, parsed.Position); - } + this.CompareCoordinate(Coordinate.Empty, parsed.Position); + } - [Fact] - public void Parse_Parses2DPoint() - { - string wkt = "point (-10.1 15.5)"; + [Fact] + public void Parse_Parses2DPoint() + { + string wkt = "point (-10.1 15.5)"; - Point parsed = WktReader.Parse(wkt); + Point parsed = WktReader.Parse(wkt); - Assert.False(parsed.Is3D); - Assert.False(parsed.IsMeasured); - this.CompareCoordinate(_coordinatesXY[0], parsed.Position); - } + Assert.False(parsed.Is3D); + Assert.False(parsed.IsMeasured); + this.CompareCoordinate(_coordinatesXY[0], parsed.Position); + } - [Fact] - public void Parse_Parses2DMeasuredPoint() - { - string wkt = "point m (-10.1 15.5 1000.5)"; + [Fact] + public void Parse_Parses2DMeasuredPoint() + { + string wkt = "point m (-10.1 15.5 1000.5)"; - Point parsed = WktReader.Parse(wkt); + Point parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.False(parsed.Is3D); - this.CompareCoordinate(_coordinatesXYM[0], parsed.Position); - } + Assert.NotNull(parsed); + Assert.False(parsed.Is3D); + this.CompareCoordinate(_coordinatesXYM[0], parsed.Position); + } - [Fact] - public void Parse_Parses3DPoint() - { - string wkt = "point z (-10.1 15.5 100.5)"; + [Fact] + public void Parse_Parses3DPoint() + { + string wkt = "point z (-10.1 15.5 100.5)"; - Point parsed = WktReader.Parse(wkt); + Point parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.False(parsed.IsMeasured); - this.CompareCoordinate(_coordinatesXYZ[0], parsed.Position); - } + Assert.NotNull(parsed); + Assert.False(parsed.IsMeasured); + this.CompareCoordinate(_coordinatesXYZ[0], parsed.Position); + } - [Fact] - public void Parse_Parses3DMeasuredPoint() - { - string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; + [Fact] + public void Parse_Parses3DMeasuredPoint() + { + string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; - Point parsed = WktReader.Parse(wkt); + Point parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinate(_coordinatesXYZM[0], parsed.Position); - } + Assert.NotNull(parsed); + this.CompareCoordinate(_coordinatesXYZM[0], parsed.Position); + } - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentPoint() - { - string wkt = "linestring empty"; + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentPoint() + { + string wkt = "linestring empty"; - Assert.Throws(() => WktReader.Parse(wkt)); - } + Assert.Throws(() => WktReader.Parse(wkt)); + } - [Fact] - public void Parse_ParsesEmptyLineString() - { - string wkt = "linestring empty"; + [Fact] + public void Parse_ParsesEmptyLineString() + { + string wkt = "linestring empty"; - LineString parsed = WktReader.Parse(wkt); + LineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Coordinates); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Coordinates); + } - [Fact] - public void Parse_Parses2DLineString() - { - string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; + [Fact] + public void Parse_Parses2DLineString() + { + string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; - LineString parsed = WktReader.Parse(wkt); + LineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXY, parsed.Coordinates); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXY, parsed.Coordinates); + } - [Fact] - public void Parse_Parses2DMeasuredLineString() - { - string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; + [Fact] + public void Parse_Parses2DMeasuredLineString() + { + string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; - LineString parsed = WktReader.Parse(wkt); + LineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYM, parsed.Coordinates); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYM, parsed.Coordinates); + } - [Fact] - public void Parse_Parses3DLineString() - { - string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; + [Fact] + public void Parse_Parses3DLineString() + { + string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; - LineString parsed = WktReader.Parse(wkt); + LineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZ, parsed.Coordinates); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZ, parsed.Coordinates); + } - [Fact] - public void Parse_Parses3DMeasuredLineString() - { - string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; + [Fact] + public void Parse_Parses3DMeasuredLineString() + { + string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; - LineString parsed = WktReader.Parse(wkt); + LineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.Coordinates); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZM, parsed.Coordinates); + } - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentLineString() - { - string wkt = "point empty"; + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentLineString() + { + string wkt = "point empty"; - Assert.Throws(() => WktReader.Parse(wkt)); - } + Assert.Throws(() => WktReader.Parse(wkt)); + } - [Fact] - public void ParsePolygon_ParsesEmptyPolygon() - { - string wkt = "polygon empty"; + [Fact] + public void ParsePolygon_ParsesEmptyPolygon() + { + string wkt = "polygon empty"; - Polygon parsed = WktReader.Parse(wkt); + Polygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } - [Fact] - public void ParsePolygon_Parses2DPolygonOnlyExteriorRing() - { - string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + [Fact] + public void ParsePolygon_Parses2DPolygonOnlyExteriorRing() + { + string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - Polygon parsed = WktReader.Parse(wkt); + Polygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXY, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXY, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } - [Fact] - public void ParsePolygon_Parses3DPolygonOnlyExteriorRing() - { - string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + [Fact] + public void ParsePolygon_Parses3DPolygonOnlyExteriorRing() + { + string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - Polygon parsed = WktReader.Parse(wkt); + Polygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZ, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZ, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } - [Fact] - public void ParsePolygon_Parses2DMeauredPolygonOnlyExteriorRing() - { - string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + [Fact] + public void ParsePolygon_Parses2DMeauredPolygonOnlyExteriorRing() + { + string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - Polygon parsed = WktReader.Parse(wkt); + Polygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYM, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYM, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } - [Fact] - public void ParsePolygon_Parses3DMeasuredPolygonOnlyExteriorRing() - { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + [Fact] + public void ParsePolygon_Parses3DMeasuredPolygonOnlyExteriorRing() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - Polygon parsed = WktReader.Parse(wkt); + Polygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); - Assert.Empty(parsed.InteriorRings); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); + Assert.Empty(parsed.InteriorRings); + } - [Fact] - public void ParsePolygon_Parses3DMeasuredPolygonWithInteriorRings() - { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + [Fact] + public void ParsePolygon_Parses3DMeasuredPolygonWithInteriorRings() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon parsed = WktReader.Parse(wkt); + Polygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); - Assert.Equal(2, parsed.InteriorRings.Count); - this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[0]); - this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[1]); - } + Assert.NotNull(parsed); + this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); + Assert.Equal(2, parsed.InteriorRings.Count); + this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[0]); + this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[1]); + } - [Fact] - public void ParsePolygong_ThrowsExceptionIfWktDoNotRepresentPolygon() - { - string wkt = "point empty"; + [Fact] + public void ParsePolygong_ThrowsExceptionIfWktDoNotRepresentPolygon() + { + string wkt = "point empty"; - Assert.Throws(() => WktReader.Parse(wkt)); - } + Assert.Throws(() => WktReader.Parse(wkt)); + } - [Fact] - public void Parse_ParsesEmptyMultiPoint() - { - string wkt = "multipoint empty"; + [Fact] + public void Parse_ParsesEmptyMultiPoint() + { + string wkt = "multipoint empty"; - MultiPoint parsed = WktReader.Parse(wkt); + MultiPoint parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_Parses2DMultiPoint() - { - string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; + [Fact] + public void Parse_Parses2DMultiPoint() + { + string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; - MultiPoint parsed = WktReader.Parse(wkt); + MultiPoint parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXY[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXY[1], parsed.Geometries[1].Position); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXY[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXY[1], parsed.Geometries[1].Position); + } - [Fact] - public void Parse_Parses2DMeasuredMultiPoint() - { - string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; + [Fact] + public void Parse_Parses2DMeasuredMultiPoint() + { + string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; - MultiPoint parsed = WktReader.Parse(wkt); + MultiPoint parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYM[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYM[1], parsed.Geometries[1].Position); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXYM[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXYM[1], parsed.Geometries[1].Position); + } - [Fact] - public void Parse_Parses3DMultiPoint() - { - string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; + [Fact] + public void Parse_Parses3DMultiPoint() + { + string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; - MultiPoint parsed = WktReader.Parse(wkt); + MultiPoint parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYZ[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYZ[1], parsed.Geometries[1].Position); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXYZ[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXYZ[1], parsed.Geometries[1].Position); + } - [Fact] - public void Parse_Parses3DMeasuredMultiPoint() - { - string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; + [Fact] + public void Parse_Parses3DMeasuredMultiPoint() + { + string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; - MultiPoint parsed = WktReader.Parse(wkt); + MultiPoint parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYZM[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYZM[1], parsed.Geometries[1].Position); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXYZM[0], parsed.Geometries[0].Position); + this.CompareCoordinate(_coordinatesXYZM[1], parsed.Geometries[1].Position); + } - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPoint() - { - string wkt = "point empty"; + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPoint() + { + string wkt = "point empty"; - Assert.Throws(() => WktReader.Parse(wkt)); - } + Assert.Throws(() => WktReader.Parse(wkt)); + } - [Fact] - public void Parse_ParsesEmptyMultiLineString() - { - string wkt = "multilinestring empty"; + [Fact] + public void Parse_ParsesEmptyMultiLineString() + { + string wkt = "multilinestring empty"; - MultiLineString parsed = WktReader.Parse(wkt); + MultiLineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_Parses2DMultiLineString() - { - string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; + [Fact] + public void Parse_Parses2DMultiLineString() + { + string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - MultiLineString parsed = WktReader.Parse(wkt); + MultiLineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].Coordinates); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].Coordinates); + } - [Fact] - public void Parse_Parses2DMeasuredMultiLineString() - { - string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; + [Fact] + public void Parse_Parses2DMeasuredMultiLineString() + { + string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - MultiLineString parsed = WktReader.Parse(wkt); + MultiLineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].Coordinates); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].Coordinates); + } - [Fact] - public void Parse_Parses3DMultiLineString() - { - string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; + [Fact] + public void Parse_Parses3DMultiLineString() + { + string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - MultiLineString parsed = WktReader.Parse(wkt); + MultiLineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].Coordinates); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].Coordinates); + } - [Fact] - public void Parse_Parses3DMeasuredMultiLineString() - { - string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; + [Fact] + public void Parse_Parses3DMeasuredMultiLineString() + { + string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - MultiLineString parsed = WktReader.Parse(wkt); + MultiLineString parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].Coordinates); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].Coordinates); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].Coordinates); + } - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiLineString() - { - string wkt = "point empty"; + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiLineString() + { + string wkt = "point empty"; - Assert.Throws(() => WktReader.Parse(wkt)); - } + Assert.Throws(() => WktReader.Parse(wkt)); + } - [Fact] - public void Parse_ParsesEmptyMultiPolygon() - { - string wkt = "multipolygon empty"; + [Fact] + public void Parse_ParsesEmptyMultiPolygon() + { + string wkt = "multipolygon empty"; - MultiPolygon parsed = WktReader.Parse(wkt); + MultiPolygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_Parses2DMultiPolygon() - { - string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + [Fact] + public void Parse_Parses2DMultiPolygon() + { + string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - MultiPolygon parsed = WktReader.Parse(wkt); + MultiPolygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].ExteriorRing); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].ExteriorRing); + } - [Fact] - public void Parse_Parses2DMeasuredMultiPolygon() - { - string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; + [Fact] + public void Parse_Parses2DMeasuredMultiPolygon() + { + string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; - MultiPolygon parsed = WktReader.Parse(wkt); + MultiPolygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].ExteriorRing); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].ExteriorRing); + } - [Fact] - public void Parse_Parses3DMultiPolygon() - { - string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; + [Fact] + public void Parse_Parses3DMultiPolygon() + { + string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; - MultiPolygon parsed = WktReader.Parse(wkt); + MultiPolygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].ExteriorRing); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].ExteriorRing); + } - [Fact] - public void Parse_Parses3DMeasuredMultiPolygon() - { - string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; + [Fact] + public void Parse_Parses3DMeasuredMultiPolygon() + { + string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; - MultiPolygon parsed = WktReader.Parse(wkt); + MultiPolygon parsed = WktReader.Parse(wkt); - Assert.NotNull(parsed); - Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].ExteriorRing); - } + Assert.NotNull(parsed); + Assert.Equal(2, parsed.Geometries.Count); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].ExteriorRing); + this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].ExteriorRing); + } - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPolygon() - { - string wkt = "point empty"; + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentMultiPolygon() + { + string wkt = "point empty"; - Assert.Throws(() => WktReader.Parse(wkt)); - } + Assert.Throws(() => WktReader.Parse(wkt)); + } - [Fact] - public void Parse_ParsesEmptyGeometryCollection() - { - string wkt = "geometrycollection empty"; + [Fact] + public void Parse_ParsesEmptyGeometryCollection() + { + string wkt = "geometrycollection empty"; - GeometryCollection parsed = WktReader.Parse>(wkt); + GeometryCollection parsed = WktReader.Parse>(wkt); - Assert.NotNull(parsed); - Assert.Empty(parsed.Geometries); - } + Assert.NotNull(parsed); + Assert.Empty(parsed.Geometries); + } - [Fact] - public void Parse_Parses2DGeometryCollectionWithPoint() - { - string wkt = "geometrycollection (point (-10.1 15.5))"; + [Fact] + public void Parse_Parses2DGeometryCollectionWithPoint() + { + string wkt = "geometrycollection (point (-10.1 15.5))"; - GeometryCollection parsed = WktReader.Parse>(wkt); + GeometryCollection parsed = WktReader.Parse>(wkt); - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); - } + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); + } - [Fact] - public void Parse_Parses2DMeasuredGeometryCollectionWithPoint() - { - string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; + [Fact] + public void Parse_Parses2DMeasuredGeometryCollectionWithPoint() + { + string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - GeometryCollection parsed = WktReader.Parse>(wkt); + GeometryCollection parsed = WktReader.Parse>(wkt); - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYM[0], ((Point)parsed.Geometries[0]).Position); - } + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXYM[0], ((Point)parsed.Geometries[0]).Position); + } - [Fact] - public void Parse_Parses3DGeometryCollectionWithPoint() - { - string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; + [Fact] + public void Parse_Parses3DGeometryCollectionWithPoint() + { + string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - GeometryCollection parsed = WktReader.Parse>(wkt); + GeometryCollection parsed = WktReader.Parse>(wkt); - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYZ[0], ((Point)parsed.Geometries[0]).Position); - } + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXYZ[0], ((Point)parsed.Geometries[0]).Position); + } - [Fact] - public void Parse_Parses3DMeasuredGeometryCollectionWithPoint() - { - string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; + [Fact] + public void Parse_Parses3DMeasuredGeometryCollectionWithPoint() + { + string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - GeometryCollection parsed = WktReader.Parse>(wkt); + GeometryCollection parsed = WktReader.Parse>(wkt); - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYZM[0], ((Point)parsed.Geometries[0]).Position); - } + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + this.CompareCoordinate(_coordinatesXYZM[0], ((Point)parsed.Geometries[0]).Position); + } - [Fact] - public void Parse_ParsesCollectionWithPointLineStringAndPolygon() - { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; + [Fact] + public void Parse_ParsesCollectionWithPointLineStringAndPolygon() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - GeometryCollection parsed = WktReader.Parse>(wkt); + GeometryCollection parsed = WktReader.Parse>(wkt); - Assert.NotNull(parsed); - Assert.Equal(3, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); - this.CompareCoordinates(_coordinatesXY, ((LineString)parsed.Geometries[1]).Coordinates); - this.CompareCoordinates(_coordinatesXY, ((Polygon)parsed.Geometries[2]).ExteriorRing); - } + Assert.NotNull(parsed); + Assert.Equal(3, parsed.Geometries.Count); + this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); + this.CompareCoordinates(_coordinatesXY, ((LineString)parsed.Geometries[1]).Coordinates); + this.CompareCoordinates(_coordinatesXY, ((Polygon)parsed.Geometries[2]).ExteriorRing); + } - [Fact] - public void Parse_ParsesNestedCollections() - { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + [Fact] + public void Parse_ParsesNestedCollections() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection parsed = WktReader.Parse>(wkt); + GeometryCollection parsed = WktReader.Parse>(wkt); - Assert.NotNull(parsed); - Assert.Single(parsed.Geometries); - GeometryCollection nested = (GeometryCollection)parsed.Geometries[0]; - this.CompareCoordinate(_coordinatesXY[0], ((Point)nested.Geometries[0]).Position); - } + Assert.NotNull(parsed); + Assert.Single(parsed.Geometries); + GeometryCollection nested = (GeometryCollection)parsed.Geometries[0]; + this.CompareCoordinate(_coordinatesXY[0], ((Point)nested.Geometries[0]).Position); + } - [Fact] - public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometryCollection() - { - string wkt = "point empty"; + [Fact] + public void Parse_ThrowsExceptionIfWktDoNotRepresentGeometryCollection() + { + string wkt = "point empty"; - Assert.Throws(() => WktReader.Parse>(wkt)); - } + Assert.Throws(() => WktReader.Parse>(wkt)); + } - private void CompareCoordinate(Coordinate expected, Coordinate actual) - { - Assert.Equal(expected, actual); - } + private void CompareCoordinate(Coordinate expected, Coordinate actual) + { + Assert.Equal(expected, actual); + } - private void CompareCoordinates(Coordinate[] expected, ICoordinateList actual) - { - Assert.Equal(expected.Length, actual.Count); + private void CompareCoordinates(Coordinate[] expected, ICoordinateList actual) + { + Assert.Equal(expected.Length, actual.Count); - for (int i = 0; i < expected.Length; i++) - { - Assert.Equal(expected[i], actual[i]); - } + for (int i = 0; i < expected.Length; i++) + { + Assert.Equal(expected[i], actual[i]); } } } diff --git a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs index 0b4bd9d..1c239b3 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs @@ -9,134 +9,133 @@ using SpatialLite.Core.IO; using System.IO; -namespace Tests.SpatialLite.Core.IO +namespace Tests.SpatialLite.Core.IO; + +public class WktTokenizerTests { - public class WktTokenizerTests - { - [Fact] - void Tokenize_String_ReturnsEmptyTokenForEmptyString() - { - string data = string.Empty; - var tokens = WktTokenizer.Tokenize(data); + [Fact] + void Tokenize_String_ReturnsEmptyTokenForEmptyString() + { + string data = string.Empty; + var tokens = WktTokenizer.Tokenize(data); - Assert.Empty(tokens); - } + Assert.Empty(tokens); + } - [Theory] - [InlineData("stringTOOKEN", TokenType.STRING)] - [InlineData(" ", TokenType.WHITESPACE)] - [InlineData("\t", TokenType.WHITESPACE)] - [InlineData("\n", TokenType.WHITESPACE)] - [InlineData("\r", TokenType.WHITESPACE)] - [InlineData("(", TokenType.LEFT_PARENTHESIS)] - [InlineData(")", TokenType.RIGHT_PARENTHESIS)] - [InlineData(",", TokenType.COMMA)] - [InlineData("-123456780.9", TokenType.NUMBER)] - void Tokenize_String_CorrectlyRecognizesTokenTypes(string str, TokenType expectedType) - { - var tokens = WktTokenizer.Tokenize(str).ToArray(); + [Theory] + [InlineData("stringTOOKEN", TokenType.STRING)] + [InlineData(" ", TokenType.WHITESPACE)] + [InlineData("\t", TokenType.WHITESPACE)] + [InlineData("\n", TokenType.WHITESPACE)] + [InlineData("\r", TokenType.WHITESPACE)] + [InlineData("(", TokenType.LEFT_PARENTHESIS)] + [InlineData(")", TokenType.RIGHT_PARENTHESIS)] + [InlineData(",", TokenType.COMMA)] + [InlineData("-123456780.9", TokenType.NUMBER)] + void Tokenize_String_CorrectlyRecognizesTokenTypes(string str, TokenType expectedType) + { + var tokens = WktTokenizer.Tokenize(str).ToArray(); - Assert.Single(tokens); + Assert.Single(tokens); - WktToken t = tokens.First(); - Assert.Equal(expectedType, t.Type); - Assert.Equal(str, t.Value); - } + WktToken t = tokens.First(); + Assert.Equal(expectedType, t.Type); + Assert.Equal(str, t.Value); + } - [Fact] - void Tokenize_String_ProcessesComplexText() - { - string data = "point z (-10 -15 -100.1)"; - var tokens = WktTokenizer.Tokenize(data).ToArray(); + [Fact] + void Tokenize_String_ProcessesComplexText() + { + string data = "point z (-10 -15 -100.1)"; + var tokens = WktTokenizer.Tokenize(data).ToArray(); - Assert.Equal(11, tokens.Length); + Assert.Equal(11, tokens.Length); - WktToken t = tokens[0]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("point", t.Value); + WktToken t = tokens[0]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("point", t.Value); - t = tokens[1]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[1]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[2]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("z", t.Value); + t = tokens[2]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("z", t.Value); - t = tokens[3]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[3]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[4]; - Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); + t = tokens[4]; + Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); - t = tokens[5]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-10", t.Value); + t = tokens[5]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-10", t.Value); - t = tokens[6]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[6]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[7]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-15", t.Value); + t = tokens[7]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-15", t.Value); - t = tokens[8]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[8]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[9]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-100.1", t.Value); + t = tokens[9]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-100.1", t.Value); - t = tokens[10]; - Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); - } + t = tokens[10]; + Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); + } - [Fact] - void Tokenize_TextReader_ProcessesComplexText() - { - StringReader reader = new StringReader("point z (-10 -15 -100.1)"); + [Fact] + void Tokenize_TextReader_ProcessesComplexText() + { + StringReader reader = new StringReader("point z (-10 -15 -100.1)"); - var tokens = WktTokenizer.Tokenize(reader).ToArray(); + var tokens = WktTokenizer.Tokenize(reader).ToArray(); - Assert.Equal(11, tokens.Length); + Assert.Equal(11, tokens.Length); - WktToken t = tokens[0]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("point", t.Value); + WktToken t = tokens[0]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("point", t.Value); - t = tokens[1]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[1]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[2]; - Assert.Equal(TokenType.STRING, t.Type); - Assert.Equal("z", t.Value); + t = tokens[2]; + Assert.Equal(TokenType.STRING, t.Type); + Assert.Equal("z", t.Value); - t = tokens[3]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[3]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[4]; - Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); + t = tokens[4]; + Assert.Equal(TokenType.LEFT_PARENTHESIS, t.Type); - t = tokens[5]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-10", t.Value); + t = tokens[5]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-10", t.Value); - t = tokens[6]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[6]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[7]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-15", t.Value); + t = tokens[7]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-15", t.Value); - t = tokens[8]; - Assert.Equal(TokenType.WHITESPACE, t.Type); + t = tokens[8]; + Assert.Equal(TokenType.WHITESPACE, t.Type); - t = tokens[9]; - Assert.Equal(TokenType.NUMBER, t.Type); - Assert.Equal("-100.1", t.Value); + t = tokens[9]; + Assert.Equal(TokenType.NUMBER, t.Type); + Assert.Equal("-100.1", t.Value); - t = tokens[10]; - Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); - } + t = tokens[10]; + Assert.Equal(TokenType.RIGHT_PARENTHESIS, t.Type); } } diff --git a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs index 7b88fff..6dafd5f 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs @@ -7,199 +7,198 @@ using SpatialLite.Core.IO; -namespace Tests.SpatialLite.Core.IO +namespace Tests.SpatialLite.Core.IO; + +public class WktTokensBufferTests { - public class WktTokensBufferTests + WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, + new WktToken() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; + + [Fact] + public void Constructor__CreatesEmptyBuffer() { - WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, - new WktToken() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; + WktTokensBuffer target = new WktTokensBuffer(); - [Fact] - public void Constructor__CreatesEmptyBuffer() - { - WktTokensBuffer target = new WktTokensBuffer(); + Assert.Empty(target); + } - Assert.Empty(target); - } + [Fact] + public void Constructor_TextReader_CreatesBufferWithSpecificTokens() + { + WktTokensBuffer target = new WktTokensBuffer(_testData); - [Fact] - public void Constructor_TextReader_CreatesBufferWithSpecificTokens() + Assert.Equal(_testData.Length, target.Count()); + for (int i = 0; i < _testData.Length; i++) { - WktTokensBuffer target = new WktTokensBuffer(_testData); - - Assert.Equal(_testData.Length, target.Count()); - for (int i = 0; i < _testData.Length; i++) - { - Assert.Equal(_testData[i], target.ToArray()[i]); - } + Assert.Equal(_testData[i], target.ToArray()[i]); } + } - [Fact] - public void Count_GetsNumberOfItemsInBufffer() - { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData); + [Fact] + public void Count_GetsNumberOfItemsInBufffer() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData); - Assert.Equal(_testData.Length, target.Count); - } + Assert.Equal(_testData.Length, target.Count); + } - [Fact] - public void Add_WktToken_AddsItemToTheCollection() - { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData[0]); + [Fact] + public void Add_WktToken_AddsItemToTheCollection() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData[0]); - Assert.Single(target); - Assert.Contains(_testData[0], target); - } + Assert.Single(target); + Assert.Contains(_testData[0], target); + } - [Fact] - public void Add_IEnumerable_AddsItemsToTheCollection() + [Fact] + public void Add_IEnumerable_AddsItemsToTheCollection() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData); + + Assert.Equal(_testData.Length, target.Count()); + for (int i = 0; i < _testData.Length; i++) { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData); - - Assert.Equal(_testData.Length, target.Count()); - for (int i = 0; i < _testData.Length; i++) - { - Assert.Equal(_testData[i], target.ToArray()[i]); - } + Assert.Equal(_testData[i], target.ToArray()[i]); } + } - [Fact] - public void Clear_RemovesAllItemsFromCollection() - { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData); + [Fact] + public void Clear_RemovesAllItemsFromCollection() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData); - target.Clear(); + target.Clear(); - Assert.Empty(target); - } + Assert.Empty(target); + } - [Fact] - public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() - { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData[0]); + [Fact] + public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData[0]); - var result = target.Peek(false); + var result = target.Peek(false); - Assert.Equal(_testData[0], result); - Assert.Contains(_testData[0], target); - } + Assert.Equal(_testData[0], result); + Assert.Contains(_testData[0], target); + } - [Fact] - public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() - { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(_testData[0]); + [Fact] + public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(_testData[0]); - var result = target.Peek(true); + var result = target.Peek(true); - Assert.Equal(_testData[0], result); - Assert.Equal(3, target.Count); - } + Assert.Equal(_testData[0], result); + Assert.Equal(3, target.Count); + } - [Fact] - public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() - { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); - target.Add(_testData[0]); + [Fact] + public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); + target.Add(_testData[0]); - var result = target.Peek(false); + var result = target.Peek(false); - Assert.Equal(whitespaceToken, result); - Assert.Equal(2, target.Count); - } + Assert.Equal(whitespaceToken, result); + Assert.Equal(2, target.Count); + } - [Fact] - public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() - { - WktTokensBuffer target = new WktTokensBuffer(); + [Fact] + public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() + { + WktTokensBuffer target = new WktTokensBuffer(); - var result = target.Peek(false); + var result = target.Peek(false); - Assert.Equal(WktToken.EndOfDataToken, result); - } + Assert.Equal(WktToken.EndOfDataToken, result); + } - [Fact] - public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() - { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); + [Fact] + public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); - var result = target.Peek(true); + var result = target.Peek(true); - Assert.Equal(WktToken.EndOfDataToken, result); - } + Assert.Equal(WktToken.EndOfDataToken, result); + } - [Fact] - public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() - { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(_testData[0]); + [Fact] + public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(_testData[0]); - var result = target.GetToken(false); + var result = target.GetToken(false); - Assert.Equal(_testData[0], result); - Assert.DoesNotContain(_testData[0], target); - } + Assert.Equal(_testData[0], result); + Assert.DoesNotContain(_testData[0], target); + } - [Fact] - public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() - { - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); - target.Add(_testData[0]); + [Fact] + public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() + { + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); + target.Add(_testData[0]); - var result = target.GetToken(true); + var result = target.GetToken(true); - Assert.Equal(_testData[0], result); - Assert.Equal(0, target.Count); - } + Assert.Equal(_testData[0], result); + Assert.Equal(0, target.Count); + } - [Fact] - public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() - { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); - target.Add(_testData[0]); + [Fact] + public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); + target.Add(_testData[0]); - var result = target.GetToken(false); + var result = target.GetToken(false); - Assert.Equal(whitespaceToken, result); - Assert.Equal(1, target.Count); - } + Assert.Equal(whitespaceToken, result); + Assert.Equal(1, target.Count); + } - [Fact] - public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() - { - WktTokensBuffer target = new WktTokensBuffer(); + [Fact] + public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() + { + WktTokensBuffer target = new WktTokensBuffer(); - var result = target.GetToken(false); + var result = target.GetToken(false); - Assert.Equal(WktToken.EndOfDataToken, result); - } + Assert.Equal(WktToken.EndOfDataToken, result); + } - [Fact] - public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() - { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); - target.Add(whitespaceToken); + [Fact] + public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() + { + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); + target.Add(whitespaceToken); - var result = target.GetToken(true); + var result = target.GetToken(true); - Assert.Equal(WktToken.EndOfDataToken, result); - Assert.Empty(target); - } + Assert.Equal(WktToken.EndOfDataToken, result); + Assert.Empty(target); } } diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs index d5d846d..60f9e55 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs @@ -7,18 +7,17 @@ using SpatialLite.Core.IO; -namespace Tests.SpatialLite.Core.IO -{ - public class WktWriterSettingsTests - { +namespace Tests.SpatialLite.Core.IO; - [Fact] - public void Constructor__SetsDefaultValues() - { - WktWriterSettings target = new WktWriterSettings(); +public class WktWriterSettingsTests +{ - Assert.False(target.IsReadOnly); - } + [Fact] + public void Constructor__SetsDefaultValues() + { + WktWriterSettings target = new WktWriterSettings(); + Assert.False(target.IsReadOnly); } + } diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs index a1d1938..e0421f4 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs @@ -11,336 +11,335 @@ using SpatialLite.Core.Geometries; using SpatialLite.Core.IO; -namespace Tests.SpatialLite.Core.IO +namespace Tests.SpatialLite.Core.IO; + +public class WktWriterTests { - public class WktWriterTests - { - private static Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) - }; + private static Coordinate[] _coordinatesXY = new Coordinate[] { + new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) + }; - private static Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) - }; + private static Coordinate[] _coordinatesXYZ = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) + }; - private static Coordinate[] _coordinatesXYM = new Coordinate[] { - new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) - }; + private static Coordinate[] _coordinatesXYM = new Coordinate[] { + new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) + }; - private static Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) - }; + private static Coordinate[] _coordinatesXYZM = new Coordinate[] { + new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) + }; - private static Coordinate[] _coordinates2XYZM = new Coordinate[] { - new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) - }; + private static Coordinate[] _coordinates2XYZM = new Coordinate[] { + new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) + }; - [Fact] - public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + [Fact] + public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + { + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(new MemoryStream(), settings)) { - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(new MemoryStream(), settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() - { - Stream stream = null; - Assert.Throws(() => new WktWriter(stream, new WktWriterSettings())); - } + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + Stream stream = null; + Assert.Throws(() => new WktWriter(stream, new WktWriterSettings())); + } + + [Fact] + public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + Assert.Throws(() => new WktWriter(new MemoryStream(), null)); + } - [Fact] - public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + [Fact] + public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() + { + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(new MemoryStream(), settings)) { - Assert.Throws(() => new WktWriter(new MemoryStream(), null)); + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() + [Fact] + public void Constructor_PathSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("wktwriter-constructor-creates-output-test.wkt"); + File.Delete(filename); + + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(filename, settings)) { - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(new MemoryStream(), settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + ; } - [Fact] - public void Constructor_PathSettings_CreatesOutputFile() - { - string filename = PathHelper.GetTempFilePath("wktwriter-constructor-creates-output-test.wkt"); - File.Delete(filename); + Assert.True(File.Exists(filename)); + } - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(filename, settings)) - { - ; - } + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() + { + string path = null; + Assert.Throws(() => new WktWriter(path, new WktWriterSettings())); + } - Assert.True(File.Exists(filename)); - } + [Fact] + public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + { + string path = PathHelper.GetTempFilePath("WktWriter-constructor-test.bin"); - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfStreamIsNull() - { - string path = null; - Assert.Throws(() => new WktWriter(path, new WktWriterSettings())); - } + Assert.Throws(() => new WktWriter(path, null)); + } - [Fact] - public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull() + public static IEnumerable WriteToStringTestData + { + get { - string path = PathHelper.GetTempFilePath("WktWriter-constructor-test.bin"); + yield return new object[] { new Point(), "point empty" }; + yield return new object[] { new LineString(), "linestring empty" }; + yield return new object[] { new Polygon(), "polygon empty" }; + yield return new object[] { new MultiPoint(), "multipoint empty" }; + yield return new object[] { new MultiLineString(), "multilinestring empty" }; + yield return new object[] { new MultiPolygon(), "multipolygon empty" }; + yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; - Assert.Throws(() => new WktWriter(path, null)); - } - - public static IEnumerable WriteToStringTestData - { - get - { - yield return new object[] { new Point(), "point empty" }; - yield return new object[] { new LineString(), "linestring empty" }; - yield return new object[] { new Polygon(), "polygon empty" }; - yield return new object[] { new MultiPoint(), "multipoint empty" }; - yield return new object[] { new MultiLineString(), "multilinestring empty" }; - yield return new object[] { new MultiPolygon(), "multipolygon empty" }; - yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; - - } } + } - [Theory] - [MemberData(nameof(WriteToStringTestData))] - public void WriteToString_WritesAllGeometryTypes(Geometry toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(WriteToStringTestData))] + public void WriteToString_WritesAllGeometryTypes(Geometry toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = PathHelper.GetTempFilePath("wktwriter-closes-output-filestream-test.wkt"); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = PathHelper.GetTempFilePath("wktwriter-closes-output-filestream-test.wkt"); - WktWriterSettings settings = new WktWriterSettings(); - WktWriter target = new WktWriter(filename, settings); - target.Dispose(); + WktWriterSettings settings = new WktWriterSettings(); + WktWriter target = new WktWriter(filename, settings); + target.Dispose(); - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() - { - MemoryStream stream = new MemoryStream(); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + MemoryStream stream = new MemoryStream(); - WktWriter target = new WktWriter(stream, new WktWriterSettings()); - target.Dispose(); + WktWriter target = new WktWriter(stream, new WktWriterSettings()); + target.Dispose(); - Assert.False(stream.CanRead); - } + Assert.False(stream.CanRead); + } - public static IEnumerable Write_WritesPointsOfAllDimensionsTestData + public static IEnumerable Write_WritesPointsOfAllDimensionsTestData + { + get { - get - { - yield return new object[] { new Point(), "point empty" }; - yield return new object[] { new Point(_coordinatesXY[0]), "point (-10.1 15.5)" }; - yield return new object[] { new Point(_coordinatesXYM[0]), "point m (-10.1 15.5 1000.5)" }; - yield return new object[] { new Point(_coordinatesXYZ[0]), "point z (-10.1 15.5 100.5)" }; - yield return new object[] { new Point(_coordinatesXYZM[0]), "point zm (-10.1 15.5 100.5 1000.5)" }; - } + yield return new object[] { new Point(), "point empty" }; + yield return new object[] { new Point(_coordinatesXY[0]), "point (-10.1 15.5)" }; + yield return new object[] { new Point(_coordinatesXYM[0]), "point m (-10.1 15.5 1000.5)" }; + yield return new object[] { new Point(_coordinatesXYZ[0]), "point z (-10.1 15.5 100.5)" }; + yield return new object[] { new Point(_coordinatesXYZM[0]), "point zm (-10.1 15.5 100.5 1000.5)" }; } + } - [Theory] - [MemberData(nameof(Write_WritesPointsOfAllDimensionsTestData))] - public void Write_WritesPointsOfAllDimensions(Point toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(Write_WritesPointsOfAllDimensionsTestData))] + public void Write_WritesPointsOfAllDimensions(Point toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - public static IEnumerable Write_WritesLinestringOfAllDimensionsTestData + public static IEnumerable Write_WritesLinestringOfAllDimensionsTestData + { + get { - get - { - yield return new object[] { new LineString(), "linestring empty" }; - yield return new object[] { new LineString(_coordinatesXY), "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)" }; - yield return new object[] { new LineString(_coordinatesXYM), "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)" }; - yield return new object[] { new LineString(_coordinatesXYZ), "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)" }; - yield return new object[] { new LineString(_coordinatesXYZM), "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)" }; - } + yield return new object[] { new LineString(), "linestring empty" }; + yield return new object[] { new LineString(_coordinatesXY), "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)" }; + yield return new object[] { new LineString(_coordinatesXYM), "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)" }; + yield return new object[] { new LineString(_coordinatesXYZ), "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)" }; + yield return new object[] { new LineString(_coordinatesXYZM), "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)" }; } + } - [Theory] - [MemberData(nameof(Write_WritesLinestringOfAllDimensionsTestData))] - public void Write_WritesLinestringsOfAllDimensions(LineString toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(Write_WritesLinestringOfAllDimensionsTestData))] + public void Write_WritesLinestringsOfAllDimensions(LineString toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - public static IEnumerable Write_WritesPolygonsOfAllDimensionsTestData + public static IEnumerable Write_WritesPolygonsOfAllDimensionsTestData + { + get { - get - { - yield return new object[] { new Polygon(), "polygon empty" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXY)), "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYM)), "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZ)), "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; - yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZM)), "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; - } + yield return new object[] { new Polygon(), "polygon empty" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXY)), "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYM)), "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZ)), "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; + yield return new object[] { new Polygon(new CoordinateList(_coordinatesXYZM)), "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; } + } - [Theory] - [MemberData(nameof(Write_WritesPolygonsOfAllDimensionsTestData))] - public void Write_WritesPolygonsOfAllDimensions(Polygon toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(Write_WritesPolygonsOfAllDimensionsTestData))] + public void Write_WritesPolygonsOfAllDimensions(Polygon toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - [Fact] - public void Write_WritesComplexPolygonWitOuterAndInnerRings() - { - string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon polygon = new Polygon(new CoordinateList(_coordinatesXYZM)); - polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); - polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); + [Fact] + public void Write_WritesComplexPolygonWitOuterAndInnerRings() + { + string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; + Polygon polygon = new Polygon(new CoordinateList(_coordinatesXYZM)); + polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); + polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); - this.TestWriteGeometry(polygon, wkt); - } + this.TestWriteGeometry(polygon, wkt); + } - public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestData + public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestData + { + get { - get - { - yield return new object[] { new MultiPoint(), "multipoint empty" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXY[0]), new Point(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYM[0]), new Point(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZ[0]), new Point(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZM[0]), new Point(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; - } + yield return new object[] { new MultiPoint(), "multipoint empty" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXY[0]), new Point(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYM[0]), new Point(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZ[0]), new Point(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZM[0]), new Point(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; } + } - [Theory] - [MemberData(nameof(Write_WritesMultiPoinsOfAllDimensionsTestData))] - public void Write_WritesMultiPointsOfAllDimensions(MultiPoint toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(Write_WritesMultiPoinsOfAllDimensionsTestData))] + public void Write_WritesMultiPointsOfAllDimensions(MultiPoint toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsTestData + public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsTestData + { + get { - get - { - yield return new object[] { new MultiLineString(), "multilinestring empty" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXY), new LineString(_coordinatesXY) }), - "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYM), new LineString(_coordinatesXYM) }), - "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZ), new LineString(_coordinatesXYZ) }), - "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZM), new LineString(_coordinatesXYZM) }), - "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; - } + yield return new object[] { new MultiLineString(), "multilinestring empty" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXY), new LineString(_coordinatesXY) }), + "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYM), new LineString(_coordinatesXYM) }), + "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZ), new LineString(_coordinatesXYZ) }), + "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZM), new LineString(_coordinatesXYZM) }), + "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; } + } - [Theory] - [MemberData(nameof(Write_WritesMultiLineStringsOfAllDimensionsTestData))] - public void Write_WritesMultiLineStringsOfAllDimensions(MultiLineString toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(Write_WritesMultiLineStringsOfAllDimensionsTestData))] + public void Write_WritesMultiLineStringsOfAllDimensions(MultiLineString toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTestData + public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTestData + { + get { - get - { - yield return new object[] { new MultiPolygon(), "multipolygon empty" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXY)), new Polygon(new CoordinateList(_coordinatesXY)) }), - "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYM)), new Polygon(new CoordinateList(_coordinatesXYM)) }), - "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZ)), new Polygon(new CoordinateList(_coordinatesXYZ)) }), - "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZM)), new Polygon(new CoordinateList(_coordinatesXYZM)) }), - "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))" }; - } + yield return new object[] { new MultiPolygon(), "multipolygon empty" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXY)), new Polygon(new CoordinateList(_coordinatesXY)) }), + "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYM)), new Polygon(new CoordinateList(_coordinatesXYM)) }), + "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZ)), new Polygon(new CoordinateList(_coordinatesXYZ)) }), + "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))" }; + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZM)), new Polygon(new CoordinateList(_coordinatesXYZM)) }), + "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))" }; } + } - [Theory] - [MemberData(nameof(Write_WritesMultiPolygonsOfAllDimensionsTestData))] - public void Write_WritesMultiPolygonsOfAllDimensions(MultiPolygon toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(Write_WritesMultiPolygonsOfAllDimensionsTestData))] + public void Write_WritesMultiPolygonsOfAllDimensions(MultiPolygon toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - public static IEnumerable Write_WritesGeometryCollectionOfAllDimensionsTestData + public static IEnumerable Write_WritesGeometryCollectionOfAllDimensionsTestData + { + get { - get - { - yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXY[0]) }), "geometrycollection (point (-10.1 15.5))" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYM[0]) }), "geometrycollection m (point m (-10.1 15.5 1000.5))" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZ[0]) }), "geometrycollection z (point z (-10.1 15.5 100.5))" }; - yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZM[0]) }), "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))" }; - } + yield return new object[] { new GeometryCollection(), "geometrycollection empty" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXY[0]) }), "geometrycollection (point (-10.1 15.5))" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYM[0]) }), "geometrycollection m (point m (-10.1 15.5 1000.5))" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZ[0]) }), "geometrycollection z (point z (-10.1 15.5 100.5))" }; + yield return new object[] { new GeometryCollection(new Geometry[] { new Point(_coordinatesXYZM[0]) }), "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))" }; } + } - [Theory] - [MemberData(nameof(Write_WritesGeometryCollectionOfAllDimensionsTestData))] - public void Write_WritesGeometryCollectionOfAllDimensions(GeometryCollection toWrite, string expectedWkt) - { - this.TestWriteGeometry(toWrite, expectedWkt); - } + [Theory] + [MemberData(nameof(Write_WritesGeometryCollectionOfAllDimensionsTestData))] + public void Write_WritesGeometryCollectionOfAllDimensions(GeometryCollection toWrite, string expectedWkt) + { + this.TestWriteGeometry(toWrite, expectedWkt); + } - [Fact] - public void Write_WritesCollectionWithAllGeometryTypes() - { - string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection collection = new GeometryCollection(); - collection.Geometries.Add(new Point(_coordinatesXY[0])); - collection.Geometries.Add(new LineString(_coordinatesXY)); - collection.Geometries.Add(new Polygon(new CoordinateList(_coordinatesXY))); - collection.Geometries.Add(new MultiPoint()); - collection.Geometries.Add(new MultiLineString()); - collection.Geometries.Add(new MultiPolygon()); - - this.TestWriteGeometry(collection, wkt); - } + [Fact] + public void Write_WritesCollectionWithAllGeometryTypes() + { + string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),multipoint empty,multilinestring empty,multipolygon empty)"; + GeometryCollection collection = new GeometryCollection(); + collection.Geometries.Add(new Point(_coordinatesXY[0])); + collection.Geometries.Add(new LineString(_coordinatesXY)); + collection.Geometries.Add(new Polygon(new CoordinateList(_coordinatesXY))); + collection.Geometries.Add(new MultiPoint()); + collection.Geometries.Add(new MultiLineString()); + collection.Geometries.Add(new MultiPolygon()); + + this.TestWriteGeometry(collection, wkt); + } - [Fact] - public void Write_WritesNestedCollection() - { - string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection collection = new GeometryCollection(); - GeometryCollection nested = new GeometryCollection(); - nested.Geometries.Add(new Point(_coordinatesXY[0])); - collection.Geometries.Add(nested); + [Fact] + public void Write_WritesNestedCollection() + { + string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; + GeometryCollection collection = new GeometryCollection(); + GeometryCollection nested = new GeometryCollection(); + nested.Geometries.Add(new Point(_coordinatesXY[0])); + collection.Geometries.Add(nested); + + this.TestWriteGeometry(collection, wkt); + } - this.TestWriteGeometry(collection, wkt); + private void TestWriteGeometry(IGeometry geometry, string expectedWkt) + { + MemoryStream stream = new MemoryStream(); + using (WktWriter writer = new WktWriter(stream, new WktWriterSettings())) + { + writer.Write(geometry); } - private void TestWriteGeometry(IGeometry geometry, string expectedWkt) + using (TextReader tr = new StreamReader(new MemoryStream(stream.ToArray()))) { - MemoryStream stream = new MemoryStream(); - using (WktWriter writer = new WktWriter(stream, new WktWriterSettings())) - { - writer.Write(geometry); - } - - using (TextReader tr = new StreamReader(new MemoryStream(stream.ToArray()))) - { - string wkt = tr.ReadToEnd(); - Assert.Equal(expectedWkt, wkt, StringComparer.OrdinalIgnoreCase); - } + string wkt = tr.ReadToEnd(); + Assert.Equal(expectedWkt, wkt, StringComparer.OrdinalIgnoreCase); } } } diff --git a/src/Tests.SpatialLite.Core/MeasurementsTests.cs b/src/Tests.SpatialLite.Core/MeasurementsTests.cs index c7fb079..72b7044 100644 --- a/src/Tests.SpatialLite.Core/MeasurementsTests.cs +++ b/src/Tests.SpatialLite.Core/MeasurementsTests.cs @@ -11,286 +11,285 @@ using SpatialLite.Core.Geometries; using SpatialLite.Core.Algorithms; -namespace Tests.SpatialLite.Core -{ - public class MeasurementsTests - { - - [Fact] - public void Euclidean2D_GetsInstanceOfMeasuremntsWithTheEuclidean2DCalculator() - { - Assert.IsType(Measurements.Euclidean2D.DimensionsCalculator); - } +namespace Tests.SpatialLite.Core; - [Fact] - public void Sphere2D_GetsInstanceOfMeasuremntsWithTheSphere2DCalculator() - { - Assert.IsType(Measurements.Sphere2D.DimensionsCalculator); - } - - [Fact] - public void Constructor_SetsCalculatorObject() - { - Mock calculatorM = new Mock(); - - Measurements target = new Measurements(calculatorM.Object); +public class MeasurementsTests +{ - Assert.Same(calculatorM.Object, target.DimensionsCalculator); - } + [Fact] + public void Euclidean2D_GetsInstanceOfMeasuremntsWithTheEuclidean2DCalculator() + { + Assert.IsType(Measurements.Euclidean2D.DimensionsCalculator); + } - [Fact] - public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCorrectParameters() - { - Coordinate c1 = new Coordinate(10.1, 20.1); - Coordinate c2 = new Coordinate(10.2, 20.2); - Mock calculatorM = new Mock(); + [Fact] + public void Sphere2D_GetsInstanceOfMeasuremntsWithTheSphere2DCalculator() + { + Assert.IsType(Measurements.Sphere2D.DimensionsCalculator); + } - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(c1, c2); + [Fact] + public void Constructor_SetsCalculatorObject() + { + Mock calculatorM = new Mock(); - calculatorM.Verify(calc => calc.CalculateDistance(c1, c2), Times.Once()); - } + Measurements target = new Measurements(calculatorM.Object); - [Fact] - public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() - { - Point p1 = new Point(Coordinate.Empty); - Point p2 = new Point(new Coordinate(10.2, 20.2)); - Mock calculatorM = new Mock(); + Assert.Same(calculatorM.Object, target.DimensionsCalculator); + } - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(p1, p2); + [Fact] + public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCorrectParameters() + { + Coordinate c1 = new Coordinate(10.1, 20.1); + Coordinate c2 = new Coordinate(10.2, 20.2); + Mock calculatorM = new Mock(); - Assert.True(double.IsNaN(distance)); - } + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(c1, c2); - [Fact] - public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() - { - Point p1 = new Point(new Coordinate(10.1, 20.1)); - Point p2 = new Point(Coordinate.Empty); - Mock calculatorM = new Mock(); + calculatorM.Verify(calc => calc.CalculateDistance(c1, c2), Times.Once()); + } - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(p1, p2); + [Fact] + public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() + { + Point p1 = new Point(Coordinate.Empty); + Point p2 = new Point(new Coordinate(10.2, 20.2)); + Mock calculatorM = new Mock(); - Assert.True(double.IsNaN(distance)); - } + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(p1, p2); - [Fact] - public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParameters() - { - Point p1 = new Point(new Coordinate(10.1, 20.1)); - Point p2 = new Point(new Coordinate(10.2, 20.2)); - Mock calculatorM = new Mock(); + Assert.True(double.IsNaN(distance)); + } - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(p1, p2); + [Fact] + public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() + { + Point p1 = new Point(new Coordinate(10.1, 20.1)); + Point p2 = new Point(Coordinate.Empty); + Mock calculatorM = new Mock(); - calculatorM.Verify(calc => calc.CalculateDistance(p1.Position, p2.Position), Times.Once()); - } + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(p1, p2); - [Fact] - public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() - { - Point point = new Point(new Coordinate(10.1, 20.1)); - LineString linestring = new LineString(); + Assert.True(double.IsNaN(distance)); + } - Mock calculatorM = new Mock(); + [Fact] + public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParameters() + { + Point p1 = new Point(new Coordinate(10.1, 20.1)); + Point p2 = new Point(new Coordinate(10.2, 20.2)); + Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, linestring); + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(p1, p2); - Assert.True(double.IsNaN(distance)); - } + calculatorM.Verify(calc => calc.CalculateDistance(p1.Position, p2.Position), Times.Once()); + } - [Fact] - public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() - { - Point point = new Point(Coordinate.Empty); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + [Fact] + public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() + { + Point point = new Point(new Coordinate(10.1, 20.1)); + LineString linestring = new LineString(); - Mock calculatorM = new Mock(); + Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, linestring); + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, linestring); - Assert.True(double.IsNaN(distance)); - } + Assert.True(double.IsNaN(distance)); + } - [Fact] - public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEmpty() - { - Point point = new Point(new Coordinate(10.1, 20.1)); - MultiLineString multilinestring = new MultiLineString(); + [Fact] + public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() + { + Point point = new Point(Coordinate.Empty); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - Mock calculatorM = new Mock(); + Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, multilinestring); + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, linestring); - Assert.True(double.IsNaN(distance)); - } + Assert.True(double.IsNaN(distance)); + } - [Fact] - public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() - { - Point point = new Point(Coordinate.Empty); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); + [Fact] + public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEmpty() + { + Point point = new Point(new Coordinate(10.1, 20.1)); + MultiLineString multilinestring = new MultiLineString(); - Mock calculatorM = new Mock(); + Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); - double distance = target.ComputeDistance(point, multilinestring); + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, multilinestring); - Assert.True(double.IsNaN(distance)); - } + Assert.True(double.IsNaN(distance)); + } - [Fact] - public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() - { - LineString linestring = new LineString(); + [Fact] + public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() + { + Point point = new Point(Coordinate.Empty); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); + Mock calculatorM = new Mock(); - double length = target.ComputeLength(linestring); + Measurements target = new Measurements(calculatorM.Object); + double distance = target.ComputeDistance(point, multilinestring); - Assert.Equal(0, length); - } + Assert.True(double.IsNaN(distance)); + } - [Fact] - public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() - { - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1) }); + [Fact] + public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() + { + LineString linestring = new LineString(); - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); - double length = target.ComputeLength(linestring); + double length = target.ComputeLength(linestring); - Assert.Equal(0, length); - } + Assert.Equal(0, length); + } - [Fact] - public void ComputeLength_LineString_RetursSumOfSegmentsLengths() - { - Random generator = new Random(); - double segment1Length = generator.Next(100); - double segment2Length = generator.Next(100); - double sum = segment1Length + segment2Length; + [Fact] + public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() + { + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1) }); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); - Measurements target = new Measurements(calculatorM.Object); - double length = target.ComputeLength(linestring); + double length = target.ComputeLength(linestring); - Assert.Equal(sum, length); - } + Assert.Equal(0, length); + } - [Fact] - public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMembers() - { - MultiLineString multilinestring = new MultiLineString(); + [Fact] + public void ComputeLength_LineString_RetursSumOfSegmentsLengths() + { + Random generator = new Random(); + double segment1Length = generator.Next(100); + double segment2Length = generator.Next(100); + double sum = segment1Length + segment2Length; - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - double length = target.ComputeLength(multilinestring); + Measurements target = new Measurements(calculatorM.Object); + double length = target.ComputeLength(linestring); - Assert.Equal(0, length); - } + Assert.Equal(sum, length); + } - [Fact] - public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() - { - Random generator = new Random(); - double segment1Length = generator.Next(100); - double segment2Length = generator.Next(100); - double sum = 2 * (segment1Length + segment2Length); + [Fact] + public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMembers() + { + MultiLineString multilinestring = new MultiLineString(); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); - calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); + double length = target.ComputeLength(multilinestring); - Measurements target = new Measurements(calculatorM.Object); - double length = target.ComputeLength(multilinestring); + Assert.Equal(0, length); + } - Assert.Equal(sum, length); - } + [Fact] + public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() + { + Random generator = new Random(); + double segment1Length = generator.Next(100); + double segment2Length = generator.Next(100); + double sum = 2 * (segment1Length + segment2Length); - [Fact] - public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator() - { - Polygon polygon = new Polygon(new CoordinateList()); - Random generator = new Random(); - double expectedArea = generator.Next(100); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea); - Measurements target = new Measurements(calculatorM.Object); + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); + calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - double area = target.ComputeArea(polygon); + Measurements target = new Measurements(calculatorM.Object); + double length = target.ComputeLength(multilinestring); - Assert.Equal(expectedArea, area); - } + Assert.Equal(sum, length); + } - [Fact] - public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator() - { - // Create polygon with interior ring - Polygon polygon = new Polygon(new CoordinateList()); - polygon.InteriorRings.Add(new CoordinateList()); + [Fact] + public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator() + { + Polygon polygon = new Polygon(new CoordinateList()); + Random generator = new Random(); + double expectedArea = generator.Next(100); - // Fixed test values - double exteriorArea = 50; - double interiorArea = 10; - double expectedArea = exteriorArea - interiorArea; + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea); + Measurements target = new Measurements(calculatorM.Object); - // Setup mock - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateArea(It.IsAny())) - .Returns(coords => - { - if (coords == polygon.ExteriorRing) return exteriorArea; - if (coords == polygon.InteriorRings[0]) return interiorArea; - return 0; - }); + double area = target.ComputeArea(polygon); - // Create the object being tested - Measurements target = new Measurements(calculatorM.Object); + Assert.Equal(expectedArea, area); + } - // Execute the method being tested - double area = target.ComputeArea(polygon); + [Fact] + public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator() + { + // Create polygon with interior ring + Polygon polygon = new Polygon(new CoordinateList()); + polygon.InteriorRings.Add(new CoordinateList()); + + // Fixed test values + double exteriorArea = 50; + double interiorArea = 10; + double expectedArea = exteriorArea - interiorArea; + + // Setup mock + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateArea(It.IsAny())) + .Returns(coords => + { + if (coords == polygon.ExteriorRing) return exteriorArea; + if (coords == polygon.InteriorRings[0]) return interiorArea; + return 0; + }); + + // Create the object being tested + Measurements target = new Measurements(calculatorM.Object); + + // Execute the method being tested + double area = target.ComputeArea(polygon); + + // Verify the result + Assert.Equal(expectedArea, area); + } - // Verify the result - Assert.Equal(expectedArea, area); - } - - [Fact] - public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas() - { - Random generator = new Random(); + [Fact] + public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas() + { + Random generator = new Random(); - Polygon polygon = new Polygon(new CoordinateList()); - double polygonArea = generator.Next(100); - MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon }); + Polygon polygon = new Polygon(new CoordinateList()); + double polygonArea = generator.Next(100); + MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon }); - Mock calculatorM = new Mock(); - calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea); + Mock calculatorM = new Mock(); + calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); - double area = target.ComputeArea(multipolygon); + double area = target.ComputeArea(multipolygon); - Assert.Equal(2 * polygonArea, area); - } + Assert.Equal(2 * polygonArea, area); } } diff --git a/src/Tests.SpatialLite.Core/PathHelper.cs b/src/Tests.SpatialLite.Core/PathHelper.cs index b7c8d09..b7b5bb9 100644 --- a/src/Tests.SpatialLite.Core/PathHelper.cs +++ b/src/Tests.SpatialLite.Core/PathHelper.cs @@ -1,28 +1,27 @@ using System.IO; -namespace Tests.SpatialLite.Core +namespace Tests.SpatialLite.Core; + +static class PathHelper { - static class PathHelper - { - private const string TempDirectoryName = "Temp"; + private const string TempDirectoryName = "Temp"; - private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); - public static string RealGpxFilePath => _realGpxFilePath; + private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); + public static string RealGpxFilePath => _realGpxFilePath; - public static string GetTempFilePath(string filename) + public static string GetTempFilePath(string filename) + { + if (!Directory.Exists(TempDirectoryName)) { - if (!Directory.Exists(TempDirectoryName)) - { - Directory.CreateDirectory(TempDirectoryName); - } - - string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); - if (File.Exists(pbfFile)) - { - File.Delete(pbfFile); - } + Directory.CreateDirectory(TempDirectoryName); + } - return pbfFile; + string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); + if (File.Exists(pbfFile)) + { + File.Delete(pbfFile); } + + return pbfFile; } } diff --git a/src/Tests.SpatialLite.Core/TopologyTests.cs b/src/Tests.SpatialLite.Core/TopologyTests.cs index 49ddfd5..5518017 100644 --- a/src/Tests.SpatialLite.Core/TopologyTests.cs +++ b/src/Tests.SpatialLite.Core/TopologyTests.cs @@ -10,16 +10,15 @@ using Xunit; using Moq; -namespace Tests.SpatialLite.Core -{ - public class TopologyTests - { +namespace Tests.SpatialLite.Core; - [Fact] - public void Euclidean2D_GetTopologyInstanceWithEuclidean2DLocator() - { - Assert.IsType(Topology.Euclidean2D.GeometryLocator); - } +public class TopologyTests +{ + [Fact] + public void Euclidean2D_GetTopologyInstanceWithEuclidean2DLocator() + { + Assert.IsType(Topology.Euclidean2D.GeometryLocator); } + } diff --git a/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs b/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs index 9c7ec58..d60da25 100644 --- a/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs +++ b/src/Tests.SpatialLite.Gps/Data/TestDataReader.cs @@ -1,24 +1,23 @@ using System.IO; using System.Reflection; -namespace Tests.SpatialLite.Gps.Data +namespace Tests.SpatialLite.Gps.Data; + +public static class TestDataReader { - public static class TestDataReader + public static Stream Open(string name) { - public static Stream Open(string name) - { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name); - } + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name); + } - public static byte[] Read(string name) - { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + public static byte[] Read(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - var stream = new MemoryStream(); - assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name).CopyTo(stream); + var stream = new MemoryStream(); + assembly.GetManifestResourceStream("Tests.SpatialLite.Gps.Data.Gpx." + name).CopyTo(stream); - return stream.ToArray(); - } + return stream.ToArray(); } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs index d11e9fc..169892c 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs @@ -5,58 +5,57 @@ using SpatialLite.Gps.Geometries; using SpatialLite.Core.API; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpsPointTests { - public class GpsPointTests + + double _xOrdinate = 3.5; + double _yOrdinate = 4.2; + double _zOrdinate = 10.5; + + Coordinate _coordinate; + + public GpsPointTests() + { + _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); + } + + [Fact] + public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() + { + var target = new GpsPoint(); + + Assert.Equal(Coordinate.Empty, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() + { + var target = new GpsPoint(_coordinate); + + Assert.Equal(_coordinate, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() + { + var timestamp = DateTime.Now; + var target = new GpsPoint(_coordinate, timestamp); + + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); + } + + [Fact] + public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() { + var timestamp = DateTime.Now; + var target = new GpsPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - - Coordinate _coordinate; - - public GpsPointTests() - { - _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); - } - - [Fact] - public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() - { - var target = new GpsPoint(); - - Assert.Equal(Coordinate.Empty, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() - { - var target = new GpsPoint(_coordinate); - - Assert.Equal(_coordinate, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() - { - var timestamp = DateTime.Now; - var target = new GpsPoint(_coordinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } - - [Fact] - public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() - { - var timestamp = DateTime.Now; - var target = new GpsPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs index ec3735b..e03b49e 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs @@ -5,65 +5,64 @@ using SpatialLite.Gps.Geometries; using SpatialLite.Core.Geometries; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpsTrackBaseTests { - public class GpsTrackBaseTests - { - List _points; + List _points; - public GpsTrackBaseTests() - { - _points = new List { - new GpsPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), - new GpsPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), - new GpsPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; + public GpsTrackBaseTests() + { + _points = new List { + new GpsPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), + new GpsPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), + new GpsPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - } + } - [Fact] - public void Constructor__CreatesEmptyGpsTrack() - { - GpsTrackBase target = new GpsTrackBase(); + [Fact] + public void Constructor__CreatesEmptyGpsTrack() + { + GpsTrackBase target = new GpsTrackBase(); - Assert.Equal(0, target.Coordinates.Count); - } + Assert.Equal(0, target.Coordinates.Count); + } - [Fact] - public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() - { + [Fact] + public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() + { - GpsTrackBase target = new GpsTrackBase(_points); + GpsTrackBase target = new GpsTrackBase(_points); - Assert.Equal(_points.Count, target.Points.Count); - for (int i = 0; i < target.Points.Count; i++) - { - Assert.Same(_points[i], target.Points[i]); - } + Assert.Equal(_points.Count, target.Points.Count); + for (int i = 0; i < target.Points.Count; i++) + { + Assert.Same(_points[i], target.Points[i]); } + } - [Fact] - public void Coordinates_GetsPositionOfPoints() - { - GpsTrackBase target = new GpsTrackBase(_points); + [Fact] + public void Coordinates_GetsPositionOfPoints() + { + GpsTrackBase target = new GpsTrackBase(_points); - Assert.Equal(_points.Count, target.Coordinates.Count); - for (int i = 0; i < _points.Count; i++) - { - Assert.Equal(_points[i].Position, target.Coordinates[i]); - } + Assert.Equal(_points.Count, target.Coordinates.Count); + for (int i = 0; i < _points.Count; i++) + { + Assert.Equal(_points[i].Position, target.Coordinates[i]); } + } - [Fact] - public void Coordinates_GetsPositionOfPointsIfWayCastedToLineString() - { - GpsTrackBase line = new GpsTrackBase(_points); - LineString target = (LineString)line; + [Fact] + public void Coordinates_GetsPositionOfPointsIfWayCastedToLineString() + { + GpsTrackBase line = new GpsTrackBase(_points); + LineString target = (LineString)line; - Assert.Equal(_points.Count, target.Coordinates.Count); - for (int i = 0; i < _points.Count; i++) - { - Assert.Equal(_points[i].Position, target.Coordinates[i]); - } + Assert.Equal(_points.Count, target.Coordinates.Count); + for (int i = 0; i < _points.Count; i++) + { + Assert.Equal(_points[i].Position, target.Coordinates[i]); } } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs index 23584b3..ec475d8 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs @@ -2,47 +2,46 @@ using SpatialLite.Gps.Geometries; using Xunit; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpxFixHelperTests { - public class GpxFixHelperTests + public static IEnumerable GpsFixes { - public static IEnumerable GpsFixes + get { - get - { - yield return new object[] { GpsFix.Dgps, "dgps" }; - yield return new object[] { GpsFix.Fix2D, "2d" }; - yield return new object[] { GpsFix.Fix3D, "3d" }; - yield return new object[] { GpsFix.None, "none" }; - yield return new object[] { GpsFix.Pps, "pps" }; - } + yield return new object[] { GpsFix.Dgps, "dgps" }; + yield return new object[] { GpsFix.Fix2D, "2d" }; + yield return new object[] { GpsFix.Fix3D, "3d" }; + yield return new object[] { GpsFix.None, "none" }; + yield return new object[] { GpsFix.Pps, "pps" }; } + } - [Theory] - [MemberData(nameof(GpsFixes))] - public void ParseGpsFix_ValidGpsFixes_ParsesStringValue(GpsFix expectedValue, string s) - { - GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(s); + [Theory] + [MemberData(nameof(GpsFixes))] + public void ParseGpsFix_ValidGpsFixes_ParsesStringValue(GpsFix expectedValue, string s) + { + GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(s); - Assert.Equal(expectedValue, parsedValue); - } + Assert.Equal(expectedValue, parsedValue); + } - [Fact] - public void ParseGpsFix_InvalidValue_ReturnsNull() - { - string invalidValue = "some other string"; - GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(invalidValue); + [Fact] + public void ParseGpsFix_InvalidValue_ReturnsNull() + { + string invalidValue = "some other string"; + GpsFix? parsedValue = GpxFixHelper.ParseGpsFix(invalidValue); - Assert.Null(parsedValue); - } + Assert.Null(parsedValue); + } - [Theory] - [MemberData(nameof(GpsFixes))] - public void GpsFixToString_GpsFixes_ConvertsToStringEquivalents(GpsFix fix, string expectedValue) - { - string strValue = GpxFixHelper.GpsFixToString(fix); + [Theory] + [MemberData(nameof(GpsFixes))] + public void GpsFixToString_GpsFixes_ConvertsToStringEquivalents(GpsFix fix, string expectedValue) + { + string strValue = GpxFixHelper.GpsFixToString(fix); - Assert.Equal(expectedValue, strValue); - } + Assert.Equal(expectedValue, strValue); } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs index 408cf53..dd2aff7 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs @@ -2,19 +2,18 @@ using Xunit; using SpatialLite.Gps.Geometries; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpxLinkTests { - public class GpxLinkTests - { - [Fact] - public void Constructor_Url_SetsUrl() - { - Uri url = new Uri("http://spatial.litesolutions.net"); + [Fact] + public void Constructor_Url_SetsUrl() + { + Uri url = new Uri("http://spatial.litesolutions.net"); - GpxLink target = new GpxLink(url); + GpxLink target = new GpxLink(url); - Assert.Same(url, target.Url); - } + Assert.Same(url, target.Url); } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs index 23e0028..8c8ca44 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs @@ -2,21 +2,20 @@ using SpatialLite.Gps.Geometries; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpxMetadataTests { - public class GpxMetadataTests - { - [Fact] - public void Constructor_CreatesMetadataWithEmptyCollectionOfLinks() - { - GpxMetadata target = new GpxMetadataWrapper(); + [Fact] + public void Constructor_CreatesMetadataWithEmptyCollectionOfLinks() + { + GpxMetadata target = new GpxMetadataWrapper(); - Assert.Empty(target.Links); - } + Assert.Empty(target.Links); } +} - public class GpxMetadataWrapper : GpxMetadata - { - } +public class GpxMetadataWrapper : GpxMetadata +{ } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs index 608efd7..0f4d7ab 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs @@ -6,65 +6,64 @@ using SpatialLite.Core.API; using SpatialLite.Gps; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpxPointTests { - public class GpxPointTests + + double _xOrdinate = 3.5; + double _yOrdinate = 4.2; + double _zOrdinate = 10.5; + + Coordinate _coordinate; + public GpxPointTests() + { + _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); + } + + [Fact] + public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() + { + var target = new GpsPoint(); + + Assert.Equal(Coordinate.Empty, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() + { + var target = new GpxPoint(_coordinate); + + Assert.Equal(_coordinate, target.Position); + Assert.Null(target.Timestamp); + } + + [Fact] + public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() + { + var timestamp = DateTime.Now; + var target = new GpxPoint(_coordinate, timestamp); + + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); + } + + [Fact] + public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() + { + var timestamp = DateTime.Now; + var target = new GpxPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); + + Assert.Equal(_coordinate, target.Position); + Assert.Equal(timestamp, target.Timestamp); + } + + [Fact] + public void GeometryType_ReturnsWaypoint() { + GpxPoint target = new GpxPoint(); - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - - Coordinate _coordinate; - public GpxPointTests() - { - _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); - } - - [Fact] - public void Constructor__CreatesPointWithEmptyPositionAndNullTimestamp() - { - var target = new GpsPoint(); - - Assert.Equal(Coordinate.Empty, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndNullTimestamp() - { - var target = new GpxPoint(_coordinate); - - Assert.Equal(_coordinate, target.Position); - Assert.Null(target.Timestamp); - } - - [Fact] - public void Constructor_Coordinate_CreatesPointWithPositionAndTimestamp() - { - var timestamp = DateTime.Now; - var target = new GpxPoint(_coordinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } - - [Fact] - public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTimestamp() - { - var timestamp = DateTime.Now; - var target = new GpxPoint(_xOrdinate, _yOrdinate, _zOrdinate, timestamp); - - Assert.Equal(_coordinate, target.Position); - Assert.Equal(timestamp, target.Timestamp); - } - - [Fact] - public void GeometryType_ReturnsWaypoint() - { - GpxPoint target = new GpxPoint(); - - Assert.Equal(GpxGeometryType.Waypoint, target.GeometryType); - } + Assert.Equal(GpxGeometryType.Waypoint, target.GeometryType); } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs index 0f30eee..c08c8fc 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs @@ -4,41 +4,40 @@ using SpatialLite.Gps.Geometries; using Xunit; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpxRouteTests { - public class GpxRouteTests + [Fact] + public void Constructor_Parameterless_CreatesEmptyRoute() { - [Fact] - public void Constructor_Parameterless_CreatesEmptyRoute() - { - GpxRoute target = new GpxRoute(); + GpxRoute target = new GpxRoute(); - Assert.Empty(target.Points); - } + Assert.Empty(target.Points); + } + + [Fact] + public void Constructor_IEnumerablePoints_CreatesRouteWithPoints() + { + List points = new List { + new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), + new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), + new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - [Fact] - public void Constructor_IEnumerablePoints_CreatesRouteWithPoints() + GpxRoute target = new GpxRoute(points); + + Assert.Equal(points.Count, target.Points.Count); + for (int i = 0; i < target.Points.Count; i++) { - List points = new List { - new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), - new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), - new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - - GpxRoute target = new GpxRoute(points); - - Assert.Equal(points.Count, target.Points.Count); - for (int i = 0; i < target.Points.Count; i++) - { - Assert.Same(points[i], target.Points[i]); - } + Assert.Same(points[i], target.Points[i]); } + } - [Fact] - public void GeometryType_ReturnsRoute() - { - GpxRoute target = new GpxRoute(); + [Fact] + public void GeometryType_ReturnsRoute() + { + GpxRoute target = new GpxRoute(); - Assert.Equal(GpxGeometryType.Route, target.GeometryType); - } + Assert.Equal(GpxGeometryType.Route, target.GeometryType); } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs index 54a661b..435e9ef 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs @@ -3,33 +3,32 @@ using SpatialLite.Gps.Geometries; using Xunit; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpxTrackSegmentTests { - public class GpxTrackSegmentTests + [Fact] + public void Constructor_CreatesEmptyGpsTrack() { - [Fact] - public void Constructor_CreatesEmptyGpsTrack() - { - GpxTrackSegment target = new GpxTrackSegment(); + GpxTrackSegment target = new GpxTrackSegment(); - Assert.Empty(target.Points); - } + Assert.Empty(target.Points); + } - [Fact] - public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() - { - List points = new List { - new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), - new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), - new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; + [Fact] + public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() + { + List points = new List { + new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), + new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), + new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - GpxTrackSegment target = new GpxTrackSegment(points); + GpxTrackSegment target = new GpxTrackSegment(points); - Assert.Equal(points.Count, target.Points.Count); - for (int i = 0; i < target.Points.Count; i++) - { - Assert.Same(points[i], target.Points[i]); - } + Assert.Equal(points.Count, target.Points.Count); + for (int i = 0; i < target.Points.Count; i++) + { + Assert.Same(points[i], target.Points[i]); } } } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs index 23bbbb5..bf37b5d 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs @@ -2,38 +2,37 @@ using SpatialLite.Gps.Geometries; using Xunit; -namespace Tests.SpatialLite.Gps.Geometries +namespace Tests.SpatialLite.Gps.Geometries; + +public class GpxTrackTests { - public class GpxTrackTests + [Fact] + public void Constructor_Parameterless_CreateEmptyGpxTrack() { - [Fact] - public void Constructor_Parameterless_CreateEmptyGpxTrack() - { - GpxTrack target = new GpxTrack(); + GpxTrack target = new GpxTrack(); - Assert.Empty(target.Geometries); - } + Assert.Empty(target.Geometries); + } - [Fact] - public void Constructor_Segments_CreateGpxTrackWithSegments() - { - GpxTrackSegment[] segments = new GpxTrackSegment[] { new GpxTrackSegment(), new GpxTrackSegment(), new GpxTrackSegment() }; + [Fact] + public void Constructor_Segments_CreateGpxTrackWithSegments() + { + GpxTrackSegment[] segments = new GpxTrackSegment[] { new GpxTrackSegment(), new GpxTrackSegment(), new GpxTrackSegment() }; - GpxTrack target = new GpxTrack(segments); + GpxTrack target = new GpxTrack(segments); - Assert.Equal(segments.Length, target.Geometries.Count); - for (int i = 0; i < target.Geometries.Count; i++) - { - Assert.Same(segments[i], target.Geometries[i]); - } + Assert.Equal(segments.Length, target.Geometries.Count); + for (int i = 0; i < target.Geometries.Count; i++) + { + Assert.Same(segments[i], target.Geometries[i]); } + } - [Fact] - public void GeometryType_ReturnsTrack() - { - GpxTrack target = new GpxTrack(); + [Fact] + public void GeometryType_ReturnsTrack() + { + GpxTrack target = new GpxTrack(); - Assert.Equal(GpxGeometryType.Track, target.GeometryType); - } + Assert.Equal(GpxGeometryType.Track, target.GeometryType); } } diff --git a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs index debfa2d..8484fe4 100644 --- a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs +++ b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs @@ -11,160 +11,159 @@ using Moq; using Tests.SpatialLite.Gps.Data; -namespace Tests.SpatialLite.Gps +namespace Tests.SpatialLite.Gps; + +public class GpxDocumentTests { - public class GpxDocumentTests + [Fact] + public void Constructor_CreatesEmptyDocument() { - [Fact] - public void Constructor_CreatesEmptyDocument() - { - var target = new GpxDocument(); + var target = new GpxDocument(); - Assert.Empty(target.Waypoints); - Assert.Empty(target.Routes); - Assert.Empty(target.Tracks); - } + Assert.Empty(target.Waypoints); + Assert.Empty(target.Routes); + Assert.Empty(target.Tracks); + } - [Fact] - public void Constructor_WaypointsRoutesTracks_CreatesDocumentWithGpxEntities() - { - IEnumerable waypoints = new[] { new GpxPoint() }; - IEnumerable routes = new[] { new GpxRoute() }; - IEnumerable tracks = new[] { new GpxTrack() }; + [Fact] + public void Constructor_WaypointsRoutesTracks_CreatesDocumentWithGpxEntities() + { + IEnumerable waypoints = new[] { new GpxPoint() }; + IEnumerable routes = new[] { new GpxRoute() }; + IEnumerable tracks = new[] { new GpxTrack() }; - var target = new GpxDocument(waypoints, routes, tracks); + var target = new GpxDocument(waypoints, routes, tracks); - Assert.Equal(waypoints, target.Waypoints); - Assert.Equal(routes, target.Routes); - Assert.Equal(tracks, target.Tracks); - } + Assert.Equal(waypoints, target.Waypoints); + Assert.Equal(routes, target.Routes); + Assert.Equal(tracks, target.Tracks); + } - [Fact] - public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfWaypointsIsNull() - { - IEnumerable routes = new[] { new GpxRoute() }; - IEnumerable tracks = new[] { new GpxTrack() }; + [Fact] + public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfWaypointsIsNull() + { + IEnumerable routes = new[] { new GpxRoute() }; + IEnumerable tracks = new[] { new GpxTrack() }; - Assert.Throws(() => new GpxDocument(null, routes, tracks)); - } + Assert.Throws(() => new GpxDocument(null, routes, tracks)); + } - [Fact] - public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfRoutesIsNull() - { - IEnumerable waypoints = new[] { new GpxPoint() }; - IEnumerable tracks = new[] { new GpxTrack() }; + [Fact] + public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfRoutesIsNull() + { + IEnumerable waypoints = new[] { new GpxPoint() }; + IEnumerable tracks = new[] { new GpxTrack() }; - Assert.Throws(() => new GpxDocument(waypoints, null, tracks)); - } + Assert.Throws(() => new GpxDocument(waypoints, null, tracks)); + } - [Fact] - public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfTracksIsNull() - { - IEnumerable waypoints = new[] { new GpxPoint() }; - IEnumerable routes = new[] { new GpxRoute() }; + [Fact] + public void Constructor_WaypointsRoutesTracks_ThrowsArgumentNullExceptionIfTracksIsNull() + { + IEnumerable waypoints = new[] { new GpxPoint() }; + IEnumerable routes = new[] { new GpxRoute() }; - Assert.Throws(() => new GpxDocument(waypoints, routes, null)); - } + Assert.Throws(() => new GpxDocument(waypoints, routes, null)); + } - [Fact] - public void Load_IGpxReader_ThrowsExceptionIfReaderIsNull() - { - IGpxReader reader = null; + [Fact] + public void Load_IGpxReader_ThrowsExceptionIfReaderIsNull() + { + IGpxReader reader = null; - Assert.Throws(() => GpxDocument.Load(reader)); - } + Assert.Throws(() => GpxDocument.Load(reader)); + } - [Fact] - public void Load_IGpxReader_LoadsEntitiesFromReader() + [Fact] + public void Load_IGpxReader_LoadsEntitiesFromReader() + { + using (var reader = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), new GpxReaderSettings() { ReadMetadata = true })) { - using (var reader = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), new GpxReaderSettings() { ReadMetadata = true })) - { - var target = GpxDocument.Load(reader); - - Assert.Equal(3, target.Waypoints.Count); - Assert.Equal(2, target.Routes.Count); - Assert.Single(target.Tracks); - } + var target = GpxDocument.Load(reader); + + Assert.Equal(3, target.Waypoints.Count); + Assert.Equal(2, target.Routes.Count); + Assert.Single(target.Tracks); } + } - [Fact] - public void Load_string_ThrowsExceptionIfPathIsNull() - { - string path = null; + [Fact] + public void Load_string_ThrowsExceptionIfPathIsNull() + { + string path = null; - Assert.Throws(() => GpxDocument.Load(path)); - } + Assert.Throws(() => GpxDocument.Load(path)); + } - [Fact] - public void Load_string_ThrowsExceptionIfFileDoesntExists() - { - string path = "non-existing-file.gpx"; + [Fact] + public void Load_string_ThrowsExceptionIfFileDoesntExists() + { + string path = "non-existing-file.gpx"; - Assert.Throws(() => GpxDocument.Load(path)); - } + Assert.Throws(() => GpxDocument.Load(path)); + } - [Fact] - public void Load_LoadsGpxEntitiesFromFile() - { - string path = "../../../Data/Gpx/gpx-real-file.gpx"; + [Fact] + public void Load_LoadsGpxEntitiesFromFile() + { + string path = "../../../Data/Gpx/gpx-real-file.gpx"; - var target = GpxDocument.Load(path); + var target = GpxDocument.Load(path); - Assert.Equal(3, target.Waypoints.Count); - Assert.Equal(2, target.Routes.Count); - Assert.Single(target.Tracks); - } + Assert.Equal(3, target.Waypoints.Count); + Assert.Equal(2, target.Routes.Count); + Assert.Single(target.Tracks); + } - [Fact] - public void Save_IGpxWriter_ThrowsExceptionIfWriterIsNull() - { - IGpxWriter writer = null; + [Fact] + public void Save_IGpxWriter_ThrowsExceptionIfWriterIsNull() + { + IGpxWriter writer = null; - var target = new GpxDocument(); - Assert.Throws(() => target.Save(writer)); - } + var target = new GpxDocument(); + Assert.Throws(() => target.Save(writer)); + } - [Fact] - public void Save_IGpxWriter_WritesDataToWriter() - { - var waypoint = new GpxPoint(); - var route = new GpxRoute(); - var track = new GpxTrack(); + [Fact] + public void Save_IGpxWriter_WritesDataToWriter() + { + var waypoint = new GpxPoint(); + var route = new GpxRoute(); + var track = new GpxTrack(); - Mock writerM = new Mock(); - writerM.Setup(w => w.Write(waypoint)).Verifiable(); - writerM.Setup(w => w.Write(route)).Verifiable(); - writerM.Setup(w => w.Write(track)).Verifiable(); + Mock writerM = new Mock(); + writerM.Setup(w => w.Write(waypoint)).Verifiable(); + writerM.Setup(w => w.Write(route)).Verifiable(); + writerM.Setup(w => w.Write(track)).Verifiable(); - var target = new GpxDocument(new[] { waypoint }, new[] { route }, new[] { track }); - target.Save(writerM.Object); + var target = new GpxDocument(new[] { waypoint }, new[] { route }, new[] { track }); + target.Save(writerM.Object); - writerM.Verify(w => w.Write(waypoint), Times.Once()); - writerM.Verify(w => w.Write(route), Times.Once()); - writerM.Verify(w => w.Write(track), Times.Once()); - } + writerM.Verify(w => w.Write(waypoint), Times.Once()); + writerM.Verify(w => w.Write(route), Times.Once()); + writerM.Verify(w => w.Write(track), Times.Once()); + } - [Fact] - public void Save_ThrowsExceptionIfPathIsNull() - { - string path = null; - var target = new GpxDocument(); + [Fact] + public void Save_ThrowsExceptionIfPathIsNull() + { + string path = null; + var target = new GpxDocument(); - Assert.Throws(() => target.Save(path)); - } + Assert.Throws(() => target.Save(path)); + } - [Fact] - public void Save_SavesDataToFile() - { - string path = PathHelper.GetTempFilePath("gpxdocument-save-test.gpx"); + [Fact] + public void Save_SavesDataToFile() + { + string path = PathHelper.GetTempFilePath("gpxdocument-save-test.gpx"); - var target = GpxDocument.Load(PathHelper.RealGpxFilePath); - target.Save(path); + var target = GpxDocument.Load(PathHelper.RealGpxFilePath); + target.Save(path); - var original = XDocument.Load(PathHelper.RealGpxFilePath); - var saved = XDocument.Load(path); + var original = XDocument.Load(PathHelper.RealGpxFilePath); + var saved = XDocument.Load(path); - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(original, saved)); - } + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(original, saved)); } } diff --git a/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs index ee9c418..d30399d 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs @@ -2,26 +2,25 @@ using SpatialLite.Gps.IO; using Xunit; -namespace Tests.SpatialLite.Gps.IO +namespace Tests.SpatialLite.Gps.IO; + +public class GpxReaderSettingsTests { - public class GpxReaderSettingsTests - { - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() - { - var target = new GpxReaderSettings(); + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() + { + var target = new GpxReaderSettings(); - Assert.True(target.ReadMetadata); - } + Assert.True(target.ReadMetadata); + } - [Fact] - public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - var target = new GpxReaderSettings(); - target.IsReadOnly = true; + [Fact] + public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + var target = new GpxReaderSettings(); + target.IsReadOnly = true; - Assert.Throws(() => target.ReadMetadata = true); - } + Assert.Throws(() => target.ReadMetadata = true); } } diff --git a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs index 3dd0284..3a75d1c 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs @@ -9,437 +9,436 @@ using Xunit; using Tests.SpatialLite.Gps.Data; -namespace Tests.SpatialLite.Gps.IO +namespace Tests.SpatialLite.Gps.IO; + +public class GpxReaderTests { - public class GpxReaderTests + + [Fact] + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() { + Assert.Throws(delegate { new GpxReader("non-existing-file.gpx", new GpxReaderSettings() { ReadMetadata = false }); }); + } - [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() + [Fact] + public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() + { + string path = "../../../Data/Gpx/gpx-real-file.gpx"; + var settings = new GpxReaderSettings() { ReadMetadata = false }; + using (var target = new GpxReader(path, settings)) { - Assert.Throws(delegate { new GpxReader("non-existing-file.gpx", new GpxReaderSettings() { ReadMetadata = false }); }); + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() + { + var settings = new GpxReaderSettings() { ReadMetadata = false }; + using (var target = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), settings)) { - string path = "../../../Data/Gpx/gpx-real-file.gpx"; - var settings = new GpxReaderSettings() { ReadMetadata = false }; - using (var target = new GpxReader(path, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() - { - var settings = new GpxReaderSettings() { ReadMetadata = false }; - using (var target = new GpxReader(TestDataReader.Open("gpx-real-file.gpx"), settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } + [Fact] + public void Constructor_StreamSettings_ThrowsExceptionIfVersionIsnt10or11() + { + Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-version-2_0.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); + } - [Fact] - public void Constructor_StreamSettings_ThrowsExceptionIfVersionIsnt10or11() - { - Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-version-2_0.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); - } + [Fact] + public void Constructor_StreamSettings_ThrowsExceptionXmlContainsInvalidRootElement() + { + Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-invalid-root-element.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); + } - [Fact] - public void Constructor_StreamSettings_ThrowsExceptionXmlContainsInvalidRootElement() - { - Assert.Throws(delegate { new GpxReader(TestDataReader.Open("gpx-invalid-root-element.gpx"), new GpxReaderSettings() { ReadMetadata = false }); }); - } + [Fact] + public void Read_ThrowsExceptionIfWaypointHasntLat() + { + GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lat.gpx"), new GpxReaderSettings() { ReadMetadata = false }); - [Fact] - public void Read_ThrowsExceptionIfWaypointHasntLat() - { - GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lat.gpx"), new GpxReaderSettings() { ReadMetadata = false }); + Assert.Throws(() => target.Read()); + } - Assert.Throws(() => target.Read()); - } + [Fact] + public void Read_ThrowsExceptionIfWaypointHasntLon() + { + GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lon.gpx"), new GpxReaderSettings() { ReadMetadata = false }); - [Fact] - public void Read_ThrowsExceptionIfWaypointHasntLon() - { - GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lon.gpx"), new GpxReaderSettings() { ReadMetadata = false }); + Assert.Throws(() => target.Read()); + } - Assert.Throws(() => target.Read()); - } + [Fact] + public void Read_SetsMetadataIfReadMetadataIsTrue() + { + var data = TestDataReader.Open("gpx-waypoint-simple.gpx"); + var expectedCoordinate = new Coordinate(-71.119277, 42.438878); - [Fact] - public void Read_SetsMetadataIfReadMetadataIsTrue() - { - var data = TestDataReader.Open("gpx-waypoint-simple.gpx"); - var expectedCoordinate = new Coordinate(-71.119277, 42.438878); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxPoint; - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxPoint; + Assert.NotNull(result.Metadata); + } - Assert.NotNull(result.Metadata); - } + [Fact] + public void Read_DoesntSetMetadataIfReadMetadataIsFalse() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + var expectedCoordinate = new Coordinate(-71.119277, 42.438878); - [Fact] - public void Read_DoesntSetMetadataIfReadMetadataIsFalse() - { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - var expectedCoordinate = new Coordinate(-71.119277, 42.438878); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxPoint; - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxPoint; + Assert.Null(result.Metadata); + } - Assert.Null(result.Metadata); - } + [Fact] + public void Read_ParsesWaypointWithLatLonElevationAndTime() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); + DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); - [Fact] - public void Read_ParsesWaypointWithLatLonElevationAndTime() - { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); - DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxPoint; - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxPoint; + Assert.Equal(result.Position, expectedCoordinate); + Assert.Equal(result.Timestamp, expectedTime); + } - Assert.Equal(result.Position, expectedCoordinate); - Assert.Equal(result.Timestamp, expectedTime); - } + [Fact] + public void Read_ParsesWaypointWithExtensions() + { + var data = TestDataReader.Open("gpx-waypoint-extensions.gpx"); + Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); + DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); - [Fact] - public void Read_ParsesWaypointWithExtensions() - { - var data = TestDataReader.Open("gpx-waypoint-extensions.gpx"); - Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); - DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxPoint; - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxPoint; + Assert.Equal(result.Position, expectedCoordinate); + Assert.Equal(result.Timestamp, expectedTime); + } - Assert.Equal(result.Position, expectedCoordinate); - Assert.Equal(result.Timestamp, expectedTime); - } + [Fact] + public void Read_ParsesMultipleWaypoints() + { + var data = TestDataReader.Open("gpx-waypoint-multiple.gpx"); - [Fact] - public void Read_ParsesMultipleWaypoints() + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxPoint result = null; + + int count = 0; + while ((result = target.Read() as GpxPoint) != null) { - var data = TestDataReader.Open("gpx-waypoint-multiple.gpx"); + count++; + } - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - GpxPoint result = null; + Assert.Equal(3, count); + } - int count = 0; - while ((result = target.Read() as GpxPoint) != null) - { - count++; - } + [Fact] + public void Read_ReadsWaypointMetadata() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxPoint; + + Assert.Equal(0.98, result.Metadata.MagVar); + Assert.Equal(12.5, result.Metadata.GeoidHeight); + Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); + Assert.Equal(8, result.Metadata.SatellitesCount); + Assert.Equal(5.1, result.Metadata.Hdop); + Assert.Equal(8.1, result.Metadata.Vdop); + Assert.Equal(10.8, result.Metadata.Pdop); + Assert.Equal(45, result.Metadata.AgeOfDgpsData); + Assert.Equal(124, result.Metadata.DgpsId); + + Assert.Equal("WPT Comment", result.Metadata.Comment); + Assert.Equal("WPT Description", result.Metadata.Description); + Assert.Equal("WPT Name", result.Metadata.Name); + Assert.Equal("WPT Source", result.Metadata.Source); + + Assert.Equal(1, result.Metadata.Links.Count); + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } - Assert.Equal(3, count); - } + [Fact] + public void Read_ReadsWaypointUnsortedMetadataAndExtension() + { + var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxPoint; + + Assert.Equal(0.98, result.Metadata.MagVar); + Assert.Equal(12.5, result.Metadata.GeoidHeight); + Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); + Assert.Equal(8, result.Metadata.SatellitesCount); + Assert.Equal(5.1, result.Metadata.Hdop); + Assert.Equal(8.1, result.Metadata.Vdop); + Assert.Equal(10.8, result.Metadata.Pdop); + Assert.Equal(45, result.Metadata.AgeOfDgpsData); + Assert.Equal(124, result.Metadata.DgpsId); + + Assert.Equal("WPT Comment", result.Metadata.Comment); + Assert.Equal("WPT Description", result.Metadata.Description); + Assert.Equal("WPT Name", result.Metadata.Name); + Assert.Equal("WPT Source", result.Metadata.Source); + + Assert.Equal(1, result.Metadata.Links.Count); + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } - [Fact] - public void Read_ReadsWaypointMetadata() - { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxPoint; - - Assert.Equal(0.98, result.Metadata.MagVar); - Assert.Equal(12.5, result.Metadata.GeoidHeight); - Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); - Assert.Equal(8, result.Metadata.SatellitesCount); - Assert.Equal(5.1, result.Metadata.Hdop); - Assert.Equal(8.1, result.Metadata.Vdop); - Assert.Equal(10.8, result.Metadata.Pdop); - Assert.Equal(45, result.Metadata.AgeOfDgpsData); - Assert.Equal(124, result.Metadata.DgpsId); - - Assert.Equal("WPT Comment", result.Metadata.Comment); - Assert.Equal("WPT Description", result.Metadata.Description); - Assert.Equal("WPT Name", result.Metadata.Name); - Assert.Equal("WPT Source", result.Metadata.Source); - - Assert.Equal(1, result.Metadata.Links.Count); - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } + [Fact] + public void Read_ParsesTrackWithSingleSegment() + { + var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); - [Fact] - public void Read_ReadsWaypointUnsortedMetadataAndExtension() - { - var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxPoint; - - Assert.Equal(0.98, result.Metadata.MagVar); - Assert.Equal(12.5, result.Metadata.GeoidHeight); - Assert.Equal(GpsFix.Fix3D, result.Metadata.Fix); - Assert.Equal(8, result.Metadata.SatellitesCount); - Assert.Equal(5.1, result.Metadata.Hdop); - Assert.Equal(8.1, result.Metadata.Vdop); - Assert.Equal(10.8, result.Metadata.Pdop); - Assert.Equal(45, result.Metadata.AgeOfDgpsData); - Assert.Equal(124, result.Metadata.DgpsId); - - Assert.Equal("WPT Comment", result.Metadata.Comment); - Assert.Equal("WPT Description", result.Metadata.Description); - Assert.Equal("WPT Name", result.Metadata.Name); - Assert.Equal("WPT Source", result.Metadata.Source); - - Assert.Equal(1, result.Metadata.Links.Count); - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; - [Fact] - public void Read_ParsesTrackWithSingleSegment() - { - var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); + Assert.Single(result.Geometries); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; + GpxTrackSegment segment = result.Geometries[0]; + Assert.Equal(new Coordinate(-76.638178825, 39.449270368), segment.Points[0].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), segment.Points[0].Timestamp); + Assert.Equal(new Coordinate(-76.638012528, 39.449130893), segment.Points[1].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), segment.Points[1].Timestamp); + Assert.Equal(new Coordinate(-76.637980342, 39.449098706), segment.Points[2].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), segment.Points[2].Timestamp); + } - Assert.Single(result.Geometries); + [Fact] + public void Read_ParsesTrackWithSingleSegmentAndExtensions() + { + var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); - GpxTrackSegment segment = result.Geometries[0]; - Assert.Equal(new Coordinate(-76.638178825, 39.449270368), segment.Points[0].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), segment.Points[0].Timestamp); - Assert.Equal(new Coordinate(-76.638012528, 39.449130893), segment.Points[1].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), segment.Points[1].Timestamp); - Assert.Equal(new Coordinate(-76.637980342, 39.449098706), segment.Points[2].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), segment.Points[2].Timestamp); - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; - [Fact] - public void Read_ParsesTrackWithSingleSegmentAndExtensions() - { - var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); + Assert.Single(result.Geometries); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; + GpxTrackSegment segment = result.Geometries[0]; + } - Assert.Single(result.Geometries); + [Fact] + public void Read_ParsesTrackWithMultipleSegments() + { + var data = TestDataReader.Open("gpx-track-2-track-segments.gpx"); - GpxTrackSegment segment = result.Geometries[0]; - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; - [Fact] - public void Read_ParsesTrackWithMultipleSegments() - { - var data = TestDataReader.Open("gpx-track-2-track-segments.gpx"); + //segments + Assert.Equal(2, result.Geometries.Count); + //points in segments + Assert.Equal(3, result.Geometries[0].Points.Count); + Assert.Equal(2, result.Geometries[1].Points.Count); + } - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; + [Fact] + public void Read_ParsesMultipleTracks() + { + var data = TestDataReader.Open("gpx-track-multiple-tracks.gpx"); + + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result1 = target.Read() as GpxTrack; + var result2 = target.Read() as GpxTrack; + + //segments - first track + Assert.Equal(2, result1.Geometries.Count); + //points in segments - first track + Assert.Equal(3, result1.Geometries[0].Points.Count); + Assert.Equal(2, result1.Geometries[1].Points.Count); + + //segments - second track + Assert.Single(result2.Geometries); + //points in segments - second track + Assert.Equal(2, result2.Geometries[0].Points.Count); + } - //segments - Assert.Equal(2, result.Geometries.Count); - //points in segments - Assert.Equal(3, result.Geometries[0].Points.Count); - Assert.Equal(2, result.Geometries[1].Points.Count); - } + [Fact] + public void Read_ParsesEmptyTrack() + { + var data = TestDataReader.Open("gpx-track-empty.gpx"); - [Fact] - public void Read_ParsesMultipleTracks() - { - var data = TestDataReader.Open("gpx-track-multiple-tracks.gpx"); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result1 = target.Read() as GpxTrack; - var result2 = target.Read() as GpxTrack; - - //segments - first track - Assert.Equal(2, result1.Geometries.Count); - //points in segments - first track - Assert.Equal(3, result1.Geometries[0].Points.Count); - Assert.Equal(2, result1.Geometries[1].Points.Count); - - //segments - second track - Assert.Single(result2.Geometries); - //points in segments - second track - Assert.Equal(2, result2.Geometries[0].Points.Count); - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; - [Fact] - public void Read_ParsesEmptyTrack() - { - var data = TestDataReader.Open("gpx-track-empty.gpx"); + Assert.Empty(result.Geometries); + } - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; + [Fact] + public void Read_ParsesTrackWithEmptySegment() + { + var data = TestDataReader.Open("gpx-track-empty-track-segment.gpx"); - Assert.Empty(result.Geometries); - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; - [Fact] - public void Read_ParsesTrackWithEmptySegment() - { - var data = TestDataReader.Open("gpx-track-empty-track-segment.gpx"); + Assert.Single(result.Geometries); + Assert.Empty(result.Geometries[0].Points); + } - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; + [Fact] + public void Read_ParsesTrackMetadata() + { + var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); - Assert.Single(result.Geometries); - Assert.Empty(result.Geometries[0].Points); - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + var result = target.Read() as GpxTrack; - [Fact] - public void Read_ParsesTrackMetadata() - { - var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); + Assert.Equal("TRK Comment", result.Metadata.Comment); + Assert.Equal("TRK Description", result.Metadata.Description); + Assert.Equal("TRK Name", result.Metadata.Name); + Assert.Equal("TRK Source", result.Metadata.Source); + Assert.Equal("TRK Type", result.Metadata.Type); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - var result = target.Read() as GpxTrack; + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } - Assert.Equal("TRK Comment", result.Metadata.Comment); - Assert.Equal("TRK Description", result.Metadata.Description); - Assert.Equal("TRK Name", result.Metadata.Name); - Assert.Equal("TRK Source", result.Metadata.Source); - Assert.Equal("TRK Type", result.Metadata.Type); + [Fact] + public void Read_SetsTrackMetadataToNullIfReadMetadataIsFalse() + { + var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + var result = target.Read() as GpxTrack; - [Fact] - public void Read_SetsTrackMetadataToNullIfReadMetadataIsFalse() - { - var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); + Assert.Null(result.Metadata); + } - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - var result = target.Read() as GpxTrack; + [Fact] + public void Read_ParsesEmptyRoute() + { + var data = TestDataReader.Open("gpx-route-empty.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - Assert.Null(result.Metadata); - } + var result = target.Read() as GpxRoute; - [Fact] - public void Read_ParsesEmptyRoute() - { - var data = TestDataReader.Open("gpx-route-empty.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + Assert.Empty(result.Points); + } - var result = target.Read() as GpxRoute; + [Fact] + public void Read_ParsesSingleRoute() + { + var data = TestDataReader.Open("gpx-route-single-route.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - Assert.Empty(result.Points); - } + var result = target.Read() as GpxRoute; - [Fact] - public void Read_ParsesSingleRoute() - { - var data = TestDataReader.Open("gpx-route-single-route.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + Assert.Equal(new Coordinate(-76.638178825, 39.449270368), result.Points[0].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), result.Points[0].Timestamp); + Assert.Equal(new Coordinate(-76.638012528, 39.449130893), result.Points[1].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), result.Points[1].Timestamp); + Assert.Equal(new Coordinate(-76.637980342, 39.449098706), result.Points[2].Position); + Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), result.Points[2].Timestamp); + } - var result = target.Read() as GpxRoute; + [Fact] + public void Read_ParsesSingleRouteWithExtensions() + { + var data = TestDataReader.Open("gpx-route-with-metadata-and-extensions.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - Assert.Equal(new Coordinate(-76.638178825, 39.449270368), result.Points[0].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc), result.Points[0].Timestamp); - Assert.Equal(new Coordinate(-76.638012528, 39.449130893), result.Points[1].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc), result.Points[1].Timestamp); - Assert.Equal(new Coordinate(-76.637980342, 39.449098706), result.Points[2].Position); - Assert.Equal(new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc), result.Points[2].Timestamp); - } + var result = target.Read() as GpxRoute; - [Fact] - public void Read_ParsesSingleRouteWithExtensions() - { - var data = TestDataReader.Open("gpx-route-with-metadata-and-extensions.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + Assert.Equal(3, result.Points.Count); + } - var result = target.Read() as GpxRoute; + [Fact] + public void Read_ParsesMultipleRoutes() + { + var data = TestDataReader.Open("gpx-route-multiple-routes.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - Assert.Equal(3, result.Points.Count); - } + var result1 = target.Read() as GpxRoute; + var result2 = target.Read() as GpxRoute; - [Fact] - public void Read_ParsesMultipleRoutes() - { - var data = TestDataReader.Open("gpx-route-multiple-routes.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + Assert.Equal(3, result1.Points.Count); + Assert.Equal(2, result2.Points.Count); + } - var result1 = target.Read() as GpxRoute; - var result2 = target.Read() as GpxRoute; + [Fact] + public void Read_ParsesRouteWithMetadata() + { + var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + + var result = target.Read() as GpxRoute; + + Assert.Equal("RTE Comment", result.Metadata.Comment); + Assert.Equal("RTE Description", result.Metadata.Description); + Assert.Equal("RTE Name", result.Metadata.Name); + Assert.Equal("RTE Source", result.Metadata.Source); + Assert.Equal("RTE Type", result.Metadata.Type); + + Assert.Equal(1, result.Metadata.Links.Count); + GpxLink link = result.Metadata.Links.Single(); + Assert.Equal("http://www.topografix.com", link.Url.OriginalString); + Assert.Equal("Link text", link.Text); + Assert.Equal("plain/text", link.Type); + } - Assert.Equal(3, result1.Points.Count); - Assert.Equal(2, result2.Points.Count); - } + [Fact] + public void Read_SetsRouteMetadataToNullIfReadMetadataIsFalse() + { + var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - [Fact] - public void Read_ParsesRouteWithMetadata() - { - var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - - var result = target.Read() as GpxRoute; - - Assert.Equal("RTE Comment", result.Metadata.Comment); - Assert.Equal("RTE Description", result.Metadata.Description); - Assert.Equal("RTE Name", result.Metadata.Name); - Assert.Equal("RTE Source", result.Metadata.Source); - Assert.Equal("RTE Type", result.Metadata.Type); - - Assert.Equal(1, result.Metadata.Links.Count); - GpxLink link = result.Metadata.Links.Single(); - Assert.Equal("http://www.topografix.com", link.Url.OriginalString); - Assert.Equal("Link text", link.Text); - Assert.Equal("plain/text", link.Type); - } + var result = target.Read() as GpxRoute; - [Fact] - public void Read_SetsRouteMetadataToNullIfReadMetadataIsFalse() - { - var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + Assert.Null(result.Metadata); + } - var result = target.Read() as GpxRoute; + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/Gpx/gpx-real-file.gpx"; - Assert.Null(result.Metadata); - } + var target = new GpxReader(filename, new GpxReaderSettings() { ReadMetadata = false }); + target.Dispose(); - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = "../../../Data/Gpx/gpx-real-file.gpx"; + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - var target = new GpxReader(filename, new GpxReaderSettings() { ReadMetadata = false }); - target.Dispose(); + [Fact] + public void Read_ReadsAllEntitiesFromRealGpxFile() + { + var data = TestDataReader.Open("gpx-real-file.gpx"); + List parsed = new List(); - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - [Fact] - public void Read_ReadsAllEntitiesFromRealGpxFile() + IGpxGeometry geometry = null; + while ((geometry = target.Read()) != null) { - var data = TestDataReader.Open("gpx-real-file.gpx"); - List parsed = new List(); - - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); - - IGpxGeometry geometry = null; - while ((geometry = target.Read()) != null) - { - parsed.Add(geometry); - } + parsed.Add(geometry); + } - // waypoints - Assert.Equal(3, parsed.Where(g => g.GeometryType == GpxGeometryType.Waypoint).Count()); + // waypoints + Assert.Equal(3, parsed.Where(g => g.GeometryType == GpxGeometryType.Waypoint).Count()); - // routes - Assert.Equal(2, parsed.Where(g => g.GeometryType == GpxGeometryType.Route).Count()); + // routes + Assert.Equal(2, parsed.Where(g => g.GeometryType == GpxGeometryType.Route).Count()); - // tracks - Assert.Single(parsed.Where(g => g.GeometryType == GpxGeometryType.Track)); - } + // tracks + Assert.Single(parsed.Where(g => g.GeometryType == GpxGeometryType.Track)); } } diff --git a/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs index 044a6fa..7ddf3cf 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs @@ -2,35 +2,34 @@ using SpatialLite.Gps.IO; using Xunit; -namespace Tests.SpatialLite.Gps.IO +namespace Tests.SpatialLite.Gps.IO; + +public class GpxWriterSettingsTests { - public class GpxWriterSettingsTests - { - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() - { - var target = new GpxWriterSettings(); + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() + { + var target = new GpxWriterSettings(); - Assert.True(target.WriteMetadata); - } + Assert.True(target.WriteMetadata); + } - [Fact] - public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - var target = new GpxWriterSettings(); - target.IsReadOnly = true; + [Fact] + public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + var target = new GpxWriterSettings(); + target.IsReadOnly = true; - Assert.Throws(() => target.WriteMetadata = true); - } + Assert.Throws(() => target.WriteMetadata = true); + } - [Fact] - public void GeneratorNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - var target = new GpxWriterSettings(); - target.IsReadOnly = true; + [Fact] + public void GeneratorNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + var target = new GpxWriterSettings(); + target.IsReadOnly = true; - Assert.Throws(() => target.GeneratorName = "TEST"); - } + Assert.Throws(() => target.GeneratorName = "TEST"); } } diff --git a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs index c89dd25..6efb358 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs @@ -9,366 +9,365 @@ using SpatialLite.Core.API; using Tests.SpatialLite.Gps.Data; -namespace Tests.SpatialLite.Gps.IO +namespace Tests.SpatialLite.Gps.IO; + +public class GpxWriterTests { - public class GpxWriterTests + GpxPoint _waypoint = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + GpxPoint _waypointWithMetadata = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + GpxPointMetadata _pointMetadata; + + GpxRoute _route = new GpxRoute(new GpxPoint[] { + new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + }); + GpxRoute _routeWithMetadata = new GpxRoute(new GpxPoint[] { + new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + }); + GpxTrackMetadata _routeMetadata; + + GpxTrackSegment _segment = new GpxTrackSegment(new GpxPoint[] { + new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + }); + GpxTrackMetadata _trackMetadata; + GpxTrack _track; + GpxTrack _trackWithMetadata; + public GpxWriterTests() { - GpxPoint _waypoint = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); - GpxPoint _waypointWithMetadata = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); - GpxPointMetadata _pointMetadata; - - GpxRoute _route = new GpxRoute(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) - }); - GpxRoute _routeWithMetadata = new GpxRoute(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) - }); - GpxTrackMetadata _routeMetadata; - - GpxTrackSegment _segment = new GpxTrackSegment(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) - }); - GpxTrackMetadata _trackMetadata; - GpxTrack _track; - GpxTrack _trackWithMetadata; - public GpxWriterTests() - { - _pointMetadata = new GpxPointMetadata(); - _pointMetadata.AgeOfDgpsData = 45; - _pointMetadata.DgpsId = 124; - _pointMetadata.Fix = GpsFix.Fix3D; - _pointMetadata.GeoidHeight = 12.5; - _pointMetadata.Hdop = 5.1; - _pointMetadata.MagVar = 0.98; - _pointMetadata.Pdop = 10.8; - _pointMetadata.SatellitesCount = 8; - _pointMetadata.Symbol = "WPT Symbol"; - _pointMetadata.Vdop = 8.1; - - _pointMetadata.Comment = "WPT Comment"; - _pointMetadata.Description = "WPT Description"; - _pointMetadata.Name = "WPT Name"; - _pointMetadata.Source = "WPT Source"; - _pointMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); - _waypointWithMetadata.Metadata = _pointMetadata; - - _routeMetadata = new GpxTrackMetadata(); - _routeMetadata.Comment = "RTE Comment"; - _routeMetadata.Description = "RTE Description"; - _routeMetadata.Name = "RTE Name"; - _routeMetadata.Source = "RTE Source"; - _routeMetadata.Type = "RTE Type"; - _routeMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); - _routeWithMetadata.Metadata = _routeMetadata; - - _trackMetadata = new GpxTrackMetadata(); - _trackMetadata.Comment = "TRK Comment"; - _trackMetadata.Description = "TRK Description"; - _trackMetadata.Name = "TRK Name"; - _trackMetadata.Source = "TRK Source"; - _trackMetadata.Type = "TRK Type"; - _trackMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); - - _track = new GpxTrack(new GpxTrackSegment[] { _segment }); - _trackWithMetadata = new GpxTrack(new GpxTrackSegment[] { _segment }); - _trackWithMetadata.Metadata = _trackMetadata; - } + _pointMetadata = new GpxPointMetadata(); + _pointMetadata.AgeOfDgpsData = 45; + _pointMetadata.DgpsId = 124; + _pointMetadata.Fix = GpsFix.Fix3D; + _pointMetadata.GeoidHeight = 12.5; + _pointMetadata.Hdop = 5.1; + _pointMetadata.MagVar = 0.98; + _pointMetadata.Pdop = 10.8; + _pointMetadata.SatellitesCount = 8; + _pointMetadata.Symbol = "WPT Symbol"; + _pointMetadata.Vdop = 8.1; + + _pointMetadata.Comment = "WPT Comment"; + _pointMetadata.Description = "WPT Description"; + _pointMetadata.Name = "WPT Name"; + _pointMetadata.Source = "WPT Source"; + _pointMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); + _waypointWithMetadata.Metadata = _pointMetadata; + + _routeMetadata = new GpxTrackMetadata(); + _routeMetadata.Comment = "RTE Comment"; + _routeMetadata.Description = "RTE Description"; + _routeMetadata.Name = "RTE Name"; + _routeMetadata.Source = "RTE Source"; + _routeMetadata.Type = "RTE Type"; + _routeMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); + _routeWithMetadata.Metadata = _routeMetadata; + + _trackMetadata = new GpxTrackMetadata(); + _trackMetadata.Comment = "TRK Comment"; + _trackMetadata.Description = "TRK Description"; + _trackMetadata.Name = "TRK Name"; + _trackMetadata.Source = "TRK Source"; + _trackMetadata.Type = "TRK Type"; + _trackMetadata.Links.Add(new GpxLink(new Uri("http://www.topografix.com")) { Text = "Link text", Type = "plain/text" }); + + _track = new GpxTrack(new GpxTrackSegment[] { _segment }); + _trackWithMetadata = new GpxTrack(new GpxTrackSegment[] { _segment }); + _trackWithMetadata.Metadata = _trackMetadata; + } - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMarkSettingsAsReadOnly() + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMarkSettingsAsReadOnly() + { + var stream = new MemoryStream(); + var settings = new GpxWriterSettings(); + using (var target = new GpxWriter(stream, settings)) { - var stream = new MemoryStream(); - var settings = new GpxWriterSettings(); - using (var target = new GpxWriter(stream, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(target.Settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(target.Settings.IsReadOnly); } + } + + [Fact] + public void Constructor_StreamSettings_CreatesGpxFileWithRootElement() + { + string generatorName = "SpatialLite"; + var stream = new MemoryStream(); - [Fact] - public void Constructor_StreamSettings_CreatesGpxFileWithRootElement() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) { - string generatorName = "SpatialLite"; - var stream = new MemoryStream(); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) - { - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() + { + string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-1.gpx"); - [Fact] - public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() + var settings = new GpxWriterSettings(); + using (var target = new GpxWriter(path, settings)) { - string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-1.gpx"); - - var settings = new GpxWriterSettings(); - using (var target = new GpxWriter(path, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(target.Settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(target.Settings.IsReadOnly); } + } + + [Fact] + public void Constructor_PathSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("gpxwriter-constructor-creates-output-test.gpx"); - [Fact] - public void Constructor_PathSettings_CreatesOutputFile() + var settings = new GpxWriterSettings(); + using (var target = new GpxWriter(filename, settings)) { - string filename = PathHelper.GetTempFilePath("gpxwriter-constructor-creates-output-test.gpx"); + ; + } - var settings = new GpxWriterSettings(); - using (var target = new GpxWriter(filename, settings)) - { - ; - } + Assert.True(File.Exists(filename)); + } - Assert.True(File.Exists(filename)); - } + [Fact] + public void Constructor_PathSettings_CreatesGpxFileWithRootElement() + { + string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-2.gpx"); + string generatorName = "SpatialLite"; - [Fact] - public void Constructor_PathSettings_CreatesGpxFileWithRootElement() + using (GpxWriter target = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) { - string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-2.gpx"); - string generatorName = "SpatialLite"; + } - using (GpxWriter target = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) - { - } + XDocument written = XDocument.Load(path); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); - XDocument written = XDocument.Load(path); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-empty-file.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesWaypointWithoutMetadataIfMetadataIsNull() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesWaypointWithoutMetadataIfMetadataIsNull() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_waypoint); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) - { - target.Write(_waypoint); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesWaypointWithoutMetadataIfWriteMetadataIsFalse() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesWaypointWithoutMetadataIfWriteMetadataIsFalse() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_waypointWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) - { - target.Write(_waypointWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-simple.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesWaypointWithMetadata() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesWaypointWithMetadata() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); + target.Write(_waypointWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) - { - target.Write(_waypointWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesWaypointWithoutUnnecessaryElements() + { + _waypointWithMetadata.Metadata.SatellitesCount = null; + _waypointWithMetadata.Metadata.Name = null; + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesWaypointWithoutUnnecessaryElements() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - _waypointWithMetadata.Metadata.SatellitesCount = null; - _waypointWithMetadata.Metadata.Name = null; - MemoryStream stream = new MemoryStream(); + target.Write(_waypointWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) - { - target.Write(_waypointWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata-selection.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-waypoint-with-metadata-selection.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesRouteWith3Points() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesRouteWith3Points() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_route); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) - { - target.Write(_route); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesRouteWithMetadata() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesRouteWithMetadata() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); + target.Write(_routeWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) - { - target.Write(_routeWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesRouteWithoutMetadataIfWriteMetadataIsFalse() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesRouteWithoutMetadataIfWriteMetadataIsFalse() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_routeWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) - { - target.Write(_routeWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-single-route.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesRouteWithoutUnnecessaryElements() + { + _routeWithMetadata.Metadata.Source = null; + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesRouteWithoutUnnecessaryElements() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - _routeWithMetadata.Metadata.Source = null; - MemoryStream stream = new MemoryStream(); + target.Write(_routeWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) - { - target.Write(_routeWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata-selection.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-route-with-metadata-selection.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesTrack() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesTrack() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_track); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) - { - target.Write(_track); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_WritesTrackWithMetadata() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_WritesTrackWithMetadata() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); + target.Write(_trackWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) - { - target.Write(_trackWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_DoesntWriteTrackMetadataIfWriteMetadataIsFalse() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_DoesntWriteTrackMetadataIfWriteMetadataIsFalse() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_trackWithMetadata); + } - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) - { - target.Write(_trackWithMetadata); - } + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-single-track-segment.gpx")); + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + [Fact] + public void Write_TrackWithEntityDetailsButNullValues_WritesTrackWithoutUnnecessaryElements() + { + MemoryStream stream = new MemoryStream(); + _trackWithMetadata.Metadata.Source = null; - [Fact] - public void Write_TrackWithEntityDetailsButNullValues_WritesTrackWithoutUnnecessaryElements() + using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); - _trackWithMetadata.Metadata.Source = null; - - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) - { - target.Write(_trackWithMetadata); - } + target.Write(_trackWithMetadata); + } - XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); - XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata-selection.gpx")); + XDocument written = XDocument.Load(new MemoryStream(stream.ToArray())); + XDocument expected = XDocument.Load(TestDataReader.Open("gpx-track-with-metadata-selection.gpx")); - Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); - } + Assert.True(XDocumentExtensions.DeepEqualsWithNormalization(written, expected)); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string path = PathHelper.GetTempFilePath("gpxwriter-closes-output-filestream-test.osm"); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string path = PathHelper.GetTempFilePath("gpxwriter-closes-output-filestream-test.osm"); - var target = new GpxWriter(path, new GpxWriterSettings()); - target.Dispose(); + var target = new GpxWriter(path, new GpxWriterSettings()); + target.Dispose(); - FileStream testStream = null; - testStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + FileStream testStream = null; + testStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() - { - MemoryStream stream = new MemoryStream(); + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + MemoryStream stream = new MemoryStream(); - var target = new GpxWriter(stream, new GpxWriterSettings()); - target.Dispose(); + var target = new GpxWriter(stream, new GpxWriterSettings()); + target.Dispose(); - Assert.False(stream.CanRead); - } + Assert.False(stream.CanRead); } } diff --git a/src/Tests.SpatialLite.Gps/PathHelper.cs b/src/Tests.SpatialLite.Gps/PathHelper.cs index e5d7362..397b356 100644 --- a/src/Tests.SpatialLite.Gps/PathHelper.cs +++ b/src/Tests.SpatialLite.Gps/PathHelper.cs @@ -1,28 +1,27 @@ using System.IO; -namespace Tests.SpatialLite.Gps +namespace Tests.SpatialLite.Gps; + +static class PathHelper { - static class PathHelper - { - private const string TempDirectoryName = "Temp"; + private const string TempDirectoryName = "Temp"; - private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); - public static string RealGpxFilePath => _realGpxFilePath; + private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); + public static string RealGpxFilePath => _realGpxFilePath; - public static string GetTempFilePath(string filename) + public static string GetTempFilePath(string filename) + { + if (!Directory.Exists(TempDirectoryName)) { - if (!Directory.Exists(TempDirectoryName)) - { - Directory.CreateDirectory(TempDirectoryName); - } - - string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); - if (File.Exists(pbfFile)) - { - File.Delete(pbfFile); - } + Directory.CreateDirectory(TempDirectoryName); + } - return pbfFile; + string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); + if (File.Exists(pbfFile)) + { + File.Delete(pbfFile); } + + return pbfFile; } } diff --git a/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs b/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs index 6ee386b..430e661 100644 --- a/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs +++ b/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs @@ -1,55 +1,54 @@ using System.Linq; using System.Xml.Linq; -namespace Tests.SpatialLite.Gps +namespace Tests.SpatialLite.Gps; + +/// +/// Extends XDocument with correct DeepEquals function +/// +public static class XDocumentExtensions { - /// - /// Extends XDocument with correct DeepEquals function - /// - public static class XDocumentExtensions + public static bool DeepEqualsWithNormalization(XDocument doc1, XDocument doc2) { - public static bool DeepEqualsWithNormalization(XDocument doc1, XDocument doc2) - { - return XMLCompare(doc1.Root, doc2.Root); - } + return XMLCompare(doc1.Root, doc2.Root); + } - public static bool XMLCompare(XElement ele1, XElement ele2) + public static bool XMLCompare(XElement ele1, XElement ele2) + { + if (ele1.HasAttributes) { - if (ele1.HasAttributes) + if (ele1.Attributes().Count() != ele2.Attributes().Count()) { - if (ele1.Attributes().Count() != ele2.Attributes().Count()) - { - return false; - } - - foreach (XAttribute attr in ele1.Attributes()) - { - if (ele2.Attribute(attr.Name.LocalName) == null) - { - return false; - } - if (attr.Value.ToLower() != ele2.Attribute(attr.Name.LocalName).Value.ToLower()) - { - return false; - } - } + return false; } - if (ele1.HasElements) + foreach (XAttribute attr in ele1.Attributes()) { - if (ele1.Elements().Count() != ele2.Elements().Count()) + if (ele2.Attribute(attr.Name.LocalName) == null) { return false; } - - for (var i = 0; i <= ele1.Elements().Count() - 1; i++) + if (attr.Value.ToLower() != ele2.Attribute(attr.Name.LocalName).Value.ToLower()) { - if (XMLCompare(ele1.Elements().ElementAt(i), ele2.Elements().ElementAt(i)) == false) - return false; + return false; } } + } - return true; + if (ele1.HasElements) + { + if (ele1.Elements().Count() != ele2.Elements().Count()) + { + return false; + } + + for (var i = 0; i <= ele1.Elements().Count() - 1; i++) + { + if (XMLCompare(ele1.Elements().ElementAt(i), ele2.Elements().ElementAt(i)) == false) + return false; + } } + + return true; } } diff --git a/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs b/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs index eb09eeb..ef527f0 100644 --- a/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs +++ b/src/Tests.SpatialLite.Osm/Data/TestDataReader.cs @@ -1,26 +1,25 @@ using System.IO; using System.Reflection; -namespace Tests.SpatialLite.Osm.Data +namespace Tests.SpatialLite.Osm.Data; + +public static class TestDataReader { - public static class TestDataReader + public static Stream OpenXml(string name) { - public static Stream OpenXml(string name) - { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Xml." + name); - } + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Xml." + name); + } - public static Stream OpenPbf(string name) - { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Pbf." + name); - } + public static Stream OpenPbf(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.Pbf." + name); + } - public static Stream OpenOsmDB(string name) - { - var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; - return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.OsmDatabase." + name); - } + public static Stream OpenOsmDB(string name) + { + var assembly = typeof(TestDataReader).GetTypeInfo().Assembly; + return assembly.GetManifestResourceStream("Tests.SpatialLite.Osm.Data.OsmDatabase." + name); } } diff --git a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs index 97f146c..0de9435 100644 --- a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs @@ -7,221 +7,220 @@ using SpatialLite.Osm; using SpatialLite.Osm.Geometries; -namespace Tests.SpatialLite.Osm +namespace Tests.SpatialLite.Osm; + +public class EntityCollectionTests { - public class EntityCollectionTests + IOsmGeometry[] _data; + + public EntityCollectionTests() { - IOsmGeometry[] _data; + _data = new IOsmGeometry[3]; + _data[0] = new Node(1); + _data[1] = new Node(2); + _data[2] = new Node(3); + } - public EntityCollectionTests() - { - _data = new IOsmGeometry[3]; - _data[0] = new Node(1); - _data[1] = new Node(2); - _data[2] = new Node(3); - } + [Fact] + public void Constructor__CreatesEmptyCollection() + { + EntityCollection target = new EntityCollection(); - [Fact] - public void Constructor__CreatesEmptyCollection() - { - EntityCollection target = new EntityCollection(); + Assert.Empty(target); + } - Assert.Empty(target); - } + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + EntityCollection target = new EntityCollection(_data); - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + for (int i = 0; i < _data.Length; i++) { - EntityCollection target = new EntityCollection(_data); - - for (int i = 0; i < _data.Length; i++) - { - Assert.Contains(_data[i], target); - } + Assert.Contains(_data[i], target); } + } - [Fact] - public void Count_ReturnsNumberOfElements() - { - EntityCollection target = new EntityCollection(_data); - Mock entityM = new Mock(); + [Fact] + public void Count_ReturnsNumberOfElements() + { + EntityCollection target = new EntityCollection(_data); + Mock entityM = new Mock(); - Assert.Equal(_data.Length, target.Count); - } + Assert.Equal(_data.Length, target.Count); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseForEmptyCollection() - { - EntityCollection target = new EntityCollection(); + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseForEmptyCollection() + { + EntityCollection target = new EntityCollection(); - Assert.DoesNotContain(_data[0], target); - } + Assert.DoesNotContain(_data[0], target); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseForNull() - { - EntityCollection target = new EntityCollection(); + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseForNull() + { + EntityCollection target = new EntityCollection(); - Assert.DoesNotContain(null, target); - } + Assert.DoesNotContain(null, target); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainEntity() - { - EntityCollection target = new EntityCollection(_data.Skip(1)); + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainEntity() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); - Assert.DoesNotContain(_data[0], target); - } + Assert.DoesNotContain(_data[0], target); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsEntity() - { - EntityCollection target = new EntityCollection(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsEntity() + { + EntityCollection target = new EntityCollection(_data); - Assert.Contains(_data[0], target); - } + Assert.Contains(_data[0], target); + } - [Fact] - public void Contains_ID_ReturnsFalseForEmptyCollection() - { - EntityCollection target = new EntityCollection(); + [Fact] + public void Contains_ID_ReturnsFalseForEmptyCollection() + { + EntityCollection target = new EntityCollection(); - Assert.False(target.Contains(_data[0].ID)); - } + Assert.False(target.Contains(_data[0].ID)); + } - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainEntity() - { - EntityCollection target = new EntityCollection(_data.Skip(1)); + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainEntity() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); - Assert.False(target.Contains(_data[0].ID)); - } + Assert.False(target.Contains(_data[0].ID)); + } - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsEntity() - { - EntityCollection target = new EntityCollection(_data); + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsEntity() + { + EntityCollection target = new EntityCollection(_data); - Assert.True(target.Contains(_data[0].ID)); - } + Assert.True(target.Contains(_data[0].ID)); + } - [Fact] - public void Clear_RemovesAllItemsFromCollection() - { - EntityCollection target = new EntityCollection(_data); - target.Clear(); + [Fact] + public void Clear_RemovesAllItemsFromCollection() + { + EntityCollection target = new EntityCollection(_data); + target.Clear(); - Assert.Empty(target); - } + Assert.Empty(target); + } - [Fact] - public void Add_AddsEntityToCollection() - { - EntityCollection target = new EntityCollection(); - target.Add(_data[0]); + [Fact] + public void Add_AddsEntityToCollection() + { + EntityCollection target = new EntityCollection(); + target.Add(_data[0]); - Assert.Contains(_data[0], target); - } + Assert.Contains(_data[0], target); + } - [Fact] - public void Add_ThrowsArgumentNullExceptionIfItemIsNull() - { - EntityCollection target = new EntityCollection(); + [Fact] + public void Add_ThrowsArgumentNullExceptionIfItemIsNull() + { + EntityCollection target = new EntityCollection(); - Assert.Throws(() => target.Add(null)); - } + Assert.Throws(() => target.Add(null)); + } - [Fact] - public void Add_ThrowsExceptionWhenAddingDuplicateID() - { - EntityCollection target = new EntityCollection(_data); + [Fact] + public void Add_ThrowsExceptionWhenAddingDuplicateID() + { + EntityCollection target = new EntityCollection(_data); - Assert.Throws(() => target.Add(_data[0])); - } + Assert.Throws(() => target.Add(_data[0])); + } - [Fact] - public void IsReadOnly_ReturnsFalse() - { - EntityCollection target = new EntityCollection(); + [Fact] + public void IsReadOnly_ReturnsFalse() + { + EntityCollection target = new EntityCollection(); - Assert.False(target.IsReadOnly); - } + Assert.False(target.IsReadOnly); + } - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() - { - EntityCollection target = new EntityCollection(_data.Skip(1)); + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); - bool callResult = target.Remove(_data[0]); + bool callResult = target.Remove(_data[0]); - Assert.False(callResult); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } + Assert.False(callResult); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() - { - EntityCollection target = new EntityCollection(_data); + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() + { + EntityCollection target = new EntityCollection(_data); - bool callResult = target.Remove(null); + bool callResult = target.Remove(null); - Assert.False(callResult); - } + Assert.False(callResult); + } - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesItemFromCollection() - { - EntityCollection target = new EntityCollection(_data); + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesItemFromCollection() + { + EntityCollection target = new EntityCollection(_data); - bool callResult = target.Remove(_data[0]); + bool callResult = target.Remove(_data[0]); - Assert.True(callResult); - Assert.DoesNotContain(_data[0], target); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } + Assert.True(callResult); + Assert.DoesNotContain(_data[0], target); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() - { - EntityCollection target = new EntityCollection(_data.Skip(1)); + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() + { + EntityCollection target = new EntityCollection(_data.Skip(1)); - bool callResult = target.Remove(_data[0].ID); + bool callResult = target.Remove(_data[0].ID); - Assert.False(callResult); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } + Assert.False(callResult); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesItemFromCollection() - { - EntityCollection target = new EntityCollection(_data); + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesItemFromCollection() + { + EntityCollection target = new EntityCollection(_data); - bool callResult = target.Remove(_data[0].ID); + bool callResult = target.Remove(_data[0].ID); - Assert.True(callResult); - Assert.DoesNotContain(_data[0], target); - Assert.Contains(_data[1], target); - Assert.Contains(_data[2], target); - } + Assert.True(callResult); + Assert.DoesNotContain(_data[0], target); + Assert.Contains(_data[1], target); + Assert.Contains(_data[2], target); + } - [Fact] - public void Item_ReturnsNullIfIDIsNotpResentInCollection() - { - EntityCollection target = new EntityCollection(_data); + [Fact] + public void Item_ReturnsNullIfIDIsNotpResentInCollection() + { + EntityCollection target = new EntityCollection(_data); - Assert.Null(target[1000]); - } + Assert.Null(target[1000]); + } - [Fact] - public void Item_ReturnsEntityWitSpecificID() - { - EntityCollection target = new EntityCollection(_data); - IOsmGeometry entity = target[1]; + [Fact] + public void Item_ReturnsEntityWitSpecificID() + { + EntityCollection target = new EntityCollection(_data); + IOsmGeometry entity = target[1]; - Assert.Equal(1, entity.ID); - } + Assert.Equal(1, entity.ID); } } diff --git a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs index 36d4ed2..069af9c 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs @@ -5,101 +5,100 @@ using SpatialLite.Osm; using SpatialLite.Osm.Geometries; -namespace Tests.SpatialLite.Osm.Geometry +namespace Tests.SpatialLite.Osm.Geometry; + +public class NodeTests { - public class NodeTests + + [Fact] + public void Constructor_int_CreatesNodeAndInitializeProperties() + { + int id = 11; + Node target = new Node(id); + + Assert.Equal(Coordinate.Empty, target.Position); + Assert.Equal(id, target.ID); + Assert.NotNull(target.Tags); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_int_double_double_CreatesNodeAndInitializeProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + Node target = new Node(id, coord.X, coord.Y); + + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.Equal(id, target.ID); + Assert.NotNull(target.Tags); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_int_double_double_Tags_CreatesNodeAndInitializesProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + TagsCollection tags = new TagsCollection(); + + Node target = new Node(id, coord.X, coord.Y, tags); + + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Null(target.Metadata); + } + + [Fact] + public void Constructor_int_Coordinate_CreatesNodeAndInitializeProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + Node target = new Node(id, coord); + + Assert.Equal(id, target.ID); + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.NotNull(target.Tags); + } + + [Fact] + public void Constructor_int_Coordinate_Tags_CreatesNodeAndInitializeProperties() + { + int id = 11; + Coordinate coord = new Coordinate(-15.6, 68.7); + TagsCollection tags = new TagsCollection(); + + Node target = new Node(id, coord, tags); + + Assert.Equal(id, target.ID); + Assert.Equal(target.Position.X, coord.X); + Assert.Equal(target.Position.Y, coord.Y); + Assert.Same(tags, target.Tags); + } + + [Fact] + public void Constructor_NodeInfo_CreatesNodeFromNodeInfo() + { + NodeInfo info = new NodeInfo(1, 15.6, 20.4, new TagsCollection(), new EntityMetadata()); + + Node target = Node.FromNodeInfo(info); + + Assert.Equal(info.ID, target.ID); + Assert.Equal(info.Longitude, target.Position.X); + Assert.Equal(info.Latitude, target.Position.Y); + Assert.Same(info.Tags, target.Tags); + Assert.Same(info.Metadata, target.Metadata); + } + + [Fact] + public void EntityType_Returns_Node() { + Node target = new Node(1); - [Fact] - public void Constructor_int_CreatesNodeAndInitializeProperties() - { - int id = 11; - Node target = new Node(id); - - Assert.Equal(Coordinate.Empty, target.Position); - Assert.Equal(id, target.ID); - Assert.NotNull(target.Tags); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_int_double_double_CreatesNodeAndInitializeProperties() - { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - Node target = new Node(id, coord.X, coord.Y); - - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.Equal(id, target.ID); - Assert.NotNull(target.Tags); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_int_double_double_Tags_CreatesNodeAndInitializesProperties() - { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - TagsCollection tags = new TagsCollection(); - - Node target = new Node(id, coord.X, coord.Y, tags); - - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Null(target.Metadata); - } - - [Fact] - public void Constructor_int_Coordinate_CreatesNodeAndInitializeProperties() - { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - Node target = new Node(id, coord); - - Assert.Equal(id, target.ID); - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.NotNull(target.Tags); - } - - [Fact] - public void Constructor_int_Coordinate_Tags_CreatesNodeAndInitializeProperties() - { - int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - TagsCollection tags = new TagsCollection(); - - Node target = new Node(id, coord, tags); - - Assert.Equal(id, target.ID); - Assert.Equal(target.Position.X, coord.X); - Assert.Equal(target.Position.Y, coord.Y); - Assert.Same(tags, target.Tags); - } - - [Fact] - public void Constructor_NodeInfo_CreatesNodeFromNodeInfo() - { - NodeInfo info = new NodeInfo(1, 15.6, 20.4, new TagsCollection(), new EntityMetadata()); - - Node target = Node.FromNodeInfo(info); - - Assert.Equal(info.ID, target.ID); - Assert.Equal(info.Longitude, target.Position.X); - Assert.Equal(info.Latitude, target.Position.Y); - Assert.Same(info.Tags, target.Tags); - Assert.Same(info.Metadata, target.Metadata); - } - - [Fact] - public void EntityType_Returns_Node() - { - Node target = new Node(1); - - Assert.Equal(EntityType.Node, target.EntityType); - } + Assert.Equal(EntityType.Node, target.EntityType); } } diff --git a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs index b073604..78947a6 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs @@ -9,172 +9,171 @@ using SpatialLite.Osm.Geometries; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.Geometries +namespace Tests.SpatialLite.Osm.Geometries; + +public class OsmGeometryDatabaseTests { - public class OsmGeometryDatabaseTests + Node[] _nodeData; + Way[] _wayData; + Relation[] _relationData; + IOsmGeometry[] _data; + public OsmGeometryDatabaseTests() { - Node[] _nodeData; - Way[] _wayData; - Relation[] _relationData; - IOsmGeometry[] _data; - public OsmGeometryDatabaseTests() - { - _nodeData = new Node[3]; - _nodeData[0] = new Node(1); - _nodeData[1] = new Node(2); - _nodeData[2] = new Node(3); + _nodeData = new Node[3]; + _nodeData[0] = new Node(1); + _nodeData[1] = new Node(2); + _nodeData[2] = new Node(3); - _wayData = new Way[2]; - _wayData[0] = new Way(10, _nodeData); - _wayData[1] = new Way(11, _nodeData.Skip(1)); + _wayData = new Way[2]; + _wayData[0] = new Way(10, _nodeData); + _wayData[1] = new Way(11, _nodeData.Skip(1)); - _relationData = new Relation[2]; - _relationData[0] = new Relation(100, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); - _relationData[1] = new Relation(101, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); + _relationData = new Relation[2]; + _relationData[0] = new Relation(100, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); + _relationData[1] = new Relation(101, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); - _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); - } + _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); + } - [Fact] - public void Constructor__CreatesEmptyDatabase() - { - OsmGeometryDatabase target = new OsmGeometryDatabase(); + [Fact] + public void Constructor__CreatesEmptyDatabase() + { + OsmGeometryDatabase target = new OsmGeometryDatabase(); - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() - { - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + OsmGeometryDatabase target = new OsmGeometryDatabase(_data); - for (int i = 0; i < _data.Length; i++) - { - Assert.Contains(_data[i], target); - } + for (int i = 0; i < _data.Length; i++) + { + Assert.Contains(_data[i], target); } + } - [Fact] - public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() + [Fact] + public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() + { + OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + + for (int i = 0; i < _nodeData.Length; i++) { - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); - - for (int i = 0; i < _nodeData.Length; i++) - { - Assert.Contains(_nodeData[i], target.Nodes); - } - - for (int i = 0; i < _wayData.Length; i++) - { - Assert.Contains(_wayData[i], target.Ways); - } - - for (int i = 0; i < _relationData.Length; i++) - { - Assert.Contains(_relationData[i], target.Relations); - } + Assert.Contains(_nodeData[i], target.Nodes); } - [Fact] - public void Load_LoadsNodes() + for (int i = 0; i < _wayData.Length; i++) { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); + Assert.Contains(_wayData[i], target.Ways); } - [Fact] - public void Load_LoadsWay() + for (int i = 0; i < _relationData.Length; i++) { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + Assert.Contains(_relationData[i], target.Relations); + } + } - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); + [Fact] + public void Load_LoadsNodes() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(1, target.Ways.Count); - Assert.True(target.Ways.Contains(10)); - } + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); + } - [Fact] - public void Load_LoadsRelation() - { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + [Fact] + public void Load_LoadsWay() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(1, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); - Assert.Equal(1, target.Relations.Count); - Assert.True(target.Relations.Contains(100)); - } + Assert.Equal(1, target.Ways.Count); + Assert.True(target.Ways.Contains(10)); + } - [Fact] - public void Load_CanLoadRelationsWithReferenceToRelationsNotYetCreated() - { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-ref-other-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + [Fact] + public void Load_LoadsRelation() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(2, target.Relations.Count); - Assert.True(target.Relations.Contains(100)); - Assert.True(target.Relations.Contains(101)); + Assert.Equal(1, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); - Assert.Equal(101, target.Relations[100].Geometries[0].Member.ID); - } + Assert.Equal(1, target.Relations.Count); + Assert.True(target.Relations.Contains(100)); + } - [Fact] - public void Load_ThrowsExceptionIfAllRelationReferencesAreNotResolvedAtTheEndOfLoadingAndIgnoreMissingIsFalse() - { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - Assert.Throws(() => OsmGeometryDatabase.Load(reader, false)); - } + [Fact] + public void Load_CanLoadRelationsWithReferenceToRelationsNotYetCreated() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-ref-other-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - [Fact] - public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndWaysNodeIsMissing() - { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = null; - target = OsmGeometryDatabase.Load(reader, true); + Assert.Equal(2, target.Relations.Count); + Assert.True(target.Relations.Contains(100)); + Assert.True(target.Relations.Contains(101)); - Assert.Equal(2, target.Nodes.Count); - Assert.Equal(0, target.Ways.Count); - } + Assert.Equal(101, target.Relations[100].Geometries[0].Member.ID); + } - [Fact] - public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndRelationMemberIsMissing() - { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = null; - target = OsmGeometryDatabase.Load(reader, true); + [Fact] + public void Load_ThrowsExceptionIfAllRelationReferencesAreNotResolvedAtTheEndOfLoadingAndIgnoreMissingIsFalse() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + Assert.Throws(() => OsmGeometryDatabase.Load(reader, false)); + } - Assert.Equal(1, target.Relations.Count); - } + [Fact] + public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndWaysNodeIsMissing() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = null; + target = OsmGeometryDatabase.Load(reader, true); - [Fact] - public void Save_CallsIOsmWriterWriteForAllEntities() - { - List written = new List(); - Mock writerM = new Mock(); + Assert.Equal(2, target.Nodes.Count); + Assert.Equal(0, target.Ways.Count); + } + + [Fact] + public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndRelationMemberIsMissing() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation-invalid-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = null; + target = OsmGeometryDatabase.Load(reader, true); + + Assert.Equal(1, target.Relations.Count); + } - writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); + [Fact] + public void Save_CallsIOsmWriterWriteForAllEntities() + { + List written = new List(); + Mock writerM = new Mock(); + + writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); - target.Save(writerM.Object); + OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + target.Save(writerM.Object); - Assert.Equal(target.Count, written.Count); - foreach (var entity in target) - { - Assert.Contains(entity, written); - } + Assert.Equal(target.Count, written.Count); + foreach (var entity in target) + { + Assert.Contains(entity, written); } } } diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs index 53fd2f7..fc2f8e2 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs @@ -7,174 +7,173 @@ using SpatialLite.Core.API; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.Geometries +namespace Tests.SpatialLite.Osm.Geometries; + +public class RelationMemberTests { - public class RelationMemberTests - { - IEntityCollection _nodesEntityCollection; - - public RelationMemberTests() - { - Mock> _nodesCollectionM = new Mock>(); - _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); - _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); - _nodesEntityCollection = _nodesCollectionM.Object; - } - - [Fact] - public void Constructor_Member_CreatesNewRelationMembeAndSetsMember() - { - Node member = new Node(11); - RelationMember target = new RelationMember(member); - - Assert.Same(member, target.Member); - Assert.True(string.IsNullOrEmpty(target.Role)); - } - - [Fact] - public void Constructor_Member_ThrowsExceptionIfMemberIsNull() - { - Assert.Throws(() => new RelationMember(null)); - } - - [Fact] - public void Constructor_Member_Role_CreatesRelationMemberAndSetsMemberAndRole() - { - Node member = new Node(11); - string role = "role"; - RelationMember target = new RelationMember(member, role); - - Assert.Same(member, target.Member); - Assert.Equal(role, target.Role); - } - - [Fact] - public void Constructor_Member_Role_ThrowsExceptionIfMemberIsNull() - { - Assert.Throws(() => new RelationMember(null)); - } - - [Fact] - public void FromRelationMemberInfo_ThrowExceptionIfTypeIsUnknown() - { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Unknown, Role = "role" }; - - Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); - } - - [Fact] - public void FromRelationMemberInfo_CreatesRelationMember() - { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node, Role = "role" }; - RelationMember target = RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true); - - Assert.Equal(info.Reference, target.Member.ID); - Assert.Equal(info.Role, target.Role); - Assert.Equal(info.MemberType, target.MemberType); - } - - [Fact] - public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityIsNotAvailable() - { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; - - Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); - } - - [Fact] - public void FromRelationMemberInfo_ReturnsNullIfReferencedEntityIsNotAvailableAndThrowOnMissingIsFalse() - { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; - - Assert.Null(RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, false)); - } - - [Fact] - public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityTypeDoesntMatchMemberType() - { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Way, Role = "role" }; - - Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); - } - - [Fact] - public void Is3D_GetsTrueFor3DMember() - { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.Is3D).Returns(true); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.Is3D, target.Is3D); - } - - [Fact] - public void Is3D_GetsFalseFor2DMember() - { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.Is3D).Returns(false); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.Is3D, target.Is3D); - } - - [Fact] - public void IsMeasured_GetsTrueForMeasuredMember() - { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.IsMeasured).Returns(true); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); - } - - [Fact] - public void IsMeasured_GetFalseForNonMeasuredMember() - { - Mock memberM = new Mock(11); - memberM.SetupGet(property => property.IsMeasured).Returns(false); - - RelationMember target = new RelationMember(memberM.Object); - - Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); - } - - [Fact] - public void MemberType_ReturnsCorrectValueForNode() - { - RelationMember target = new RelationMember(new Node(11)); + IEntityCollection _nodesEntityCollection; + + public RelationMemberTests() + { + Mock> _nodesCollectionM = new Mock>(); + _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); + _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); + _nodesEntityCollection = _nodesCollectionM.Object; + } + + [Fact] + public void Constructor_Member_CreatesNewRelationMembeAndSetsMember() + { + Node member = new Node(11); + RelationMember target = new RelationMember(member); + + Assert.Same(member, target.Member); + Assert.True(string.IsNullOrEmpty(target.Role)); + } + + [Fact] + public void Constructor_Member_ThrowsExceptionIfMemberIsNull() + { + Assert.Throws(() => new RelationMember(null)); + } + + [Fact] + public void Constructor_Member_Role_CreatesRelationMemberAndSetsMemberAndRole() + { + Node member = new Node(11); + string role = "role"; + RelationMember target = new RelationMember(member, role); + + Assert.Same(member, target.Member); + Assert.Equal(role, target.Role); + } + + [Fact] + public void Constructor_Member_Role_ThrowsExceptionIfMemberIsNull() + { + Assert.Throws(() => new RelationMember(null)); + } - Assert.Equal(EntityType.Node, target.MemberType); - } - - [Fact] - public void MemberType_ReturnsCorrectValueForWay() - { - RelationMember target = new RelationMember(new Way(11)); + [Fact] + public void FromRelationMemberInfo_ThrowExceptionIfTypeIsUnknown() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Unknown, Role = "role" }; - Assert.Equal(EntityType.Way, target.MemberType); - } + Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); + } - [Fact] - public void MemberType_ReturnsCorrectValueForRelation() - { - RelationMember target = new RelationMember(new Relation(11)); + [Fact] + public void FromRelationMemberInfo_CreatesRelationMember() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node, Role = "role" }; + RelationMember target = RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true); - Assert.Equal(EntityType.Relation, target.MemberType); - } + Assert.Equal(info.Reference, target.Member.ID); + Assert.Equal(info.Role, target.Role); + Assert.Equal(info.MemberType, target.MemberType); + } + + [Fact] + public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityIsNotAvailable() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; + + Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); + } + + [Fact] + public void FromRelationMemberInfo_ReturnsNullIfReferencedEntityIsNotAvailableAndThrowOnMissingIsFalse() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; + + Assert.Null(RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, false)); + } + + [Fact] + public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityTypeDoesntMatchMemberType() + { + RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Way, Role = "role" }; + + Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); + } - [Fact] - public void GetEnvelopeReturnsMembersEnvelope() - { - Envelope expectedEnvelope = new Envelope(new Coordinate(1.1, 2.2)); - Mock member = new Mock(11); - member.Setup(function => function.GetEnvelope()).Returns(expectedEnvelope); + [Fact] + public void Is3D_GetsTrueFor3DMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.Is3D).Returns(true); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.Is3D, target.Is3D); + } + + [Fact] + public void Is3D_GetsFalseFor2DMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.Is3D).Returns(false); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.Is3D, target.Is3D); + } + + [Fact] + public void IsMeasured_GetsTrueForMeasuredMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.IsMeasured).Returns(true); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); + } + + [Fact] + public void IsMeasured_GetFalseForNonMeasuredMember() + { + Mock memberM = new Mock(11); + memberM.SetupGet(property => property.IsMeasured).Returns(false); + + RelationMember target = new RelationMember(memberM.Object); + + Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); + } + + [Fact] + public void MemberType_ReturnsCorrectValueForNode() + { + RelationMember target = new RelationMember(new Node(11)); + + Assert.Equal(EntityType.Node, target.MemberType); + } + + [Fact] + public void MemberType_ReturnsCorrectValueForWay() + { + RelationMember target = new RelationMember(new Way(11)); + + Assert.Equal(EntityType.Way, target.MemberType); + } + + [Fact] + public void MemberType_ReturnsCorrectValueForRelation() + { + RelationMember target = new RelationMember(new Relation(11)); + + Assert.Equal(EntityType.Relation, target.MemberType); + } + + [Fact] + public void GetEnvelopeReturnsMembersEnvelope() + { + Envelope expectedEnvelope = new Envelope(new Coordinate(1.1, 2.2)); + Mock member = new Mock(11); + member.Setup(function => function.GetEnvelope()).Returns(expectedEnvelope); - RelationMember target = new RelationMember(member.Object); + RelationMember target = new RelationMember(member.Object); - Assert.Same(expectedEnvelope, target.GetEnvelope()); - } + Assert.Same(expectedEnvelope, target.GetEnvelope()); } } diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs index bea2080..d136d10 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs @@ -7,112 +7,111 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.Geometries +namespace Tests.SpatialLite.Osm.Geometries; + +public class RelationTests { - public class RelationTests - { - RelationInfo _relationEmptyInfo = new RelationInfo(100, new TagsCollection(), new List(), new EntityMetadata()); - RelationInfo _relationInfo = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); + RelationInfo _relationEmptyInfo = new RelationInfo(100, new TagsCollection(), new List(), new EntityMetadata()); + RelationInfo _relationInfo = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); - IEntityCollection _nodesEntityCollection; + IEntityCollection _nodesEntityCollection; - public RelationTests() - { - Mock> _nodesCollectionM = new Mock>(); - _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); - _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); + public RelationTests() + { + Mock> _nodesCollectionM = new Mock>(); + _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); + _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); - _nodesEntityCollection = _nodesCollectionM.Object; - } + _nodesEntityCollection = _nodesCollectionM.Object; + } - [Fact] - public void Constructor_int_CreatesNewRelationAndInitializesProperties() - { - int id = 11; - Relation target = new Relation(id); + [Fact] + public void Constructor_int_CreatesNewRelationAndInitializesProperties() + { + int id = 11; + Relation target = new Relation(id); - Assert.Equal(id, target.ID); - Assert.Empty(target.Tags); - Assert.Empty(target.Geometries); - } + Assert.Equal(id, target.ID); + Assert.Empty(target.Tags); + Assert.Empty(target.Geometries); + } + + [Fact] + public void Constructor_int_IEnumerable_CreatesRelationWithMembersAndInitializesProperties() + { + int id = 11; + var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; + Relation target = new Relation(id, members); - [Fact] - public void Constructor_int_IEnumerable_CreatesRelationWithMembersAndInitializesProperties() + Assert.Equal(id, target.ID); + Assert.Equal(members.Length, target.Geometries.Count); + for (int i = 0; i < members.Length; i++) { - int id = 11; - var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; - Relation target = new Relation(id, members); - - Assert.Equal(id, target.ID); - Assert.Equal(members.Length, target.Geometries.Count); - for (int i = 0; i < members.Length; i++) - { - Assert.Same(members[i], target.Geometries[i]); - } - - Assert.Empty(target.Tags); + Assert.Same(members[i], target.Geometries[i]); } - [Fact] - public void Constructor_int_tags_CreatesRelationAndIntializesProperties() + Assert.Empty(target.Tags); + } + + [Fact] + public void Constructor_int_tags_CreatesRelationAndIntializesProperties() + { + int id = 11; + var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; + TagsCollection tags = new TagsCollection(); + Relation target = new Relation(id, members, tags); + + Assert.Equal(id, target.ID); + Assert.Equal(members.Length, target.Geometries.Count); + for (int i = 0; i < members.Length; i++) { - int id = 11; - var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; - TagsCollection tags = new TagsCollection(); - Relation target = new Relation(id, members, tags); - - Assert.Equal(id, target.ID); - Assert.Equal(members.Length, target.Geometries.Count); - for (int i = 0; i < members.Length; i++) - { - Assert.Same(members[i], target.Geometries[i]); - } - - Assert.Same(tags, target.Tags); + Assert.Same(members[i], target.Geometries[i]); } - [Fact] - public void FromRelationInfo_SetsRelationProperties() - { - Relation target = Relation.FromRelationInfo(_relationEmptyInfo, _nodesEntityCollection, true); + Assert.Same(tags, target.Tags); + } - Assert.Equal(_relationEmptyInfo.ID, target.ID); - Assert.Same(_relationEmptyInfo.Tags, target.Tags); - Assert.Same(_relationEmptyInfo.Metadata, target.Metadata); - } + [Fact] + public void FromRelationInfo_SetsRelationProperties() + { + Relation target = Relation.FromRelationInfo(_relationEmptyInfo, _nodesEntityCollection, true); - [Fact] - public void FromRelationInfo_SetsRelationMembers() - { - Relation target = Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true); + Assert.Equal(_relationEmptyInfo.ID, target.ID); + Assert.Same(_relationEmptyInfo.Tags, target.Tags); + Assert.Same(_relationEmptyInfo.Metadata, target.Metadata); + } - Assert.Single(target.Geometries); - Assert.Equal(_relationInfo.Members[0].Reference, target.Geometries[0].Member.ID); - } + [Fact] + public void FromRelationInfo_SetsRelationMembers() + { + Relation target = Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true); - [Fact] - public void FromRelationInfo_ThrowExceptionIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsTrue() - { - _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; + Assert.Single(target.Geometries); + Assert.Equal(_relationInfo.Members[0].Reference, target.Geometries[0].Member.ID); + } - Assert.Throws(() => Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true)); - } + [Fact] + public void FromRelationInfo_ThrowExceptionIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsTrue() + { + _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; - [Fact] - public void FromRelationInfo_ReturnsNullIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsFalse() - { - _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; + Assert.Throws(() => Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, true)); + } - Assert.Null(Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, false)); - } + [Fact] + public void FromRelationInfo_ReturnsNullIfCollectionDoesntContainReferencedEntityAndThrowOnMissingIsFalse() + { + _relationInfo.Members[0] = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node }; - [Fact] - public void EntityType_Returns_Relation() - { - Relation target = new Relation(100); + Assert.Null(Relation.FromRelationInfo(_relationInfo, _nodesEntityCollection, false)); + } - Assert.Equal(EntityType.Relation, target.EntityType); - } + [Fact] + public void EntityType_Returns_Relation() + { + Relation target = new Relation(100); + Assert.Equal(EntityType.Relation, target.EntityType); } + } diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs index 2d9e7e1..fd42e1e 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs @@ -7,89 +7,88 @@ using SpatialLite.Core.API; using SpatialLite.Osm.Geometries; -namespace Tests.SpatialLite.Osm.Geometries +namespace Tests.SpatialLite.Osm.Geometries; + +public class WayCoordinateListTests { - public class WayCoordinateListTests - { - List _nodes = new List(new Node[] { - new Node(5, 1.1, 2.2), - new Node(6, 10.1, -20.2), - new Node(7, -30.1, 40.2) }); + List _nodes = new List(new Node[] { + new Node(5, 1.1, 2.2), + new Node(6, 10.1, -20.2), + new Node(7, -30.1, 40.2) }); - [Fact] - public void Constructor_Source_SetsSource() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Constructor_Source_SetsSource() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Same(_nodes, target.Source); - } + Assert.Same(_nodes, target.Source); + } - [Fact] - public void Indexer_Get_ReturnsCoordinatesFromSourceList() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Indexer_Get_ReturnsCoordinatesFromSourceList() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - for (int i = 0; i < _nodes.Count; i++) - { - Assert.Equal(_nodes[i].Position, target[i]); - } + for (int i = 0; i < _nodes.Count; i++) + { + Assert.Equal(_nodes[i].Position, target[i]); } + } - [Fact] - public void Indexer_Set_ThrowsNotSupportedException() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Indexer_Set_ThrowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); - } + Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); + } - [Fact] - public void Count_GetsNumberOfItemsInSourceCollection() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Count_GetsNumberOfItemsInSourceCollection() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Equal(_nodes.Count, target.Count); - } + Assert.Equal(_nodes.Count, target.Count); + } - [Fact] - public void Add_Coordinate_ThowsNotSupportedException() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Add_Coordinate_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Throws(() => target.Add(Coordinate.Empty)); - } + Assert.Throws(() => target.Add(Coordinate.Empty)); + } - [Fact] - public void Add_Coordinates_ThowsNotSupportedException() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Add_Coordinates_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); - } + Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); + } - [Fact] - public void Insert_Index_Coordinate_ThowsNotSupportedException() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Insert_Index_Coordinate_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Throws(() => target.Insert(0, Coordinate.Empty)); - } + Assert.Throws(() => target.Insert(0, Coordinate.Empty)); + } - [Fact] - public void RemoveAt_Index_ThowsNotSupportedException() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void RemoveAt_Index_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Throws(() => target.RemoveAt(0)); - } + Assert.Throws(() => target.RemoveAt(0)); + } - [Fact] - public void Clear_ThowsNotSupportedException() - { - WayCoordinateList target = new WayCoordinateList(_nodes); + [Fact] + public void Clear_ThowsNotSupportedException() + { + WayCoordinateList target = new WayCoordinateList(_nodes); - Assert.Throws(() => target.Clear()); - } + Assert.Throws(() => target.Clear()); } } diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs index 62d6b6f..beaaaf4 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs @@ -9,162 +9,161 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.Geometries +namespace Tests.SpatialLite.Osm.Geometries; + +public class WayTests { - public class WayTests + List _nodes = new List(new Node[] { + new Node(1, 1.1, 2.2), + new Node(2, 10.1, -20.2), + new Node(3, -30.1, 40.2) }); + + WayInfo _wayEmptyInfo = new WayInfo(10, new TagsCollection(), new List(), new EntityMetadata()); + WayInfo _wayInfo = new WayInfo(10, new TagsCollection(), new long[] { 1, 2, 3 }, new EntityMetadata()); + + IEntityCollection _nodesEntityCollection; + + public WayTests() + { + Mock> _nodesCollectionM = new Mock>(); + _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(_nodes[0]); + _nodesCollectionM.SetupGet(c => c[2, EntityType.Node]).Returns(_nodes[1]); + _nodesCollectionM.SetupGet(c => c[3, EntityType.Node]).Returns(_nodes[2]); + _nodesEntityCollection = _nodesCollectionM.Object; + } + + [Fact] + public void Constructor_ID_CreatesNewEmptyWayAndInitializesProperties() { - List _nodes = new List(new Node[] { - new Node(1, 1.1, 2.2), - new Node(2, 10.1, -20.2), - new Node(3, -30.1, 40.2) }); + int id = 11; + + Way target = new Way(id); - WayInfo _wayEmptyInfo = new WayInfo(10, new TagsCollection(), new List(), new EntityMetadata()); - WayInfo _wayInfo = new WayInfo(10, new TagsCollection(), new long[] { 1, 2, 3 }, new EntityMetadata()); + Assert.Equal(id, target.ID); + Assert.Empty(target.Nodes); + Assert.Empty(target.Tags); + Assert.Null(target.Metadata); + } - IEntityCollection _nodesEntityCollection; + [Fact] + public void Constructor_ID_Nodes_CreatesWayAddsNodesAndInitializesProperties() + { + int id = 11; + Way target = new Way(id, _nodes); - public WayTests() + Assert.Equal(id, target.ID); + Assert.Equal(_nodes.Count, target.Nodes.Count); + for (int i = 0; i < _nodes.Count; i++) { - Mock> _nodesCollectionM = new Mock>(); - _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(_nodes[0]); - _nodesCollectionM.SetupGet(c => c[2, EntityType.Node]).Returns(_nodes[1]); - _nodesCollectionM.SetupGet(c => c[3, EntityType.Node]).Returns(_nodes[2]); - _nodesEntityCollection = _nodesCollectionM.Object; + Assert.Same(_nodes[i], target.Nodes[i]); } - [Fact] - public void Constructor_ID_CreatesNewEmptyWayAndInitializesProperties() - { - int id = 11; + Assert.Empty(target.Tags); + Assert.Null(target.Metadata); + } - Way target = new Way(id); + [Fact] + public void Constructor_ID_Nodes_Tags_CreatesWayAddsNodesAndInitializesProperties() + { + int id = 11; + TagsCollection tags = new TagsCollection(); - Assert.Equal(id, target.ID); - Assert.Empty(target.Nodes); - Assert.Empty(target.Tags); - Assert.Null(target.Metadata); - } + Way target = new Way(id, _nodes, tags); - [Fact] - public void Constructor_ID_Nodes_CreatesWayAddsNodesAndInitializesProperties() + Assert.Equal(id, target.ID); + Assert.Equal(_nodes.Count, target.Nodes.Count); + for (int i = 0; i < _nodes.Count; i++) { - int id = 11; - Way target = new Way(id, _nodes); - - Assert.Equal(id, target.ID); - Assert.Equal(_nodes.Count, target.Nodes.Count); - for (int i = 0; i < _nodes.Count; i++) - { - Assert.Same(_nodes[i], target.Nodes[i]); - } - - Assert.Empty(target.Tags); - Assert.Null(target.Metadata); + Assert.Same(_nodes[i], target.Nodes[i]); } - [Fact] - public void Constructor_ID_Nodes_Tags_CreatesWayAddsNodesAndInitializesProperties() - { - int id = 11; - TagsCollection tags = new TagsCollection(); + Assert.Same(tags, target.Tags); + Assert.Null(target.Metadata); + } - Way target = new Way(id, _nodes, tags); + [Fact] + public void FromWayInfo_SetsProperties() + { + Way target = Way.FromWayInfo(_wayEmptyInfo, _nodesEntityCollection, true); - Assert.Equal(id, target.ID); - Assert.Equal(_nodes.Count, target.Nodes.Count); - for (int i = 0; i < _nodes.Count; i++) - { - Assert.Same(_nodes[i], target.Nodes[i]); - } + Assert.Equal(_wayEmptyInfo.ID, target.ID); + Assert.Same(_wayEmptyInfo.Tags, target.Tags); + Assert.Same(_wayEmptyInfo.Metadata, target.Metadata); + Assert.Empty(target.Nodes); + } - Assert.Same(tags, target.Tags); - Assert.Null(target.Metadata); - } + [Fact] + public void FromWayInfo_SetsNodes() + { + Way target = Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true); - [Fact] - public void FromWayInfo_SetsProperties() + Assert.Equal(_wayInfo.Nodes.Count, target.Nodes.Count); + for (int i = 0; i < _wayInfo.Nodes.Count; i++) { - Way target = Way.FromWayInfo(_wayEmptyInfo, _nodesEntityCollection, true); - - Assert.Equal(_wayEmptyInfo.ID, target.ID); - Assert.Same(_wayEmptyInfo.Tags, target.Tags); - Assert.Same(_wayEmptyInfo.Metadata, target.Metadata); - Assert.Empty(target.Nodes); + Assert.Equal(_wayInfo.Nodes[i], target.Nodes[i].ID); } + } - [Fact] - public void FromWayInfo_SetsNodes() - { - Way target = Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true); - - Assert.Equal(_wayInfo.Nodes.Count, target.Nodes.Count); - for (int i = 0; i < _wayInfo.Nodes.Count; i++) - { - Assert.Equal(_wayInfo.Nodes[i], target.Nodes[i].ID); - } - } + [Fact] + public void FromWayInfo_ThrowsArgumentExceptionIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsTrue() + { + _wayInfo.Nodes[0] = 10000; - [Fact] - public void FromWayInfo_ThrowsArgumentExceptionIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsTrue() - { - _wayInfo.Nodes[0] = 10000; + Assert.Throws(() => Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true)); + } - Assert.Throws(() => Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true)); - } + [Fact] + public void FromWayInfo_ReturnsNullIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsFalse() + { + _wayInfo.Nodes[0] = 10000; - [Fact] - public void FromWayInfo_ReturnsNullIfReferencedNodeIsNotInCollectionAndMissingNodesAsErrorsIsFalse() - { - _wayInfo.Nodes[0] = 10000; + Assert.Null(Way.FromWayInfo(_wayInfo, _nodesEntityCollection, false)); + } - Assert.Null(Way.FromWayInfo(_wayInfo, _nodesEntityCollection, false)); - } + [Fact] + public void WhenWayIsInitializedFromWayInfo_CoordinatesReturnsNodesCoordinates() + { + Way target = Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true); - [Fact] - public void WhenWayIsInitializedFromWayInfo_CoordinatesReturnsNodesCoordinates() - { - Way target = Way.FromWayInfo(_wayInfo, _nodesEntityCollection, true); + Assert.Equal(_wayInfo.Nodes.Count, target.Nodes.Count); - Assert.Equal(_wayInfo.Nodes.Count, target.Nodes.Count); + Assert.Equal(_nodes[0].Position, target.Coordinates[0]); + Assert.Equal(_nodes[0].Position, target.Coordinates[0]); + Assert.Equal(_nodes[0].Position, target.Coordinates[0]); + } - Assert.Equal(_nodes[0].Position, target.Coordinates[0]); - Assert.Equal(_nodes[0].Position, target.Coordinates[0]); - Assert.Equal(_nodes[0].Position, target.Coordinates[0]); - } + [Fact] + public void Coordinates_GetsPositionOfNodes() + { + int id = 11; + Way target = new Way(id, _nodes); - [Fact] - public void Coordinates_GetsPositionOfNodes() + Assert.Equal(_nodes.Count, target.Coordinates.Count); + for (int i = 0; i < _nodes.Count; i++) { - int id = 11; - Way target = new Way(id, _nodes); - - Assert.Equal(_nodes.Count, target.Coordinates.Count); - for (int i = 0; i < _nodes.Count; i++) - { - Assert.Equal(_nodes[i].Position, target.Coordinates[i]); - } + Assert.Equal(_nodes[i].Position, target.Coordinates[i]); } + } - [Fact] - public void Coordinates_GetsPositionOfNodesIfWayCastedToLineString() + [Fact] + public void Coordinates_GetsPositionOfNodesIfWayCastedToLineString() + { + int id = 11; + Way way = new Way(id, _nodes); + LineString target = (LineString)way; + + Assert.Equal(_nodes.Count, target.Coordinates.Count); + for (int i = 0; i < _nodes.Count; i++) { - int id = 11; - Way way = new Way(id, _nodes); - LineString target = (LineString)way; - - Assert.Equal(_nodes.Count, target.Coordinates.Count); - for (int i = 0; i < _nodes.Count; i++) - { - Assert.Equal(_nodes[i].Position, target.Coordinates[i]); - } + Assert.Equal(_nodes[i].Position, target.Coordinates[i]); } + } - [Fact] - public void EntityType_Returns_Way() - { - Way target = new Way(10); + [Fact] + public void EntityType_Returns_Way() + { + Way target = new Way(10); - Assert.Equal(EntityType.Way, target.EntityType); - } + Assert.Equal(EntityType.Way, target.EntityType); } } diff --git a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs index 6cf603f..2364f70 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs @@ -4,25 +4,24 @@ using SpatialLite.Osm.IO; -namespace Tests.SpatialLite.Osm.IO +namespace Tests.SpatialLite.Osm.IO; + +public class OsmReaderSettingsTests { - public class OsmReaderSettingsTests + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() { - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() - { - OsmReaderSettings target = new OsmReaderSettings(); + OsmReaderSettings target = new OsmReaderSettings(); - Assert.True(target.ReadMetadata); - } + Assert.True(target.ReadMetadata); + } - [Fact] - public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - OsmReaderSettings target = new OsmReaderSettings(); - target.IsReadOnly = true; + [Fact] + public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + OsmReaderSettings target = new OsmReaderSettings(); + target.IsReadOnly = true; - Assert.Throws(() => target.ReadMetadata = true); - } + Assert.Throws(() => target.ReadMetadata = true); } } diff --git a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs index 094ee8d..a92f0a7 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs @@ -4,34 +4,33 @@ using SpatialLite.Osm.IO; -namespace Tests.SpatialLite.Osm.IO +namespace Tests.SpatialLite.Osm.IO; + +public class OsmWriterSettingsTests { - public class OsmWriterSettingsTests + [Fact] + public void Constructor__CreatesSettingsWithDefaultValues() + { + OsmWriterSettings target = new OsmWriterSettings(); + + Assert.True(target.WriteMetadata); + } + + [Fact] + public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - [Fact] - public void Constructor__CreatesSettingsWithDefaultValues() - { - OsmWriterSettings target = new OsmWriterSettings(); - - Assert.True(target.WriteMetadata); - } - - [Fact] - public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - OsmWriterSettings target = new OsmWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.WriteMetadata = true); - } - - [Fact] - public void ProgramNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - OsmWriterSettings target = new OsmWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.ProgramName = "TEST"); - } + OsmWriterSettings target = new OsmWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.WriteMetadata = true); + } + + [Fact] + public void ProgramNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + OsmWriterSettings target = new OsmWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.ProgramName = "TEST"); } } diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs index a1fee68..4e9bcb0 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs @@ -8,401 +8,400 @@ using SpatialLite.Osm; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.IO +namespace Tests.SpatialLite.Osm.IO; + +public class OsmXmlReaderTests { - public class OsmXmlReaderTests - { - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationTags, _relationProperties, _relationWithoutMembers; + private EntityMetadata _details; + private NodeInfo _node, _nodeTags, _nodeProperties; + private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private RelationInfo _relationNode, _relationWay, _relationRelation, _relationTags, _relationProperties, _relationWithoutMembers; - public OsmXmlReaderTests() - { - _details = new EntityMetadata() - { - Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), - Uid = 127998, - User = "Luk@s", - Visible = true, - Version = 2, - Changeset = 6410629 - }; - - _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(2, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); - _nodeProperties = new NodeInfo(3, 50.4, 16.2, new TagsCollection(), _details); - - _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); - _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); - _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); - _relationTags = new RelationInfo( - 2, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); - _relationWithoutMembers = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { }); - } + public OsmXmlReaderTests() + { + _details = new EntityMetadata() + { + Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), + Uid = 127998, + User = "Luk@s", + Visible = true, + Version = 2, + Changeset = 6410629 + }; + + _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); + _nodeTags = new NodeInfo(2, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeProperties = new NodeInfo(3, 50.4, 16.2, new TagsCollection(), _details); + + _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); + _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); + + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationTags = new RelationInfo( + 2, + new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), + new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + _relationWithoutMembers = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { }); + } - [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() - { - Assert.Throws(delegate { new OsmXmlReader("non-existing-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false }); }); - } + [Fact] + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() + { + Assert.Throws(delegate { new OsmXmlReader("non-existing-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false }); }); + } - [Fact] - public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() + [Fact] + public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() + { + string path = "../../../Data/Xml/osm-real-file.osm"; + OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; + using (OsmXmlReader target = new OsmXmlReader(path, settings)) { - string path = "../../../Data/Xml/osm-real-file.osm"; - OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; - using (OsmXmlReader target = new OsmXmlReader(path, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() + { + OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; + using (OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), settings)) { - OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; - using (OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Read_SkipsUnknownElements() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-unknown-inner-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - IEntityInfo result = target.Read(); + [Fact] + public void Read_SkipsUnknownElements() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-unknown-inner-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + IEntityInfo result = target.Read(); - Assert.NotNull(result as NodeInfo); - } + Assert.NotNull(result as NodeInfo); + } - //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation - [Fact] - public void Read_ThrowsExceptionIfTagHasNotKey() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-key.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation + [Fact] + public void Read_ThrowsExceptionIfTagHasNotKey() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-key.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation - [Fact] - public void Read_ThrowsExceptionIfTagHasNotValue() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-value.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation + [Fact] + public void Read_ThrowsExceptionIfTagHasNotValue() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-value.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); - Assert.Throws(() => target.Read()); - } + [Fact] + public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); - target.Read(); - } + [Fact] + public void Read_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); + target.Read(); + } - [Fact] - public void Read_ThrowsExceptionIfNodeHasNotID() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfNodeHasNotID() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ThrowsExceptionIfNodeHasNotLat() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lat.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfNodeHasNotLat() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lat.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ThrowsExceptionIfNodeHasNotLon() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfNodeHasNotLon() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ReadsSimpleNode() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsSimpleNode() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); - } + this.CompareNodes(_node, readNode); + } - [Fact] - public void Read_ReadsNodeWithUnknownElement() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tag-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNodeWithUnknownElement() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tag-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); + this.CompareNodes(_node, readNode); - // nothing more left to read in the file - Assert.Null(target.Read()); - } + // nothing more left to read in the file + Assert.Null(target.Read()); + } - [Fact] - public void Read_ReadsNodeWithTags() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNodeWithTags() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeTags, readNode); - } + this.CompareNodes(_nodeTags, readNode); + } - [Fact] - public void Read_ReadsNodeWithAllAttributes() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNodeWithAllAttributes() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeProperties, readNode); - } + this.CompareNodes(_nodeProperties, readNode); + } - [Fact] - public void Read_ThrowsExceptionIfWayHasNotID() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfWayHasNotID() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ThrowsExceptionIfWayNDHasNotRef() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfWayNDHasNotRef() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ReadsWayWithoutNodes() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-without-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWayWithoutNodes() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-without-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayWithoutNodes, readWay); - } + this.CompareWays(_wayWithoutNodes, readWay); + } - [Fact] - public void Read_ReadsSimpleWay() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsSimpleWay() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_way, readWay); - } + this.CompareWays(_way, readWay); + } - [Fact] - public void Read_ReadsWayWithTags() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWayWithTags() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayTags, readWay); - } + this.CompareWays(_wayTags, readWay); + } - [Fact] - public void Read_ReadsWayWithUnknownElement() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWayWithUnknownElement() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayTags, readWay); - } + this.CompareWays(_wayTags, readWay); + } - [Fact] - public void Read_ReadsWayWithAllAttributes() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWayWithAllAttributes() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayProperties, readWay); - } + this.CompareWays(_wayProperties, readWay); + } - [Fact] - public void Read_ThrowsExceptionIfRelationHasNotID() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfRelationHasNotID() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ThrowsExceptionIfRelationMemberHasNotRef() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfRelationMemberHasNotRef() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ThrowsExceptionIfRelationMemberHasNotType() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + [Fact] + public void Read_ThrowsExceptionIfRelationMemberHasNotType() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); - } + Assert.Throws(() => target.Read()); + } - [Fact] - public void Read_ReadsRelationWithoutMembers() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-members.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithoutMembers() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-members.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationWithoutMembers, readRelation); - } + this.CompareRelation(_relationWithoutMembers, readRelation); + } - [Fact] - public void Read_ReadsRelationWithNodeMember() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithNodeMember() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationNode, readRelation); - } + this.CompareRelation(_relationNode, readRelation); + } - [Fact] - public void Read_ReadsRelationWithWayMember() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithWayMember() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationWay, readRelation); - } + this.CompareRelation(_relationWay, readRelation); + } - [Fact] - public void Read_ReadsRelationWithRelationMember() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithRelationMember() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationRelation, readRelation); - } + this.CompareRelation(_relationRelation, readRelation); + } - [Fact] - public void Read_ReadsRelationWithTags() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithTags() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationTags, readRelation); - } + this.CompareRelation(_relationTags, readRelation); + } - [Fact] - public void Read_ReadsRelationWithTagsAndUnknownElement() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithTagsAndUnknownElement() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationTags, readRelation); - } + this.CompareRelation(_relationTags, readRelation); + } - [Fact] - public void Read_ReadsRelationWithAllProperties() - { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithAllProperties() + { + OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationProperties, readRelation); - } + this.CompareRelation(_relationProperties, readRelation); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = "../../../Data/Xml/osm-real-file.osm"; + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = "../../../Data/Xml/osm-real-file.osm"; - OsmXmlReader target = new OsmXmlReader(filename, new OsmXmlReaderSettings() { ReadMetadata = false }); - target.Dispose(); + OsmXmlReader target = new OsmXmlReader(filename, new OsmXmlReaderSettings() { ReadMetadata = false }); + target.Dispose(); - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - private void CompareNodes(NodeInfo expected, NodeInfo actual) - { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Longitude, actual.Longitude); - Assert.Equal(expected.Latitude, actual.Latitude); + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Longitude, actual.Longitude); + Assert.Equal(expected.Latitude, actual.Latitude); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - private void CompareWays(WayInfo expected, WayInfo actual) + private void CompareWays(WayInfo expected, WayInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); + for (int i = 0; i < expected.Nodes.Count; i++) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) - { - Assert.Equal(expected.Nodes[i], actual.Nodes[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - private void CompareRelation(RelationInfo expected, RelationInfo actual) + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Members.Count, actual.Members.Count); + for (int i = 0; i < expected.Members.Count; i++) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) - { - Assert.Equal(expected.Members[i], actual.Members[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + Assert.Equal(expected.Members[i], actual.Members[i]); } - private void CompareTags(TagsCollection expected, TagsCollection actual) - { - if (expected == null && actual == null) - { - return; - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { + return; } - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + Assert.Equal(expected.Count, actual.Count); + Assert.True(expected.All(tag => actual.Contains(tag))); + } + + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) { - if (expected == null && actual == null) - { - return; - } - - Assert.Equal(expected.Timestamp, actual.Timestamp); - Assert.Equal(expected.Uid, actual.Uid); - Assert.Equal(expected.User, actual.User); - Assert.Equal(expected.Visible, actual.Visible); - Assert.Equal(expected.Version, actual.Version); - Assert.Equal(expected.Changeset, actual.Changeset); + return; } + + Assert.Equal(expected.Timestamp, actual.Timestamp); + Assert.Equal(expected.Uid, actual.Uid); + Assert.Equal(expected.User, actual.User); + Assert.Equal(expected.Visible, actual.Visible); + Assert.Equal(expected.Version, actual.Version); + Assert.Equal(expected.Changeset, actual.Changeset); } } diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs index 17ed6f2..869451b 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs @@ -9,531 +9,530 @@ using SpatialLite.Osm.IO; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.IO +namespace Tests.SpatialLite.Osm.IO; + +public class OsmXmlWriterTests { - public class OsmXmlWriterTests - { - //resolution for default granularity - private const double _resolution = 1E-07; + //resolution for default granularity + private const double _resolution = 1E-07; - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; + private EntityMetadata _details; + private NodeInfo _node, _nodeTags, _nodeProperties; + private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; - public OsmXmlWriterTests() + public OsmXmlWriterTests() + { + _details = new EntityMetadata() + { + Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), + Uid = 127998, + User = "Luk@s", + Visible = true, + Version = 2, + Changeset = 6410629 + }; + + _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); + _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); + + _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); + _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); + + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationTags = new RelationInfo( + 1, + new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), + new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + } + + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakesThemReadOnly() + { + MemoryStream stream = new MemoryStream(); + OsmWriterSettings settings = new OsmWriterSettings(); + using (OsmXmlWriter target = new OsmXmlWriter(stream, settings)) { - _details = new EntityMetadata() - { - Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), - Uid = 127998, - User = "Luk@s", - Visible = true, - Version = 2, - Changeset = 6410629 - }; - - _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); - _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); - - _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); - _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); - _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); - _relationTags = new RelationInfo( - 1, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); - } - - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesThemReadOnly() - { - MemoryStream stream = new MemoryStream(); - OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(target.Settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(target.Settings.IsReadOnly); } + } - [Fact] - public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() - { - string path = PathHelper.GetTempFilePath("xmlwriter-constructor-test.osm"); + [Fact] + public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() + { + string path = PathHelper.GetTempFilePath("xmlwriter-constructor-test.osm"); - OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(path, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(target.Settings.IsReadOnly); - } + OsmWriterSettings settings = new OsmWriterSettings(); + using (OsmXmlWriter target = new OsmXmlWriter(path, settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(target.Settings.IsReadOnly); } + } + + [Fact] + public void Constructor_PathSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("osmwriter-constructor-creates-output-test.pbf"); - [Fact] - public void Constructor_PathSettings_CreatesOutputFile() + OsmWriterSettings settings = new OsmWriterSettings(); + using (OsmXmlWriter target = new OsmXmlWriter(filename, settings)) { - string filename = PathHelper.GetTempFilePath("osmwriter-constructor-creates-output-test.pbf"); + ; + } - OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(filename, settings)) - { - ; - } + Assert.True(File.Exists(filename)); + } - Assert.True(File.Exists(filename)); - } + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string path = PathHelper.GetTempFilePath("xmlwriter-closes-output-filestream-test.osm"); - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string path = PathHelper.GetTempFilePath("xmlwriter-closes-output-filestream-test.osm"); + OsmXmlWriter target = new OsmXmlWriter(path, new OsmWriterSettings()); + target.Dispose(); - OsmXmlWriter target = new OsmXmlWriter(path, new OsmWriterSettings()); - target.Dispose(); + FileStream testStream = null; + testStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - FileStream testStream = null; - testStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + [Fact] + public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); - - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) - { - Assert.Throws(() => target.Write(_node)); - } + Assert.Throws(() => target.Write(_node)); } + } - [Fact] - public void Write_DoesNotThrowsExceptionIfMetadataContainsNullInsteadUsername() - { - MemoryStream stream = new MemoryStream(); - _nodeProperties.Metadata.User = null; + [Fact] + public void Write_DoesNotThrowsExceptionIfMetadataContainsNullInsteadUsername() + { + MemoryStream stream = new MemoryStream(); + _nodeProperties.Metadata.User = null; - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) - { - target.Write(_nodeProperties); - } + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + { + target.Write(_nodeProperties); } + } + + [Fact] + public void Write_IEntityInfo_WritesNode() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesNode() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_node); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_node); - } + this.TestXmlOutput(stream, _node, false); + } - this.TestXmlOutput(stream, _node, false); - } + [Fact] + public void Write_IEntityInfo_WritesNodeWithTags() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesNodeWithTags() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_nodeTags); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_nodeTags); - } + this.TestXmlOutput(stream, _nodeTags, false); + } - this.TestXmlOutput(stream, _nodeTags, false); - } + [Fact] + public void Write_IEntityInfo_WritesNodeWithMetadata() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesNodeWithMetadata() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); + target.Write(_nodeProperties); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) - { - target.Write(_nodeProperties); - } + this.TestXmlOutput(stream, _nodeProperties, true); + } - this.TestXmlOutput(stream, _nodeProperties, true); - } + [Fact] + public void Write_IEntityInfo_DoesntWriteNodeMetadataIfWriteMedataIsFalse() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_DoesntWriteNodeMetadataIfWriteMedataIsFalse() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); - - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_nodeProperties); - } + target.Write(_nodeProperties); + } - stream = new MemoryStream(stream.ToArray()); + stream = new MemoryStream(stream.ToArray()); - using (TextReader reader = new StreamReader(stream)) + using (TextReader reader = new StreamReader(stream)) + { + string line = null; + while ((line = reader.ReadLine()) != null) { - string line = null; - while ((line = reader.ReadLine()) != null) - { - Assert.DoesNotContain("timestamp", line); - } + Assert.DoesNotContain("timestamp", line); } } + } + + [Fact] + public void Write_IEntityInfo_WritesWay() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesWay() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_way); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_way); - } + this.TestXmlOutput(stream, _way, false); + } - this.TestXmlOutput(stream, _way, false); - } + [Fact] + public void Write_IEntityInfo_WritesWayWithTags() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesWayWithTags() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_wayTags); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_wayTags); - } + this.TestXmlOutput(stream, _wayTags, false); + } - this.TestXmlOutput(stream, _wayTags, false); - } + [Fact] + public void Write_IEntityInfo_WritesWayWithMetadata() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesWayWithMetadata() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); + target.Write(_wayProperties); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) - { - target.Write(_wayProperties); - } + this.TestXmlOutput(stream, _wayProperties, true); + } - this.TestXmlOutput(stream, _wayProperties, true); - } + [Fact] + public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMedataIsFalse() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMedataIsFalse() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); - - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_wayProperties); - } + target.Write(_wayProperties); + } - stream = new MemoryStream(stream.ToArray()); + stream = new MemoryStream(stream.ToArray()); - using (TextReader reader = new StreamReader(stream)) + using (TextReader reader = new StreamReader(stream)) + { + string line = null; + while ((line = reader.ReadLine()) != null) { - string line = null; - while ((line = reader.ReadLine()) != null) - { - Assert.DoesNotContain("timestamp", line); - } + Assert.DoesNotContain("timestamp", line); } } + } + + [Fact] + public void Write_IEntityInfo_WritesRelationWithNode() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesRelationWithNode() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_relationNode); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_relationNode); - } + this.TestXmlOutput(stream, _relationNode, false); + } - this.TestXmlOutput(stream, _relationNode, false); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithWay() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesRelationWithWay() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_relationWay); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_relationWay); - } + this.TestXmlOutput(stream, _relationWay, false); + } - this.TestXmlOutput(stream, _relationWay, false); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithRelation() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesRelationWithRelation() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_relationRelation); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_relationRelation); - } + this.TestXmlOutput(stream, _relationRelation, false); + } - this.TestXmlOutput(stream, _relationRelation, false); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithTags() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesRelationWithTags() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); + target.Write(_relationTags); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_relationTags); - } + this.TestXmlOutput(stream, _relationTags, false); + } - this.TestXmlOutput(stream, _relationTags, false); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithMetadata() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_WritesRelationWithMetadata() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) { - MemoryStream stream = new MemoryStream(); + target.Write(_relationNodeProperties); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) - { - target.Write(_relationNodeProperties); - } + this.TestXmlOutput(stream, _relationNodeProperties, true); + } - this.TestXmlOutput(stream, _relationNodeProperties, true); - } + [Fact] + public void Write_IEntityInfo_DoesntWriteRelationMetadataIfWriteMedataIsFalse() + { + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IEntityInfo_DoesntWriteRelationMetadataIfWriteMedataIsFalse() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - MemoryStream stream = new MemoryStream(); - - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(_relationNodeProperties); - } + target.Write(_relationNodeProperties); + } - stream = new MemoryStream(stream.ToArray()); + stream = new MemoryStream(stream.ToArray()); - using (TextReader reader = new StreamReader(stream)) + using (TextReader reader = new StreamReader(stream)) + { + string line = null; + while ((line = reader.ReadLine()) != null) { - string line = null; - while ((line = reader.ReadLine()) != null) - { - Assert.DoesNotContain("timestamp", line); - } + Assert.DoesNotContain("timestamp", line); } } + } + + [Fact] + public void Write_IOsmGeometry_WritesNode() + { + Node node = new Node(1, 11.1, 12.1); + + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IOsmGeometry_WritesNode() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - Node node = new Node(1, 11.1, 12.1); + target.Write(node); + } - MemoryStream stream = new MemoryStream(); + this.TestXmlOutput(stream, new NodeInfo(node), false); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(node); - } + [Fact] + public void Write_IOsmGeometry_WritesWay() + { + Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); - this.TestXmlOutput(stream, new NodeInfo(node), false); - } + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IOsmGeometry_WritesWay() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); + target.Write(way); + } - MemoryStream stream = new MemoryStream(); + this.TestXmlOutput(stream, new WayInfo(way), false); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(way); - } + [Fact] + public void Write_IOsmGeometry_WritesRelation() + { + Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); - this.TestXmlOutput(stream, new WayInfo(way), false); - } + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IOsmGeometry_WritesRelation() + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); + target.Write(relation); + } - MemoryStream stream = new MemoryStream(); + this.TestXmlOutput(stream, new RelationInfo(relation), false); + } - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - target.Write(relation); - } + [Fact] + public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() + { + MemoryStream stream = new MemoryStream(); - this.TestXmlOutput(stream, new RelationInfo(relation), false); + using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + { + IOsmGeometry entity = null; + Assert.Throws(() => target.Write(entity)); } + } - [Fact] - public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() + private void TestXmlOutput(MemoryStream xmlStream, IEntityInfo expected, bool readMetadata) + { + if (xmlStream.CanSeek) { - MemoryStream stream = new MemoryStream(); - - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) - { - IOsmGeometry entity = null; - Assert.Throws(() => target.Write(entity)); - } + xmlStream.Seek(0, SeekOrigin.Begin); } - - private void TestXmlOutput(MemoryStream xmlStream, IEntityInfo expected, bool readMetadata) + else { - if (xmlStream.CanSeek) - { - xmlStream.Seek(0, SeekOrigin.Begin); - } - else - { - xmlStream = new MemoryStream(xmlStream.ToArray()); - } + xmlStream = new MemoryStream(xmlStream.ToArray()); + } - OsmXmlReader reader = new OsmXmlReader(xmlStream, new OsmXmlReaderSettings() { ReadMetadata = readMetadata }); - IEntityInfo read = reader.Read(); + OsmXmlReader reader = new OsmXmlReader(xmlStream, new OsmXmlReaderSettings() { ReadMetadata = readMetadata }); + IEntityInfo read = reader.Read(); - switch (expected.EntityType) - { - case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; - case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; - case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; - } + switch (expected.EntityType) + { + case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; + case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; + case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; } + } - private void CompareNodes(NodeInfo expected, NodeInfo actual) - { - Assert.Equal(expected.ID, actual.ID); - Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); - Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); + Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - private void CompareWays(WayInfo expected, WayInfo actual) + private void CompareWays(WayInfo expected, WayInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); + for (int i = 0; i < expected.Nodes.Count; i++) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) - { - Assert.Equal(expected.Nodes[i], actual.Nodes[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - private void CompareRelation(RelationInfo expected, RelationInfo actual) - { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) - { - Assert.Equal(expected.Members[i], actual.Members[i]); - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Members.Count, actual.Members.Count); + for (int i = 0; i < expected.Members.Count; i++) + { + Assert.Equal(expected.Members[i], actual.Members[i]); } - private void CompareTags(TagsCollection expected, TagsCollection actual) - { - if (expected == null && actual == null) - { - return; - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { + return; } - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + Assert.Equal(expected.Count, actual.Count); + Assert.True(expected.All(tag => actual.Contains(tag))); + } + + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) { - if (expected == null && actual == null) - { - return; - } + return; + } - Assert.NotNull(actual); + Assert.NotNull(actual); - Assert.Equal(expected.Timestamp, actual.Timestamp); - Assert.Equal(expected.Uid, actual.Uid); - Assert.Equal(expected.User, actual.User); - Assert.Equal(expected.Visible, actual.Visible); - Assert.Equal(expected.Version, actual.Version); - Assert.Equal(expected.Changeset, actual.Changeset); - } + Assert.Equal(expected.Timestamp, actual.Timestamp); + Assert.Equal(expected.Uid, actual.Uid); + Assert.Equal(expected.User, actual.User); + Assert.Equal(expected.Visible, actual.Visible); + Assert.Equal(expected.Version, actual.Version); + Assert.Equal(expected.Changeset, actual.Changeset); + } - private void CheckNode(XElement element) - { - Assert.Equal("15", element.Attribute("id").Value); - Assert.Equal("46.8", element.Attribute("lon").Value); - Assert.Equal("-15.6", element.Attribute("lat").Value); + private void CheckNode(XElement element) + { + Assert.Equal("15", element.Attribute("id").Value); + Assert.Equal("46.8", element.Attribute("lon").Value); + Assert.Equal("-15.6", element.Attribute("lat").Value); - XElement tagE = element.Elements("tag").Single(); - Assert.Equal("source", tagE.Attribute("k").Value); - Assert.Equal("survey", tagE.Attribute("v").Value); - } + XElement tagE = element.Elements("tag").Single(); + Assert.Equal("source", tagE.Attribute("k").Value); + Assert.Equal("survey", tagE.Attribute("v").Value); + } - private void CheckWay(XElement element) - { - Assert.Equal("25", element.Attribute("id").Value); + private void CheckWay(XElement element) + { + Assert.Equal("25", element.Attribute("id").Value); - var nodesElement = element.Elements("nd"); - Assert.Equal(3, nodesElement.Count()); - Assert.Equal("11", nodesElement.ToList()[0].Attribute("ref").Value); - Assert.Equal("12", nodesElement.ToList()[1].Attribute("ref").Value); - Assert.Equal("13", nodesElement.ToList()[2].Attribute("ref").Value); + var nodesElement = element.Elements("nd"); + Assert.Equal(3, nodesElement.Count()); + Assert.Equal("11", nodesElement.ToList()[0].Attribute("ref").Value); + Assert.Equal("12", nodesElement.ToList()[1].Attribute("ref").Value); + Assert.Equal("13", nodesElement.ToList()[2].Attribute("ref").Value); - XElement tagE = element.Elements("tag").Single(); - Assert.Equal("source", tagE.Attribute("k").Value); - Assert.Equal("survey", tagE.Attribute("v").Value); - } + XElement tagE = element.Elements("tag").Single(); + Assert.Equal("source", tagE.Attribute("k").Value); + Assert.Equal("survey", tagE.Attribute("v").Value); + } - private void CheckRelation(XElement element) - { - Assert.Equal("25", element.Attribute("id").Value); + private void CheckRelation(XElement element) + { + Assert.Equal("25", element.Attribute("id").Value); - XElement tagE = element.Elements("tag").Single(); - Assert.Equal("source", tagE.Attribute("k").Value); - Assert.Equal("survey", tagE.Attribute("v").Value); - } + XElement tagE = element.Elements("tag").Single(); + Assert.Equal("source", tagE.Attribute("k").Value); + Assert.Equal("survey", tagE.Attribute("v").Value); + } - private void CheckOsmDetails(EntityMetadata details, XElement element) - { - if (details == null) - { - Assert.Null(element.Attribute("version")); - Assert.Null(element.Attribute("changeset")); - Assert.Null(element.Attribute("uid")); - Assert.Null(element.Attribute("user")); - Assert.Null(element.Attribute("visible")); - Assert.Null(element.Attribute("timestamp")); - } - else - { - Assert.Equal("2", element.Attribute("version").Value); - Assert.Equal("123", element.Attribute("changeset").Value); - Assert.Equal("4587", element.Attribute("uid").Value); - Assert.Equal("username", element.Attribute("user").Value); - Assert.Equal("true", element.Attribute("visible").Value); - Assert.Equal("2011-01-20T14:00:04Z", element.Attribute("timestamp").Value); - } + private void CheckOsmDetails(EntityMetadata details, XElement element) + { + if (details == null) + { + Assert.Null(element.Attribute("version")); + Assert.Null(element.Attribute("changeset")); + Assert.Null(element.Attribute("uid")); + Assert.Null(element.Attribute("user")); + Assert.Null(element.Attribute("visible")); + Assert.Null(element.Attribute("timestamp")); + } + else + { + Assert.Equal("2", element.Attribute("version").Value); + Assert.Equal("123", element.Attribute("changeset").Value); + Assert.Equal("4587", element.Attribute("uid").Value); + Assert.Equal("username", element.Attribute("user").Value); + Assert.Equal("true", element.Attribute("visible").Value); + Assert.Equal("2011-01-20T14:00:04Z", element.Attribute("timestamp").Value); } } } diff --git a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs index 4b060bb..dddd7a7 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs @@ -8,393 +8,392 @@ using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.IO +namespace Tests.SpatialLite.Osm.IO; + +public class PbfReaderTests { - public class PbfReaderTests + //resolution for default granularity + private const double _resolution = 1E-07; + + private EntityMetadata _details; + private NodeInfo _node, _nodeTags, _nodeProperties; + private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private RelationInfo _relationNode, _relationWay, _relationRelation, _relationProperties, _relationTags; + + public PbfReaderTests() { - //resolution for default granularity - private const double _resolution = 1E-07; + _details = new EntityMetadata() + { + Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), + Uid = 127998, + User = "Luk@s", + Visible = true, + Version = 2, + Changeset = 6410629 + }; + + _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); + _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); + + _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); + _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); + + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationTags = new RelationInfo( + 1, + new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), + new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + } - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationProperties, _relationTags; + [Fact] + public void Constructor_StreamSettings_ThrowsExceptionIfStreamDoesntContainOSMHeaderBeforeOSMData() + { + var dataStream = TestDataReader.OpenPbf("pbf-without-osm-header.pbf"); + Assert.Throws(() => new PbfReader(dataStream, new OsmReaderSettings() { ReadMetadata = false })); + } - public PbfReaderTests() - { - _details = new EntityMetadata() - { - Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), - Uid = 127998, - User = "Luk@s", - Visible = true, - Version = 2, - Changeset = 6410629 - }; - - _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); - _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); - - _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); - _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); - _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); - _relationTags = new RelationInfo( - 1, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); - } + [Fact] + public void Constructor_StreamSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() + { + var dataStream = TestDataReader.OpenPbf("pbf-unsupported-required-feature.pbf"); + Assert.Throws(() => new PbfReader(dataStream, new OsmReaderSettings() { ReadMetadata = false })); + } - [Fact] - public void Constructor_StreamSettings_ThrowsExceptionIfStreamDoesntContainOSMHeaderBeforeOSMData() - { - var dataStream = TestDataReader.OpenPbf("pbf-without-osm-header.pbf"); - Assert.Throws(() => new PbfReader(dataStream, new OsmReaderSettings() { ReadMetadata = false })); - } + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakesThemIsReadOnly() + { + var dataStream = TestDataReader.OpenPbf("pbf-n-node.pbf"); + OsmReaderSettings settings = new OsmReaderSettings(); - [Fact] - public void Constructor_StreamSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() + using (PbfReader target = new PbfReader(dataStream, settings)) { - var dataStream = TestDataReader.OpenPbf("pbf-unsupported-required-feature.pbf"); - Assert.Throws(() => new PbfReader(dataStream, new OsmReaderSettings() { ReadMetadata = false })); + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakesThemIsReadOnly() - { - var dataStream = TestDataReader.OpenPbf("pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings(); - - using (PbfReader target = new PbfReader(dataStream, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } - } + [Fact] + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() + { + Assert.Throws(delegate { new PbfReader("non-existing-file.pbf", new OsmReaderSettings() { ReadMetadata = false }); }); + } - [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() - { - Assert.Throws(delegate { new PbfReader("non-existing-file.pbf", new OsmReaderSettings() { ReadMetadata = false }); }); - } + [Fact] + public void Constructor_StringSettings_ThrowsExceptionIfFileDoesntContainOSMHeaderBeforeOSMData() + { + string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-without-osm-header.pbf"); + Assert.Throws(() => new PbfReader(filename, new OsmReaderSettings() { ReadMetadata = false })); + } - [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfFileDoesntContainOSMHeaderBeforeOSMData() - { - string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-without-osm-header.pbf"); - Assert.Throws(() => new PbfReader(filename, new OsmReaderSettings() { ReadMetadata = false })); - } + [Fact] + public void Constructor_StringSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() + { + string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-unsupported-required-feature.pbf"); + Assert.Throws(() => new PbfReader(filename, new OsmReaderSettings() { ReadMetadata = false })); + } - [Fact] - public void Constructor_StringSettings_ThrowsExceptionIfOSMHeaderDefinedUnsupportedRequiredFeature() - { - string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-unsupported-required-feature.pbf"); - Assert.Throws(() => new PbfReader(filename, new OsmReaderSettings() { ReadMetadata = false })); - } + [Fact] + public void Constructor_StringSettings_SetsSettingsAndMakesThemIsReadOnly() + { + string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); + OsmReaderSettings settings = new OsmReaderSettings(); - [Fact] - public void Constructor_StringSettings_SetsSettingsAndMakesThemIsReadOnly() + using (PbfReader target = new PbfReader(filename, settings)) { - string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings(); - - using (PbfReader target = new PbfReader(filename, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Read_ReturnsNullIfAllEntitiesHaveBeenRead() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - //read only entity - IEntityInfo read = target.Read(); + [Fact] + public void Read_ReturnsNullIfAllEntitiesHaveBeenRead() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + //read only entity + IEntityInfo read = target.Read(); - // should return null - read = target.Read(); - Assert.Null(read); - } + // should return null + read = target.Read(); + Assert.Null(read); + } - [Fact] - public void Read_ThrowInvalidDataExceptionIfHeaderBlockSizeExceedesAllowdValue() - { - Assert.Throws(() => new PbfReader(TestDataReader.OpenPbf("pbf-too-large-header-block.pbf"), new OsmReaderSettings() { ReadMetadata = false })); - } + [Fact] + public void Read_ThrowInvalidDataExceptionIfHeaderBlockSizeExceedesAllowdValue() + { + Assert.Throws(() => new PbfReader(TestDataReader.OpenPbf("pbf-too-large-header-block.pbf"), new OsmReaderSettings() { ReadMetadata = false })); + } - [Fact] - public void Read_ThrowInvalidDataExceptionIfOsmDataBlockSizeExceedesAllowdValue() - { - Assert.Throws(() => new PbfReader(TestDataReader.OpenPbf("pbf-too-large-data-block.pbf"), new OsmReaderSettings() { ReadMetadata = false })); - } + [Fact] + public void Read_ThrowInvalidDataExceptionIfOsmDataBlockSizeExceedesAllowdValue() + { + Assert.Throws(() => new PbfReader(TestDataReader.OpenPbf("pbf-too-large-data-block.pbf"), new OsmReaderSettings() { ReadMetadata = false })); + } - [Fact] - public void Read_ReadsNode_DenseNoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNode_DenseNoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); - } + this.CompareNodes(_node, readNode); + } - [Fact] - public void Read_ReadsNodeWithTags_DenseNoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNodeWithTags_DenseNoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeTags, readNode); - } + this.CompareNodes(_nodeTags, readNode); + } - [Fact] - public void Read_ReadsNodeWithMetadata_DenseNoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNodeWithMetadata_DenseNoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeProperties, readNode); - } + this.CompareNodes(_nodeProperties, readNode); + } - [Fact] - public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_DenseNoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_DenseNoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - Assert.Null(readNode.Metadata); - } + Assert.Null(readNode.Metadata); + } - [Fact] - public void Read_ReadsNode_NoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNode_NoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); - } + this.CompareNodes(_node, readNode); + } - [Fact] - public void Read_ReadsNodeWithTags_NoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNodeWithTags_NoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeTags, readNode); - } + this.CompareNodes(_nodeTags, readNode); + } - [Fact] - public void Read_ReadsNodeWithMetadata_NoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_ReadsNodeWithMetadata_NoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeProperties, readNode); - } + this.CompareNodes(_nodeProperties, readNode); + } - [Fact] - public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - NodeInfo readNode = target.Read() as NodeInfo; + [Fact] + public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + NodeInfo readNode = target.Read() as NodeInfo; - Assert.Null(readNode.Metadata); - } + Assert.Null(readNode.Metadata); + } - [Fact] - public void Read_ReadsWay_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWay_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_way, readWay); - } + this.CompareWays(_way, readWay); + } - [Fact] - public void Read_ReadsWayWithTags_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWayWithTags_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayTags, readWay); - } + this.CompareWays(_wayTags, readWay); + } - [Fact] - public void Read_ReadsWayWithMetadata_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWayWithMetadata_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayProperties, readWay); - } + this.CompareWays(_wayProperties, readWay); + } - [Fact] - public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - Assert.Null(readWay.Metadata); - } + Assert.Null(readWay.Metadata); + } - [Fact] - public void Read_ReadsWayWithoutNodes_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-without-nodes.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - WayInfo readWay = target.Read() as WayInfo; + [Fact] + public void Read_ReadsWayWithoutNodes_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-without-nodes.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayWithoutNodes, readWay); - } + this.CompareWays(_wayWithoutNodes, readWay); + } - [Fact] - public void Read_ReadsRelationWithNode_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithNode_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationNode, readRelation); - } + this.CompareRelation(_relationNode, readRelation); + } - [Fact] - public void Read_ReadsRelationWithWay_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithWay_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationWay, readRelation); - } + this.CompareRelation(_relationWay, readRelation); + } - [Fact] - public void Read_ReadsRelationWithRelation_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-relation.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithRelation_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-relation.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationRelation, readRelation); - } + this.CompareRelation(_relationRelation, readRelation); + } - [Fact] - public void Read_ReadsRelationWithTags_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithTags_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationTags, readRelation); - } + this.CompareRelation(_relationTags, readRelation); + } - [Fact] - public void Read_ReadsRelationWithAllProperties_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_ReadsRelationWithAllProperties_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationProperties, readRelation); - } + this.CompareRelation(_relationProperties, readRelation); + } - [Fact] - public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion() - { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); - RelationInfo readRelation = target.Read() as RelationInfo; + [Fact] + public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion() + { + PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + RelationInfo readRelation = target.Read() as RelationInfo; - Assert.Null(readRelation.Metadata); - } + Assert.Null(readRelation.Metadata); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); + OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; - var aaa = Path.GetFullPath(filename); - PbfReader target = new PbfReader(filename, settings); - target.Dispose(); + var aaa = Path.GetFullPath(filename); + PbfReader target = new PbfReader(filename, settings); + target.Dispose(); - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); - testStream.Dispose(); - } + FileStream testStream = null; + testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + testStream.Dispose(); + } - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToStream() - { - var stream = TestDataReader.OpenPbf("pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToStream() + { + var stream = TestDataReader.OpenPbf("pbf-n-node.pbf"); + OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; - PbfReader target = new PbfReader(stream, settings); - target.Dispose(); + PbfReader target = new PbfReader(stream, settings); + target.Dispose(); - Assert.False(stream.CanRead); - } + Assert.False(stream.CanRead); + } - private void CompareNodes(NodeInfo expected, NodeInfo actual) - { - Assert.Equal(expected.ID, actual.ID); - Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); - Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); + Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - private void CompareWays(WayInfo expected, WayInfo actual) + private void CompareWays(WayInfo expected, WayInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); + for (int i = 0; i < expected.Nodes.Count; i++) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) - { - Assert.Equal(expected.Nodes[i], actual.Nodes[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - private void CompareRelation(RelationInfo expected, RelationInfo actual) + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } + + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Members.Count, actual.Members.Count); + for (int i = 0; i < expected.Members.Count; i++) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) - { - Assert.Equal(expected.Members[i], actual.Members[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + Assert.Equal(expected.Members[i], actual.Members[i]); } - private void CompareTags(TagsCollection expected, TagsCollection actual) - { - if (expected == null && actual == null) - { - return; - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { + return; } - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + Assert.Equal(expected.Count, actual.Count); + Assert.True(expected.All(tag => actual.Contains(tag))); + } + + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) { - if (expected == null && actual == null) - { - return; - } - - Assert.NotNull(actual); - - Assert.Equal(expected.Timestamp, actual.Timestamp); - Assert.Equal(expected.Uid, actual.Uid); - Assert.Equal(expected.User, actual.User); - Assert.Equal(expected.Visible, actual.Visible); - Assert.Equal(expected.Version, actual.Version); - Assert.Equal(expected.Changeset, actual.Changeset); + return; } + + Assert.NotNull(actual); + + Assert.Equal(expected.Timestamp, actual.Timestamp); + Assert.Equal(expected.Uid, actual.Uid); + Assert.Equal(expected.User, actual.User); + Assert.Equal(expected.Visible, actual.Visible); + Assert.Equal(expected.Version, actual.Version); + Assert.Equal(expected.Changeset, actual.Changeset); } } diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs index a178ceb..7563d8a 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs @@ -4,36 +4,35 @@ using SpatialLite.Osm.IO; -namespace Tests.SpatialLite.Osm.IO +namespace Tests.SpatialLite.Osm.IO; + +public class PbfWriterSettingsTests { - public class PbfWriterSettingsTests + [Fact] + public void Constructor__SetsDefaultValues() + { + PbfWriterSettings target = new PbfWriterSettings(); + + Assert.True(target.UseDenseFormat); + Assert.Equal(CompressionMode.ZlibDeflate, target.Compression); + Assert.True(target.WriteMetadata); + } + + [Fact] + public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - [Fact] - public void Constructor__SetsDefaultValues() - { - PbfWriterSettings target = new PbfWriterSettings(); - - Assert.True(target.UseDenseFormat); - Assert.Equal(CompressionMode.ZlibDeflate, target.Compression); - Assert.True(target.WriteMetadata); - } - - [Fact] - public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - PbfWriterSettings target = new PbfWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.UseDenseFormat = false); - } - - [Fact] - public void ConpressionSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() - { - PbfWriterSettings target = new PbfWriterSettings(); - target.IsReadOnly = true; - - Assert.Throws(() => target.Compression = CompressionMode.ZlibDeflate); - } + PbfWriterSettings target = new PbfWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.UseDenseFormat = false); + } + + [Fact] + public void ConpressionSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() + { + PbfWriterSettings target = new PbfWriterSettings(); + target.IsReadOnly = true; + + Assert.Throws(() => target.Compression = CompressionMode.ZlibDeflate); } } diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs index 4c6ecc0..f9ac92c 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs @@ -8,563 +8,562 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm.IO -{ - public class PbfWriterTests - { - //resolution for default granularity - private const double _resolution = 1E-07; - - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; +namespace Tests.SpatialLite.Osm.IO; - public PbfWriterTests() - { - _details = new EntityMetadata() - { - Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), - Uid = 127998, - User = "Luk@s", - Visible = true, - Version = 2, - Changeset = 6410629 - }; +public class PbfWriterTests +{ + //resolution for default granularity + private const double _resolution = 1E-07; - _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); - _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); + private EntityMetadata _details; + private NodeInfo _node, _nodeTags, _nodeProperties; + private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; - _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); - _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); - _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); + public PbfWriterTests() + { + _details = new EntityMetadata() + { + Timestamp = new DateTime(2010, 11, 19, 22, 5, 56, DateTimeKind.Utc), + Uid = 127998, + User = "Luk@s", + Visible = true, + Version = 2, + Changeset = 6410629 + }; + + _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); + _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); + + _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); + _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); + + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationTags = new RelationInfo( + 1, + new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), + new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + } - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); - _relationTags = new RelationInfo( - 1, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); - } + [Fact] + public void Constructor_FilenameSettings_SetsSettingsAndMakesThemReadOnly() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-test.pbf"); - [Fact] - public void Constructor_FilenameSettings_SetsSettingsAndMakesThemReadOnly() + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(filename, settings)) { - string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-test.pbf"); - - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } + + [Fact] + public void Constructor_FilenameSettings_CreatesOutputFile() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-creates-output-test.pbf"); - [Fact] - public void Constructor_FilenameSettings_CreatesOutputFile() + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(filename, settings)) { - string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-creates-output-test.pbf"); + ; + } - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) - { - ; - } + Assert.True(File.Exists(filename)); + } - Assert.True(File.Exists(filename)); - } + [Fact] + public void Constructor_FilenameSettings_WritesOsmHeader() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-writes-header-test.pbf"); - [Fact] - public void Constructor_FilenameSettings_WritesOsmHeader() + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(filename, settings)) { - string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-writes-header-test.pbf"); + ; + } - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) - { - ; - } + FileInfo fi = new FileInfo(filename); + Assert.True(fi.Length > 0); + } - FileInfo fi = new FileInfo(filename); - Assert.True(fi.Length > 0); + [Fact] + public void Constructor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + { + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(new MemoryStream(), settings)) + { + Assert.Same(settings, target.Settings); + Assert.True(settings.IsReadOnly); } + } - [Fact] - public void Constructor_StreamSettings_SetsSettingsAndMakeThemReadOnly() + [Fact] + public void Constructor_StreamSettings_WritesOsmHeader() + { + MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new PbfWriterSettings(); + using (PbfWriter target = new PbfWriter(stream, settings)) { - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(new MemoryStream(), settings)) - { - Assert.Same(settings, target.Settings); - Assert.True(settings.IsReadOnly); - } + ; } - [Fact] - public void Constructor_StreamSettings_WritesOsmHeader() - { - MemoryStream stream = new MemoryStream(); - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(stream, settings)) - { - ; - } + Assert.True(stream.ToArray().Length > 0); + } - Assert.True(stream.ToArray().Length > 0); - } + [Fact] + public void Dispose_ClosesOutputStreamIfWritingToFiles() + { + string filename = PathHelper.GetTempFilePath("pbfwriter-closes-output-filestream-test.pbf"); - [Fact] - public void Dispose_ClosesOutputStreamIfWritingToFiles() - { - string filename = PathHelper.GetTempFilePath("pbfwriter-closes-output-filestream-test.pbf"); + PbfWriterSettings settings = new PbfWriterSettings(); + PbfWriter target = new PbfWriter(filename, settings); + target.Dispose(); - PbfWriterSettings settings = new PbfWriterSettings(); - PbfWriter target = new PbfWriter(filename, settings); - target.Dispose(); + new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + } - new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + [Fact] + public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() + { + using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) + { + Assert.Throws(() => target.Write(_node)); } + } - [Fact] - public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() + [Fact] + public void Write_ThrowsArgumentNullExceptionIfMetadataContainsNullInsteadUsername() + { + _nodeProperties.Metadata.User = null; + + using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) { - using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) - { - Assert.Throws(() => target.Write(_node)); - } + Assert.Throws(() => target.Write(_nodeProperties)); } + } - [Fact] - public void Write_ThrowsArgumentNullExceptionIfMetadataContainsNullInsteadUsername() - { - _nodeProperties.Metadata.User = null; + [Fact] + public void Write_IEntityInfo_WritesNode() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) - { - Assert.Throws(() => target.Write(_nodeProperties)); - } + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_node); } - [Fact] - public void Write_IEntityInfo_WritesNode() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _node); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_node); - } + [Fact] + public void Write_IEntityInfo_WritesNodeWithTags() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _node); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeTags); } - [Fact] - public void Write_IEntityInfo_WritesNodeWithTags() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _nodeTags); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_nodeTags); - } + [Fact] + public void Write_IEntityInfo_WritesNodeWithMetadata() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _nodeTags); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); } - [Fact] - public void Write_IEntityInfo_WritesNodeWithMetadata() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _nodeProperties); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_nodeProperties); - } + [Fact] + public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _nodeProperties); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); } - [Fact] - public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _node); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_nodeProperties); - } + [Fact] + public void Write_IEntityInfo_WritesNode_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _node); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_node); } - [Fact] - public void Write_IEntityInfo_WritesNode_Dense() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _node); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_node); - } + [Fact] + public void Write_IEntityInfo_WritesNodeWithTags_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _node); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeTags); } - [Fact] - public void Write_IEntityInfo_WritesNodeWithTags_Dense() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _nodeTags); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_nodeTags); - } + [Fact] + public void Write_IEntityInfo_WritesNodeWithMetadata_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _nodeTags); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); } - [Fact] - public void Write_IEntityInfo_WritesNodeWithMetadata_Dense() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _nodeProperties); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_nodeProperties); - } + [Fact] + public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse_Dense() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _nodeProperties); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_nodeProperties); } - [Fact] - public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse_Dense() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _node); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_nodeProperties); - } + [Fact] + public void Write_IEntityInfo_WritesWay() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _node); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_way); } - [Fact] - public void Write_IEntityInfo_WritesWay() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _way); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_way); - } + [Fact] + public void Write_IEntityInfo_WritesWayWithTags() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _way); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_wayTags); } - [Fact] - public void Write_IEntityInfo_WritesWayWithTags() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _wayTags); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_wayTags); - } + [Fact] + public void Write_IEntityInfo_WritesWayWithMetadata() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _wayTags); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_wayProperties); } - [Fact] - public void Write_IEntityInfo_WritesWayWithMetadata() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _wayProperties); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_wayProperties); - } + [Fact] + public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMetadataSettingsIsFalse() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _wayProperties); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_wayProperties); } - [Fact] - public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMetadataSettingsIsFalse() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _way); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_wayProperties); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithNode() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _way); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationNode); } - [Fact] - public void Write_IEntityInfo_WritesRelationWithNode() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _relationNode); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_relationNode); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithWay() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _relationNode); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationWay); } - [Fact] - public void Write_IEntityInfo_WritesRelationWithWay() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _relationWay); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_relationWay); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithRelation() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _relationWay); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationRelation); } - [Fact] - public void Write_IEntityInfo_WritesRelationWithRelation() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _relationRelation); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_relationRelation); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithTags() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _relationRelation); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationTags); } - [Fact] - public void Write_IEntityInfo_WritesRelationWithTags() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _relationTags); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_relationTags); - } + [Fact] + public void Write_IEntityInfo_WritesRelationWithMetadata() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _relationTags); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationNodeProperties); } - [Fact] - public void Write_IEntityInfo_WritesRelationWithMetadata() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _relationNodeProperties); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_relationNodeProperties); - } + [Fact] + public void Write_IEntityInfo_DoesntWritesRelationMetadataIfWriteMetasdataSettingsIsFalse() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _relationNodeProperties); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(_relationNodeProperties); } - [Fact] - public void Write_IEntityInfo_DoesntWritesRelationMetadataIfWriteMetasdataSettingsIsFalse() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, _relationNode); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(_relationNodeProperties); - } + [Fact] + public void Write_IOsmGeometry_WritesNode() + { + Node node = new Node(1, 11.1, 12.1); + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, _relationNode); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(node); } - [Fact] - public void Write_IOsmGeometry_WritesNode() - { - Node node = new Node(1, 11.1, 12.1); - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, new NodeInfo(node)); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(node); - } + [Fact] + public void Write_IOsmGeometry_WritesWay() + { + Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, new NodeInfo(node)); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + target.Write(way); } - [Fact] - public void Write_IOsmGeometry_WritesWay() - { - Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, new WayInfo(way)); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(way); - } + [Fact] + public void Write_IOsmGeometry_WritesRelation() + { + Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); - this.TestPbfOutput(stream, new WayInfo(way)); - } + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - [Fact] - public void Write_IOsmGeometry_WritesRelation() + using (PbfWriter target = new PbfWriter(stream, settings)) { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); + target.Write(relation); + } - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + this.TestPbfOutput(stream, new RelationInfo(relation)); + } - using (PbfWriter target = new PbfWriter(stream, settings)) - { - target.Write(relation); - } + [Fact] + public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() + { + PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new MemoryStream(); - this.TestPbfOutput(stream, new RelationInfo(relation)); + using (PbfWriter target = new PbfWriter(stream, settings)) + { + IOsmGeometry entity = null; + Assert.Throws(() => target.Write(entity)); } + } - [Fact] - public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() - { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + [Fact] + public void Flush_ForcesWriterToWriteDataToUnderalyingStorage() + { + MemoryStream stream = new MemoryStream(); - using (PbfWriter target = new PbfWriter(stream, settings)) - { - IOsmGeometry entity = null; - Assert.Throws(() => target.Write(entity)); - } - } + PbfWriter target = new PbfWriter(stream, new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }); - [Fact] - public void Flush_ForcesWriterToWriteDataToUnderalyingStorage() + //1000 nodes should fit into tokens + for (int i = 0; i < 1000; i++) { - MemoryStream stream = new MemoryStream(); - - PbfWriter target = new PbfWriter(stream, new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }); + NodeInfo node = new NodeInfo(i, 45.87, -126.5, new TagsCollection()); + target.Write(node); + } + int minimalExpectedLengthIncrease = 1000 * 8; - //1000 nodes should fit into tokens - for (int i = 0; i < 1000; i++) - { - NodeInfo node = new NodeInfo(i, 45.87, -126.5, new TagsCollection()); - target.Write(node); - } - int minimalExpectedLengthIncrease = 1000 * 8; + long originalStreamLength = stream.Length; + target.Flush(); - long originalStreamLength = stream.Length; - target.Flush(); + Assert.True(stream.Length > originalStreamLength + minimalExpectedLengthIncrease); + } - Assert.True(stream.Length > originalStreamLength + minimalExpectedLengthIncrease); + private void TestPbfOutput(MemoryStream pbfStream, IEntityInfo expected) + { + if (pbfStream.CanSeek) + { + pbfStream.Seek(0, SeekOrigin.Begin); } - - private void TestPbfOutput(MemoryStream pbfStream, IEntityInfo expected) + else { - if (pbfStream.CanSeek) - { - pbfStream.Seek(0, SeekOrigin.Begin); - } - else - { - pbfStream = new MemoryStream(pbfStream.ToArray()); - } + pbfStream = new MemoryStream(pbfStream.ToArray()); + } - PbfReader reader = new PbfReader(pbfStream, new OsmReaderSettings() { ReadMetadata = true }); - IEntityInfo read = reader.Read(); + PbfReader reader = new PbfReader(pbfStream, new OsmReaderSettings() { ReadMetadata = true }); + IEntityInfo read = reader.Read(); - switch (expected.EntityType) - { - case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; - case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; - case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; - } + switch (expected.EntityType) + { + case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; + case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; + case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; } + } - private void CompareNodes(NodeInfo expected, NodeInfo actual) - { - Assert.Equal(expected.ID, actual.ID); - Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); - Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); + private void CompareNodes(NodeInfo expected, NodeInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); + Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - private void CompareWays(WayInfo expected, WayInfo actual) + private void CompareWays(WayInfo expected, WayInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); + for (int i = 0; i < expected.Nodes.Count; i++) { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Nodes.Count, actual.Nodes.Count); - for (int i = 0; i < expected.Nodes.Count; i++) - { - Assert.Equal(expected.Nodes[i], actual.Nodes[i]); - } - - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - private void CompareRelation(RelationInfo expected, RelationInfo actual) - { - Assert.Equal(expected.ID, actual.ID); - Assert.Equal(expected.Members.Count, actual.Members.Count); - for (int i = 0; i < expected.Members.Count; i++) - { - Assert.Equal(expected.Members[i], actual.Members[i]); - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + private void CompareRelation(RelationInfo expected, RelationInfo actual) + { + Assert.Equal(expected.ID, actual.ID); + Assert.Equal(expected.Members.Count, actual.Members.Count); + for (int i = 0; i < expected.Members.Count; i++) + { + Assert.Equal(expected.Members[i], actual.Members[i]); } - private void CompareTags(TagsCollection expected, TagsCollection actual) - { - if (expected == null && actual == null) - { - return; - } + this.CompareTags(expected.Tags, actual.Tags); + this.CompareEntityDetails(expected.Metadata, actual.Metadata); + } - Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + private void CompareTags(TagsCollection expected, TagsCollection actual) + { + if (expected == null && actual == null) + { + return; } - private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + Assert.Equal(expected.Count, actual.Count); + Assert.True(expected.All(tag => actual.Contains(tag))); + } + + private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) + { + if (expected == null && actual == null) { - if (expected == null && actual == null) - { - return; - } + return; + } - Assert.NotNull(actual); + Assert.NotNull(actual); - Assert.Equal(expected.Timestamp, actual.Timestamp); - Assert.Equal(expected.Uid, actual.Uid); - Assert.Equal(expected.User, actual.User); - Assert.Equal(expected.Visible, actual.Visible); - Assert.Equal(expected.Version, actual.Version); - Assert.Equal(expected.Changeset, actual.Changeset); - } + Assert.Equal(expected.Timestamp, actual.Timestamp); + Assert.Equal(expected.Uid, actual.Uid); + Assert.Equal(expected.User, actual.User); + Assert.Equal(expected.Visible, actual.Visible); + Assert.Equal(expected.Version, actual.Version); + Assert.Equal(expected.Changeset, actual.Changeset); } } diff --git a/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs b/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs index 05b57f9..fbe89b9 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs @@ -8,201 +8,200 @@ using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.Integration.Pbf +namespace Tests.SpatialLite.Osm.Integration.Pbf; + +public class OsmosisIntegrationTests { - public class OsmosisIntegrationTests + private const int TestFileNodesCount = 129337; + private const int TestFileWaysCount = 14461; + private const int TestFileRelationsCount = 124; + + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseNoCompression() { - private const int TestFileNodesCount = 129337; - private const int TestFileWaysCount = 14461; - private const int TestFileRelationsCount = 124; + string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file.pbf"); + + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=none", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseNoCompression() + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file.pbf"); + this.TestReader(reader); + } + } - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=none", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_DenseNoCompression() + { + var pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-d.pbf"); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) - { - this.TestReader(reader); - } - } + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=none", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_DenseNoCompression() + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - var pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-d.pbf"); + this.TestReader(reader); + } + } - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=none", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseDeflateCompression() + { + string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-c.pbf"); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) - { - this.TestReader(reader); - } - } + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=deflate", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseDeflateCompression() + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-c.pbf"); + this.TestReader(reader); + } + } - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=deflate", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate() + { + string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-dc.pbf"); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) - { - this.TestReader(reader); - } - } + string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=deflate", PathHelper.RealPbfFilePath, pbfFile); + this.CallOsmosis(osmosisArguments); - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate() + using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-dc.pbf"); + this.TestReader(reader); + } + } - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=deflate", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseNoCompression() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file.pbf"); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) + { + foreach (var entityInfo in this.GetTestData()) { - this.TestReader(reader); + writer.Write(entityInfo); } } - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseNoCompression() - { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file.pbf"); - - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) - { - foreach (var entityInfo in this.GetTestData()) - { - writer.Write(entityInfo); - } - } + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseDeflate() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-c.pbf"); - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseDeflate() + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = false })) { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-c.pbf"); - - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = false })) + foreach (var entityInfo in this.GetTestData()) { - foreach (var entityInfo in this.GetTestData()) - { - writer.Write(entityInfo); - } + writer.Write(entityInfo); } + } - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseNoCompression() - { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-d.pbf"); + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseNoCompression() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-d.pbf"); - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = true })) + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = true })) + { + foreach (var entityInfo in this.GetTestData()) { - foreach (var entityInfo in this.GetTestData()) - { - writer.Write(entityInfo); - } + writer.Write(entityInfo); } + } - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate() - { - string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-dc.pbf"); + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate() + { + string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-dc.pbf"); - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + { + foreach (var entityInfo in this.GetTestData()) { - foreach (var entityInfo in this.GetTestData()) - { - writer.Write(entityInfo); - } + writer.Write(entityInfo); } + } - string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } - private void CallOsmosis(string arguments) - { - ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); - osmosisInfo.Arguments = arguments; + private void CallOsmosis(string arguments) + { + ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); + osmosisInfo.Arguments = arguments; - Process osmosis = Process.Start(osmosisInfo); - osmosis.WaitForExit(); + Process osmosis = Process.Start(osmosisInfo); + osmosis.WaitForExit(); - Assert.Equal(0, osmosis.ExitCode); - } + Assert.Equal(0, osmosis.ExitCode); + } - private void TestReader(IOsmReader reader) + private void TestReader(IOsmReader reader) + { + IEntityInfo info = null; + int nodesCount = 0, waysCount = 0, relationsCount = 0; + while ((info = reader.Read()) != null) { - IEntityInfo info = null; - int nodesCount = 0, waysCount = 0, relationsCount = 0; - while ((info = reader.Read()) != null) + switch (info.EntityType) { - switch (info.EntityType) - { - case EntityType.Node: nodesCount++; break; - case EntityType.Way: waysCount++; break; - case EntityType.Relation: relationsCount++; break; - } + case EntityType.Node: nodesCount++; break; + case EntityType.Way: waysCount++; break; + case EntityType.Relation: relationsCount++; break; } - - Assert.Equal(TestFileNodesCount, nodesCount); - Assert.Equal(TestFileWaysCount, waysCount); - Assert.Equal(TestFileRelationsCount, relationsCount); } - private IEnumerable GetTestData() - { - List data = new List(); + Assert.Equal(TestFileNodesCount, nodesCount); + Assert.Equal(TestFileWaysCount, waysCount); + Assert.Equal(TestFileRelationsCount, relationsCount); + } + + private IEnumerable GetTestData() + { + List data = new List(); - using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + { + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + IEntityInfo info = null; + while ((info = reader.Read()) != null) { - IEntityInfo info = null; - while ((info = reader.Read()) != null) - { - data.Add(info); - } + data.Add(info); } } - - return data; } + + return data; } } diff --git a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs index 7a09f26..bde6b0f 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs @@ -7,138 +7,137 @@ using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.Integration.Pbf +namespace Tests.SpatialLite.Osm.Integration.Pbf; + +public class PbfReaderPbfWriterComplianceTests { - public class PbfReaderPbfWriterComplianceTests + private const int TestFileNodesCount = 129337; + private const int TestFileWaysCount = 14461; + private const int TestFileRelationsCount = 124; + + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseNoCompression() { - private const int TestFileNodesCount = 129337; - private const int TestFileWaysCount = 14461; - private const int TestFileRelationsCount = 124; + MemoryStream stream = new MemoryStream(); - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseNoCompression() + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.None })) { - MemoryStream stream = new MemoryStream(); - - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.None })) + foreach (var info in this.GetTestData()) { - foreach (var info in this.GetTestData()) - { - writer.Write(info); - } + writer.Write(info); + } - writer.Flush(); + writer.Flush(); - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) - { - this.TestReader(reader); - } + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); } } + } - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_DenseNoCompression() - { - MemoryStream stream = new MemoryStream(); + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_DenseNoCompression() + { + MemoryStream stream = new MemoryStream(); - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.None })) + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.None })) + { + foreach (var info in this.GetTestData()) { - foreach (var info in this.GetTestData()) - { - writer.Write(info); - } + writer.Write(info); + } - writer.Flush(); + writer.Flush(); - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) - { - this.TestReader(reader); - } + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); } } + } - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate() - { - MemoryStream stream = new MemoryStream(); + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate() + { + MemoryStream stream = new MemoryStream(); - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.ZlibDeflate })) + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.ZlibDeflate })) + { + foreach (var info in this.GetTestData()) { - foreach (var info in this.GetTestData()) - { - writer.Write(info); - } + writer.Write(info); + } - writer.Flush(); + writer.Flush(); - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) - { - this.TestReader(reader); - } + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); } } + } - [Fact, Trait("Category", "Osm.Integration")] - public void PbfReaderCanReadFileCreatedByPbfWriter_DenseDeflate() - { - MemoryStream stream = new MemoryStream(); + [Fact, Trait("Category", "Osm.Integration")] + public void PbfReaderCanReadFileCreatedByPbfWriter_DenseDeflate() + { + MemoryStream stream = new MemoryStream(); - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.ZlibDeflate })) + using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.ZlibDeflate })) + { + foreach (var info in this.GetTestData()) { - foreach (var info in this.GetTestData()) - { - writer.Write(info); - } + writer.Write(info); + } - writer.Flush(); + writer.Flush(); - stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) - { - this.TestReader(reader); - } + stream.Seek(0, SeekOrigin.Begin); + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + { + this.TestReader(reader); } } + } - private void TestReader(IOsmReader reader) + private void TestReader(IOsmReader reader) + { + IEntityInfo info = null; + int nodesCount = 0, waysCount = 0, relationsCount = 0; + while ((info = reader.Read()) != null) { - IEntityInfo info = null; - int nodesCount = 0, waysCount = 0, relationsCount = 0; - while ((info = reader.Read()) != null) + switch (info.EntityType) { - switch (info.EntityType) - { - case EntityType.Node: nodesCount++; break; - case EntityType.Way: waysCount++; break; - case EntityType.Relation: relationsCount++; break; - } + case EntityType.Node: nodesCount++; break; + case EntityType.Way: waysCount++; break; + case EntityType.Relation: relationsCount++; break; } - - Assert.Equal(TestFileNodesCount, nodesCount); - Assert.Equal(TestFileWaysCount, waysCount); - Assert.Equal(TestFileRelationsCount, relationsCount); } - private IEnumerable GetTestData() - { - List data = new List(); + Assert.Equal(TestFileNodesCount, nodesCount); + Assert.Equal(TestFileWaysCount, waysCount); + Assert.Equal(TestFileRelationsCount, relationsCount); + } + + private IEnumerable GetTestData() + { + List data = new List(); - using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + { + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + IEntityInfo info = null; + while ((info = reader.Read()) != null) { - IEntityInfo info = null; - while ((info = reader.Read()) != null) - { - data.Add(info); - } + data.Add(info); } } - - return data; } + + return data; } } diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs index d34553a..0b2dc99 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs @@ -7,30 +7,29 @@ using Tests.SpatialLite.Osm.Data; using Xunit; -namespace Tests.SpatialLite.Osm.Integration.Xml +namespace Tests.SpatialLite.Osm.Integration.Xml; + +public class OsmDatabaseTests { - public class OsmDatabaseTests + [Fact, Trait("Category", "Osm.Integration")] + public void OsmEntityInfoDatabase_LoadesRealFile() { - [Fact, Trait("Category", "Osm.Integration")] - public void OsmEntityInfoDatabase_LoadesRealFile() - { - OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - Assert.Equal(6688, target.Nodes.Count); - Assert.Equal(740, target.Ways.Count); - Assert.Equal(75, target.Relations.Count); - } + Assert.Equal(6688, target.Nodes.Count); + Assert.Equal(740, target.Ways.Count); + Assert.Equal(75, target.Relations.Count); + } - [Fact, Trait("Category", "Osm.Integration")] - public void OsmGeometryDatabase_LoadesRealFile() - { - OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); + [Fact, Trait("Category", "Osm.Integration")] + public void OsmGeometryDatabase_LoadesRealFile() + { + OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(6688, target.Nodes.Count); - Assert.Equal(740, target.Ways.Count); - Assert.Equal(75, target.Relations.Count); - } + Assert.Equal(6688, target.Nodes.Count); + Assert.Equal(740, target.Ways.Count); + Assert.Equal(75, target.Relations.Count); } } diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs index f3cd632..9981ae6 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs @@ -8,95 +8,94 @@ using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.Integration.Xml +namespace Tests.SpatialLite.Osm.Integration.Xml; + +public class OsmosisIntegrationTests { - public class OsmosisIntegrationTests - { - private const int TestFileNodesCount = 129337; - private const int TestFileWaysCount = 14461; - private const int TestFileRelationsCount = 124; + private const int TestFileNodesCount = 129337; + private const int TestFileWaysCount = 14461; + private const int TestFileRelationsCount = 124; - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void XmlOsmReaderReadsFilesCreatedByOsmosis() - { - string xmlFile = PathHelper.GetTempFilePath("xmlreader-osmosis-compatibility-test-osmosis-real-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", PathHelper.RealPbfFilePath, xmlFile); - this.CallOsmosis(osmosisArguments); + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void XmlOsmReaderReadsFilesCreatedByOsmosis() + { + string xmlFile = PathHelper.GetTempFilePath("xmlreader-osmosis-compatibility-test-osmosis-real-file.osm"); + string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", PathHelper.RealPbfFilePath, xmlFile); + this.CallOsmosis(osmosisArguments); - using (OsmXmlReader reader = new OsmXmlReader(xmlFile, new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false })) - { - this.TestReader(reader); - } + using (OsmXmlReader reader = new OsmXmlReader(xmlFile, new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false })) + { + this.TestReader(reader); } + } - [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] - public void XmlOsmWriterWritesFilesCompatibleWithOsmosis() + [Fact(Skip = "Test requires Windows-specific osmosis.bat file which is not available in Linux CI environment"), Trait("Category", "Osm.Integration")] + public void XmlOsmWriterWritesFilesCompatibleWithOsmosis() + { + string xmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-xmlwriter-real-file.osm"); + using (OsmXmlWriter writer = new OsmXmlWriter(xmlFile, new OsmWriterSettings() { WriteMetadata = true })) { - string xmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-xmlwriter-real-file.osm"); - using (OsmXmlWriter writer = new OsmXmlWriter(xmlFile, new OsmWriterSettings() { WriteMetadata = true })) + foreach (var entityInfo in this.GetTestData()) { - foreach (var entityInfo in this.GetTestData()) - { - writer.Write(entityInfo); - } + writer.Write(entityInfo); } + } - string osmosisXmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-xml file={0} --write-xml file={1}", xmlFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisXmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-test-file.osm"); + string osmosisArguments = string.Format("--read-xml file={0} --write-xml file={1}", xmlFile, osmosisXmlFile); + this.CallOsmosis(osmosisArguments); - Assert.True(File.Exists(osmosisXmlFile)); - Assert.True(new FileInfo(osmosisXmlFile).Length > 0); - } + Assert.True(File.Exists(osmosisXmlFile)); + Assert.True(new FileInfo(osmosisXmlFile).Length > 0); + } - private IEnumerable GetTestData() - { - List data = new List(); + private IEnumerable GetTestData() + { + List data = new List(); - using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) + { + using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + IEntityInfo info = null; + while ((info = reader.Read()) != null) { - IEntityInfo info = null; - while ((info = reader.Read()) != null) - { - data.Add(info); - } + data.Add(info); } } - - return data; } - private void CallOsmosis(string arguments) - { - ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); - osmosisInfo.Arguments = arguments; + return data; + } - Process osmosis = Process.Start(osmosisInfo); - osmosis.WaitForExit(); + private void CallOsmosis(string arguments) + { + ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); + osmosisInfo.Arguments = arguments; - Assert.Equal(0, osmosis.ExitCode); - } + Process osmosis = Process.Start(osmosisInfo); + osmosis.WaitForExit(); - private void TestReader(IOsmReader reader) + Assert.Equal(0, osmosis.ExitCode); + } + + private void TestReader(IOsmReader reader) + { + IEntityInfo info = null; + int nodesCount = 0, waysCount = 0, relationsCount = 0; + while ((info = reader.Read()) != null) { - IEntityInfo info = null; - int nodesCount = 0, waysCount = 0, relationsCount = 0; - while ((info = reader.Read()) != null) + switch (info.EntityType) { - switch (info.EntityType) - { - case EntityType.Node: nodesCount++; break; - case EntityType.Way: waysCount++; break; - case EntityType.Relation: relationsCount++; break; - } + case EntityType.Node: nodesCount++; break; + case EntityType.Way: waysCount++; break; + case EntityType.Relation: relationsCount++; break; } - - Assert.Equal(TestFileNodesCount, nodesCount); - Assert.Equal(TestFileWaysCount, waysCount); - Assert.Equal(TestFileRelationsCount, relationsCount); } + + Assert.Equal(TestFileNodesCount, nodesCount); + Assert.Equal(TestFileWaysCount, waysCount); + Assert.Equal(TestFileRelationsCount, relationsCount); } } diff --git a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs index d761578..5a330f1 100644 --- a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs @@ -5,66 +5,65 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm +namespace Tests.SpatialLite.Osm; + +public class NodeInfoTests { - public class NodeInfoTests - { - [Fact] - public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() - { - int id = 15; - double latitude = 15.4; - double longitude = -23.7; - TagsCollection tags = new TagsCollection(); + [Fact] + public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() + { + int id = 15; + double latitude = 15.4; + double longitude = -23.7; + TagsCollection tags = new TagsCollection(); - NodeInfo target = new NodeInfo(id, latitude, longitude, tags); + NodeInfo target = new NodeInfo(id, latitude, longitude, tags); - Assert.Equal(EntityType.Node, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Equal(latitude, target.Latitude); - Assert.Equal(longitude, target.Longitude); - Assert.Same(tags, target.Tags); - Assert.Null(target.Metadata); - } + Assert.Equal(EntityType.Node, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Equal(latitude, target.Latitude); + Assert.Equal(longitude, target.Longitude); + Assert.Same(tags, target.Tags); + Assert.Null(target.Metadata); + } - [Fact] - public void Constructor_Properties_SetsProperties() - { - int id = 15; - double latitude = 15.4; - double longitude = -23.7; - TagsCollection tags = new TagsCollection(); - EntityMetadata details = new EntityMetadata(); + [Fact] + public void Constructor_Properties_SetsProperties() + { + int id = 15; + double latitude = 15.4; + double longitude = -23.7; + TagsCollection tags = new TagsCollection(); + EntityMetadata details = new EntityMetadata(); - NodeInfo target = new NodeInfo(id, latitude, longitude, tags, details); + NodeInfo target = new NodeInfo(id, latitude, longitude, tags, details); - Assert.Equal(EntityType.Node, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Equal(latitude, target.Latitude); - Assert.Equal(longitude, target.Longitude); - Assert.Same(tags, target.Tags); - Assert.Same(details, target.Metadata); - } + Assert.Equal(EntityType.Node, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Equal(latitude, target.Latitude); + Assert.Equal(longitude, target.Longitude); + Assert.Same(tags, target.Tags); + Assert.Same(details, target.Metadata); + } - [Fact] - public void Constructor_Node_SetsProperties() - { - Node node = new Node(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; + [Fact] + public void Constructor_Node_SetsProperties() + { + Node node = new Node(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; - NodeInfo target = new NodeInfo(node); + NodeInfo target = new NodeInfo(node); - Assert.Equal(node.ID, target.ID); - Assert.Equal(node.Position.X, target.Longitude); - Assert.Equal(node.Position.Y, target.Latitude); - Assert.Same(node.Tags, target.Tags); - Assert.Same(node.Metadata, target.Metadata); - } + Assert.Equal(node.ID, target.ID); + Assert.Equal(node.Position.X, target.Longitude); + Assert.Equal(node.Position.Y, target.Latitude); + Assert.Same(node.Tags, target.Tags); + Assert.Same(node.Metadata, target.Metadata); + } - [Fact] - public void Constructor_Node_ThrowsExceptionIfNodeIsNull() - { - Assert.Throws(() => new NodeInfo(null)); - } + [Fact] + public void Constructor_Node_ThrowsExceptionIfNodeIsNull() + { + Assert.Throws(() => new NodeInfo(null)); } } diff --git a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs index ad98b7f..a97bd67 100644 --- a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs @@ -7,465 +7,464 @@ using SpatialLite.Osm; using SpatialLite.Osm.Geometries; -namespace Tests.SpatialLite.Osm +namespace Tests.SpatialLite.Osm; + +public class OsmDatabaseTests { - public class OsmDatabaseTests + Node[] _nodeData; + Way[] _wayData; + Relation[] _relationData; + IOsmGeometry[] _data; + + public OsmDatabaseTests() { - Node[] _nodeData; - Way[] _wayData; - Relation[] _relationData; - IOsmGeometry[] _data; + _nodeData = new Node[3]; + _nodeData[0] = new Node(1); + _nodeData[1] = new Node(2); + _nodeData[2] = new Node(3); - public OsmDatabaseTests() - { - _nodeData = new Node[3]; - _nodeData[0] = new Node(1); - _nodeData[1] = new Node(2); - _nodeData[2] = new Node(3); + _wayData = new Way[2]; + _wayData[0] = new Way(1, _nodeData); + _wayData[1] = new Way(2, _nodeData.Skip(1)); - _wayData = new Way[2]; - _wayData[0] = new Way(1, _nodeData); - _wayData[1] = new Way(2, _nodeData.Skip(1)); + _relationData = new Relation[2]; + _relationData[0] = new Relation(1, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); + _relationData[1] = new Relation(2, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); - _relationData = new Relation[2]; - _relationData[0] = new Relation(1, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); - _relationData[1] = new Relation(2, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); + _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); + } - _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); - } + [Fact] + public void Constructor__CreatesEmptyDatabase() + { + OsmDatabase target = new OsmDatabase(); - [Fact] - public void Constructor__CreatesEmptyDatabase() - { - OsmDatabase target = new OsmDatabase(); + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + OsmDatabase target = new OsmDatabase(_data); - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + for (int i = 0; i < _data.Length; i++) { - OsmDatabase target = new OsmDatabase(_data); - - for (int i = 0; i < _data.Length; i++) - { - Assert.Contains(_data[i], target); - } + Assert.Contains(_data[i], target); } + } - [Fact] - public void Constructor_IEnumerable_AddEnittiesToCorrectCollections() + [Fact] + public void Constructor_IEnumerable_AddEnittiesToCorrectCollections() + { + OsmDatabase target = new OsmDatabase(_data); + + for (int i = 0; i < _nodeData.Length; i++) { - OsmDatabase target = new OsmDatabase(_data); - - for (int i = 0; i < _nodeData.Length; i++) - { - Assert.Contains(_nodeData[i], target.Nodes); - } - - for (int i = 0; i < _wayData.Length; i++) - { - Assert.Contains(_wayData[i], target.Ways); - } - - for (int i = 0; i < _relationData.Length; i++) - { - Assert.Contains(_relationData[i], target.Relations); - } + Assert.Contains(_nodeData[i], target.Nodes); } - [Fact] - public void Count_ReturnsNumberOfAllEntities() + for (int i = 0; i < _wayData.Length; i++) { - OsmDatabase target = new OsmDatabase(_data); - - Assert.Equal(_data.Length, target.Count); + Assert.Contains(_wayData[i], target.Ways); } - [Fact] - public void IsReadOnly_ReturnsFalse() + for (int i = 0; i < _relationData.Length; i++) { - OsmDatabase target = new OsmDatabase(_data); - - Assert.False(target.IsReadOnly); + Assert.Contains(_relationData[i], target.Relations); } + } - [Fact] - public void Item_ReturnsNullIfIDIsNotPresentInCollection() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Count_ReturnsNumberOfAllEntities() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.Null(target[10000, EntityType.Node]); - } + Assert.Equal(_data.Length, target.Count); + } - [Fact] - public void Item_ReturnsNodeWithSpecificID() - { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry entity = target[_nodeData[0].ID, EntityType.Node]; + [Fact] + public void IsReadOnly_ReturnsFalse() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.Same(_nodeData[0], entity); - } + Assert.False(target.IsReadOnly); + } - [Fact] - public void Item_ReturnsWayWithSpecificID() - { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry entity = target[_wayData[0].ID, EntityType.Way]; + [Fact] + public void Item_ReturnsNullIfIDIsNotPresentInCollection() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.Same(_wayData[0], entity); - } + Assert.Null(target[10000, EntityType.Node]); + } - [Fact] - public void Item_ReturnsRelationWithSpecificID() - { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry entity = target[_relationData[0].ID, EntityType.Relation]; + [Fact] + public void Item_ReturnsNodeWithSpecificID() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry entity = target[_nodeData[0].ID, EntityType.Node]; - Assert.Same(_relationData[0], entity); - } + Assert.Same(_nodeData[0], entity); + } - [Fact] - public void Add_AddsNodeToCollection() - { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); - target.Add(_nodeData[0]); + [Fact] + public void Item_ReturnsWayWithSpecificID() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry entity = target[_wayData[0].ID, EntityType.Way]; - Assert.Contains(_nodeData[0], target); - } + Assert.Same(_wayData[0], entity); + } - [Fact] - public void Add_AddsWayToCollection() - { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); - target.Add(_wayData[0]); + [Fact] + public void Item_ReturnsRelationWithSpecificID() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry entity = target[_relationData[0].ID, EntityType.Relation]; - Assert.Contains(_wayData[0], target); - } + Assert.Same(_relationData[0], entity); + } - [Fact] - public void Add_AddsRelationToCollection() - { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); - target.Add(_relationData[0]); + [Fact] + public void Add_AddsNodeToCollection() + { + OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + target.Add(_nodeData[0]); - Assert.Contains(_relationData[0], target); - } + Assert.Contains(_nodeData[0], target); + } - [Fact] - public void Add_ThrowsArgumentNullExceptionIfItemIsNull() - { - OsmDatabase target = new OsmDatabase(); + [Fact] + public void Add_AddsWayToCollection() + { + OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + target.Add(_wayData[0]); - Assert.Throws(() => target.Add(null)); - } + Assert.Contains(_wayData[0], target); + } - [Fact] - public void Add_ThrowsExceptionWhenAddingDuplicateID() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Add_AddsRelationToCollection() + { + OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + target.Add(_relationData[0]); - Assert.Throws(() => target.Add(_data[0])); - } + Assert.Contains(_relationData[0], target); + } - [Fact] - public void Clear_RemovesAllItemsFromCollection() - { - OsmDatabase target = new OsmDatabase(_data); - target.Clear(); + [Fact] + public void Add_ThrowsArgumentNullExceptionIfItemIsNull() + { + OsmDatabase target = new OsmDatabase(); - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } + Assert.Throws(() => target.Add(null)); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseForNull() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Add_ThrowsExceptionWhenAddingDuplicateID() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.DoesNotContain(null, target); - } + Assert.Throws(() => target.Add(_data[0])); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainNode() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Clear_RemovesAllItemsFromCollection() + { + OsmDatabase target = new OsmDatabase(_data); + target.Clear(); - Assert.DoesNotContain(new Node(10000), target); - } + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsNode() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseForNull() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.Contains(_nodeData[0], target); - } + Assert.DoesNotContain(null, target); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainWay() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainNode() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.DoesNotContain(new Way(10000), target); - } + Assert.DoesNotContain(new Node(10000), target); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsWay() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsNode() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.Contains(_wayData[0], target); - } + Assert.Contains(_nodeData[0], target); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainRelation() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainWay() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.DoesNotContain(new Relation(10000), target); - } + Assert.DoesNotContain(new Way(10000), target); + } - [Fact] - public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsRelation() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsWay() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.Contains(_relationData[0], target); - } + Assert.Contains(_wayData[0], target); + } - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainNodeID() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainRelation() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.False(target.Contains(10000, EntityType.Node)); - } + Assert.DoesNotContain(new Relation(10000), target); + } - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsNodeID() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsRelation() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.True(target.Contains(_nodeData[0].ID, EntityType.Node)); - } + Assert.Contains(_relationData[0], target); + } - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainWayID() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainNodeID() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.False(target.Contains(10000, EntityType.Way)); - } + Assert.False(target.Contains(10000, EntityType.Node)); + } - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsWayID() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsNodeID() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.True(target.Contains(_wayData[0].ID, EntityType.Way)); - } + Assert.True(target.Contains(_nodeData[0].ID, EntityType.Node)); + } - [Fact] - public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainRelationID() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainWayID() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.False(target.Contains(10000, EntityType.Relation)); - } + Assert.False(target.Contains(10000, EntityType.Way)); + } - [Fact] - public void Contains_ID_ReturnsTrueIfCollectionContainsRelationID() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsWayID() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.True(target.Contains(_relationData[0].ID, EntityType.Relation)); - } + Assert.True(target.Contains(_wayData[0].ID, EntityType.Way)); + } - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() - { - OsmDatabase target = new OsmDatabase(_data); + [Fact] + public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainRelationID() + { + OsmDatabase target = new OsmDatabase(_data); - bool callResult = target.Remove(null); + Assert.False(target.Contains(10000, EntityType.Relation)); + } - Assert.False(callResult); - } + [Fact] + public void Contains_ID_ReturnsTrueIfCollectionContainsRelationID() + { + OsmDatabase target = new OsmDatabase(_data); - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() - { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + Assert.True(target.Contains(_relationData[0].ID, EntityType.Relation)); + } - bool callResult = target.Remove(_nodeData[0]); + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() + { + OsmDatabase target = new OsmDatabase(_data); - Assert.False(callResult); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } + bool callResult = target.Remove(null); - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesNodeFromCollection() - { - OsmDatabase target = new OsmDatabase(_nodeData); + Assert.False(callResult); + } - bool callResult = target.Remove(_data[0]); + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); - Assert.True(callResult); - Assert.DoesNotContain(_nodeData[0], target); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } + bool callResult = target.Remove(_nodeData[0]); - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() - { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + Assert.False(callResult); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } - bool callResult = target.Remove(_wayData[0]); + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesNodeFromCollection() + { + OsmDatabase target = new OsmDatabase(_nodeData); - Assert.False(callResult); - Assert.Contains(_wayData[1], target); - } + bool callResult = target.Remove(_data[0]); - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesWayFromCollection() - { - OsmDatabase target = new OsmDatabase(_wayData); + Assert.True(callResult); + Assert.DoesNotContain(_nodeData[0], target); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } - bool callResult = target.Remove(_wayData[0]); + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); - Assert.True(callResult); - Assert.DoesNotContain(_wayData[0], target); - Assert.Contains(_wayData[1], target); - } + bool callResult = target.Remove(_wayData[0]); - [Fact] - public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() - { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + Assert.False(callResult); + Assert.Contains(_wayData[1], target); + } - bool callResult = target.Remove(_relationData[0]); + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesWayFromCollection() + { + OsmDatabase target = new OsmDatabase(_wayData); - Assert.False(callResult); - Assert.Contains(_relationData[1], target); - } + bool callResult = target.Remove(_wayData[0]); - [Fact] - public void Remove_IOsmGeometry_ReturnsTrueAndRemovesRelationFromCollection() - { - OsmDatabase target = new OsmDatabase(_relationData); + Assert.True(callResult); + Assert.DoesNotContain(_wayData[0], target); + Assert.Contains(_wayData[1], target); + } - bool callResult = target.Remove(_relationData[0]); + [Fact] + public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); - Assert.True(callResult); - Assert.DoesNotContain(_relationData[0], target); - Assert.Contains(_relationData[1], target); - } + bool callResult = target.Remove(_relationData[0]); - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() - { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + Assert.False(callResult); + Assert.Contains(_relationData[1], target); + } - bool callResult = target.Remove(_nodeData[0].ID, EntityType.Node); + [Fact] + public void Remove_IOsmGeometry_ReturnsTrueAndRemovesRelationFromCollection() + { + OsmDatabase target = new OsmDatabase(_relationData); - Assert.False(callResult); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } + bool callResult = target.Remove(_relationData[0]); - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesNodeFromCollection() - { - OsmDatabase target = new OsmDatabase(_nodeData); + Assert.True(callResult); + Assert.DoesNotContain(_relationData[0], target); + Assert.Contains(_relationData[1], target); + } - bool callResult = target.Remove(_data[0].ID, EntityType.Node); + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); - Assert.True(callResult); - Assert.DoesNotContain(_nodeData[0], target); - Assert.Contains(_nodeData[1], target); - Assert.Contains(_nodeData[2], target); - } + bool callResult = target.Remove(_nodeData[0].ID, EntityType.Node); - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() - { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + Assert.False(callResult); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } - bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesNodeFromCollection() + { + OsmDatabase target = new OsmDatabase(_nodeData); - Assert.False(callResult); - Assert.Contains(_wayData[1], target); - } + bool callResult = target.Remove(_data[0].ID, EntityType.Node); - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesWayFromCollection() - { - OsmDatabase target = new OsmDatabase(_wayData); + Assert.True(callResult); + Assert.DoesNotContain(_nodeData[0], target); + Assert.Contains(_nodeData[1], target); + Assert.Contains(_nodeData[2], target); + } - bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); - Assert.True(callResult); - Assert.DoesNotContain(_wayData[0], target); - Assert.Contains(_wayData[1], target); - } + bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); - [Fact] - public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() - { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + Assert.False(callResult); + Assert.Contains(_wayData[1], target); + } - bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesWayFromCollection() + { + OsmDatabase target = new OsmDatabase(_wayData); - Assert.False(callResult); - Assert.Contains(_relationData[1], target); - } + bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); - [Fact] - public void Remove_ID_ReturnsTrueAndRemovesRelationFromCollection() - { - OsmDatabase target = new OsmDatabase(_relationData); + Assert.True(callResult); + Assert.DoesNotContain(_wayData[0], target); + Assert.Contains(_wayData[1], target); + } - bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); + [Fact] + public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() + { + OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); - Assert.True(callResult); - Assert.DoesNotContain(_relationData[0], target); - Assert.Contains(_relationData[1], target); - } + bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); - [Fact] - public void GetEnumerator_ReturnsEnumeratorThatEnumeratesAllEntities() - { - OsmDatabase target = new OsmDatabase(_data); + Assert.False(callResult); + Assert.Contains(_relationData[1], target); + } - IEnumerable result = target; + [Fact] + public void Remove_ID_ReturnsTrueAndRemovesRelationFromCollection() + { + OsmDatabase target = new OsmDatabase(_relationData); - Assert.Equal(_data.Length, target.Count()); - foreach (var entity in target) - { - Assert.Contains(entity, _data); - } - } + bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); - [Fact] - public void CopyTo_CopiesEntitiesToArray() - { - OsmDatabase target = new OsmDatabase(_data); - IOsmGeometry[] array = new IOsmGeometry[_data.Length]; + Assert.True(callResult); + Assert.DoesNotContain(_relationData[0], target); + Assert.Contains(_relationData[1], target); + } + + [Fact] + public void GetEnumerator_ReturnsEnumeratorThatEnumeratesAllEntities() + { + OsmDatabase target = new OsmDatabase(_data); - target.CopyTo(array, 0); + IEnumerable result = target; - for (int i = 0; i < _data.Length; i++) - { - Assert.Same(_data[i], array[i]); - } + Assert.Equal(_data.Length, target.Count()); + foreach (var entity in target) + { + Assert.Contains(entity, _data); } + } + [Fact] + public void CopyTo_CopiesEntitiesToArray() + { + OsmDatabase target = new OsmDatabase(_data); + IOsmGeometry[] array = new IOsmGeometry[_data.Length]; + + target.CopyTo(array, 0); + + for (int i = 0; i < _data.Length; i++) + { + Assert.Same(_data[i], array[i]); + } } + } diff --git a/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs index b14c339..d07c6bf 100644 --- a/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs @@ -9,132 +9,131 @@ using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; -namespace Tests.SpatialLite.Osm.Geometries +namespace Tests.SpatialLite.Osm.Geometries; + +public class OsmEntityInfoDatabaseTests { - public class OsmEntityInfoDatabaseTests + NodeInfo[] _nodeData; + WayInfo[] _wayData; + RelationInfo[] _relationData; + IEntityInfo[] _data; + + public OsmEntityInfoDatabaseTests() { - NodeInfo[] _nodeData; - WayInfo[] _wayData; - RelationInfo[] _relationData; - IEntityInfo[] _data; + _nodeData = new NodeInfo[3]; + _nodeData[0] = new NodeInfo(1, 10.1, 11.1, new TagsCollection()); + _nodeData[1] = new NodeInfo(2, 10.2, 11.2, new TagsCollection()); + _nodeData[2] = new NodeInfo(3, 10.3, 11.3, new TagsCollection()); - public OsmEntityInfoDatabaseTests() - { - _nodeData = new NodeInfo[3]; - _nodeData[0] = new NodeInfo(1, 10.1, 11.1, new TagsCollection()); - _nodeData[1] = new NodeInfo(2, 10.2, 11.2, new TagsCollection()); - _nodeData[2] = new NodeInfo(3, 10.3, 11.3, new TagsCollection()); + _wayData = new WayInfo[2]; + _wayData[0] = new WayInfo(10, new TagsCollection(), _nodeData.Select(n => n.ID).ToArray()); + _wayData[1] = new WayInfo(11, new TagsCollection(), _nodeData.Select(n => n.ID).Skip(1).ToArray()); - _wayData = new WayInfo[2]; - _wayData[0] = new WayInfo(10, new TagsCollection(), _nodeData.Select(n => n.ID).ToArray()); - _wayData[1] = new WayInfo(11, new TagsCollection(), _nodeData.Select(n => n.ID).Skip(1).ToArray()); + _relationData = new RelationInfo[2]; + _relationData[0] = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 10, Role = "way" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); + _relationData[1] = new RelationInfo(101, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 101, Role = "relation" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); - _relationData = new RelationInfo[2]; - _relationData[0] = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 10, Role = "way" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); - _relationData[1] = new RelationInfo(101, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 101, Role = "relation" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); + _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); + } - _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); - } + [Fact] + public void Constructor__CreatesEmptyDatabase() + { + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(); - [Fact] - public void Constructor__CreatesEmptyDatabase() - { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(); + Assert.Empty(target); + Assert.Empty(target.Nodes); + Assert.Empty(target.Ways); + Assert.Empty(target.Relations); + } - Assert.Empty(target); - Assert.Empty(target.Nodes); - Assert.Empty(target.Ways); - Assert.Empty(target.Relations); - } + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + { + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() + for (int i = 0; i < _data.Length; i++) { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); - - for (int i = 0; i < _data.Length; i++) - { - Assert.Contains(_data[i], target); - } + Assert.Contains(_data[i], target); } + } - [Fact] - public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() + [Fact] + public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() + { + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + + for (int i = 0; i < _nodeData.Length; i++) { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); - - for (int i = 0; i < _nodeData.Length; i++) - { - Assert.Contains(_nodeData[i], target.Nodes); - } - - for (int i = 0; i < _wayData.Length; i++) - { - Assert.Contains(_wayData[i], target.Ways); - } - - for (int i = 0; i < _relationData.Length; i++) - { - Assert.Contains(_relationData[i], target.Relations); - } + Assert.Contains(_nodeData[i], target.Nodes); } - [Fact] - public void Load_IOsmReader_LoadsNodes() + for (int i = 0; i < _wayData.Length; i++) { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); + Assert.Contains(_wayData[i], target.Ways); } - [Fact] - public void Load_IOsmReader_LoadsWay() + for (int i = 0; i < _relationData.Length; i++) { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + Assert.Contains(_relationData[i], target.Relations); + } + } - Assert.Equal(3, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); - Assert.True(target.Nodes.Contains(2)); - Assert.True(target.Nodes.Contains(3)); + [Fact] + public void Load_IOsmReader_LoadsNodes() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - Assert.Equal(1, target.Ways.Count); - Assert.True(target.Ways.Contains(10)); - } + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); + } - [Fact] - public void Load_IOsmReader_LoadsRelation() - { - IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); - OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + [Fact] + public void Load_IOsmReader_LoadsWay() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - Assert.Equal(1, target.Nodes.Count); - Assert.True(target.Nodes.Contains(1)); + Assert.Equal(3, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + Assert.True(target.Nodes.Contains(2)); + Assert.True(target.Nodes.Contains(3)); - Assert.Equal(1, target.Relations.Count); - Assert.True(target.Relations.Contains(100)); - } + Assert.Equal(1, target.Ways.Count); + Assert.True(target.Ways.Contains(10)); + } - [Fact] - public void Save_CallsIOsmWriterWriteForAllEntities() - { - List written = new List(); - Mock writerM = new Mock(); + [Fact] + public void Load_IOsmReader_LoadsRelation() + { + IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); + + Assert.Equal(1, target.Nodes.Count); + Assert.True(target.Nodes.Contains(1)); + + Assert.Equal(1, target.Relations.Count); + Assert.True(target.Relations.Contains(100)); + } + + [Fact] + public void Save_CallsIOsmWriterWriteForAllEntities() + { + List written = new List(); + Mock writerM = new Mock(); - writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); + writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); - target.Save(writerM.Object); + OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + target.Save(writerM.Object); - Assert.Equal(target.Count, written.Count); - foreach (var entity in target) - { - Assert.Contains(entity, written); - } + Assert.Equal(target.Count, written.Count); + foreach (var entity in target) + { + Assert.Contains(entity, written); } } } diff --git a/src/Tests.SpatialLite.Osm/PathHelper.cs b/src/Tests.SpatialLite.Osm/PathHelper.cs index 96453d2..fda0327 100644 --- a/src/Tests.SpatialLite.Osm/PathHelper.cs +++ b/src/Tests.SpatialLite.Osm/PathHelper.cs @@ -1,35 +1,34 @@ using System.IO; -namespace Tests.SpatialLite.Osm +namespace Tests.SpatialLite.Osm; + +static class PathHelper { - static class PathHelper - { - private const string TempDirectoryName = "Temp"; + private const string TempDirectoryName = "Temp"; - private static string _osmosisPath = Path.GetFullPath(Path.Combine("Utils", "Osmosis", "bin", "osmosis.bat")); - public static string OsmosisPath => _osmosisPath; + private static string _osmosisPath = Path.GetFullPath(Path.Combine("Utils", "Osmosis", "bin", "osmosis.bat")); + public static string OsmosisPath => _osmosisPath; - private static string _realXmlFilePath = Path.GetFullPath(Path.Combine("Data", "Xml", "osm-real-file.osm")); - public static string RealXmlFilePath => _realXmlFilePath; + private static string _realXmlFilePath = Path.GetFullPath(Path.Combine("Data", "Xml", "osm-real-file.osm")); + public static string RealXmlFilePath => _realXmlFilePath; - private static string _realPbfFilePath = Path.GetFullPath(Path.Combine("Data", "Pbf", "pbf-real-file.pbf")); - public static string RealPbfFilePath => _realPbfFilePath; + private static string _realPbfFilePath = Path.GetFullPath(Path.Combine("Data", "Pbf", "pbf-real-file.pbf")); + public static string RealPbfFilePath => _realPbfFilePath; - public static string GetTempFilePath(string filename) + public static string GetTempFilePath(string filename) + { + if (!Directory.Exists(TempDirectoryName)) { - if (!Directory.Exists(TempDirectoryName)) - { - Directory.CreateDirectory(TempDirectoryName); - } - - string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); - if (File.Exists(pbfFile)) - { - File.Delete(pbfFile); - } - - return pbfFile; + Directory.CreateDirectory(TempDirectoryName); } + + string pbfFile = Path.GetFullPath(Path.Combine(TempDirectoryName, filename)); + if (File.Exists(pbfFile)) + { + File.Delete(pbfFile); + } + + return pbfFile; } } diff --git a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs index abe78d8..e9a7a19 100644 --- a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs @@ -6,74 +6,73 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm -{ - public class RelationMemberTests - { +namespace Tests.SpatialLite.Osm; - [Fact] - public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() - { - int id = 45; - TagsCollection tags = new TagsCollection(); - List members = new List(); +public class RelationMemberTests +{ - RelationInfo target = new RelationInfo(id, tags, members); + [Fact] + public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List members = new List(); - Assert.Equal(EntityType.Relation, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(members, target.Members); - Assert.Null(target.Metadata); - } + RelationInfo target = new RelationInfo(id, tags, members); - [Fact] - public void Constructor_Properties_SetsProperties() - { - int id = 45; - TagsCollection tags = new TagsCollection(); - List members = new List(); - EntityMetadata details = new EntityMetadata(); - - RelationInfo target = new RelationInfo(id, tags, members, details); - - Assert.Equal(EntityType.Relation, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(members, target.Members); - Assert.Same(details, target.Metadata); - } + Assert.Equal(EntityType.Relation, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(members, target.Members); + Assert.Null(target.Metadata); + } - [Fact] - public void Constructor_Relation_SetsProperties() - { - Relation relation = new Relation(100, new RelationMember[0], new TagsCollection()) { Metadata = new EntityMetadata() }; + [Fact] + public void Constructor_Properties_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List members = new List(); + EntityMetadata details = new EntityMetadata(); + + RelationInfo target = new RelationInfo(id, tags, members, details); + + Assert.Equal(EntityType.Relation, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(members, target.Members); + Assert.Same(details, target.Metadata); + } - RelationInfo target = new RelationInfo(relation); + [Fact] + public void Constructor_Relation_SetsProperties() + { + Relation relation = new Relation(100, new RelationMember[0], new TagsCollection()) { Metadata = new EntityMetadata() }; - Assert.Equal(relation.ID, target.ID); - Assert.Same(relation.Tags, target.Tags); - Assert.Same(relation.Metadata, target.Metadata); - } + RelationInfo target = new RelationInfo(relation); - [Fact] - public void Constructor_Relation_SetsRelationMembers() - { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)) }, new TagsCollection()) { Metadata = new EntityMetadata() }; + Assert.Equal(relation.ID, target.ID); + Assert.Same(relation.Tags, target.Tags); + Assert.Same(relation.Metadata, target.Metadata); + } - RelationInfo target = new RelationInfo(relation); + [Fact] + public void Constructor_Relation_SetsRelationMembers() + { + Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)) }, new TagsCollection()) { Metadata = new EntityMetadata() }; - Assert.Equal(relation.Geometries.Count, target.Members.Count); - for (int i = 0; i < relation.Geometries.Count; i++) - { - Assert.Equal(relation.Geometries[i].Member.ID, target.Members[i].Reference); - } - } + RelationInfo target = new RelationInfo(relation); - [Fact] - public void Constructor_Relation_ThrowExceptionIfRelationIsNull() + Assert.Equal(relation.Geometries.Count, target.Members.Count); + for (int i = 0; i < relation.Geometries.Count; i++) { - Assert.Throws(() => new RelationInfo(null)); + Assert.Equal(relation.Geometries[i].Member.ID, target.Members[i].Reference); } } + + [Fact] + public void Constructor_Relation_ThrowExceptionIfRelationIsNull() + { + Assert.Throws(() => new RelationInfo(null)); + } } diff --git a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs index 9d639f5..2fd6316 100644 --- a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs @@ -3,21 +3,20 @@ using SpatialLite.Osm; using SpatialLite.Osm.Geometries; -namespace Tests.SpatialLite.Osm +namespace Tests.SpatialLite.Osm; + +public class RelationMemberInfoTests { - public class RelationMemberInfoTests - { - [Fact] - public void Constructor_RelationMember_SetsProperties() - { - RelationMember member = new RelationMember(new Node(1), "test-role"); + [Fact] + public void Constructor_RelationMember_SetsProperties() + { + RelationMember member = new RelationMember(new Node(1), "test-role"); - RelationMemberInfo target = new RelationMemberInfo(member); + RelationMemberInfo target = new RelationMemberInfo(member); - Assert.Equal(member.Member.ID, target.Reference); - Assert.Equal(member.MemberType, target.MemberType); - Assert.Equal(member.Role, target.Role); - } + Assert.Equal(member.Member.ID, target.Reference); + Assert.Equal(member.MemberType, target.MemberType); + Assert.Equal(member.Role, target.Role); } } diff --git a/src/Tests.SpatialLite.Osm/TagTests.cs b/src/Tests.SpatialLite.Osm/TagTests.cs index 25ee471..1c310d6 100644 --- a/src/Tests.SpatialLite.Osm/TagTests.cs +++ b/src/Tests.SpatialLite.Osm/TagTests.cs @@ -4,103 +4,102 @@ using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm +namespace Tests.SpatialLite.Osm; + +public class TagTests { - public class TagTests + + [Fact] + public void Constructor_TagValue_SetsKeyAndValue() + { + string key = "test-key"; + string value = "test-value"; + + Tag target = new Tag(key, value); + + Assert.Equal(key, target.Key); + Assert.Equal(value, target.Value); + } + + [Fact] + public void Constructor_TagValue_ThrowsExceptionIfKeyIsNull() + { + string key = null; + string value = "test-value"; + + Assert.Throws(delegate { new Tag(key, value); }); + } + + [Fact] + public void Constructor_TagValue_ThrowsExceptionIfKeyIsEmpty() + { + string key = string.Empty; + string value = "test-value"; + + Assert.Throws(delegate { new Tag(key, value); }); + } + + [Fact] + public void Constructor_TagValue_ThrowsExceptionIfValueIsNull() { + string key = "test-key"; + string value = null; - [Fact] - public void Constructor_TagValue_SetsKeyAndValue() - { - string key = "test-key"; - string value = "test-value"; - - Tag target = new Tag(key, value); - - Assert.Equal(key, target.Key); - Assert.Equal(value, target.Value); - } - - [Fact] - public void Constructor_TagValue_ThrowsExceptionIfKeyIsNull() - { - string key = null; - string value = "test-value"; - - Assert.Throws(delegate { new Tag(key, value); }); - } - - [Fact] - public void Constructor_TagValue_ThrowsExceptionIfKeyIsEmpty() - { - string key = string.Empty; - string value = "test-value"; - - Assert.Throws(delegate { new Tag(key, value); }); - } - - [Fact] - public void Constructor_TagValue_ThrowsExceptionIfValueIsNull() - { - string key = "test-key"; - string value = null; - - Assert.Throws(delegate { new Tag(key, value); }); - } - - [Fact] - public void Equals_ReturnTrueForSameKeyAndValue() - { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "test-value"); - - Assert.True(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnTrueForSameKeyAndValueAsObject() - { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "test-value"); - - Assert.True(target.Equals((object)other)); - } - - [Fact] - public void Equals_ReturnFalseForDifferentKeys() - { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("different-key", "test-value"); - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnFalseForDifferentValues() - { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "different-value"); - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnFalseForOtherObject() - { - Tag target = new Tag("test-key", "test-value"); - string other = "Test"; - - Assert.False(target.Equals(other)); - } - - [Fact] - public void Equals_ReturnFalseForNull() - { - Tag target = new Tag("test-key", "test-value"); - object other = null; - - Assert.False(target.Equals(other)); - } + Assert.Throws(delegate { new Tag(key, value); }); + } + + [Fact] + public void Equals_ReturnTrueForSameKeyAndValue() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("test-key", "test-value"); + Assert.True(target.Equals(other)); } + + [Fact] + public void Equals_ReturnTrueForSameKeyAndValueAsObject() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("test-key", "test-value"); + + Assert.True(target.Equals((object)other)); + } + + [Fact] + public void Equals_ReturnFalseForDifferentKeys() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("different-key", "test-value"); + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnFalseForDifferentValues() + { + Tag target = new Tag("test-key", "test-value"); + Tag other = new Tag("test-key", "different-value"); + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnFalseForOtherObject() + { + Tag target = new Tag("test-key", "test-value"); + string other = "Test"; + + Assert.False(target.Equals(other)); + } + + [Fact] + public void Equals_ReturnFalseForNull() + { + Tag target = new Tag("test-key", "test-value"); + object other = null; + + Assert.False(target.Equals(other)); + } + } diff --git a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs index afea05c..492dbd2 100644 --- a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs @@ -6,338 +6,337 @@ using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm +namespace Tests.SpatialLite.Osm; + +public class TagsCollectionTests { - public class TagsCollectionTests - { - Tag[] _tags = new Tag[] { - new Tag("test-key-1", "test-value-1"), - new Tag("test-key-2", "test-value-2"), - new Tag("test-key-3", "test-value-3") - }; - - Tag[] _tagsDuplicitKeys = new Tag[] { - new Tag("test-key-1", "test-value-1"), - new Tag("test-key-1", "test-value-2") - }; - - [Fact] - public void Constructor_CreatesEmptyTagsCollection() - { - TagsCollection target = new TagsCollection(); - - Assert.Empty(target); - } - - [Fact] - public void Constructor_IEnumerable_CreatesCollectionWithGivetTags() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.Equal(_tags.Count(), target.Count()); - Assert.Contains(_tags[0], target); - Assert.Contains(_tags[1], target); - } - - [Fact] - public void Constructor_IEnumerable_ThrowsExceptionWithDuplicateKeys() - { - Assert.Throws(() => new TagsCollection(_tagsDuplicitKeys)); - } - - [Fact] - public void Add_AddsTag() - { - TagsCollection target = new TagsCollection(); - target.Add(_tags[0]); - - Assert.Contains(_tags[0], target); - } - - [Fact] - public void Add_ThrowsExceptionIfTagAlreadyPresent() - { - TagsCollection target = new TagsCollection(); - target.Add(_tagsDuplicitKeys[0]); - - Assert.Throws(delegate { target.Add(_tagsDuplicitKeys[1]); }); - } - - [Fact] - public void Clear_DoesNothingOnEmptyCollection() - { - TagsCollection target = new TagsCollection(); - - target.Clear(); - } - - [Fact] - public void Clear_RemovesAllItems() - { - TagsCollection target = new TagsCollection(_tags); - target.Clear(); - - Assert.Empty(target); - } - - [Fact] - public void Contains_Tag_ReturnsFalseForEmptyCollection() - { - TagsCollection target = new TagsCollection(); - - Assert.DoesNotContain(new Tag("key", "value"), target); - } - - [Fact] - public void Contains_Tag_ReturnsFalseIfCollectionDoesNotContainTag() - { - TagsCollection target = new TagsCollection(_tags); - - Tag testTag = new Tag("test-key-1", "other-value"); - Assert.DoesNotContain(testTag, target); - } - - [Fact] - public void Contains_Tag_ReturnsTrueIfCollectionContainsTag() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.Contains(_tags[0], target); - } - - [Fact] - public void Contains_string_ReturnsFalseForEmptyCollection() - { - TagsCollection target = new TagsCollection(); - - Assert.False(target.Contains("key")); - } - - [Fact] - public void Contains_string_ReturnsFalseIfCollectionDoesNotContainTag() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.False(target.Contains("non-existing-key")); - } - - [Fact] - public void Contains_string_ReturnsTrueIfCollectionContainsTag() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.True(target.Contains(_tags[0].Key)); - } - - [Fact] - public void CopyTo_ThrowsArgumentNullExceptionIfArrayIsNull() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.CopyTo(null, 0)); - } - - [Fact] - public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero() - { - Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.CopyTo(array, -4)); - } - - [Fact] - public void CopyTo_ThrowsArgumentExceptionIfSpaceDesignedForCollectionInArrayIsShort() - { - Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.CopyTo(array, 4)); - } - - [Fact] - public void CopyTo_CopiesElementsToArray() - { - Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); - - target.CopyTo(array, 1); - - Assert.Null(array[0]); - Assert.Same(_tags[0], array[1]); - Assert.Same(_tags[1], array[2]); - Assert.Same(_tags[2], array[3]); - Assert.Null(array[4]); - } - - [Fact] - public void GetTag_ReturnsNullForEmptyCollection() - { - TagsCollection target = new TagsCollection(); - - Assert.Throws(() => target.GetTag("other-key")); - } - - [Fact] - public void GetTag_ReturnsNullIfCollectionDoesNotContainTag() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target.GetTag("other-key")); - } - - [Fact] - public void GetTag_ReturnsTagIfCollectionContainsTag() - { - TagsCollection target = new TagsCollection(_tags); - Tag returned = target.GetTag(_tags[0].Key); - - Assert.Same(_tags[0], returned); - } - - [Fact] - public void Remove_Tag_ReturnsFalseForEmptyCollection() - { - TagsCollection target = new TagsCollection(); - bool removed = target.Remove(new Tag("key", "value")); - - Assert.False(removed); - } - - [Fact] - public void Remove_Tag_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() - { - TagsCollection target = new TagsCollection(_tags); - - Tag testTag = new Tag("other-key", "other-value"); - Assert.False(target.Remove(testTag)); - this.CompareCollections(_tags, target); - } - - [Fact] - public void Remove_Tag_RemovesItemAndReturnsTrueIfCollectionContainsTag() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.True(target.Remove(_tags[0])); - this.CompareCollections(_tags.Skip(1), target); - } - - [Fact] - public void Remove_string_ReturnsFalseForEmptyCollection() - { - TagsCollection target = new TagsCollection(); - bool removed = target.Remove("key"); - - Assert.False(removed); - } - - [Fact] - public void Remove_string_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() - { - Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; - - TagsCollection target = new TagsCollection(tags); - - Assert.False(target.Remove("non-existing-tag")); - } - - [Fact] - public void Remove_string_RemovesItemAndReturnsTrueIfCollectionContainsTag() - { - Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; - - TagsCollection target = new TagsCollection(tags); - - Assert.True(target.Remove(tags[1].Key)); - Assert.Single(target); - Assert.Contains(tags[0], target); - } - - [Fact] - public void Count_ReturnsZeroForEmptyCollection() - { - TagsCollection target = new TagsCollection(); - - Assert.Empty(target); - } - - [Fact] - public void Count_ReturnsTagsCount() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.Equal(_tags.Length, target.Count); - } - - [Fact] - public void IsReadOnly_ReturnsFalse() - { - TagsCollection target = new TagsCollection(); - - Assert.False(target.IsReadOnly); - } - - [Fact] - public void Item_Get_ThrowsExceptionForEmptyCollection() - { - TagsCollection target = new TagsCollection(); - - Assert.Throws(() => target["other-key"]); - } - - [Fact] - public void Item_Get_ThrowsExceptionIfCollectionDoesNotContainTag() - { - TagsCollection target = new TagsCollection(_tags); - - Assert.Throws(() => target["other-key"]); - } - - [Fact] - public void Item_Get_ReturnsTagValueIfCollectionContainsTag() - { - TagsCollection target = new TagsCollection(_tags); - string returnedValue = target[_tags[0].Key]; - - Assert.Equal(_tags[0].Value, returnedValue); - } - - [Fact] - public void Item_Set_AddsItemToEmptyCollection() - { - TagsCollection target = new TagsCollection(); - - target["test-key"] = "test-value"; - - Assert.Single(target); - Assert.Equal("test-value", target["test-key"]); - } + Tag[] _tags = new Tag[] { + new Tag("test-key-1", "test-value-1"), + new Tag("test-key-2", "test-value-2"), + new Tag("test-key-3", "test-value-3") + }; + + Tag[] _tagsDuplicitKeys = new Tag[] { + new Tag("test-key-1", "test-value-1"), + new Tag("test-key-1", "test-value-2") + }; + + [Fact] + public void Constructor_CreatesEmptyTagsCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.Empty(target); + } + + [Fact] + public void Constructor_IEnumerable_CreatesCollectionWithGivetTags() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Equal(_tags.Count(), target.Count()); + Assert.Contains(_tags[0], target); + Assert.Contains(_tags[1], target); + } + + [Fact] + public void Constructor_IEnumerable_ThrowsExceptionWithDuplicateKeys() + { + Assert.Throws(() => new TagsCollection(_tagsDuplicitKeys)); + } + + [Fact] + public void Add_AddsTag() + { + TagsCollection target = new TagsCollection(); + target.Add(_tags[0]); + + Assert.Contains(_tags[0], target); + } + + [Fact] + public void Add_ThrowsExceptionIfTagAlreadyPresent() + { + TagsCollection target = new TagsCollection(); + target.Add(_tagsDuplicitKeys[0]); + + Assert.Throws(delegate { target.Add(_tagsDuplicitKeys[1]); }); + } + + [Fact] + public void Clear_DoesNothingOnEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + target.Clear(); + } + + [Fact] + public void Clear_RemovesAllItems() + { + TagsCollection target = new TagsCollection(_tags); + target.Clear(); + + Assert.Empty(target); + } + + [Fact] + public void Contains_Tag_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.DoesNotContain(new Tag("key", "value"), target); + } + + [Fact] + public void Contains_Tag_ReturnsFalseIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Tag testTag = new Tag("test-key-1", "other-value"); + Assert.DoesNotContain(testTag, target); + } + + [Fact] + public void Contains_Tag_ReturnsTrueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Contains(_tags[0], target); + } + + [Fact] + public void Contains_string_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.False(target.Contains("key")); + } + + [Fact] + public void Contains_string_ReturnsFalseIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.False(target.Contains("non-existing-key")); + } + + [Fact] + public void Contains_string_ReturnsTrueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.True(target.Contains(_tags[0].Key)); + } + + [Fact] + public void CopyTo_ThrowsArgumentNullExceptionIfArrayIsNull() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.CopyTo(null, 0)); + } + + [Fact] + public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero() + { + Tag[] array = new Tag[5]; + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.CopyTo(array, -4)); + } + + [Fact] + public void CopyTo_ThrowsArgumentExceptionIfSpaceDesignedForCollectionInArrayIsShort() + { + Tag[] array = new Tag[5]; + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.CopyTo(array, 4)); + } + + [Fact] + public void CopyTo_CopiesElementsToArray() + { + Tag[] array = new Tag[5]; + TagsCollection target = new TagsCollection(_tags); + + target.CopyTo(array, 1); + + Assert.Null(array[0]); + Assert.Same(_tags[0], array[1]); + Assert.Same(_tags[1], array[2]); + Assert.Same(_tags[2], array[3]); + Assert.Null(array[4]); + } + + [Fact] + public void GetTag_ReturnsNullForEmptyCollection() + { + TagsCollection target = new TagsCollection(); - [Fact] - public void Item_Set_AddsItemToCollection() - { - TagsCollection target = new TagsCollection(_tags); + Assert.Throws(() => target.GetTag("other-key")); + } + + [Fact] + public void GetTag_ReturnsNullIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target.GetTag("other-key")); + } + + [Fact] + public void GetTag_ReturnsTagIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + Tag returned = target.GetTag(_tags[0].Key); + + Assert.Same(_tags[0], returned); + } + + [Fact] + public void Remove_Tag_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + bool removed = target.Remove(new Tag("key", "value")); + + Assert.False(removed); + } + + [Fact] + public void Remove_Tag_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Tag testTag = new Tag("other-key", "other-value"); + Assert.False(target.Remove(testTag)); + this.CompareCollections(_tags, target); + } + + [Fact] + public void Remove_Tag_RemovesItemAndReturnsTrueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.True(target.Remove(_tags[0])); + this.CompareCollections(_tags.Skip(1), target); + } + + [Fact] + public void Remove_string_ReturnsFalseForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + bool removed = target.Remove("key"); + + Assert.False(removed); + } + + [Fact] + public void Remove_string_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() + { + Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; + + TagsCollection target = new TagsCollection(tags); + + Assert.False(target.Remove("non-existing-tag")); + } + + [Fact] + public void Remove_string_RemovesItemAndReturnsTrueIfCollectionContainsTag() + { + Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; + + TagsCollection target = new TagsCollection(tags); + + Assert.True(target.Remove(tags[1].Key)); + Assert.Single(target); + Assert.Contains(tags[0], target); + } - target["test-key-101"] = "test-value-101"; + [Fact] + public void Count_ReturnsZeroForEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + Assert.Empty(target); + } + + [Fact] + public void Count_ReturnsTagsCount() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Equal(_tags.Length, target.Count); + } + + [Fact] + public void IsReadOnly_ReturnsFalse() + { + TagsCollection target = new TagsCollection(); - Assert.Equal(_tags.Length + 1, target.Count); - Assert.Equal("test-value-101", target["test-key-101"]); - } + Assert.False(target.IsReadOnly); + } - [Fact] - public void Item_Set_SetsTagValue() - { - TagsCollection target = new TagsCollection(_tags); - target[_tags[0].Key] = "new-value"; + [Fact] + public void Item_Get_ThrowsExceptionForEmptyCollection() + { + TagsCollection target = new TagsCollection(); - Assert.Equal("new-value", target[_tags[0].Key]); - } + Assert.Throws(() => target["other-key"]); + } + + [Fact] + public void Item_Get_ThrowsExceptionIfCollectionDoesNotContainTag() + { + TagsCollection target = new TagsCollection(_tags); + + Assert.Throws(() => target["other-key"]); + } + + [Fact] + public void Item_Get_ReturnsTagValueIfCollectionContainsTag() + { + TagsCollection target = new TagsCollection(_tags); + string returnedValue = target[_tags[0].Key]; - private void CompareCollections(IEnumerable expected, IEnumerable actual) - { - Assert.Equal(expected.Count(), actual.Count()); - Assert.True(expected.All(tag => actual.Contains(tag))); - } + Assert.Equal(_tags[0].Value, returnedValue); + } + + [Fact] + public void Item_Set_AddsItemToEmptyCollection() + { + TagsCollection target = new TagsCollection(); + + target["test-key"] = "test-value"; + + Assert.Single(target); + Assert.Equal("test-value", target["test-key"]); + } + + [Fact] + public void Item_Set_AddsItemToCollection() + { + TagsCollection target = new TagsCollection(_tags); + + target["test-key-101"] = "test-value-101"; + + Assert.Equal(_tags.Length + 1, target.Count); + Assert.Equal("test-value-101", target["test-key-101"]); + } + + [Fact] + public void Item_Set_SetsTagValue() + { + TagsCollection target = new TagsCollection(_tags); + target[_tags[0].Key] = "new-value"; + + Assert.Equal("new-value", target[_tags[0].Key]); + } + + private void CompareCollections(IEnumerable expected, IEnumerable actual) + { + Assert.Equal(expected.Count(), actual.Count()); + Assert.True(expected.All(tag => actual.Contains(tag))); } } diff --git a/src/Tests.SpatialLite.Osm/WayInfoTests.cs b/src/Tests.SpatialLite.Osm/WayInfoTests.cs index 7383f5a..520379a 100644 --- a/src/Tests.SpatialLite.Osm/WayInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/WayInfoTests.cs @@ -6,74 +6,73 @@ using SpatialLite.Osm.Geometries; using SpatialLite.Osm; -namespace Tests.SpatialLite.Osm -{ - public class WayInfoTests - { +namespace Tests.SpatialLite.Osm; - [Fact] - public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() - { - int id = 45; - TagsCollection tags = new TagsCollection(); - List nodes = new List(); +public class WayInfoTests +{ - WayInfo target = new WayInfo(id, tags, nodes); + [Fact] + public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List nodes = new List(); - Assert.Equal(EntityType.Way, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(nodes, target.Nodes); - Assert.Null(target.Metadata); - } + WayInfo target = new WayInfo(id, tags, nodes); - [Fact] - public void Constructor_Properties_SetsProperties() - { - int id = 45; - TagsCollection tags = new TagsCollection(); - List nodes = new List(); - EntityMetadata details = new EntityMetadata(); - - WayInfo target = new WayInfo(id, tags, nodes, details); - - Assert.Equal(EntityType.Way, target.EntityType); - Assert.Equal(id, target.ID); - Assert.Same(tags, target.Tags); - Assert.Same(nodes, target.Nodes); - Assert.Same(details, target.Metadata); - } + Assert.Equal(EntityType.Way, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(nodes, target.Nodes); + Assert.Null(target.Metadata); + } - [Fact] - public void Constructor_Way_SetsProperties() - { - Way way = new Way(10, new Node[0], new TagsCollection()) { Metadata = new EntityMetadata() }; + [Fact] + public void Constructor_Properties_SetsProperties() + { + int id = 45; + TagsCollection tags = new TagsCollection(); + List nodes = new List(); + EntityMetadata details = new EntityMetadata(); + + WayInfo target = new WayInfo(id, tags, nodes, details); + + Assert.Equal(EntityType.Way, target.EntityType); + Assert.Equal(id, target.ID); + Assert.Same(tags, target.Tags); + Assert.Same(nodes, target.Nodes); + Assert.Same(details, target.Metadata); + } - WayInfo target = new WayInfo(way); + [Fact] + public void Constructor_Way_SetsProperties() + { + Way way = new Way(10, new Node[0], new TagsCollection()) { Metadata = new EntityMetadata() }; - Assert.Equal(way.ID, target.ID); - Assert.Same(way.Tags, target.Tags); - Assert.Same(way.Metadata, target.Metadata); - } + WayInfo target = new WayInfo(way); - [Fact] - public void Constructor_Way_SetsNodesReferences() - { - Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }, new TagsCollection()) { Metadata = new EntityMetadata() }; + Assert.Equal(way.ID, target.ID); + Assert.Same(way.Tags, target.Tags); + Assert.Same(way.Metadata, target.Metadata); + } - WayInfo target = new WayInfo(way); + [Fact] + public void Constructor_Way_SetsNodesReferences() + { + Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }, new TagsCollection()) { Metadata = new EntityMetadata() }; - Assert.Equal(way.Nodes.Count, target.Nodes.Count); - for (int i = 0; i < way.Nodes.Count; i++) - { - Assert.Equal(way.Nodes[i].ID, target.Nodes[i]); - } - } + WayInfo target = new WayInfo(way); - [Fact] - public void Constructor_Way_ThrowsExceptionIfWayIsNull() + Assert.Equal(way.Nodes.Count, target.Nodes.Count); + for (int i = 0; i < way.Nodes.Count; i++) { - Assert.Throws(() => new WayInfo(null)); + Assert.Equal(way.Nodes[i].ID, target.Nodes[i]); } } + + [Fact] + public void Constructor_Way_ThrowsExceptionIfWayIsNull() + { + Assert.Throws(() => new WayInfo(null)); + } } From e21cf0f4485fd23a00ad9a6f7bd8d55928f6f434 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 20:57:37 +0000 Subject: [PATCH 06/14] Create initial plan to fix formatting issues Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- issues.json | 28874 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 28874 insertions(+) create mode 100644 issues.json diff --git a/issues.json b/issues.json new file mode 100644 index 0000000..e0171f7 --- /dev/null +++ b/issues.json @@ -0,0 +1,28874 @@ +[ + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 6, + "DiagnosticId": "WHITESPACE", + "FormatDescription": "Fix whitespace formatting. Replace 8 characters with \u0027\\r\\n\\r\\n\\s\\s\\s\\s\u0027." + }, + { + "LineNumber": 36, + "CharNumber": 1, + "DiagnosticId": "WHITESPACE", + "FormatDescription": "Fix whitespace formatting. Replace 2 characters with \u0027\\s\\s\\s\\s\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "a55d525e-168e-422a-9293-36fd45d37f51" + }, + "FileName": "GpxMetadata.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpxMetadata.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 2, + "DiagnosticId": "WHITESPACE", + "FormatDescription": "Fix whitespace formatting. Replace 6 characters with \u0027\\r\\n\\s\\s\\s\\s\u0027." + }, + { + "LineNumber": 11, + "CharNumber": 1, + "DiagnosticId": "WHITESPACE", + "FormatDescription": "Fix whitespace formatting. Replace 61 characters with \u0027\\s\\s\\s\\s///\\sGets\\sor\\ssets\\sthe\\sname\\sof\\sthe\\sentity\\r\\n\\s\\s\\s\\s///\\s\u003C/summary\u003E\\r\\n\u0027." + }, + { + "LineNumber": 13, + "CharNumber": 1, + "DiagnosticId": "WHITESPACE", + "FormatDescription": "Fix whitespace formatting. Replace 2 characters with \u0027\\s\\s\\s\\s\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "75041a3b-4d43-4707-a335-0901e5f60cc5" + }, + "FileName": "Euclidean2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6e12caee-c6aa-477f-a73c-10dab5336ee1" + }, + "FileName": "Euclidean2DLocator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "e892f746-e2c3-4394-ab91-2847a6088566" + }, + "FileName": "CoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/CoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "3dc4c961-d6f5-4238-aab2-9e9524dcaa71" + }, + "FileName": "Geometry.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Geometry.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "11bae556-c9ec-49db-a791-9f5367cddbeb" + }, + "FileName": "GeometryCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/GeometryCollection.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "f827447e-c54e-414f-8f5f-fd08f1e8ad5f" + }, + "FileName": "LineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/LineString.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "06efe365-b64f-4c1a-98a4-2e9e2c28dc59" + }, + "FileName": "MultiLineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/MultiLineString.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "274d8bc9-4826-4280-b046-fec01a65b8a3" + }, + "FileName": "MultiPoint.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/MultiPoint.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "8c24d6c7-94fb-49ac-a33e-32b2f4ae3949" + }, + "FileName": "MultiPolygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/MultiPolygon.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "bdf84ed1-ddb5-4bf9-b6f0-08a96daa9011" + }, + "FileName": "Point.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Point.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "b2e10966-f98a-47c4-af38-e91db2be3ee9" + }, + "FileName": "ReadOnlyCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9b283f59-4990-42c7-bc8a-d4762c88444e" + }, + "FileName": "OsmGeometryDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "61ba3949-455c-49f9-8b6c-af74267480ca" + }, + "FileName": "Relation.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Relation.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "1f21c98c-72d4-4006-819e-fddebed6c524" + }, + "FileName": "WayCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9583e21f-9041-4bca-b05e-175c194f14d7" + }, + "FileName": "IOsmWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/IOsmWriter.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "db77dd80-1c2d-48f3-8462-f958863200a7" + }, + "FileName": "OsmHeader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "3d3894b8-7c71-4d06-8efc-ea998754890f" + }, + "FileName": "PbfDenseMetadata.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "dda5c3a0-e514-4779-8301-d291881e183d" + }, + "FileName": "PbfDenseNodes.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "8d8a63cf-0610-4369-ad77-9e7403f4eed5" + }, + "FileName": "PbfNode.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "63989854-a73c-4226-9a22-c1e02f44bbe4" + }, + "FileName": "PbfRelation.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "cd7cd8e2-a488-41cd-839a-452e6c8eac2c" + }, + "FileName": "PbfWay.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "0a6d9449-8710-4958-879e-bf3de80731e7" + }, + "FileName": "PrimitiveBlock.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "17a434a2-e27e-4513-af92-0ea693a767df" + }, + "FileName": "PrimitiveGroup.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "dcf6636b-91f3-4dc2-9526-68018cf31a00" + }, + "FileName": "StringTable.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/StringTable.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4df70cec-104e-413c-912d-08ba1e533f53" + }, + "FileName": "OsmEntityInfoDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "6a150094-33df-4fa8-bb5c-8f9541dfd546" + }, + "FileName": "Euclidean2DCalculatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "2f66a141-11fb-4594-9a50-754aab7acd30" + }, + "FileName": "Euclidean2DLocatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "812f3ecb-7dfb-4792-bd59-4b2ec6b17c78" + }, + "FileName": "Sphere2DCalculatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a919bc18-1560-466b-9f62-9d14fd785b93" + }, + "FileName": "CoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "87cfbca3-dd42-4f6e-af3c-234776b51604" + }, + "FileName": "GeometryCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "078f4d47-a4db-4a77-be70-902102fd42f3" + }, + "FileName": "ReadOnlyCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "33a3b8da-40ae-4b0b-8aa2-9307f6605a09" + }, + "FileName": "WkbWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "e6c95d9e-be28-4a4f-a6ea-e3bf3a4dbbd3" + }, + "FileName": "WktTokensBufferTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1455b65b-a7c8-44da-add6-ed8d29df7dab" + }, + "FileName": "WktWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "d241403d-67a8-468f-8d15-94a931784386" + }, + "FileName": "MeasurementsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/MeasurementsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1a79cfbb-a729-4a79-975d-30676deba772" + }, + "FileName": "TopologyTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/TopologyTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "fe6e73f1-3cc8-4c9a-923e-e9a61ab1d637" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "ce33ccbc-5f31-4f98-9621-96fedc016dd9" + }, + "FileName": "NodeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "6e82c77f-c724-4056-85b5-8c81f0f54980" + }, + "FileName": "RelationMemberTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "08b15a22-fb75-4e43-8cd7-c960954c519c" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9b25f26f-0a00-4d89-8884-080e787f94c5" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "ee78d45e-19f3-493d-bfd0-56c0f3b03f63" + }, + "FileName": "OsmReaderSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "48c800d5-26f4-44b1-b0c0-3a2b1ba2aa01" + }, + "FileName": "OsmWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "3cd2c787-e010-4610-8f2a-c94cce0dc70b" + }, + "FileName": "PbfWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "52576f7c-dc5c-4a2b-8fd0-cab97bd3bf11" + }, + "FileName": "NodeInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/NodeInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5653253b-9d63-4c59-a567-caa32e7e7dc3" + }, + "FileName": "RelationInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/RelationInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "bb70de32-1d46-4daf-bf58-44106c265dee" + }, + "FileName": "RelationMemberInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "06d6a29c-87d5-47c0-8c59-1f8036366368" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "1bd755f7-d2da-4e31-a6c4-9eb7feabfc1f" + }, + "FileName": "TagTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5b4b319e-8745-4323-8c0c-e87db9ec5d15" + }, + "FileName": "WayInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/WayInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "8c562c79-f037-4ee8-98a9-d617d01e4d76" + }, + "FileName": "GpsPoint.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpsPoint.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "782b100c-f1fd-4d23-bd15-3f461a09f58c" + }, + "FileName": "GpsTrackBase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "a4e63528-c667-442a-9c1c-8f8b3947fc1c" + }, + "FileName": "GpxPoint.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpxPoint.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "973d1dfe-2d78-48b2-a954-9ca80ff393f3" + }, + "FileName": "GpxTrack.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpxTrack.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "7ee37872-480a-4a4a-9663-4dac76ca63a5" + }, + "FileName": "IGpsPoint.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IGpsPoint.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "a1ad78cb-15de-4246-b26f-7466e49810c0" + }, + "FileName": "GpsTrackBaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "dcc11bef-e730-4d04-bee0-458157278b25" + }, + "FileName": "GpxFixHelperTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "456cb2e4-a93f-49fd-9808-58ce57d0eefa" + }, + "FileName": "GpxLinkTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "743331fd-7ef9-4cca-9fd5-8dc08aab5929" + }, + "FileName": "GpxMetadataTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "40a28b68-592b-4eca-b580-253cc1d44b66" + }, + "FileName": "GpxRouteTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "28afdc35-2c53-41c4-907f-5e4e2980aa63" + }, + "FileName": "GpxTrackSegmentTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "1a292658-a968-40dd-96db-a51059999192" + }, + "FileName": "GpxDocumentTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "2e1d2b36-7e46-4cf8-b1c4-7a0868a9792f" + }, + "FileName": "GpxReaderSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f04a8e8e-2bad-4e56-a6af-b306af78fdfb" + }, + "FileName": "GpxWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 407, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "1cfb33c2-1c3d-4ce8-8bbe-f2dbe4bfae5a" + }, + "FileName": "WkbWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 51, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 62, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 68, + "CharNumber": 24, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 79, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 83, + "CharNumber": 47, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 104, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 121, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "83cb8cbd-c53c-4724-9cf8-9fe84d313796" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 13, + "DiagnosticId": "IDE0016", + "FormatDescription": "warning IDE0016: Null check can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 24, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 166, + "CharNumber": 32, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 49, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 40, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 58, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 133, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 150, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 166, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 207, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 260, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 270, + "CharNumber": 18, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 270, + "CharNumber": 60, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 292, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 297, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 297, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 297, + "CharNumber": 83, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 271, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 308, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 313, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 314, + "CharNumber": 18, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 315, + "CharNumber": 18, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 316, + "CharNumber": 18, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 271, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 336, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 272, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 341, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 342, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 343, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 344, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 272, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 273, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 365, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 369, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 273, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 274, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 385, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 411, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 389, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 415, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 393, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 274, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 419, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 423, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 275, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 275, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 276, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 276, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 277, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 277, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 254, + "CharNumber": 9, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "f827447e-c54e-414f-8f5f-fd08f1e8ad5f" + }, + "FileName": "LineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/LineString.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "f827447e-c54e-414f-8f5f-fd08f1e8ad5f" + }, + "FileName": "LineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/LineString.cs", + "FileChanges": [ + { + "LineNumber": 69, + "CharNumber": 22, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "f827447e-c54e-414f-8f5f-fd08f1e8ad5f" + }, + "FileName": "LineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/LineString.cs", + "FileChanges": [ + { + "LineNumber": 120, + "CharNumber": 24, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "f827447e-c54e-414f-8f5f-fd08f1e8ad5f" + }, + "FileName": "LineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/LineString.cs", + "FileChanges": [ + { + "LineNumber": 120, + "CharNumber": 42, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "f827447e-c54e-414f-8f5f-fd08f1e8ad5f" + }, + "FileName": "LineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/LineString.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "e892f746-e2c3-4394-ab91-2847a6088566" + }, + "FileName": "CoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/CoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 30, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6386a667-7f7e-4d86-83c3-3c0d8e684bf9" + }, + "FileName": "WktTokensBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktTokensBuffer.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6386a667-7f7e-4d86-83c3-3c0d8e684bf9" + }, + "FileName": "WktTokensBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktTokensBuffer.cs", + "FileChanges": [ + { + "LineNumber": 74, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6386a667-7f7e-4d86-83c3-3c0d8e684bf9" + }, + "FileName": "WktTokensBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktTokensBuffer.cs", + "FileChanges": [ + { + "LineNumber": 140, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 24, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 183, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 188, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 206, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 213, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 230, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 267, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 280, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 287, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 331, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 338, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 358, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 363, + "CharNumber": 21, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 380, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 387, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 405, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 410, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 426, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 433, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 451, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 456, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 472, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 479, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 79, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 113, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 117, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 121, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 125, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 129, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 133, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 137, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 244, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 251, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 304, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 309, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 314, + "CharNumber": 21, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 496, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 501, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 111, + "CharNumber": 13, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 115, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 119, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 123, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 131, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 135, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "81c2a7a7-e75f-4023-ab79-a0ed61a8d087" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 13, + "DiagnosticId": "IDE0016", + "FormatDescription": "warning IDE0016: Null check can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 32, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 24, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 24, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 59, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 94, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 222, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 223, + "CharNumber": 34, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 224, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 240, + "CharNumber": 20, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 246, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 304, + "CharNumber": 25, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 310, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 311, + "CharNumber": 29, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 326, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 327, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 333, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 336, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 339, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 360, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 361, + "CharNumber": 42, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 362, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 378, + "CharNumber": 25, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 384, + "CharNumber": 29, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 399, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 400, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 406, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 409, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 412, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 459, + "CharNumber": 22, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 465, + "CharNumber": 26, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 480, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 481, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 487, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 490, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 493, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 514, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 515, + "CharNumber": 54, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 516, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 529, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 530, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 536, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 539, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 542, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 563, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 564, + "CharNumber": 44, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 565, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 578, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 579, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 585, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 588, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 591, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 612, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 613, + "CharNumber": 48, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 614, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 627, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 628, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 634, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 637, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 640, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 70, + "CharNumber": 27, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 104, + "CharNumber": 27, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 144, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 148, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 152, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 156, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 164, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 168, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 188, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 195, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 198, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 201, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 263, + "CharNumber": 22, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 266, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 268, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 276, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 278, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 284, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 286, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 433, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 435, + "CharNumber": 47, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 443, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 661, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 664, + "CharNumber": 31, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 670, + "CharNumber": 35, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 674, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 192, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 191, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 329, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 330, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 402, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 403, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 484, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 483, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 533, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 532, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 581, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 582, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 630, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 631, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 651, + "CharNumber": 117, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 651, + "CharNumber": 106, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 770, + "CharNumber": 14, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 74, + "CharNumber": 13, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 108, + "CharNumber": 13, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 24, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 205, + "CharNumber": 24, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 246, + "CharNumber": 31, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 259, + "CharNumber": 47, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 305, + "CharNumber": 35, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 325, + "CharNumber": 35, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 345, + "CharNumber": 35, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 73, + "CharNumber": 39, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 94, + "CharNumber": 27, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 140, + "CharNumber": 20, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 222, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 226, + "CharNumber": 48, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 227, + "CharNumber": 53, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 228, + "CharNumber": 50, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 229, + "CharNumber": 53, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 230, + "CharNumber": 58, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 231, + "CharNumber": 55, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 232, + "CharNumber": 61, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 279, + "CharNumber": 44, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 284, + "CharNumber": 48, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 365, + "CharNumber": 35, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 358, + "CharNumber": 98, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 358, + "CharNumber": 109, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 156, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 391, + "CharNumber": 14, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 98, + "CharNumber": 13, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0bd6c64a-e9a9-4971-a701-aa9b0ed31c31" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 13, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 195, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 213, + "CharNumber": 32, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 214, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 225, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 226, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 236, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 237, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 254, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 258, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 270, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 274, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 285, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 289, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 89, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 90, + "CharNumber": 17, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 112, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 113, + "CharNumber": 9, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 135, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 139, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 143, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 147, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 155, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 159, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 300, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 304, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 315, + "CharNumber": 28, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 319, + "CharNumber": 13, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 35, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 112, + "CharNumber": 42, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 133, + "CharNumber": 13, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 137, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 141, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 145, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 149, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 153, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6db61c6d-6054-4957-a1eb-100449f96e32" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 157, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 69, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 89, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 115, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 138, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 181, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 168, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 185, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "9c0f1362-ce6d-43e7-8456-4165c1ef6993" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 202, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 23, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 76, + "CharNumber": 67, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 76, + "CharNumber": 136, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 32, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 65, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 57, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 70, + "CharNumber": 28, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 71, + "CharNumber": 28, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 73, + "CharNumber": 25, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 84, + "CharNumber": 32, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 85, + "CharNumber": 32, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 93, + "CharNumber": 24, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 124, + "CharNumber": 22, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 124, + "CharNumber": 71, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "0b19eb46-963f-4865-aa40-210e95a55408" + }, + "FileName": "Sphere2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 124, + "CharNumber": 130, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "8c24d6c7-94fb-49ac-a33e-32b2f4ae3949" + }, + "FileName": "MultiPolygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/MultiPolygon.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 22, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "274d8bc9-4826-4280-b046-fec01a65b8a3" + }, + "FileName": "MultiPoint.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/MultiPoint.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 22, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "06efe365-b64f-4c1a-98a4-2e9e2c28dc59" + }, + "FileName": "MultiLineString.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/MultiLineString.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 22, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "36b2b417-5fab-4089-a485-5eefe1f681d0" + }, + "FileName": "WktTokenizer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktTokenizer.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 16, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "36b2b417-5fab-4089-a485-5eefe1f681d0" + }, + "FileName": "WktTokenizer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktTokenizer.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 31, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "36b2b417-5fab-4089-a485-5eefe1f681d0" + }, + "FileName": "WktTokenizer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktTokenizer.cs", + "FileChanges": [ + { + "LineNumber": 46, + "CharNumber": 31, + "DiagnosticId": "IDE0002", + "FormatDescription": "warning IDE0002: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 89, + "CharNumber": 9, + "DiagnosticId": "IDE0251", + "FormatDescription": "warning IDE0251: Member can be made \u0027readonly\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 100, + "CharNumber": 9, + "DiagnosticId": "IDE0251", + "FormatDescription": "warning IDE0251: Member can be made \u0027readonly\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 132, + "CharNumber": 28, + "DiagnosticId": "IDE0251", + "FormatDescription": "warning IDE0251: Member can be made \u0027readonly\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 170, + "CharNumber": 25, + "DiagnosticId": "IDE0251", + "FormatDescription": "warning IDE0251: Member can be made \u0027readonly\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 180, + "CharNumber": 17, + "DiagnosticId": "IDE0251", + "FormatDescription": "warning IDE0251: Member can be made \u0027readonly\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 158, + "CharNumber": 17, + "DiagnosticId": "IDE0251", + "FormatDescription": "warning IDE0251: Member can be made \u0027readonly\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 91, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 102, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 105, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 113, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 121, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 129, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 150, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 18, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 182, + "CharNumber": 18, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 182, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 161, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 183, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 183, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 161, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 162, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 162, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 163, + "CharNumber": 15, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 163, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "b2e10966-f98a-47c4-af38-e91db2be3ee9" + }, + "FileName": "ReadOnlyCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "b2e10966-f98a-47c4-af38-e91db2be3ee9" + }, + "FileName": "ReadOnlyCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 29, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "b2e10966-f98a-47c4-af38-e91db2be3ee9" + }, + "FileName": "ReadOnlyCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 47, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "b2e10966-f98a-47c4-af38-e91db2be3ee9" + }, + "FileName": "ReadOnlyCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 107, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "b2e10966-f98a-47c4-af38-e91db2be3ee9" + }, + "FileName": "ReadOnlyCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 119, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 29, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 22, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 55, + "CharNumber": 22, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 64, + "CharNumber": 22, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 64, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 73, + "CharNumber": 22, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 73, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 84, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 84, + "CharNumber": 77, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 93, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "59e94908-8bbd-4609-92a9-732619b952ff" + }, + "FileName": "Polygon.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Polygon.cs", + "FileChanges": [ + { + "LineNumber": 93, + "CharNumber": 41, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "bdf84ed1-ddb5-4bf9-b6f0-08a96daa9011" + }, + "FileName": "Point.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Point.cs", + "FileChanges": [ + { + "LineNumber": 106, + "CharNumber": 29, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "bdf84ed1-ddb5-4bf9-b6f0-08a96daa9011" + }, + "FileName": "Point.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/Point.cs", + "FileChanges": [ + { + "LineNumber": 115, + "CharNumber": 22, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "11bae556-c9ec-49db-a791-9f5367cddbeb" + }, + "FileName": "GeometryCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Geometries/GeometryCollection.cs", + "FileChanges": [ + { + "LineNumber": 102, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "1cfb33c2-1c3d-4ce8-8bbe-f2dbe4bfae5a" + }, + "FileName": "WkbWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "1cfb33c2-1c3d-4ce8-8bbe-f2dbe4bfae5a" + }, + "FileName": "WkbWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "75041a3b-4d43-4707-a335-0901e5f60cc5" + }, + "FileName": "Euclidean2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 38, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "75041a3b-4d43-4707-a335-0901e5f60cc5" + }, + "FileName": "Euclidean2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 68, + "CharNumber": 24, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "75041a3b-4d43-4707-a335-0901e5f60cc5" + }, + "FileName": "Euclidean2DCalculator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs", + "FileChanges": [ + { + "LineNumber": 73, + "CharNumber": 24, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6e12caee-c6aa-477f-a73c-10dab5336ee1" + }, + "FileName": "Euclidean2DLocator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs", + "FileChanges": [ + { + "LineNumber": 83, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "6e12caee-c6aa-477f-a73c-10dab5336ee1" + }, + "FileName": "Euclidean2DLocator.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs", + "FileChanges": [ + { + "LineNumber": 213, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e255aaa0-569d-4345-aff5-11faa2924be1" + }, + "FileName": "OsmReaderSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmReaderSettings.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6549a1e4-5d6e-49f3-9765-a3a636b695b2" + }, + "FileName": "OsmWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6549a1e4-5d6e-49f3-9765-a3a636b695b2" + }, + "FileName": "OsmWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "1c19696f-4747-43d7-8113-0efa1f90773e" + }, + "FileName": "Blob.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/Blob.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2967dede-101a-4e2d-b848-66e15c186cf1" + }, + "FileName": "BlobHeader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "90271839-641d-4acb-8fb6-bbcc65b6941e" + }, + "FileName": "HeaderBBox.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs", + "FileChanges": [ + { + "LineNumber": 36, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ed31c426-be9f-45bd-a79f-e9968a81be2c" + }, + "FileName": "PbfChangeset.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2c9b7d1e-fcb1-4a11-a445-4bea51335ec8" + }, + "FileName": "PbfMetadata.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "8d8a63cf-0610-4369-ad77-9e7403f4eed5" + }, + "FileName": "PbfNode.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs", + "FileChanges": [ + { + "LineNumber": 49, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "17a434a2-e27e-4513-af92-0ea693a767df" + }, + "FileName": "PrimitiveGroup.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs", + "FileChanges": [ + { + "LineNumber": 43, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b8a3cdb7-18ed-4524-be2a-65d62749cf8e" + }, + "FileName": "IOsmEntity.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IOsmEntity.cs", + "FileChanges": [ + { + "LineNumber": 29, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "f066e82f-5fb1-43aa-9c14-0758097b22ef" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "790fc7ee-02b0-4833-871c-f43e3b55dbc5" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "790fc7ee-02b0-4833-871c-f43e3b55dbc5" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "790fc7ee-02b0-4833-871c-f43e3b55dbc5" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 74, + "CharNumber": 9, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "790fc7ee-02b0-4833-871c-f43e3b55dbc5" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 13, + "DiagnosticId": "IDE0016", + "FormatDescription": "warning IDE0016: Null check can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 24, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 25, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 239, + "CharNumber": 28, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 38, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 39, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 54, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 43, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 55, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 44, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 59, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 60, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 129, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 77, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 130, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 131, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 104, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 109, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 140, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 141, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 159, + "CharNumber": 55, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 52, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 161, + "CharNumber": 62, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 170, + "CharNumber": 41, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 182, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 193, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 198, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 210, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 222, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 268, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 226, + "CharNumber": 18, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 273, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 278, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 310, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 312, + "CharNumber": 37, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 316, + "CharNumber": 32, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 336, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 355, + "CharNumber": 32, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 392, + "CharNumber": 42, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 394, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 441, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 443, + "CharNumber": 32, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 489, + "CharNumber": 41, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 491, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 544, + "CharNumber": 46, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 546, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 623, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 32, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 29, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 298, + "CharNumber": 44, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 374, + "CharNumber": 44, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 398, + "CharNumber": 29, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 413, + "CharNumber": 42, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 437, + "CharNumber": 35, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 462, + "CharNumber": 52, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 44, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027blobHeader\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 86, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027blobHeader\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 132, + "CharNumber": 24, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027blobHeader\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 83, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 84, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 51, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 87, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 52, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 93, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 94, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 133, + "CharNumber": 55, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 135, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 140, + "CharNumber": 25, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 264, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 265, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 266, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 267, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 296, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 351, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 411, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 460, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 516, + "CharNumber": 14, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 477, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 135, + "CharNumber": 17, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e706747f-7094-40bc-8b57-92e721ada5ab" + }, + "FileName": "EntityInfoBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e706747f-7094-40bc-8b57-92e721ada5ab" + }, + "FileName": "EntityInfoBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 38, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e706747f-7094-40bc-8b57-92e721ada5ab" + }, + "FileName": "EntityInfoBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e706747f-7094-40bc-8b57-92e721ada5ab" + }, + "FileName": "EntityInfoBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e706747f-7094-40bc-8b57-92e721ada5ab" + }, + "FileName": "EntityInfoBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs", + "FileChanges": [ + { + "LineNumber": 111, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e706747f-7094-40bc-8b57-92e721ada5ab" + }, + "FileName": "EntityInfoBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs", + "FileChanges": [ + { + "LineNumber": 72, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e706747f-7094-40bc-8b57-92e721ada5ab" + }, + "FileName": "EntityInfoBuffer.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs", + "FileChanges": [ + { + "LineNumber": 73, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 46, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 23, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 24, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 53, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 54, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 93, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 110, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 120, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 98, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 125, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 126, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 100, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 145, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 147, + "CharNumber": 55, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 173, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 192, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 175, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 194, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 178, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 197, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 218, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 220, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 223, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 278, + "CharNumber": 14, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 38, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 39, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 40, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 75, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 52, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 53, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 78, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 54, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 81, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 178, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 135, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 180, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 137, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 197, + "CharNumber": 47, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 252, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 150, + "CharNumber": 37, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 254, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 200, + "CharNumber": 46, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 271, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 274, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 371, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 385, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 399, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 413, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 427, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 493, + "CharNumber": 14, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2cc464a-3a13-4fbc-9101-5cf4ff4c873d" + }, + "FileName": "OsmXmlReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReader.cs", + "FileChanges": [ + { + "LineNumber": 441, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 31, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 44, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 46, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 48, + "CharNumber": 53, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 104, + "CharNumber": 13, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "d93febf5-07f8-42c1-8d0b-2cf9fefdb713" + }, + "FileName": "EntityCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/EntityCollection.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 33, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "d93febf5-07f8-42c1-8d0b-2cf9fefdb713" + }, + "FileName": "EntityCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/EntityCollection.cs", + "FileChanges": [ + { + "LineNumber": 179, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "d93febf5-07f8-42c1-8d0b-2cf9fefdb713" + }, + "FileName": "EntityCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/EntityCollection.cs", + "FileChanges": [ + { + "LineNumber": 73, + "CharNumber": 20, + "DiagnosticId": "IDE0034", + "FormatDescription": "warning IDE0034: \u0027default\u0027 expression can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 89, + "CharNumber": 24, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 94, + "CharNumber": 24, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 24, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 36, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 24, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 62, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 62, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 62, + "CharNumber": 57, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 122, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 87, + "CharNumber": 44, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 124, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 89, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 129, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 92, + "CharNumber": 43, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 132, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 94, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 97, + "CharNumber": 48, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 150, + "CharNumber": 42, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 41, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 152, + "CharNumber": 46, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 169, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 176, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 177, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 178, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 187, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 188, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 204, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 232, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 241, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 246, + "CharNumber": 29, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 251, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 263, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "fd467f97-f041-4336-86a2-fa0c1b865545" + }, + "FileName": "OsmDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmDatabase.cs", + "FileChanges": [ + { + "LineNumber": 102, + "CharNumber": 20, + "DiagnosticId": "IDE0034", + "FormatDescription": "warning IDE0034: \u0027default\u0027 expression can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 71, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 76, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 78, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 79, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 83, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 233, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 214, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 216, + "CharNumber": 23, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 217, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 249, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4df70cec-104e-413c-912d-08ba1e533f53" + }, + "FileName": "OsmEntityInfoDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs", + "FileChanges": [ + { + "LineNumber": 38, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027entityInfo\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9b283f59-4990-42c7-bc8a-d4762c88444e" + }, + "FileName": "OsmGeometryDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027entityInfo\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 25, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 26, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 43, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 44, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 46, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "c967d511-0963-4099-818b-b16d8b6cb586" + }, + "FileName": "WayInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/WayInfo.cs", + "FileChanges": [ + { + "LineNumber": 49, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "f066e82f-5fb1-43aa-9c14-0758097b22ef" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "f066e82f-5fb1-43aa-9c14-0758097b22ef" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "f066e82f-5fb1-43aa-9c14-0758097b22ef" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 24, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 25, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 39, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 40, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 43, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "2e5216cc-780b-4887-a941-7a9078c23b6a" + }, + "FileName": "RelationInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationInfo.cs", + "FileChanges": [ + { + "LineNumber": 46, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 24, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 25, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 26, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 40, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 43, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "60f88480-5c5a-4c33-ae76-ddeb43a54546" + }, + "FileName": "NodeInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/NodeInfo.cs", + "FileChanges": [ + { + "LineNumber": 44, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9c145b6e-cdcd-4088-affc-ac76fb269122" + }, + "FileName": "PbfWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9c145b6e-cdcd-4088-affc-ac76fb269122" + }, + "FileName": "PbfWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9c145b6e-cdcd-4088-affc-ac76fb269122" + }, + "FileName": "PbfWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 35, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9c145b6e-cdcd-4088-affc-ac76fb269122" + }, + "FileName": "PbfWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 55, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "dcf6636b-91f3-4dc2-9526-68018cf31a00" + }, + "FileName": "StringTable.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/StringTable.cs", + "FileChanges": [ + { + "LineNumber": 46, + "CharNumber": 26, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "dcf6636b-91f3-4dc2-9526-68018cf31a00" + }, + "FileName": "StringTable.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/StringTable.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 26, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "dcf6636b-91f3-4dc2-9526-68018cf31a00" + }, + "FileName": "StringTable.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/StringTable.cs", + "FileChanges": [ + { + "LineNumber": 51, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "dcf6636b-91f3-4dc2-9526-68018cf31a00" + }, + "FileName": "StringTable.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/StringTable.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 44, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "dcf6636b-91f3-4dc2-9526-68018cf31a00" + }, + "FileName": "StringTable.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/Pbf/StringTable.cs", + "FileChanges": [ + { + "LineNumber": 42, + "CharNumber": 68, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ef3c9537-7987-4ad0-bbf0-233ef408344c" + }, + "FileName": "OsmXmlReaderSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6549a1e4-5d6e-49f3-9765-a3a636b695b2" + }, + "FileName": "OsmWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6549a1e4-5d6e-49f3-9765-a3a636b695b2" + }, + "FileName": "OsmWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6549a1e4-5d6e-49f3-9765-a3a636b695b2" + }, + "FileName": "OsmWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 53, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e255aaa0-569d-4345-aff5-11faa2924be1" + }, + "FileName": "OsmReaderSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmReaderSettings.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "e255aaa0-569d-4345-aff5-11faa2924be1" + }, + "FileName": "OsmReaderSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmReaderSettings.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "1f21c98c-72d4-4006-819e-fddebed6c524" + }, + "FileName": "WayCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "1f21c98c-72d4-4006-819e-fddebed6c524" + }, + "FileName": "WayCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "1f21c98c-72d4-4006-819e-fddebed6c524" + }, + "FileName": "WayCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 48, + "CharNumber": 20, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "1f21c98c-72d4-4006-819e-fddebed6c524" + }, + "FileName": "WayCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 120, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "1f21c98c-72d4-4006-819e-fddebed6c524" + }, + "FileName": "WayCoordinateList.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs", + "FileChanges": [ + { + "LineNumber": 108, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 36, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 79, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 90, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 49, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 137, + "CharNumber": 27, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 146, + "CharNumber": 16, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 13, + "DiagnosticId": "IDE0016", + "FormatDescription": "warning IDE0016: Null check can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "61ba3949-455c-49f9-8b6c-af74267480ca" + }, + "FileName": "Relation.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Relation.cs", + "FileChanges": [ + { + "LineNumber": 40, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "61ba3949-455c-49f9-8b6c-af74267480ca" + }, + "FileName": "Relation.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Relation.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "8c82cb2b-4a9a-452b-8821-b64c8eb4e22e" + }, + "FileName": "Node.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Node.cs", + "FileChanges": [ + { + "LineNumber": 63, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "8c82cb2b-4a9a-452b-8821-b64c8eb4e22e" + }, + "FileName": "Node.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Node.cs", + "FileChanges": [ + { + "LineNumber": 64, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 25, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 5, + "DiagnosticId": "IDE0036", + "FormatDescription": "warning IDE0036: Modifiers are not ordered" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a919bc18-1560-466b-9f62-9d14fd785b93" + }, + "FileName": "CoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a919bc18-1560-466b-9f62-9d14fd785b93" + }, + "FileName": "CoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "87cfbca3-dd42-4f6e-af3c-234776b51604" + }, + "FileName": "GeometryCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 13, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "87cfbca3-dd42-4f6e-af3c-234776b51604" + }, + "FileName": "GeometryCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 22, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "078f4d47-a4db-4a77-be70-902102fd42f3" + }, + "FileName": "ReadOnlyCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 46, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 93, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "e6c95d9e-be28-4a4f-a6ea-e3bf3a4dbbd3" + }, + "FileName": "WktTokensBufferTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a19d9cbe-63ab-48c8-995b-bf4092d23997" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1455b65b-a7c8-44da-add6-ed8d29df7dab" + }, + "FileName": "WktWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1a79cfbb-a729-4a79-975d-30676deba772" + }, + "FileName": "TopologyTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/TopologyTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a19d9cbe-63ab-48c8-995b-bf4092d23997" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "87cfbca3-dd42-4f6e-af3c-234776b51604" + }, + "FileName": "GeometryCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 13, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "87cfbca3-dd42-4f6e-af3c-234776b51604" + }, + "FileName": "GeometryCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "87cfbca3-dd42-4f6e-af3c-234776b51604" + }, + "FileName": "GeometryCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "87cfbca3-dd42-4f6e-af3c-234776b51604" + }, + "FileName": "GeometryCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 21, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "b4bd77b4-bea3-4a5c-ae52-00b1def3522e" + }, + "FileName": "LineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "078f4d47-a4db-4a77-be70-902102fd42f3" + }, + "FileName": "ReadOnlyCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 17, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "078f4d47-a4db-4a77-be70-902102fd42f3" + }, + "FileName": "ReadOnlyCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "078f4d47-a4db-4a77-be70-902102fd42f3" + }, + "FileName": "ReadOnlyCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 91, + "CharNumber": 46, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a919bc18-1560-466b-9f62-9d14fd785b93" + }, + "FileName": "CoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a919bc18-1560-466b-9f62-9d14fd785b93" + }, + "FileName": "CoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 3, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "a919bc18-1560-466b-9f62-9d14fd785b93" + }, + "FileName": "CoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 6, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "42eefee4-2f7c-49f0-87c0-de309a9bf817" + }, + "FileName": "PolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 25, + "CharNumber": 14, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "98fd3393-6719-4fc5-976d-c9d63cec625a" + }, + "FileName": "EnvelopeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs", + "FileChanges": [ + { + "LineNumber": 8, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 12, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 12, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 12, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "03fbc7da-7f36-4a98-ad12-4c234f703254" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 33, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 33, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 26, + "CharNumber": 33, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 33, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 34, + "CharNumber": 33, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 10, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 122, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 166, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 185, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 204, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 215, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 234, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 257, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 280, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 299, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 314, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "27931d1c-9392-4a55-875e-91fc6703f1c1" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 326, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "c79135f5-8b6b-4e94-9998-4c10d635d5da" + }, + "FileName": "PointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/PointTests.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "e6c95d9e-be28-4a4f-a6ea-e3bf3a4dbbd3" + }, + "FileName": "WktTokensBufferTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "e6c95d9e-be28-4a4f-a6ea-e3bf3a4dbbd3" + }, + "FileName": "WktTokensBufferTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs", + "FileChanges": [ + { + "LineNumber": 3, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "e6c95d9e-be28-4a4f-a6ea-e3bf3a4dbbd3" + }, + "FileName": "WktTokensBufferTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 35, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 162, + "CharNumber": 46, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 60, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 172, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 282, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 294, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 306, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 318, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 329, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 359, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 370, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 381, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 392, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 423, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 435, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 447, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 459, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 471, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 473, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 474, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 505, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 506, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 518, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 519, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 531, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 532, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 544, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 545, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 576, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 577, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 589, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 602, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 590, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 603, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 615, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 616, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 647, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 660, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 661, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 648, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 673, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 674, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 686, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 687, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 718, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 730, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 742, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 754, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 766, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 767, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 768, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "4b22d397-df07-407a-b859-18125cab97d1" + }, + "FileName": "WktReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 781, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "812f3ecb-7dfb-4792-bd59-4b2ec6b17c78" + }, + "FileName": "Sphere2DCalculatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "6a150094-33df-4fa8-bb5c-8f9541dfd546" + }, + "FileName": "Euclidean2DCalculatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs", + "FileChanges": [ + { + "LineNumber": 6, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "6a150094-33df-4fa8-bb5c-8f9541dfd546" + }, + "FileName": "Euclidean2DCalculatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "6c755e2e-df55-4c6e-bd23-c2c2a9eb462b" + }, + "FileName": "TestDataReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Data/TestDataReader.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "6c755e2e-df55-4c6e-bd23-c2c2a9eb462b" + }, + "FileName": "TestDataReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Data/TestDataReader.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "6c755e2e-df55-4c6e-bd23-c2c2a9eb462b" + }, + "FileName": "TestDataReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Data/TestDataReader.cs", + "FileChanges": [ + { + "LineNumber": 6, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "2f66a141-11fb-4594-9a50-754aab7acd30" + }, + "FileName": "Euclidean2DLocatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "2f66a141-11fb-4594-9a50-754aab7acd30" + }, + "FileName": "Euclidean2DLocatorTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs", + "FileChanges": [ + { + "LineNumber": 10, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "57796c5e-de2b-4214-a41f-80399e87067e" + }, + "FileName": "MultiLineStringTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "19e8807d-4c98-4e82-aefb-f6bb0069fc9e" + }, + "FileName": "MultiPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "d6211e08-cdba-4914-a096-4fe70fc0e594" + }, + "FileName": "MultiPolygonTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "33a3b8da-40ae-4b0b-8aa2-9307f6605a09" + }, + "FileName": "WkbWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 3, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 6, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "161a23d8-4b92-47b0-9a2a-4cfd61e5c59c" + }, + "FileName": "WktTokenizerTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs", + "FileChanges": [ + { + "LineNumber": 8, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 131, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 138, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 146, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 153, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 161, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 168, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 176, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 183, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 191, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 198, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 206, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 213, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 221, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 228, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 236, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 243, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 251, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 258, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 266, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 272, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 280, + "CharNumber": 36, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 287, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 295, + "CharNumber": 36, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 302, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 310, + "CharNumber": 36, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 317, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 325, + "CharNumber": 36, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 332, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 340, + "CharNumber": 36, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 347, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 355, + "CharNumber": 36, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 362, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 370, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 377, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 385, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 392, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 400, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 407, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 415, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 422, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 430, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 445, + "CharNumber": 60, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 437, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 452, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 460, + "CharNumber": 60, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 475, + "CharNumber": 60, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 467, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 482, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 490, + "CharNumber": 60, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 505, + "CharNumber": 60, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 512, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 497, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 520, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 527, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 550, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 535, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 557, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 542, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 565, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 572, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 580, + "CharNumber": 51, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 587, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 595, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 602, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 610, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 617, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 625, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 632, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 640, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 647, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 655, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 662, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 670, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 677, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 685, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 692, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 700, + "CharNumber": 81, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 707, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 730, + "CharNumber": 30, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1ac0e051-9bfd-47f8-8416-6190a40d68c3" + }, + "FileName": "WkbWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 733, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1455b65b-a7c8-44da-add6-ed8d29df7dab" + }, + "FileName": "WktWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "99659a40-c898-4491-9b69-992f5153c0de" + }, + "FileName": "AssemblyInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 109, + "CharNumber": 47, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 154, + "CharNumber": 47, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 162, + "CharNumber": 43, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 492, + "CharNumber": 38, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027expected\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 67, + "CharNumber": 33, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 72, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 78, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 79, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 84, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 87, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 33, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 132, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 191, + "CharNumber": 33, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 194, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 225, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 234, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 243, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 252, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 261, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 270, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 279, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 287, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 296, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 305, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 314, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 323, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 332, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 341, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 350, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 359, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 368, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 386, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 377, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 395, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 404, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 413, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 422, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 431, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 449, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 440, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 458, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 467, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 476, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 485, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 492, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 502, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 506, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 513, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 517, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 524, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 528, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 535, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 539, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 546, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 550, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 551, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 552, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 559, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 563, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 564, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 565, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 582, + "CharNumber": 33, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 585, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 572, + "CharNumber": 79, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 590, + "CharNumber": 43, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 593, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 577, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 598, + "CharNumber": 37, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 601, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 606, + "CharNumber": 43, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 609, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 614, + "CharNumber": 53, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 617, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 622, + "CharNumber": 47, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 625, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 644, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 649, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 654, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 664, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 674, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "951e0b6e-4f21-4fd2-84dc-78b3ec4934dc" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 684, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1a79cfbb-a729-4a79-975d-30676deba772" + }, + "FileName": "TopologyTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/TopologyTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "1a79cfbb-a729-4a79-975d-30676deba772" + }, + "FileName": "TopologyTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/TopologyTests.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fe4ad577-3e43-4491-a930-34ae6e986314" + }, + "Id": "d241403d-67a8-468f-8d15-94a931784386" + }, + "FileName": "MeasurementsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/MeasurementsTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "fe6e73f1-3cc8-4c9a-923e-e9a61ab1d637" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "6e82c77f-c724-4056-85b5-8c81f0f54980" + }, + "FileName": "RelationMemberTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 37, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 37, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 115, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "08b15a22-fb75-4e43-8cd7-c960954c519c" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 13, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 13, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 37, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 468, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 15, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 19, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "e0ae6017-3f0b-422f-abb4-dd007ee045df" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "06d6a29c-87d5-47c0-8c59-1f8036366368" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "06d6a29c-87d5-47c0-8c59-1f8036366368" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "1bd755f7-d2da-4e31-a6c4-9eb7feabfc1f" + }, + "FileName": "TagTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagTests.cs", + "FileChanges": [ + { + "LineNumber": 103, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "fe6e73f1-3cc8-4c9a-923e-e9a61ab1d637" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "fe6e73f1-3cc8-4c9a-923e-e9a61ab1d637" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 28, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027entityM\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 15, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 19, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 10, + "CharNumber": 11, + "DiagnosticId": "IDE0130", + "FormatDescription": "warning IDE0130: Namespace \u0022Tests.SpatialLite.Osm.Geometries\u0022 does not match folder structure, expected \u0022Tests.SpatialLite.Osm\u0022" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 126, + "CharNumber": 84, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 13, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 13, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 29, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5ae78cf4-0257-4e39-b1b4-7aca27f7651a" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "08b15a22-fb75-4e43-8cd7-c960954c519c" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "08b15a22-fb75-4e43-8cd7-c960954c519c" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "08b15a22-fb75-4e43-8cd7-c960954c519c" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 90, + "CharNumber": 46, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "27cedf72-3810-4942-9209-555f598d316d" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "6e82c77f-c724-4056-85b5-8c81f0f54980" + }, + "FileName": "RelationMemberTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 6, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 167, + "CharNumber": 86, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 144, + "CharNumber": 29, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027target\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 155, + "CharNumber": 29, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027target\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 99, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 26, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 548, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 161, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 175, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 203, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 217, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 231, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 245, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 259, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 273, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 287, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 301, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 315, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 329, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 343, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 357, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 371, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 385, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 399, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 414, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 429, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 445, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 498, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 499, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 510, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 500, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 511, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 523, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 536, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 524, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "041be709-b2d9-4ea2-bc0e-d4041b6e1d88" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 537, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 95, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 26, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 378, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 117, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027read\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 313, + "CharNumber": 13, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027aaa\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 317, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 178, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 187, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 196, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 214, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 223, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 232, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 250, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 259, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 268, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 277, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 286, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 295, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 340, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 341, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 353, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 354, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 366, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "339d5df9-691d-43a8-9708-4735761019e0" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 367, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 99, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 26, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 460, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 100, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 138, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 164, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 199, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 212, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 225, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 260, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 273, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 286, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 299, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 312, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 349, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 364, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 379, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 410, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 422, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 423, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 411, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 412, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 435, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 436, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 448, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "999bbaa6-633c-4944-9b2c-1db0a5dd5fc8" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 449, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 89, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 110, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 95, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 104, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 111, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 126, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 197, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 250, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 258, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 266, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 389, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 340, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 172, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 181, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 206, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 215, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 224, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 233, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 242, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 275, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 284, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 293, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 302, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 311, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 320, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 329, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 351, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 352, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 364, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 365, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 377, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "16834470-315c-4f1c-a472-a1464972b1cf" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 378, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "e0ae6017-3f0b-422f-abb4-dd007ee045df" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "e0ae6017-3f0b-422f-abb4-dd007ee045df" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "e0ae6017-3f0b-422f-abb4-dd007ee045df" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "11ea7404-3f91-408c-be1c-b3aa8cd5eaeb" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 445, + "CharNumber": 35, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027result\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "06d6a29c-87d5-47c0-8c59-1f8036366368" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "06d6a29c-87d5-47c0-8c59-1f8036366368" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "06d6a29c-87d5-47c0-8c59-1f8036366368" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 212, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "06d6a29c-87d5-47c0-8c59-1f8036366368" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 221, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "ce33ccbc-5f31-4f98-9621-96fedc016dd9" + }, + "FileName": "NodeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 11, + "DiagnosticId": "IDE0130", + "FormatDescription": "warning IDE0130: Namespace \u0022Tests.SpatialLite.Osm.Geometry\u0022 does not match folder structure, expected \u0022Tests.SpatialLite.Osm.Geometries\u0022" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "ce33ccbc-5f31-4f98-9621-96fedc016dd9" + }, + "FileName": "NodeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9b25f26f-0a00-4d89-8884-080e787f94c5" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "b208a0be-f3d4-4af0-a1f5-f2cba8370aca" + }, + "FileName": "AssemblyInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 83, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 106, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 55, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 67, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 77, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 89, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "9ca07e01-4f6f-4a72-b6d8-9ccd5cce359e" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 170, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 51, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 55, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 65, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 69, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 80, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 88, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 101, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 109, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 122, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 130, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 143, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "0ad744fe-e747-45de-949e-d968b64ed7f3" + }, + "FileName": "GpxReaderSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReaderSettings.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "6f69cd72-972c-4fa2-bd7a-90e442ee3f3a" + }, + "FileName": "GpxWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 10, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "6f69cd72-972c-4fa2-bd7a-90e442ee3f3a" + }, + "FileName": "GpxWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "782b100c-f1fd-4d23-bd15-3f461a09f58c" + }, + "FileName": "GpsTrackBase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "782b100c-f1fd-4d23-bd15-3f461a09f58c" + }, + "FileName": "GpsTrackBase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "782b100c-f1fd-4d23-bd15-3f461a09f58c" + }, + "FileName": "GpsTrackBase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs", + "FileChanges": [ + { + "LineNumber": 29, + "CharNumber": 61, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 46, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 23, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 47, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 68, + "CharNumber": 52, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 97, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 125, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 164, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 166, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 190, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 224, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "864ee4fe-49f0-4e3a-8d81-7340671e570f" + }, + "FileName": "GpxWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriter.cs", + "FileChanges": [ + { + "LineNumber": 293, + "CharNumber": 14, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 46, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 307, + "CharNumber": 52, + "DiagnosticId": "IDE0049", + "FormatDescription": "warning IDE0049: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 38, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 39, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 51, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 52, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 53, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 115, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 174, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 144, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 191, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 250, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 265, + "CharNumber": 21, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 267, + "CharNumber": 54, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 435, + "CharNumber": 14, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 96, + "CharNumber": 22, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027geometry\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 59, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 74, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 79, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 84, + "CharNumber": 31, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 101, + "CharNumber": 48, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 102, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "9935c514-43d8-4a3f-adda-a8a8088e3d43" + }, + "FileName": "GpxDocument.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/GpxDocument.cs", + "FileChanges": [ + { + "LineNumber": 103, + "CharNumber": 45, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "0ad744fe-e747-45de-949e-d968b64ed7f3" + }, + "FileName": "GpxReaderSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReaderSettings.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "0ad744fe-e747-45de-949e-d968b64ed7f3" + }, + "FileName": "GpxReaderSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReaderSettings.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "6f69cd72-972c-4fa2-bd7a-90e442ee3f3a" + }, + "FileName": "GpxWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "6f69cd72-972c-4fa2-bd7a-90e442ee3f3a" + }, + "FileName": "GpxWriterSettings.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxWriterSettings.cs", + "FileChanges": [ + { + "LineNumber": 52, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "a1ad78cb-15de-4246-b26f-7466e49810c0" + }, + "FileName": "GpsTrackBaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 22, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 22, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 21, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 35, + "CharNumber": 22, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 36, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "7f51c270-6f00-4c96-9232-2730079ff2b7" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "7f51c270-6f00-4c96-9232-2730079ff2b7" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 14, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 14, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 14, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 14, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 28, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 30, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 35, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 36, + "CharNumber": 14, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 14, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "435b570c-74cd-497e-a562-1b46b47dbe35" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 356, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "f883b86e-0aed-4448-95dc-4a68f9989268" + }, + "FileName": "GpsPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "a1ad78cb-15de-4246-b26f-7466e49810c0" + }, + "FileName": "GpsTrackBaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "a1ad78cb-15de-4246-b26f-7466e49810c0" + }, + "FileName": "GpsTrackBaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs", + "FileChanges": [ + { + "LineNumber": 59, + "CharNumber": 29, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fccae18d-9538-4bcb-b2af-6d7a48366fed" + }, + "FileName": "GpxPointTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "3d76243d-5c8d-4297-909e-bd07ffb0d942" + }, + "FileName": "AssemblyInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 63, + "CharNumber": 45, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 71, + "CharNumber": 45, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 78, + "CharNumber": 13, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027expectedCoordinate\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 90, + "CharNumber": 13, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027expectedCoordinate\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 135, + "CharNumber": 17, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027result\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 132, + "CharNumber": 18, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027result\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 232, + "CharNumber": 25, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027segment\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 416, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 132, + "CharNumber": 9, + "DiagnosticId": "IDE0019", + "FormatDescription": "warning IDE0019: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 30, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 51, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 74, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 88, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 102, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 116, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 127, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 138, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 152, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 166, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 180, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 194, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 205, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 216, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 227, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 238, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 246, + "CharNumber": 17, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "e3c7e223-c84c-4bf5-ae92-c89ac0a37c0d" + }, + "FileName": "AssemblyInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 92, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 106, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 156, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 170, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 184, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 31, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027args\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "56fae660-ecaf-42fd-adfb-9f32141ad54f" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 30, + "DiagnosticId": "CA2211", + "FormatDescription": "warning CA2211: Non-constant fields should not be visible" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "a9cf4449-ac98-405b-8df4-5b595c9e0d90" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 28, + "DiagnosticId": "CA2211", + "FormatDescription": "warning CA2211: Non-constant fields should not be visible" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 177, + "CharNumber": 37, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027WktReader.ParseGeometryTaggedText(WktTokensBuffer)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 703, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027WktReader.Expect(TokenType, WktTokensBuffer)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "6150d930-52a3-4e28-bb18-c27eb4a7d9b1" + }, + "Id": "4f3cc011-fac2-4ba6-8ce0-6580df0d7072" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 722, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027WktReader.Expect(string, WktTokensBuffer)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "f066e82f-5fb1-43aa-9c14-0758097b22ef" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 24, + "CharNumber": 17, + "DiagnosticId": "CA1051", + "FormatDescription": "warning CA1051: Do not declare visible instance fields" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "f066e82f-5fb1-43aa-9c14-0758097b22ef" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 23, + "DiagnosticId": "CA1051", + "FormatDescription": "warning CA1051: Do not declare visible instance fields" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "f066e82f-5fb1-43aa-9c14-0758097b22ef" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 19, + "DiagnosticId": "CA1051", + "FormatDescription": "warning CA1051: Do not declare visible instance fields" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "790fc7ee-02b0-4833-871c-f43e3b55dbc5" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 19, + "DiagnosticId": "CA2208", + "FormatDescription": "warning CA2208: Method .ctor passes \u0027Parameter \u0027key\u0027 can\u0027t be null.\u0027 as the paramName argument to a ArgumentNullException constructor. Replace this argument with one of the method\u0027s parameter names. Note that the provided parameter name should have the exact casing as declared on the method." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "790fc7ee-02b0-4833-871c-f43e3b55dbc5" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 19, + "DiagnosticId": "CA2208", + "FormatDescription": "warning CA2208: Method .ctor passes \u0027Parameter \u0027value\u0027 can\u0027t be null.\u0027 as the paramName argument to a ArgumentNullException constructor. Replace this argument with one of the method\u0027s parameter names. Note that the provided parameter name should have the exact casing as declared on the method." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 105, + "CharNumber": 19, + "DiagnosticId": "CA2208", + "FormatDescription": "warning CA2208: Method FromRelationMemberInfo passes parameter name \u0027info.MemberType cannot be EntityType.Unknown\u0027 as the message argument to a ArgumentException constructor. Replace this argument with a descriptive message and pass the parameter name in the correct position." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "777b09fb-7a53-42ae-8f72-7837741ff413" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 112, + "CharNumber": 45, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027RelationMember.FromRelationMemberInfo(RelationMemberInfo, IEntityCollection\u003CIOsmGeometry\u003E, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "6a147dd0-da76-46d1-9c1e-38f3ec75d284" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 86, + "CharNumber": 23, + "DiagnosticId": "CA2208", + "FormatDescription": "warning CA2208: Method Write passes \u0027Entity.Metadata.User cannot be null.\u0027 as the paramName argument to a ArgumentNullException constructor. Replace this argument with one of the method\u0027s parameter names. Note that the provided parameter name should have the exact casing as declared on the method." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 230, + "CharNumber": 50, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmXmlWriter.WriteRelation(RelationInfo)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 268, + "CharNumber": 49, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmXmlWriter.WriteMetadata(EntityMetadata)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "ace06af5-1f63-41eb-a6d2-5f0706445ac9" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 269, + "CharNumber": 51, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027DateTime.ToString(string)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmXmlWriter.WriteMetadata(EntityMetadata)\u0027 with a call to \u0027DateTime.ToString(string, IFormatProvider)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "b916617b-0b40-4427-bc94-b7c906448b2a" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 113, + "CharNumber": 49, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Way.FromWayInfo(WayInfo, IEntityCollection\u003CIOsmGeometry\u003E, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9b283f59-4990-42c7-bc8a-d4762c88444e" + }, + "FileName": "OsmGeometryDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs", + "FileChanges": [ + { + "LineNumber": 54, + "CharNumber": 57, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmGeometryDatabase.Load(IOsmReader, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "9b283f59-4990-42c7-bc8a-d4762c88444e" + }, + "FileName": "OsmGeometryDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs", + "FileChanges": [ + { + "LineNumber": 82, + "CharNumber": 53, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmGeometryDatabase.Load(IOsmReader, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 101, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027TagsCollection.Add(Tag)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 178, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027TagsCollection.GetTag(string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "4ee9a941-371e-4664-a937-7a69fe2ff122" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 37, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027TagsCollection.GetTag(string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "45cfb199-ad09-4e89-ab78-843d68cf949a" + }, + "Id": "a2ef9fea-d4e5-4199-80ed-52f639fdde76" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 252, + "CharNumber": 49, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027PbfReader.ProcessOsmHeader(OsmHeader)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.XmlOsmReaderReadsFilesCreatedByOsmosis()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "5c68d624-0d8d-4d0c-ae65-bb4945c7ce1d" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 44, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.XmlOsmWriterWritesFilesCompatibleWithOsmosis()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_NoDenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 36, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_DenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 50, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_NoDenseDeflateCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 64, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 87, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 108, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseDeflate()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 129, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_DenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "559fa06e-289e-4a3e-a933-18bf95a1ab2e" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 150, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 103, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 113, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 116, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 148, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "f9dac0c2-638b-4e93-8ae2-f52ccfcd8536" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 158, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 103, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 113, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "9eee0014-67ab-4e4c-b8ca-2032046c589a" + }, + "Id": "07b2aff0-b3af-44f4-a0a0-4a0d7322d05e" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 116, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5f478633-eb8a-43ab-a663-12d84e8e34ca" + }, + "Id": "ce5abc5d-26c9-4cbd-a08f-2e40bddb633c" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 307, + "CharNumber": 52, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027GpxReader.InitializeReader()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fac7b045-dc0d-49d2-a0b7-0b30c34597be" + }, + "FileName": "XDocumentExtensions.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 21, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027XDocumentExtensions.XMLCompare(XElement, XElement)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "fac7b045-dc0d-49d2-a0b7-0b30c34597be" + }, + "FileName": "XDocumentExtensions.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 45, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027XDocumentExtensions.XMLCompare(XElement, XElement)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 166, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 196, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "fd8ab0d1-cef1-4bf7-8102-8de2b78edec8" + }, + "Id": "37c3a629-8a65-481f-8aba-1be88c985830" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 390, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 34, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.Main(string[])\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 53, + "CharNumber": 27, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.DoTest(Action, string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 58, + "CharNumber": 27, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.DoTest(Action, string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "3eb4de73-2a83-43bc-9cb9-63f383738370" + }, + "Id": "c3b2b23f-4ebc-4e90-9d0c-3f09535ee5cf" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 66, + "CharNumber": 31, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.DoTest(Action, string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + } +] \ No newline at end of file From 723d08b3eaac5a28e6468ad17d0e23b25763023c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 21:01:44 +0000 Subject: [PATCH 07/14] Partial formatting fixes from dotnet format Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- fixed-issues.json | 7274 +++++++++++++++++ src/Benchmark.SpatialLite.Osm/Program.cs | 60 +- .../Properties/AssemblyInfo.cs | 1 - src/SpatialLite.Core/API/Coordinate.cs | 32 +- src/SpatialLite.Core/API/Envelope.cs | 79 +- .../Algorithms/Euclidean2DCalculator.cs | 10 +- .../Algorithms/Euclidean2DLocator.cs | 9 +- .../Algorithms/Sphere2DCalculator.cs | 27 +- .../Geometries/CoordinateList.cs | 7 +- src/SpatialLite.Core/Geometries/Geometry.cs | 5 +- .../Geometries/GeometryCollection.cs | 7 +- src/SpatialLite.Core/Geometries/LineString.cs | 12 +- .../Geometries/MultiLineString.cs | 7 +- src/SpatialLite.Core/Geometries/MultiPoint.cs | 7 +- .../Geometries/MultiPolygon.cs | 7 +- src/SpatialLite.Core/Geometries/Point.cs | 9 +- src/SpatialLite.Core/Geometries/Polygon.cs | 25 +- .../Geometries/ReadOnlyCoordinateList.cs | 14 +- src/SpatialLite.Core/IO/WkbReader.cs | 62 +- src/SpatialLite.Core/IO/WkbWriter.cs | 69 +- src/SpatialLite.Core/IO/WkbWriterSettings.cs | 5 +- src/SpatialLite.Core/IO/WktReader.cs | 193 +- src/SpatialLite.Core/IO/WktTokenizer.cs | 6 +- src/SpatialLite.Core/IO/WktTokensBuffer.cs | 6 +- src/SpatialLite.Core/IO/WktWriter.cs | 95 +- src/SpatialLite.Core/Measurements.cs | 25 +- src/SpatialLite.Core/Topology.cs | 30 +- src/SpatialLite.Gps/Geometries/GpsPoint.cs | 4 +- .../Geometries/GpsTrackBase.cs | 10 +- src/SpatialLite.Gps/Geometries/GpxMetadata.cs | 6 +- src/SpatialLite.Gps/Geometries/GpxPoint.cs | 4 +- src/SpatialLite.Gps/Geometries/GpxTrack.cs | 4 +- src/SpatialLite.Gps/GpxDocument.cs | 34 +- src/SpatialLite.Gps/IGpsPoint.cs | 4 +- src/SpatialLite.Gps/IO/GpxReader.cs | 44 +- src/SpatialLite.Gps/IO/GpxReaderSettings.cs | 7 +- src/SpatialLite.Gps/IO/GpxWriter.cs | 34 +- src/SpatialLite.Gps/IO/GpxWriterSettings.cs | 9 +- src/SpatialLite.Osm/EntityCollection.cs | 6 +- src/SpatialLite.Osm/Geometries/Node.cs | 4 +- .../Geometries/OsmGeometryDatabase.cs | 7 +- src/SpatialLite.Osm/Geometries/Relation.cs | 9 +- .../Geometries/RelationMember.cs | 32 +- src/SpatialLite.Osm/Geometries/Way.cs | 20 +- .../Geometries/WayCoordinateList.cs | 15 +- src/SpatialLite.Osm/IO/IOsmWriter.cs | 4 +- src/SpatialLite.Osm/IO/OsmReaderSettings.cs | 7 +- src/SpatialLite.Osm/IO/OsmWriterSettings.cs | 11 +- src/SpatialLite.Osm/IO/OsmXmlReader.cs | 58 +- .../IO/OsmXmlReaderSettings.cs | 2 +- src/SpatialLite.Osm/IO/OsmXmlWriter.cs | 67 +- src/SpatialLite.Osm/IO/Pbf/Blob.cs | 1 - src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs | 1 - .../IO/Pbf/EntityInfoBuffer.cs | 14 +- src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs | 1 - src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs | 5 +- src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs | 1 - .../IO/Pbf/PbfDenseMetadata.cs | 5 +- src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs | 5 +- src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs | 1 - src/SpatialLite.Osm/IO/Pbf/PbfNode.cs | 6 +- src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs | 5 +- src/SpatialLite.Osm/IO/Pbf/PbfWay.cs | 5 +- src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs | 5 +- src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs | 6 +- src/SpatialLite.Osm/IO/Pbf/StringTable.cs | 13 +- src/SpatialLite.Osm/IO/PbfReader.cs | 79 +- src/SpatialLite.Osm/IO/PbfWriter.cs | 107 +- src/SpatialLite.Osm/IO/PbfWriterSettings.cs | 8 +- src/SpatialLite.Osm/IOsmEntity.cs | 1 - src/SpatialLite.Osm/NodeInfo.cs | 25 +- src/SpatialLite.Osm/OsmDatabase.cs | 72 +- src/SpatialLite.Osm/OsmEntityInfoDatabase.cs | 7 +- src/SpatialLite.Osm/RelationInfo.cs | 22 +- src/SpatialLite.Osm/RelationMemberInfo.cs | 7 +- src/SpatialLite.Osm/Tag.cs | 14 +- src/SpatialLite.Osm/TagsCollection.cs | 24 +- src/SpatialLite.Osm/WayInfo.cs | 25 +- .../API/CoordinateTests.cs | 17 +- .../API/EnvelopeTests.cs | 24 +- .../Algorithms/Euclidean2DCalculatorTests.cs | 13 +- .../Algorithms/Euclidean2DLocatorTests.cs | 13 +- .../Algorithms/Sphere2DCalculatorTests.cs | 11 +- .../Data/TestDataReader.cs | 6 +- .../Geometries/CoordinateListTests.cs | 15 +- .../Geometries/GeometryCollectionTests.cs | 17 +- .../Geometries/LineStringTests.cs | 19 +- .../Geometries/MultiLineStringTests.cs | 7 +- .../Geometries/MultiPointTests.cs | 7 +- .../Geometries/MultiPolygonTests.cs | 7 +- .../Geometries/PointTests.cs | 23 +- .../Geometries/PolygonTests.cs | 25 +- .../Geometries/ReadOnlyCoordinateListTests.cs | 14 +- .../IO/WkbReaderTests.cs | 179 +- .../IO/WkbWriterSettingsTests.cs | 9 +- .../IO/WkbWriterTests.cs | 180 +- .../IO/WktReaderTests.cs | 129 +- .../IO/WktTokenizerTests.cs | 18 +- .../IO/WktTokensBufferTests.cs | 10 +- .../IO/WktWriterSettingsTests.cs | 9 +- .../IO/WktWriterTests.cs | 49 +- .../MeasurementsTests.cs | 13 +- src/Tests.SpatialLite.Core/PathHelper.cs | 4 +- .../Properties/AssemblyInfo.cs | 1 - src/Tests.SpatialLite.Core/TopologyTests.cs | 11 +- .../Geometries/GpsPointTests.cs | 18 +- .../Geometries/GpsTrackBaseTests.cs | 11 +- .../Geometries/GpxFixHelperTests.cs | 4 +- .../Geometries/GpxLinkTests.cs | 4 +- .../Geometries/GpxMetadataTests.cs | 5 +- .../Geometries/GpxPointTests.cs | 20 +- .../Geometries/GpxRouteTests.cs | 6 +- .../Geometries/GpxTrackSegmentTests.cs | 4 +- src/Tests.SpatialLite.Gps/GpxDocumentTests.cs | 12 +- .../IO/GpxReaderSettingsTests.cs | 4 +- .../IO/GpxReaderTests.cs | 31 +- .../IO/GpxWriterSettingsTests.cs | 4 +- .../IO/GpxWriterTests.cs | 30 +- src/Tests.SpatialLite.Gps/PathHelper.cs | 4 +- .../Properties/AssemblyInfo.cs | 1 - 120 files changed, 8475 insertions(+), 1463 deletions(-) create mode 100644 fixed-issues.json diff --git a/fixed-issues.json b/fixed-issues.json new file mode 100644 index 0000000..d8cb283 --- /dev/null +++ b/fixed-issues.json @@ -0,0 +1,7274 @@ +[ + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "bc32bfd4-d4ac-4eea-b11e-3db5154170b4" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "93bc939e-0308-4f3d-ae59-93a592e9b2db" + }, + "FileName": "NodeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0870c5ba-8152-4c5f-bc26-d8d5b81fc3ca" + }, + "FileName": "RelationMemberTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "64f601f5-8bac-46ba-bd1e-8684a16941c1" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "bc37fab0-a749-4a7d-9f29-f46b231045c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "c3031663-ae75-478f-aa99-e3adebfa9fa0" + }, + "FileName": "OsmReaderSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "a04f610e-1457-4b4b-b98a-691565cd4db7" + }, + "FileName": "OsmWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "c2de3379-b0ab-475a-8616-3a1e6d29a97e" + }, + "FileName": "PbfWriterSettingsTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "be122f27-6289-4e52-b503-0bd9a3b24a4b" + }, + "FileName": "NodeInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/NodeInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d6a88c59-9b64-45e2-a2a4-2a6a3508265d" + }, + "FileName": "RelationInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/RelationInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "3494aece-9bea-496b-bc18-d63be00115bf" + }, + "FileName": "RelationMemberInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "1d33d565-9db7-4987-82c1-941c348333b8" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "3fe9b312-d096-4829-ba34-67c2374b3390" + }, + "FileName": "TagTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8ac04eca-7311-492d-9d50-22aeeecfc006" + }, + "FileName": "WayInfoTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/WayInfoTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IMPORTS", + "FormatDescription": "Fix imports ordering." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "52bb6d4b-3328-4e1f-8fbd-66b263062c57" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "52bb6d4b-3328-4e1f-8fbd-66b263062c57" + }, + "FileName": "Measurements.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Measurements.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "67ad1dd5-5964-4a9a-bedf-26c7e226456c" + }, + "FileName": "Topology.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/Topology.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 38, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 62, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 106, + "CharNumber": 13, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 110, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 114, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 118, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 122, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 126, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "40b32acd-4560-4165-83e5-1a2b3eb1c8a4" + }, + "FileName": "WktWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktWriter.cs", + "FileChanges": [ + { + "LineNumber": 130, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 41, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 190, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 327, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 328, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 400, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 401, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 482, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 481, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 531, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 530, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 580, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 579, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 629, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 628, + "CharNumber": 14, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 649, + "CharNumber": 106, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 649, + "CharNumber": 117, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "52009b7b-a8dd-4b4d-a9bb-2d9edc3b0063" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 26, + "DiagnosticId": "IDE0251", + "FormatDescription": "warning IDE0251: Member can be made \u0027readonly\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "efb5d85f-724a-44d0-a28d-d25be59e22dc" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 356, + "CharNumber": 98, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027is3D\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "efb5d85f-724a-44d0-a28d-d25be59e22dc" + }, + "FileName": "WkbReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbReader.cs", + "FileChanges": [ + { + "LineNumber": 356, + "CharNumber": 109, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027isMeasured\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "ce3eb91d-566b-4882-aac7-be031ebeb09f" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 133, + "CharNumber": 13, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "ce3eb91d-566b-4882-aac7-be031ebeb09f" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 137, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "ce3eb91d-566b-4882-aac7-be031ebeb09f" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 141, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "ce3eb91d-566b-4882-aac7-be031ebeb09f" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 145, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "ce3eb91d-566b-4882-aac7-be031ebeb09f" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 149, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "ce3eb91d-566b-4882-aac7-be031ebeb09f" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 153, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "ce3eb91d-566b-4882-aac7-be031ebeb09f" + }, + "FileName": "WkbWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WkbWriter.cs", + "FileChanges": [ + { + "LineNumber": 157, + "CharNumber": 18, + "DiagnosticId": "IDE0038", + "FormatDescription": "warning IDE0038: Use pattern matching" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "56817a13-5005-47ae-aa04-81de12d6f097" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 8, + "CharNumber": 29, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "56817a13-5005-47ae-aa04-81de12d6f097" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 29, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "56817a13-5005-47ae-aa04-81de12d6f097" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 10, + "CharNumber": 29, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "56817a13-5005-47ae-aa04-81de12d6f097" + }, + "FileName": "CoordinateTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/API/CoordinateTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 29, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Missing prefix: \u0027_\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "72d7030b-75ea-4aa5-8828-e7b5be2bed4a" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 36, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "812bac79-24fa-4fc0-a7c1-d986ca4690a4" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "812bac79-24fa-4fc0-a7c1-d986ca4690a4" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "812bac79-24fa-4fc0-a7c1-d986ca4690a4" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "812bac79-24fa-4fc0-a7c1-d986ca4690a4" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "812bac79-24fa-4fc0-a7c1-d986ca4690a4" + }, + "FileName": "WktWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 42, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "71a7208d-3728-4eb4-b648-c65f1d819869" + }, + "Id": "8415e92a-6983-476c-af5b-b8bb9ba852af" + }, + "FileName": "WkbReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 487, + "CharNumber": 38, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027expected\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "bc32bfd4-d4ac-4eea-b11e-3db5154170b4" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0870c5ba-8152-4c5f-bc26-d8d5b81fc3ca" + }, + "FileName": "RelationMemberTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 37, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 18, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 37, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 115, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "64f601f5-8bac-46ba-bd1e-8684a16941c1" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 13, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 13, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 37, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 468, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 15, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 20, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 19, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "357b0ac2-a5dc-4a91-937c-7862f8ede1bb" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 14, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "1d33d565-9db7-4987-82c1-941c348333b8" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "1d33d565-9db7-4987-82c1-941c348333b8" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 11, + "DiagnosticId": "IDE0040", + "FormatDescription": "warning IDE0040: Accessibility modifiers required" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "3fe9b312-d096-4829-ba34-67c2374b3390" + }, + "FileName": "TagTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagTests.cs", + "FileChanges": [ + { + "LineNumber": 103, + "CharNumber": 1, + "DiagnosticId": "IDE2002", + "FormatDescription": "warning IDE2002: Consecutive braces must not have blank line between them" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "357b0ac2-a5dc-4a91-937c-7862f8ede1bb" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "357b0ac2-a5dc-4a91-937c-7862f8ede1bb" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "357b0ac2-a5dc-4a91-937c-7862f8ede1bb" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "64f601f5-8bac-46ba-bd1e-8684a16941c1" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "64f601f5-8bac-46ba-bd1e-8684a16941c1" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "64f601f5-8bac-46ba-bd1e-8684a16941c1" + }, + "FileName": "WayCoordinateListTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs", + "FileChanges": [ + { + "LineNumber": 90, + "CharNumber": 46, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 18, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "e0437398-81ae-4d1a-81bd-709217687aac" + }, + "FileName": "RelationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 15, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 19, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 10, + "CharNumber": 11, + "DiagnosticId": "IDE0130", + "FormatDescription": "warning IDE0130: Namespace \u0022Tests.SpatialLite.Osm.Geometries\u0022 does not match folder structure, expected \u0022Tests.SpatialLite.Osm\u0022" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 5, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 126, + "CharNumber": 84, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 6, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 167, + "CharNumber": 86, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 144, + "CharNumber": 29, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027target\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 155, + "CharNumber": 29, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027target\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 89, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 110, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 95, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 104, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 111, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 126, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 134, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 197, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 250, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 258, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 266, + "CharNumber": 37, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 389, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 340, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 172, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 181, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 206, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 215, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 224, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 233, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 242, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 275, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 284, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 293, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 302, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 311, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 320, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 329, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 351, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 352, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 364, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 365, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 377, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "fada21b7-db63-4faf-8028-2119ddf28398" + }, + "FileName": "OsmXmlReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 378, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 13, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 13, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 29, + "DiagnosticId": "IDE0004", + "FormatDescription": "warning IDE0004: Cast is redundant." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0fca1f3b-9472-47e1-8ccb-9174d1393d36" + }, + "FileName": "WayTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 99, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 26, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 548, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 161, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 175, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 217, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 203, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 231, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 245, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 259, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 273, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 301, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 287, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 315, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 329, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 343, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 357, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 371, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 385, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 399, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 414, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 429, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 445, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 498, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 499, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 500, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 510, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 511, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 523, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 524, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 536, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "7b485e90-2b34-47b2-9791-517335508481" + }, + "FileName": "PbfWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 537, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "0870c5ba-8152-4c5f-bc26-d8d5b81fc3ca" + }, + "FileName": "RelationMemberTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "bc32bfd4-d4ac-4eea-b11e-3db5154170b4" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "bc32bfd4-d4ac-4eea-b11e-3db5154170b4" + }, + "FileName": "EntityCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 28, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027entityM\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "1d33d565-9db7-4987-82c1-941c348333b8" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 11, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "1d33d565-9db7-4987-82c1-941c348333b8" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "1d33d565-9db7-4987-82c1-941c348333b8" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 212, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "1d33d565-9db7-4987-82c1-941c348333b8" + }, + "FileName": "TagsCollectionTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs", + "FileChanges": [ + { + "LineNumber": 221, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 16, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 95, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 26, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 378, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 117, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027read\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 317, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 313, + "CharNumber": 13, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027aaa\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 142, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 160, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 178, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 196, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 187, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 214, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 232, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 223, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 250, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 259, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 268, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 277, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 286, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 295, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 340, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 341, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 353, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 354, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 366, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "863e8e60-96f1-4ec8-bd60-df4a6d9ad360" + }, + "FileName": "PbfReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 367, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 12, + "CharNumber": 12, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 13, + "CharNumber": 11, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 16, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 20, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "63cda3c8-68fc-40f5-8028-1317f3eb65c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 445, + "CharNumber": 35, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027result\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 17, + "CharNumber": 28, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 22, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 29, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 18, + "CharNumber": 40, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 21, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 27, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 37, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 53, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 26, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 41, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 55, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 74, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 99, + "DiagnosticId": "IDE0044", + "FormatDescription": "warning IDE0044: Make field readonly" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 26, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 460, + "CharNumber": 34, + "DiagnosticId": "IDE0200", + "FormatDescription": "warning IDE0200: Lambda expression can be removed" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 100, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 138, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 164, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 199, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 225, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 212, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 260, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 273, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 286, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 299, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 312, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 349, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 364, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 379, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 410, + "CharNumber": 35, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 411, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 412, + "CharNumber": 39, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 422, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 423, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 435, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 436, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 448, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9651ad0a-44e9-4a86-b71a-2f644e240066" + }, + "FileName": "OsmXmlWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 449, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "93bc939e-0308-4f3d-ae59-93a592e9b2db" + }, + "FileName": "NodeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs", + "FileChanges": [ + { + "LineNumber": 7, + "CharNumber": 11, + "DiagnosticId": "IDE0130", + "FormatDescription": "warning IDE0130: Namespace \u0022Tests.SpatialLite.Osm.Geometry\u0022 does not match folder structure, expected \u0022Tests.SpatialLite.Osm.Geometries\u0022" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "93bc939e-0308-4f3d-ae59-93a592e9b2db" + }, + "FileName": "NodeTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs", + "FileChanges": [ + { + "LineNumber": 1, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "bc37fab0-a749-4a7d-9f29-f46b231045c0" + }, + "FileName": "OsmDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 4, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "a67f1e23-3df1-4b1f-8e1f-31f076301c74" + }, + "FileName": "AssemblyInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs", + "FileChanges": [ + { + "LineNumber": 2, + "CharNumber": 1, + "DiagnosticId": "IDE0005", + "FormatDescription": "warning IDE0005: Using directive is unnecessary." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 106, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 33, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 55, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 67, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 77, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 89, + "CharNumber": 34, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "8d1ab9ca-9bba-4528-89f6-b145c7dd2270" + }, + "FileName": "PbfReaderPbfWriterComplianceTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs", + "FileChanges": [ + { + "LineNumber": 99, + "CharNumber": 17, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 83, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 170, + "CharNumber": 21, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027info\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 27, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 37, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 41, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 51, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 55, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 65, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 69, + "CharNumber": 13, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 80, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 88, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 101, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 109, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 122, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 130, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 143, + "CharNumber": 40, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 151, + "CharNumber": 9, + "DiagnosticId": "IDE0003", + "FormatDescription": "warning IDE0003: Name can be simplified" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "8c7cafa4-e754-449f-a37c-07982ce3bdb3" + }, + "Id": "5e65b245-7f22-4157-a80e-40f79ededc84" + }, + "FileName": "PathHelper.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/PathHelper.cs", + "FileChanges": [ + { + "LineNumber": 9, + "CharNumber": 36, + "DiagnosticId": "IDE1006", + "FormatDescription": "warning IDE1006: Naming rule violation: Prefix \u0027_\u0027 is not expected" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "8c7cafa4-e754-449f-a37c-07982ce3bdb3" + }, + "Id": "481a65ce-e8b7-4bb4-9c43-19432d870a35" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 132, + "CharNumber": 18, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027result\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "8c7cafa4-e754-449f-a37c-07982ce3bdb3" + }, + "Id": "481a65ce-e8b7-4bb4-9c43-19432d870a35" + }, + "FileName": "GpxReaderTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs", + "FileChanges": [ + { + "LineNumber": 415, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "8c7cafa4-e754-449f-a37c-07982ce3bdb3" + }, + "Id": "493926ca-4277-4a81-9597-648e581b2597" + }, + "FileName": "GpxWriterTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs", + "FileChanges": [ + { + "LineNumber": 354, + "CharNumber": 20, + "DiagnosticId": "IDE0059", + "FormatDescription": "warning IDE0059: Unnecessary assignment of a value to \u0027testStream\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "56cdf2f5-5363-4b78-9022-64b088cf1991" + }, + "Id": "d89817ed-fdd4-4d31-a1d8-873e23250557" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 15, + "CharNumber": 39, + "DiagnosticId": "IDE0060", + "FormatDescription": "warning IDE0060: Remove unused parameter \u0027args\u0027" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "52009b7b-a8dd-4b4d-a9bb-2d9edc3b0063" + }, + "FileName": "Coordinate.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Coordinate.cs", + "FileChanges": [ + { + "LineNumber": 20, + "CharNumber": 30, + "DiagnosticId": "CA2211", + "FormatDescription": "warning CA2211: Non-constant fields should not be visible" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "afad0e2f-a3b1-4308-bac6-4338a03bbeaf" + }, + "FileName": "Envelope.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/API/Envelope.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 28, + "DiagnosticId": "CA2211", + "FormatDescription": "warning CA2211: Non-constant fields should not be visible" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 175, + "CharNumber": 37, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027WktReader.ParseGeometryTaggedText(WktTokensBuffer)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 701, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027WktReader.Expect(TokenType, WktTokensBuffer)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "e17dd4ca-3729-40c0-bbde-6a5ac2e5c5f2" + }, + "Id": "e7233b69-2233-4c56-bfef-0bbd562fdda6" + }, + "FileName": "WktReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Core/IO/WktReader.cs", + "FileChanges": [ + { + "LineNumber": 720, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027WktReader.Expect(string, WktTokensBuffer)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "f5c02abf-1e71-4b6a-b132-781ff554bd31" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 14, + "CharNumber": 23, + "DiagnosticId": "CA1051", + "FormatDescription": "warning CA1051: Do not declare visible instance fields" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "f5c02abf-1e71-4b6a-b132-781ff554bd31" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 19, + "CharNumber": 19, + "DiagnosticId": "CA1051", + "FormatDescription": "warning CA1051: Do not declare visible instance fields" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "f5c02abf-1e71-4b6a-b132-781ff554bd31" + }, + "FileName": "RelationMemberInfo.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/RelationMemberInfo.cs", + "FileChanges": [ + { + "LineNumber": 24, + "CharNumber": 17, + "DiagnosticId": "CA1051", + "FormatDescription": "warning CA1051: Do not declare visible instance fields" + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "77a4ef26-a24b-4770-8bf4-cbbd8d9faba8" + }, + "FileName": "PbfWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfWriter.cs", + "FileChanges": [ + { + "LineNumber": 86, + "CharNumber": 23, + "DiagnosticId": "CA2208", + "FormatDescription": "warning CA2208: Method Write passes \u0027Entity.Metadata.User cannot be null.\u0027 as the paramName argument to a ArgumentNullException constructor. Replace this argument with one of the method\u0027s parameter names. Note that the provided parameter name should have the exact casing as declared on the method." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "edb0e786-ea3d-462d-9fa5-57ff3adb8dc8" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 23, + "CharNumber": 19, + "DiagnosticId": "CA2208", + "FormatDescription": "warning CA2208: Method .ctor passes \u0027Parameter \u0027key\u0027 can\u0027t be null.\u0027 as the paramName argument to a ArgumentNullException constructor. Replace this argument with one of the method\u0027s parameter names. Note that the provided parameter name should have the exact casing as declared on the method." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "edb0e786-ea3d-462d-9fa5-57ff3adb8dc8" + }, + "FileName": "Tag.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Tag.cs", + "FileChanges": [ + { + "LineNumber": 32, + "CharNumber": 33, + "DiagnosticId": "CA2208", + "FormatDescription": "warning CA2208: Method .ctor passes \u0027Parameter \u0027value\u0027 can\u0027t be null.\u0027 as the paramName argument to a ArgumentNullException constructor. Replace this argument with one of the method\u0027s parameter names. Note that the provided parameter name should have the exact casing as declared on the method." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "87f54854-56dd-479e-8950-69bbdd4e0246" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 230, + "CharNumber": 50, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmXmlWriter.WriteRelation(RelationInfo)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "87f54854-56dd-479e-8950-69bbdd4e0246" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 268, + "CharNumber": 49, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmXmlWriter.WriteMetadata(EntityMetadata)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "87f54854-56dd-479e-8950-69bbdd4e0246" + }, + "FileName": "OsmXmlWriter.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/OsmXmlWriter.cs", + "FileChanges": [ + { + "LineNumber": 269, + "CharNumber": 51, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027DateTime.ToString(string)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmXmlWriter.WriteMetadata(EntityMetadata)\u0027 with a call to \u0027DateTime.ToString(string, IFormatProvider)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "9608afb3-f9b1-4700-98eb-949370e03fb8" + }, + "FileName": "RelationMember.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/RelationMember.cs", + "FileChanges": [ + { + "LineNumber": 107, + "CharNumber": 45, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027RelationMember.FromRelationMemberInfo(RelationMemberInfo, IEntityCollection\u003CIOsmGeometry\u003E, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "1db3f4b4-ebed-4410-820e-a6c3bb75c293" + }, + "FileName": "Way.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/Way.cs", + "FileChanges": [ + { + "LineNumber": 112, + "CharNumber": 49, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Way.FromWayInfo(WayInfo, IEntityCollection\u003CIOsmGeometry\u003E, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "2cd44d1c-833e-46db-9906-ea3dc07acf03" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 101, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027TagsCollection.Add(Tag)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "2cd44d1c-833e-46db-9906-ea3dc07acf03" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 178, + "CharNumber": 41, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027TagsCollection.GetTag(string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "2cd44d1c-833e-46db-9906-ea3dc07acf03" + }, + "FileName": "TagsCollection.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/TagsCollection.cs", + "FileChanges": [ + { + "LineNumber": 189, + "CharNumber": 37, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027TagsCollection.GetTag(string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "c2c28496-5280-47df-b525-69a9c43259b7" + }, + "FileName": "OsmGeometryDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs", + "FileChanges": [ + { + "LineNumber": 54, + "CharNumber": 57, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmGeometryDatabase.Load(IOsmReader, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "c2c28496-5280-47df-b525-69a9c43259b7" + }, + "FileName": "OsmGeometryDatabase.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs", + "FileChanges": [ + { + "LineNumber": 82, + "CharNumber": 53, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmGeometryDatabase.Load(IOsmReader, bool)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "d4ffe564-7b3a-4eef-97e5-ce8cf40b3465" + }, + "Id": "96f17232-e6d4-41be-bfca-0c02bd160f9e" + }, + "FileName": "PbfReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Osm/IO/PbfReader.cs", + "FileChanges": [ + { + "LineNumber": 251, + "CharNumber": 49, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027PbfReader.ProcessOsmHeader(OsmHeader)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 44, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.XmlOsmWriterWritesFilesCompatibleWithOsmosis()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "9db43cf8-62ef-4b26-a668-9e7243cbdf3f" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.XmlOsmReaderReadsFilesCreatedByOsmosis()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 22, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_NoDenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 36, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_DenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 50, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_NoDenseDeflateCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 64, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 87, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 108, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseDeflate()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 129, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_DenseNoCompression()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "d95b7e5f-5f52-464b-a0d7-a3592f4d8dde" + }, + "FileName": "OsmosisIntegrationTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs", + "FileChanges": [ + { + "LineNumber": 150, + "CharNumber": 35, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027OsmosisIntegrationTests.PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 103, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 113, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "5a2fda55-e67b-4ccd-911f-3f653ab3c9e7" + }, + "FileName": "OsmEntityInfoDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 116, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 103, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 113, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 116, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 148, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Empty instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "5cb25fe8-3013-415a-a68c-f5b2f2a2cb80" + }, + "Id": "4912a107-841e-4f3d-afee-799cf0c3dfaa" + }, + "FileName": "OsmGeometryDatabaseTests.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs", + "FileChanges": [ + { + "LineNumber": 158, + "CharNumber": 9, + "DiagnosticId": "xUnit2013", + "FormatDescription": "warning xUnit2013: Do not use Assert.Equal() to check for collection size. Use Assert.Single instead." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "08da9533-1a49-45f5-9d2b-7d7a4ab8d3f8" + }, + "Id": "0da41dc6-843a-4974-9d00-56bcb7fd2657" + }, + "FileName": "GpxReader.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/SpatialLite.Gps/IO/GpxReader.cs", + "FileChanges": [ + { + "LineNumber": 307, + "CharNumber": 52, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027GpxReader.InitializeReader()\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "8c7cafa4-e754-449f-a37c-07982ce3bdb3" + }, + "Id": "070e8087-eef4-4eef-831a-4158c41cde83" + }, + "FileName": "XDocumentExtensions.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 21, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027XDocumentExtensions.XMLCompare(XElement, XElement)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "8c7cafa4-e754-449f-a37c-07982ce3bdb3" + }, + "Id": "070e8087-eef4-4eef-831a-4158c41cde83" + }, + "FileName": "XDocumentExtensions.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs", + "FileChanges": [ + { + "LineNumber": 31, + "CharNumber": 45, + "DiagnosticId": "CA1304", + "FormatDescription": "warning CA1304: The behavior of \u0027string.ToLower()\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027XDocumentExtensions.XMLCompare(XElement, XElement)\u0027 with a call to \u0027string.ToLower(CultureInfo)\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "56cdf2f5-5363-4b78-9022-64b088cf1991" + }, + "Id": "d89817ed-fdd4-4d31-a1d8-873e23250557" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 45, + "CharNumber": 34, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.Main(string[])\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "56cdf2f5-5363-4b78-9022-64b088cf1991" + }, + "Id": "d89817ed-fdd4-4d31-a1d8-873e23250557" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 53, + "CharNumber": 27, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.DoTest(Action, string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "56cdf2f5-5363-4b78-9022-64b088cf1991" + }, + "Id": "d89817ed-fdd4-4d31-a1d8-873e23250557" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 58, + "CharNumber": 27, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.DoTest(Action, string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + }, + { + "DocumentId": { + "ProjectId": { + "Id": "56cdf2f5-5363-4b78-9022-64b088cf1991" + }, + "Id": "d89817ed-fdd4-4d31-a1d8-873e23250557" + }, + "FileName": "Program.cs", + "FilePath": "/home/runner/work/SpatialLITE/SpatialLITE/src/Benchmark.SpatialLite.Osm/Program.cs", + "FileChanges": [ + { + "LineNumber": 66, + "CharNumber": 31, + "DiagnosticId": "CA1305", + "FormatDescription": "warning CA1305: The behavior of \u0027string.Format(string, object)\u0027 could vary based on the current user\u0027s locale settings. Replace this call in \u0027Program.DoTest(Action, string)\u0027 with a call to \u0027string.Format(IFormatProvider, string, params object[])\u0027." + } + ] + } +] \ No newline at end of file diff --git a/src/Benchmark.SpatialLite.Osm/Program.cs b/src/Benchmark.SpatialLite.Osm/Program.cs index 5dfc31f..cf5d844 100644 --- a/src/Benchmark.SpatialLite.Osm/Program.cs +++ b/src/Benchmark.SpatialLite.Osm/Program.cs @@ -10,9 +10,9 @@ namespace Benchmark.SpatialLite.Osm; public class Program { - static List _entities; + private static List _entities; - static void Main(string[] args) + private static void Main(string[] args) { List> benchmarks = new List>(); benchmarks.Add(new Tuple("XmlReader with metadata", TestXmlReaderSpeed)); @@ -48,7 +48,7 @@ static void Main(string[] args) } } - static long DoTest(Action testAction, string testName) + private static long DoTest(Action testAction, string testName) { Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); @@ -71,7 +71,7 @@ static long DoTest(Action testAction, string testName) return totalTime / 10; } - static void LoadSourceData() + private static void LoadSourceData() { _entities = new List(); @@ -85,13 +85,13 @@ static void LoadSourceData() } } - static void TestXmlReaderSpeed() + private static void TestXmlReaderSpeed() { int entitiesRead = 0; - - IEntityInfo info = null; using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) { + + IEntityInfo info; while ((info = reader.Read()) != null) { entitiesRead++; @@ -99,13 +99,13 @@ static void TestXmlReaderSpeed() } } - static void TestXmlReaderSpeedWithoutMetadata() + private static void TestXmlReaderSpeedWithoutMetadata() { int entitiesRead = 0; - - IEntityInfo info = null; using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) { + + IEntityInfo info; while ((info = reader.Read()) != null) { entitiesRead++; @@ -113,7 +113,7 @@ static void TestXmlReaderSpeedWithoutMetadata() } } - static void TestXmlWriterSpeed() + private static void TestXmlWriterSpeed() { using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) { @@ -124,7 +124,7 @@ static void TestXmlWriterSpeed() } } - static void TestXmlWriterSpeedWithoutMetadata() + private static void TestXmlWriterSpeedWithoutMetadata() { using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) { @@ -135,13 +135,13 @@ static void TestXmlWriterSpeedWithoutMetadata() } } - static void TestPbfReaderSpeedNoDenseNoCompression() + private static void TestPbfReaderSpeedNoDenseNoCompression() { int entitiesRead = 0; - - IEntityInfo info = null; using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) { + + IEntityInfo info; while ((info = reader.Read()) != null) { entitiesRead++; @@ -149,13 +149,13 @@ static void TestPbfReaderSpeedNoDenseNoCompression() } } - static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() + private static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() { int entitiesRead = 0; - - IEntityInfo info = null; using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) { + + IEntityInfo info; while ((info = reader.Read()) != null) { entitiesRead++; @@ -163,13 +163,13 @@ static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() } } - static void TestPbfReaderSpeedDenseDeflate() + private static void TestPbfReaderSpeedDenseDeflate() { int entitiesRead = 0; - - IEntityInfo info = null; using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { + + IEntityInfo info; while ((info = reader.Read()) != null) { entitiesRead++; @@ -177,13 +177,13 @@ static void TestPbfReaderSpeedDenseDeflate() } } - static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() + private static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() { int entitiesRead = 0; - - IEntityInfo info = null; using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) { + + IEntityInfo info; while ((info = reader.Read()) != null) { entitiesRead++; @@ -191,7 +191,7 @@ static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() } } - static void TestPbfWriterSpeed() + private static void TestPbfWriterSpeed() { using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) { @@ -202,7 +202,7 @@ static void TestPbfWriterSpeed() } } - static void TestPbfWriterSpeedWithoutMetadata() + private static void TestPbfWriterSpeedWithoutMetadata() { using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) { @@ -213,7 +213,7 @@ static void TestPbfWriterSpeedWithoutMetadata() } } - static void TestPbfWriterSpeedDenseDeflate() + private static void TestPbfWriterSpeedDenseDeflate() { using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { @@ -224,7 +224,7 @@ static void TestPbfWriterSpeedDenseDeflate() } } - static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() + private static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() { using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { @@ -235,7 +235,7 @@ static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() } } - static void TestOsmGeometryDatabaseLoadFromPbfReader() + private static void TestOsmGeometryDatabaseLoadFromPbfReader() { using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { @@ -243,7 +243,7 @@ static void TestOsmGeometryDatabaseLoadFromPbfReader() } } - static void TestOsmEntityInfoDatabaseLoadFromPbfReader() + private static void TestOsmEntityInfoDatabaseLoadFromPbfReader() { using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { diff --git a/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs b/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs index 0236e4b..81495aa 100644 --- a/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs +++ b/src/Benchmark.SpatialLite.Osm/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/src/SpatialLite.Core/API/Coordinate.cs b/src/SpatialLite.Core/API/Coordinate.cs index b6e4571..c0e68cb 100644 --- a/src/SpatialLite.Core/API/Coordinate.cs +++ b/src/SpatialLite.Core/API/Coordinate.cs @@ -84,22 +84,22 @@ public Coordinate(double x, double y, double z, double m) /// /// Gets a value indicating whether this coordinate has assigned coordinate. /// - public bool Is3D + public readonly bool Is3D { get { - return !double.IsNaN(this.Z); + return !double.IsNaN(Z); } } /// /// Gets a value indicating whether this coordinate has assigned value. /// - public bool IsMeasured + public readonly bool IsMeasured { get { - return !double.IsNaN(this.M); + return !double.IsNaN(M); } } @@ -129,9 +129,9 @@ public bool IsMeasured /// Returns a string that represents the current Coordinate. /// /// A string that represents the current Coordinate - public override string ToString() + public override readonly string ToString() { - return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", this.X, this.Y, this.Z, this.M); + return string.Format(System.Globalization.CultureInfo.InvariantCulture, "[{0}; {1}; {2}, {3}]", X, Y, Z, M); } /// @@ -147,7 +147,7 @@ public override bool Equals(object obj) return false; } - return this.Equals(other.Value); + return Equals(other.Value); } /// @@ -155,19 +155,19 @@ public override bool Equals(object obj) /// /// The Coordinate to compare with the current Coordinate /// true if the specified Coordinate is equal to the current Coordinate; otherwise, false. - public bool Equals(Coordinate other) + public readonly bool Equals(Coordinate other) { - return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && - ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))) && - ((this.Z == other.Z) || (double.IsNaN(this.Z) && double.IsNaN(other.Z))) && - ((this.M == other.M) || (double.IsNaN(this.M) && double.IsNaN(other.M))); + return ((X == other.X) || (double.IsNaN(X) && double.IsNaN(other.X))) && + ((Y == other.Y) || (double.IsNaN(Y) && double.IsNaN(other.Y))) && + ((Z == other.Z) || (double.IsNaN(Z) && double.IsNaN(other.Z))) && + ((M == other.M) || (double.IsNaN(M) && double.IsNaN(other.M))); } /// /// Serves as a hash function for the Coordinate structure. /// /// Hash code for current Coordinate value. - public override int GetHashCode() + public override readonly int GetHashCode() { return X.GetHashCode() + 7 * Y.GetHashCode() + 13 * Z.GetHashCode() + 17 * M.GetHashCode(); } @@ -177,9 +177,9 @@ public override int GetHashCode() /// /// The Coordinate to compare with the current Coordinate /// true if the specified Coordinate is equal to the current Coordinate in 2D space otherwise, false. - public bool Equals2D(Coordinate other) + public readonly bool Equals2D(Coordinate other) { - return ((this.X == other.X) || (double.IsNaN(this.X) && double.IsNaN(other.X))) && - ((this.Y == other.Y) || (double.IsNaN(this.Y) && double.IsNaN(other.Y))); + return ((X == other.X) || (double.IsNaN(X) && double.IsNaN(other.X))) && + ((Y == other.Y) || (double.IsNaN(Y) && double.IsNaN(other.Y))); } } diff --git a/src/SpatialLite.Core/API/Envelope.cs b/src/SpatialLite.Core/API/Envelope.cs index 3b8b42d..38d468f 100644 --- a/src/SpatialLite.Core/API/Envelope.cs +++ b/src/SpatialLite.Core/API/Envelope.cs @@ -18,7 +18,7 @@ public class Envelope private const int ZIndex = 2; private const int MIndex = 3; - private double[][] _bounds = new double[][] { + private readonly double[][] _bounds = new double[][] { new double[] { double.NaN, double.NaN }, new double[] { double.NaN, double.NaN }, new double[] { double.NaN, double.NaN }, @@ -37,7 +37,7 @@ public Envelope() /// The coordinate used initialize Envelope public Envelope(Coordinate coord) { - this.Initialize(coord.X, coord.X, coord.Y, coord.Y, coord.Z, coord.Z, coord.M, coord.M); + Initialize(coord.X, coord.X, coord.Y, coord.Y, coord.Z, coord.Z, coord.M, coord.M); } /// @@ -46,7 +46,7 @@ public Envelope(Coordinate coord) /// The coordinates to be covered. public Envelope(IEnumerable coords) { - this.Extend(coords); + Extend(coords); } /// @@ -55,7 +55,7 @@ public Envelope(IEnumerable coords) /// The Envelope object whose values are to be copied. public Envelope(Envelope source) { - this.Initialize(source.MinX, source.MaxX, source.MinY, source.MaxY, source.MinZ, source.MaxZ, source.MinM, source.MaxM); + Initialize(source.MinX, source.MaxX, source.MinY, source.MaxY, source.MinZ, source.MaxZ, source.MinM, source.MaxM); } /// @@ -130,7 +130,7 @@ public double Width { get { - if (this.IsEmpty) + if (IsEmpty) { return 0; } @@ -147,7 +147,7 @@ public double Height { get { - if (this.IsEmpty) + if (IsEmpty) { return 0; } @@ -163,7 +163,7 @@ public bool IsEmpty { get { - return this.Equals(Envelope.Empty); + return Equals(Empty); } } @@ -204,7 +204,7 @@ public void Extend(IEnumerable coords) { foreach (var coord in coords) { - this.Extend(coord); + Extend(coord); } } @@ -251,13 +251,12 @@ public void Extend(Envelope envelope) /// true if the specified object is equal to the current Envelope; otherwise, false. public override bool Equals(object obj) { - Envelope other = obj as Envelope; - if (other == null) + if (obj is not Envelope other) { return false; } - return this.Equals(other); + return Equals(other); } /// @@ -267,14 +266,14 @@ public override bool Equals(object obj) /// true if the specified Envelope is equal to the current Envelope; otherwise, false. public bool Equals(Envelope other) { - return ((this.MinX == other.MinX) || (double.IsNaN(this.MinX) && double.IsNaN(other.MinX))) && - ((this.MinY == other.MinY) || (double.IsNaN(this.MinY) && double.IsNaN(other.MinY))) && - ((this.MinZ == other.MinZ) || (double.IsNaN(this.MinZ) && double.IsNaN(other.MinZ))) && - ((this.MinM == other.MinM) || (double.IsNaN(this.MinM) && double.IsNaN(other.MinM))) && - ((this.MaxX == other.MaxX) || (double.IsNaN(this.MaxX) && double.IsNaN(other.MaxX))) && - ((this.MaxY == other.MaxY) || (double.IsNaN(this.MaxY) && double.IsNaN(other.MaxY))) && - ((this.MaxZ == other.MaxZ) || (double.IsNaN(this.MaxZ) && double.IsNaN(other.MaxZ))) && - ((this.MaxM == other.MaxM) || (double.IsNaN(this.MaxM) && double.IsNaN(other.MaxM))); + return ((MinX == other.MinX) || (double.IsNaN(MinX) && double.IsNaN(other.MinX))) && + ((MinY == other.MinY) || (double.IsNaN(MinY) && double.IsNaN(other.MinY))) && + ((MinZ == other.MinZ) || (double.IsNaN(MinZ) && double.IsNaN(other.MinZ))) && + ((MinM == other.MinM) || (double.IsNaN(MinM) && double.IsNaN(other.MinM))) && + ((MaxX == other.MaxX) || (double.IsNaN(MaxX) && double.IsNaN(other.MaxX))) && + ((MaxY == other.MaxY) || (double.IsNaN(MaxY) && double.IsNaN(other.MaxY))) && + ((MaxZ == other.MaxZ) || (double.IsNaN(MaxZ) && double.IsNaN(other.MaxZ))) && + ((MaxM == other.MaxM) || (double.IsNaN(MaxM) && double.IsNaN(other.MaxM))); } /// @@ -289,12 +288,12 @@ public bool Equals(Envelope other) /// public bool Intersects(Envelope other) { - if (this.IsEmpty || other.IsEmpty) + if (IsEmpty || other.IsEmpty) { return false; } - return !(other.MinX > this.MaxX || other.MaxX < this.MinX || other.MinY > this.MaxY || other.MaxY < other.MinY); + return !(other.MinX > MaxX || other.MaxX < MinX || other.MinY > MaxY || other.MaxY < other.MinY); } /// @@ -305,15 +304,15 @@ public bool Intersects(Envelope other) /// true if (x, y) lies in the interior or on the boundary of this Envelope. public bool Covers(double x, double y) { - if (this.IsEmpty) + if (IsEmpty) { return false; } - return x >= this.MinX && - x <= this.MaxX && - y >= this.MinY && - y <= this.MaxY; + return x >= MinX && + x <= MaxX && + y >= MinY && + y <= MaxY; } /// @@ -333,15 +332,15 @@ public bool Covers(Coordinate p) /// true if this Envelope covers the other public bool Covers(Envelope other) { - if (this.IsEmpty || other.IsEmpty) + if (IsEmpty || other.IsEmpty) { return false; } - return other.MinX >= this.MinX && - other.MaxX <= this.MaxX && - other.MinY >= this.MinY && - other.MaxY <= this.MaxY; + return other.MinX >= MinX && + other.MaxX <= MaxX && + other.MinY >= MinY && + other.MaxY <= MaxY; } /// @@ -362,11 +361,11 @@ public override int GetHashCode() /// Second y-coordinate. public void Initialize(double x1, double x2, double y1, double y2) { - var sortedX = this.SortCoordinates(x1, x2); + var sortedX = SortCoordinates(x1, x2); _bounds[XIndex][0] = sortedX[0]; _bounds[XIndex][1] = sortedX[1]; - var sortedY = this.SortCoordinates(y1, y2); + var sortedY = SortCoordinates(y1, y2); _bounds[YIndex][0] = sortedY[0]; _bounds[YIndex][1] = sortedY[1]; } @@ -382,15 +381,15 @@ public void Initialize(double x1, double x2, double y1, double y2) /// Second z-coordinate. public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2) { - var sortedX = this.SortCoordinates(x1, x2); + var sortedX = SortCoordinates(x1, x2); _bounds[XIndex][0] = sortedX[0]; _bounds[XIndex][1] = sortedX[1]; - var sortedY = this.SortCoordinates(y1, y2); + var sortedY = SortCoordinates(y1, y2); _bounds[YIndex][0] = sortedY[0]; _bounds[YIndex][1] = sortedY[1]; - var sortedZ = this.SortCoordinates(z1, z2); + var sortedZ = SortCoordinates(z1, z2); _bounds[ZIndex][0] = sortedZ[0]; _bounds[ZIndex][1] = sortedZ[1]; } @@ -408,19 +407,19 @@ public void Initialize(double x1, double x2, double y1, double y2, double z1, do /// Second measure value. public void Initialize(double x1, double x2, double y1, double y2, double z1, double z2, double m1, double m2) { - var sortedX = this.SortCoordinates(x1, x2); + var sortedX = SortCoordinates(x1, x2); _bounds[XIndex][0] = sortedX[0]; _bounds[XIndex][1] = sortedX[1]; - var sortedY = this.SortCoordinates(y1, y2); + var sortedY = SortCoordinates(y1, y2); _bounds[YIndex][0] = sortedY[0]; _bounds[YIndex][1] = sortedY[1]; - var sortedZ = this.SortCoordinates(z1, z2); + var sortedZ = SortCoordinates(z1, z2); _bounds[ZIndex][0] = sortedZ[0]; _bounds[ZIndex][1] = sortedZ[1]; - var sortedM = this.SortCoordinates(m1, m2); + var sortedM = SortCoordinates(m1, m2); _bounds[MIndex][0] = sortedM[0]; _bounds[MIndex][1] = sortedM[1]; } diff --git a/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs b/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs index bf1253c..363f5a7 100644 --- a/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/Euclidean2DCalculator.cs @@ -1,5 +1,5 @@ -using System; -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System; namespace SpatialLite.Core.Algorithms; @@ -35,7 +35,7 @@ public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMo { if (a.Equals2D(b)) { - return this.CalculateDistance(c, a); + return CalculateDistance(c, a); } double deltaX = b.X - a.X; @@ -65,12 +65,12 @@ AC dot AB if (r <= 0.0) { - return this.CalculateDistance(c, a); + return CalculateDistance(c, a); } if (r >= 1.0) { - return this.CalculateDistance(c, b); + return CalculateDistance(c, b); } } diff --git a/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs b/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs index 9252164..b83b52d 100644 --- a/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs +++ b/src/SpatialLite.Core/Algorithms/Euclidean2DLocator.cs @@ -1,6 +1,5 @@ -using System; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System; namespace SpatialLite.Core.Algorithms; @@ -81,7 +80,7 @@ public bool IsOnLine(Coordinate c, ICoordinateList line) { for (int i = 1; i < line.Count; i++) { - if (this.IsOnLine(c, line[i - 1], line[i], LineMode.LineSegment)) + if (IsOnLine(c, line[i - 1], line[i], LineMode.LineSegment)) { return true; } @@ -211,7 +210,7 @@ public bool Intersects(ICoordinateList line1, ICoordinateList line2) { for (int ii = 1; ii < line2.Count; ii++) { - if (this.Intersects(line1[i - 1], line1[i], LineMode.LineSegment, line2[ii - 1], line2[ii], LineMode.LineSegment)) + if (Intersects(line1[i - 1], line1[i], LineMode.LineSegment, line2[ii - 1], line2[ii], LineMode.LineSegment)) { return true; } diff --git a/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs b/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs index 4bbbb08..4165ee6 100644 --- a/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs +++ b/src/SpatialLite.Core/Algorithms/Sphere2DCalculator.cs @@ -1,6 +1,5 @@ -using System; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System; namespace SpatialLite.Core.Algorithms; @@ -28,7 +27,7 @@ public class Sphere2DCalculator : IDimensionsCalculator /// public Sphere2DCalculator() { - this.Radius = Sphere2DCalculator.EarthRadius; + Radius = EarthRadius; } /// @@ -55,7 +54,7 @@ public double CalculateDistance(Coordinate c1, Coordinate c2) //length or arc in radians double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a))); - return c * this.Radius; + return c * Radius; } /// @@ -68,13 +67,13 @@ public double CalculateDistance(Coordinate c1, Coordinate c2) /// The distance from c to great circle connecting points AB in units of the property. public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - double bearingAB = this.CalculateBearing(a, b); - double bearingAC = this.CalculateBearing(a, c); + double bearingAB = CalculateBearing(a, b); + double bearingAC = CalculateBearing(a, c); - double distAC = this.CalculateDistance(a, c); + double distAC = CalculateDistance(a, c); //Sign can be used to determine if point is left/right of the great circle - double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / Sphere2DCalculator.EarthRadius) * Math.Sin(bearingAC - bearingAB)) * Sphere2DCalculator.EarthRadius); + double distCircleC = Math.Abs(Math.Asin(Math.Sin(distAC / EarthRadius) * Math.Sin(bearingAC - bearingAB)) * EarthRadius); if (mode == LineMode.Line) { @@ -82,8 +81,8 @@ public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMo } else { - double bearingBA = this.CalculateBearing(b, a); - double bearingBC = this.CalculateBearing(b, c); + double bearingBA = CalculateBearing(b, a); + double bearingBC = CalculateBearing(b, c); if (Math.Abs(bearingAC - bearingAB) > Math.PI / 2) { @@ -91,7 +90,7 @@ public double CalculateDistance(Coordinate c, Coordinate a, Coordinate b, LineMo } else if (Math.Abs(bearingBC - bearingBA) > Math.PI / 2) { - return this.CalculateDistance(b, c); + return CalculateDistance(b, c); } else { @@ -122,10 +121,10 @@ public double CalculateArea(ICoordinateList vertices) for (int i = 0; i <= maxIndex; i++) { - area += (this.ToRadians(vertices[(i + 1) % maxIndex].X) - this.ToRadians(vertices[(i - 1) % maxIndex].X)) * Math.Sin(this.ToRadians(vertices[i % maxIndex].Y)); + area += (ToRadians(vertices[(i + 1) % maxIndex].X) - ToRadians(vertices[(i - 1) % maxIndex].X)) * Math.Sin(ToRadians(vertices[i % maxIndex].Y)); } - return Math.Abs(area * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius); + return Math.Abs(area * EarthRadius * EarthRadius); } /// diff --git a/src/SpatialLite.Core/Geometries/CoordinateList.cs b/src/SpatialLite.Core/Geometries/CoordinateList.cs index c2c5acc..17fdae1 100644 --- a/src/SpatialLite.Core/Geometries/CoordinateList.cs +++ b/src/SpatialLite.Core/Geometries/CoordinateList.cs @@ -1,8 +1,7 @@ -using System.Collections; +using SpatialLite.Core.API; +using System.Collections; using System.Collections.Generic; -using SpatialLite.Core.API; - namespace SpatialLite.Core.Geometries; /// @@ -11,7 +10,7 @@ namespace SpatialLite.Core.Geometries; public class CoordinateList : ICoordinateList { - private List _storage; + private readonly List _storage; /// /// Initializes a new instance of the CoordinateList class, that is empty. diff --git a/src/SpatialLite.Core/Geometries/Geometry.cs b/src/SpatialLite.Core/Geometries/Geometry.cs index be2d834..21eb6df 100644 --- a/src/SpatialLite.Core/Geometries/Geometry.cs +++ b/src/SpatialLite.Core/Geometries/Geometry.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System.Collections.Generic; namespace SpatialLite.Core.Geometries; diff --git a/src/SpatialLite.Core/Geometries/GeometryCollection.cs b/src/SpatialLite.Core/Geometries/GeometryCollection.cs index 6e080fa..cbd0e13 100644 --- a/src/SpatialLite.Core/Geometries/GeometryCollection.cs +++ b/src/SpatialLite.Core/Geometries/GeometryCollection.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; +using SpatialLite.Core.API; +using System.Collections.Generic; using System.Linq; -using SpatialLite.Core.API; - namespace SpatialLite.Core.Geometries; /// @@ -100,6 +99,6 @@ public override Envelope GetEnvelope() /// the collection of all of this object public override IEnumerable GetCoordinates() { - return this.Geometries.SelectMany(o => o.GetCoordinates()); + return Geometries.SelectMany(o => o.GetCoordinates()); } } diff --git a/src/SpatialLite.Core/Geometries/LineString.cs b/src/SpatialLite.Core/Geometries/LineString.cs index 1ac9c9f..92478c4 100644 --- a/src/SpatialLite.Core/Geometries/LineString.cs +++ b/src/SpatialLite.Core/Geometries/LineString.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; +using SpatialLite.Core.API; +using System.Collections.Generic; using System.Linq; -using SpatialLite.Core.API; namespace SpatialLite.Core.Geometries; @@ -10,7 +10,7 @@ namespace SpatialLite.Core.Geometries; public class LineString : Geometry, ILineString { - private CoordinateList _coordinates; + private readonly CoordinateList _coordinates; /// /// Initializes a new instance of the LineString class that is empty and has assigned WSG84 coordinate reference system. @@ -66,7 +66,7 @@ public virtual ICoordinateList Coordinates /// ICoordinateList ILineString.Coordinates { - get { return this.Coordinates; } + get { return Coordinates; } } /// @@ -117,7 +117,7 @@ public virtual bool IsClosed } else { - return this.Start.Equals(this.End); + return Start.Equals(End); } } } @@ -139,6 +139,6 @@ public override Envelope GetEnvelope() /// the collection of all of this object public override IEnumerable GetCoordinates() { - return this.Coordinates; + return Coordinates; } } diff --git a/src/SpatialLite.Core/Geometries/MultiLineString.cs b/src/SpatialLite.Core/Geometries/MultiLineString.cs index 58a3c82..40f2796 100644 --- a/src/SpatialLite.Core/Geometries/MultiLineString.cs +++ b/src/SpatialLite.Core/Geometries/MultiLineString.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System.Collections.Generic; namespace SpatialLite.Core.Geometries; @@ -32,6 +31,6 @@ public MultiLineString(IEnumerable linestrings) /// IEnumerable IGeometryCollection.Geometries { - get { return base.Geometries; } + get { return Geometries; } } } diff --git a/src/SpatialLite.Core/Geometries/MultiPoint.cs b/src/SpatialLite.Core/Geometries/MultiPoint.cs index 1d0430b..eb2ba5f 100644 --- a/src/SpatialLite.Core/Geometries/MultiPoint.cs +++ b/src/SpatialLite.Core/Geometries/MultiPoint.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System.Collections.Generic; namespace SpatialLite.Core.Geometries; @@ -32,6 +31,6 @@ public MultiPoint(IEnumerable points) /// IEnumerable IGeometryCollection.Geometries { - get { return base.Geometries; } + get { return Geometries; } } } diff --git a/src/SpatialLite.Core/Geometries/MultiPolygon.cs b/src/SpatialLite.Core/Geometries/MultiPolygon.cs index 8af6a6d..9e576d8 100644 --- a/src/SpatialLite.Core/Geometries/MultiPolygon.cs +++ b/src/SpatialLite.Core/Geometries/MultiPolygon.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System.Collections.Generic; namespace SpatialLite.Core.Geometries; @@ -32,6 +31,6 @@ public MultiPolygon(IEnumerable polygons) /// IEnumerable IGeometryCollection.Geometries { - get { return base.Geometries; } + get { return Geometries; } } } diff --git a/src/SpatialLite.Core/Geometries/Point.cs b/src/SpatialLite.Core/Geometries/Point.cs index 4ae87d2..88d4e47 100644 --- a/src/SpatialLite.Core/Geometries/Point.cs +++ b/src/SpatialLite.Core/Geometries/Point.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System.Collections.Generic; namespace SpatialLite.Core.Geometries; @@ -104,7 +103,7 @@ public override bool IsMeasured /// Envelope, that covers this Point. public override Envelope GetEnvelope() { - return new Envelope(this.Position); + return new Envelope(Position); } /// @@ -113,6 +112,6 @@ public override Envelope GetEnvelope() /// the collection of all of this object public override IEnumerable GetCoordinates() { - yield return this.Position; + yield return Position; } } diff --git a/src/SpatialLite.Core/Geometries/Polygon.cs b/src/SpatialLite.Core/Geometries/Polygon.cs index f31fddd..045a879 100644 --- a/src/SpatialLite.Core/Geometries/Polygon.cs +++ b/src/SpatialLite.Core/Geometries/Polygon.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; +using SpatialLite.Core.API; +using System.Collections.Generic; using System.Linq; -using SpatialLite.Core.API; - namespace SpatialLite.Core.Geometries; /// @@ -16,8 +15,8 @@ public class Polygon : Geometry, IPolygon public Polygon() : base() { - this.ExteriorRing = new CoordinateList(); - this.InteriorRings = new List(0); + ExteriorRing = new CoordinateList(); + InteriorRings = new List(0); } /// @@ -26,8 +25,8 @@ public Polygon() /// The exterior boundary of the polygon. public Polygon(ICoordinateList exteriorRing) { - this.ExteriorRing = exteriorRing; - this.InteriorRings = new List(0); + ExteriorRing = exteriorRing; + InteriorRings = new List(0); } /// @@ -40,7 +39,7 @@ public Polygon(ICoordinateList exteriorRing) /// ICoordinateList IPolygon.ExteriorRing { - get { return this.ExteriorRing; } + get { return ExteriorRing; } } /// @@ -53,7 +52,7 @@ ICoordinateList IPolygon.ExteriorRing /// IEnumerable IPolygon.InteriorRings { - get { return this.InteriorRings; } + get { return InteriorRings; } } /// @@ -62,7 +61,7 @@ IEnumerable IPolygon.InteriorRings public override bool Is3D { //TODO consider using InteriorRings as well - get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.Is3D); } + get { return ExteriorRing != null && ExteriorRing.Any(c => c.Is3D); } } /// @@ -71,7 +70,7 @@ public override bool Is3D public override bool IsMeasured { //TODO consider using InteriorRings as well - get { return this.ExteriorRing != null && this.ExteriorRing.Any(c => c.IsMeasured); } + get { return ExteriorRing != null && ExteriorRing.Any(c => c.IsMeasured); } } /// @@ -82,7 +81,7 @@ public override bool IsMeasured /// public override Envelope GetEnvelope() { - return this.ExteriorRing.Count == 0 ? new Envelope() : new Envelope(this.ExteriorRing); + return ExteriorRing.Count == 0 ? new Envelope() : new Envelope(ExteriorRing); } /// @@ -91,6 +90,6 @@ public override Envelope GetEnvelope() /// the collection of all of this object public override IEnumerable GetCoordinates() { - return this.ExteriorRing.Concat(this.InteriorRings.SelectMany(o => o)); + return ExteriorRing.Concat(InteriorRings.SelectMany(o => o)); } } diff --git a/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs b/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs index 2bb6a69..52b7d7e 100644 --- a/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs +++ b/src/SpatialLite.Core/Geometries/ReadOnlyCoordinateList.cs @@ -1,7 +1,7 @@ -using System; +using SpatialLite.Core.API; +using System; using System.Collections; using System.Collections.Generic; -using SpatialLite.Core.API; namespace SpatialLite.Core.Geometries; @@ -16,7 +16,7 @@ public class ReadOnlyCoordinateList : ICoordinateList where T : IPoint /// The list of Points to be used as source for this ReadOnlyCoordinateList public ReadOnlyCoordinateList(IReadOnlyList source) { - this.Source = source; + Source = source; } /// @@ -26,7 +26,7 @@ public int Count { get { - return this.Source.Count; + return Source.Count; } } @@ -44,7 +44,7 @@ public Coordinate this[int index] { get { - return this.Source[index].Position; + return Source[index].Position; } set { @@ -104,7 +104,7 @@ public void Clear() /// The Enumerator for the CoordinateList public IEnumerator GetEnumerator() { - foreach (var node in this.Source) + foreach (var node in Source) { yield return node.Position; } @@ -116,6 +116,6 @@ public IEnumerator GetEnumerator() /// The Enumerator for the CoordinateList IEnumerator IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } } diff --git a/src/SpatialLite.Core/IO/WkbReader.cs b/src/SpatialLite.Core/IO/WkbReader.cs index d6e7a6d..524a6f8 100644 --- a/src/SpatialLite.Core/IO/WkbReader.cs +++ b/src/SpatialLite.Core/IO/WkbReader.cs @@ -1,10 +1,9 @@ -using System; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using System; using System.Collections.Generic; using System.IO; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - namespace SpatialLite.Core.IO; /// @@ -13,8 +12,8 @@ namespace SpatialLite.Core.IO; public class WkbReader : IDisposable { - private BinaryReader _inputReader; - private FileStream _inputFileStream; + private readonly BinaryReader _inputReader; + private readonly FileStream _inputFileStream; private bool _disposed = false; /// @@ -71,7 +70,7 @@ public static Geometry Parse(byte[] wkb) throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); } - Geometry parsed = WkbReader.ReadGeometry(reader); + Geometry parsed = ReadGeometry(reader); return parsed; } @@ -92,12 +91,11 @@ public static Geometry Parse(byte[] wkb) /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. public static T Parse(byte[] wkb) where T : Geometry { - Geometry parsed = WkbReader.Parse(wkb); + Geometry parsed = Parse(wkb); if (parsed != null) { - T result = parsed as T; - if (result == null) + if (parsed is not T result) { throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); } @@ -138,7 +136,7 @@ public Geometry Read() throw new NotSupportedException("Big endian encoding is not supprted in the current version of WkbReader."); } - return WkbReader.ReadGeometry(_inputReader); + return ReadGeometry(_inputReader); } catch (EndOfStreamException) { @@ -154,12 +152,11 @@ public Geometry Read() /// Throws exception if wkb array does not contrains valid WKB geometry of specific type. public T Read() where T : Geometry { - Geometry parsed = this.Read(); + Geometry parsed = Read(); if (parsed != null) { - T result = parsed as T; - if (result == null) + if (parsed is not T result) { throw new WkbFormatException("Input doesn't contain valid WKB representation of the specified geometry type."); } @@ -203,7 +200,7 @@ private static IEnumerable ReadCoordinates(BinaryReader reader, bool List result = new List(pointCount); for (int i = 0; i < pointCount; i++) { - result.Add(WkbReader.ReadCoordinate(reader, is3D, isMeasured)); + result.Add(ReadCoordinate(reader, is3D, isMeasured)); } return result; @@ -220,17 +217,17 @@ private static Geometry ReadGeometry(BinaryReader reader) bool is3D, isMeasured; WkbGeometryType basicType; - WkbReader.GetGeometryTypeDetails(geometryType, out basicType, out is3D, out isMeasured); + GetGeometryTypeDetails(geometryType, out basicType, out is3D, out isMeasured); switch (basicType) { - case WkbGeometryType.Point: return WkbReader.ReadPoint(reader, is3D, isMeasured); - case WkbGeometryType.LineString: return WkbReader.ReadLineString(reader, is3D, isMeasured); - case WkbGeometryType.Polygon: return WkbReader.ReadPolygon(reader, is3D, isMeasured); - case WkbGeometryType.MultiPoint: return WkbReader.ReadMultiPoint(reader, is3D, isMeasured); - case WkbGeometryType.MultiLineString: return WkbReader.ReadMultiLineString(reader, is3D, isMeasured); - case WkbGeometryType.MultiPolygon: return WkbReader.ReadMultiPolygon(reader, is3D, isMeasured); - case WkbGeometryType.GeometryCollection: return WkbReader.ReadGeometryCollection(reader, is3D, isMeasured); + case WkbGeometryType.Point: return ReadPoint(reader, is3D, isMeasured); + case WkbGeometryType.LineString: return ReadLineString(reader, is3D, isMeasured); + case WkbGeometryType.Polygon: return ReadPolygon(reader, is3D, isMeasured); + case WkbGeometryType.MultiPoint: return ReadMultiPoint(reader, is3D, isMeasured); + case WkbGeometryType.MultiLineString: return ReadMultiLineString(reader, is3D, isMeasured); + case WkbGeometryType.MultiPolygon: return ReadMultiPolygon(reader, is3D, isMeasured); + case WkbGeometryType.GeometryCollection: return ReadGeometryCollection(reader, is3D, isMeasured); default: throw new WkbFormatException("Unknown geometry type."); } } @@ -244,7 +241,7 @@ private static Geometry ReadGeometry(BinaryReader reader) /// Point read from the input private static Point ReadPoint(BinaryReader reader, bool is3D, bool isMeasured) { - Coordinate position = WkbReader.ReadCoordinate(reader, is3D, isMeasured); + Coordinate position = ReadCoordinate(reader, is3D, isMeasured); return new Point(position); } @@ -257,7 +254,7 @@ private static Point ReadPoint(BinaryReader reader, bool is3D, bool isMeasured) /// Linestring read from the input. private static LineString ReadLineString(BinaryReader reader, bool is3D, bool isMeasured) { - IEnumerable coordinates = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + IEnumerable coordinates = ReadCoordinates(reader, is3D, isMeasured); return new LineString(coordinates); } @@ -277,12 +274,12 @@ private static Polygon ReadPolygon(BinaryReader reader, bool is3D, bool isMeasur return new Polygon(); } - IEnumerable exterior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + IEnumerable exterior = ReadCoordinates(reader, is3D, isMeasured); Polygon result = new Polygon(new CoordinateList(exterior)); for (int i = 1; i < ringsCount; i++) { - IEnumerable interior = WkbReader.ReadCoordinates(reader, is3D, isMeasured); + IEnumerable interior = ReadCoordinates(reader, is3D, isMeasured); result.InteriorRings.Add(new CoordinateList(interior)); } @@ -303,7 +300,7 @@ private static MultiPoint ReadMultiPoint(BinaryReader reader, bool is3D, bool is MultiPoint result = new MultiPoint(); for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadPoint(reader, is3D, isMeasured)); + result.Geometries.Add(ReadPoint(reader, is3D, isMeasured)); } return result; @@ -323,7 +320,7 @@ private static MultiLineString ReadMultiLineString(BinaryReader reader, bool is3 MultiLineString result = new MultiLineString(); for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadLineString(reader, is3D, isMeasured)); + result.Geometries.Add(ReadLineString(reader, is3D, isMeasured)); } return result; @@ -343,7 +340,7 @@ private static MultiPolygon ReadMultiPolygon(BinaryReader reader, bool is3D, boo MultiPolygon result = new MultiPolygon(); for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadPolygon(reader, is3D, isMeasured)); + result.Geometries.Add(ReadPolygon(reader, is3D, isMeasured)); } return result; @@ -363,7 +360,7 @@ private static GeometryCollection ReadGeometryCollection(BinaryReader GeometryCollection result = new GeometryCollection(); for (int i = 0; i < pointsCount; i++) { - result.Geometries.Add(WkbReader.ReadGeometry(reader)); + result.Geometries.Add(ReadGeometry(reader)); } return result; @@ -389,7 +386,7 @@ private static void GetGeometryTypeDetails(WkbGeometryType type, out WkbGeometry /// true to release both managed and unmanaged resources; false to release only unmanaged resources. private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { if (disposing) { @@ -404,5 +401,4 @@ private void Dispose(bool disposing) _disposed = true; } } - } diff --git a/src/SpatialLite.Core/IO/WkbWriter.cs b/src/SpatialLite.Core/IO/WkbWriter.cs index 48b7fd7..b6a2973 100644 --- a/src/SpatialLite.Core/IO/WkbWriter.cs +++ b/src/SpatialLite.Core/IO/WkbWriter.cs @@ -1,9 +1,8 @@ -using System; +using SpatialLite.Core.API; +using System; using System.IO; using System.Linq; -using SpatialLite.Core.API; - namespace SpatialLite.Core.IO; /// @@ -13,8 +12,8 @@ public class WkbWriter : IDisposable { private bool _disposed = false; - private BinaryWriter _writer = null; - private Stream _output = null; + private readonly BinaryWriter _writer = null; + private readonly Stream _output = null; /// /// Initializes a new instance of the WkbWriter class with specific settings. @@ -32,8 +31,8 @@ protected WkbWriter(WkbWriterSettings settings) throw new NotSupportedException("BigEndian encoding is not supported in current version of the WkbWriter."); } - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings; + Settings.IsReadOnly = true; } /// @@ -87,8 +86,8 @@ public static byte[] WriteToArray(IGeometry geometry) { WkbWriterSettings defaultSettings = new WkbWriterSettings(); - WkbWriter.WriteEncoding(writer, defaultSettings.Encoding); - WkbWriter.Write(geometry, writer); + WriteEncoding(writer, defaultSettings.Encoding); + Write(geometry, writer); return dataStream.ToArray(); } @@ -110,8 +109,8 @@ public void Dispose() /// The geometry to write. public void Write(IGeometry geometry) { - WkbWriter.WriteEncoding(_writer, this.Settings.Encoding); - WkbWriter.Write(geometry, _writer); + WriteEncoding(_writer, Settings.Encoding); + Write(geometry, _writer); } /// @@ -133,31 +132,31 @@ private static void Write(IGeometry geometry, BinaryWriter writer) { if (geometry is IPoint) { - WkbWriter.WritePoint((IPoint)geometry, writer); + WritePoint((IPoint)geometry, writer); } else if (geometry is ILineString) { - WkbWriter.WriteLineString((ILineString)geometry, writer); + WriteLineString((ILineString)geometry, writer); } else if (geometry is IPolygon) { - WkbWriter.WritePolygon((IPolygon)geometry, writer); + WritePolygon((IPolygon)geometry, writer); } else if (geometry is IMultiPoint) { - WkbWriter.WriteMultiPoint((IMultiPoint)geometry, writer); + WriteMultiPoint((IMultiPoint)geometry, writer); } else if (geometry is IMultiLineString) { - WkbWriter.WriteMultiLineString((IMultiLineString)geometry, writer); + WriteMultiLineString((IMultiLineString)geometry, writer); } else if (geometry is IMultiPolygon) { - WkbWriter.WriteMultiPolygon((IMultiPolygon)geometry, writer); + WriteMultiPolygon((IMultiPolygon)geometry, writer); } else if (geometry is IGeometryCollection) { - WkbWriter.WriteGeometryCollection((IGeometryCollection)geometry, writer); + WriteGeometryCollection((IGeometryCollection)geometry, writer); } } @@ -193,7 +192,7 @@ private static void WriteCoordinates(ICoordinateList coordinates, BinaryWriter w for (int i = 0; i < coordinates.Count; i++) { - WkbWriter.WriteCoordinate(coordinates[i], writer); + WriteCoordinate(coordinates[i], writer); } } @@ -211,8 +210,8 @@ private static void WritePoint(IPoint point, BinaryWriter writer) } else { - writer.Write((uint)WkbWriter.AdjustGeometryType(point, WkbGeometryType.Point)); - WkbWriter.WriteCoordinate(point.Position, writer); + writer.Write((uint)AdjustGeometryType(point, WkbGeometryType.Point)); + WriteCoordinate(point.Position, writer); } } @@ -223,8 +222,8 @@ private static void WritePoint(IPoint point, BinaryWriter writer) /// The BinaryWriter used to write geometry to the output. private static void WriteLineString(ILineString linestring, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(linestring, WkbGeometryType.LineString)); - WkbWriter.WriteCoordinates(linestring.Coordinates, writer); + writer.Write((uint)AdjustGeometryType(linestring, WkbGeometryType.LineString)); + WriteCoordinates(linestring.Coordinates, writer); } /// @@ -234,8 +233,8 @@ private static void WriteLineString(ILineString linestring, BinaryWriter writer) /// The BinaryWriter used to write geometry to the output. private static void WritePolygon(IPolygon polygon, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(polygon, WkbGeometryType.Polygon)); - WkbWriter.WritePolygonContent(polygon, writer); + writer.Write((uint)AdjustGeometryType(polygon, WkbGeometryType.Polygon)); + WritePolygonContent(polygon, writer); } /// @@ -252,11 +251,11 @@ private static void WritePolygonContent(IPolygon polygon, BinaryWriter writer) else { writer.Write((uint)(1 + polygon.InteriorRings.Count())); - WkbWriter.WriteCoordinates(polygon.ExteriorRing, writer); + WriteCoordinates(polygon.ExteriorRing, writer); foreach (var ring in polygon.InteriorRings) { - WkbWriter.WriteCoordinates(ring, writer); + WriteCoordinates(ring, writer); } } } @@ -268,11 +267,11 @@ private static void WritePolygonContent(IPolygon polygon, BinaryWriter writer) /// The BinaryWriter used to write geometry to the output. private static void WriteMultiPoint(IMultiPoint multipoint, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multipoint, WkbGeometryType.MultiPoint)); + writer.Write((uint)AdjustGeometryType(multipoint, WkbGeometryType.MultiPoint)); writer.Write((uint)multipoint.Geometries.Count()); foreach (var point in multipoint.Geometries) { - WkbWriter.WriteCoordinate(point.Position, writer); + WriteCoordinate(point.Position, writer); } } @@ -283,11 +282,11 @@ private static void WriteMultiPoint(IMultiPoint multipoint, BinaryWriter writer) /// The BinaryWriter used to write geometry to the output. private static void WriteMultiLineString(IMultiLineString multiLineString, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multiLineString, WkbGeometryType.MultiLineString)); + writer.Write((uint)AdjustGeometryType(multiLineString, WkbGeometryType.MultiLineString)); writer.Write((uint)multiLineString.Geometries.Count()); foreach (var linestring in multiLineString.Geometries) { - WkbWriter.WriteCoordinates(linestring.Coordinates, writer); + WriteCoordinates(linestring.Coordinates, writer); } } @@ -298,11 +297,11 @@ private static void WriteMultiLineString(IMultiLineString multiLineString, Binar /// The BinaryWriter used to write geometry to the output. private static void WriteMultiPolygon(IMultiPolygon multiPolygon, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(multiPolygon, WkbGeometryType.MultiPolygon)); + writer.Write((uint)AdjustGeometryType(multiPolygon, WkbGeometryType.MultiPolygon)); writer.Write((uint)multiPolygon.Geometries.Count()); foreach (var polygon in multiPolygon.Geometries) { - WkbWriter.WritePolygonContent(polygon, writer); + WritePolygonContent(polygon, writer); } } @@ -313,11 +312,11 @@ private static void WriteMultiPolygon(IMultiPolygon multiPolygon, BinaryWriter w /// The BinaryWriter used to write geometry to the output. private static void WriteGeometryCollection(IGeometryCollection collection, BinaryWriter writer) { - writer.Write((uint)WkbWriter.AdjustGeometryType(collection, WkbGeometryType.GeometryCollection)); + writer.Write((uint)AdjustGeometryType(collection, WkbGeometryType.GeometryCollection)); writer.Write((uint)collection.Geometries.Count()); foreach (var geometry in collection.Geometries) { - WkbWriter.Write(geometry, writer); + Write(geometry, writer); } } diff --git a/src/SpatialLite.Core/IO/WkbWriterSettings.cs b/src/SpatialLite.Core/IO/WkbWriterSettings.cs index 0c7a58d..8b7a1b8 100644 --- a/src/SpatialLite.Core/IO/WkbWriterSettings.cs +++ b/src/SpatialLite.Core/IO/WkbWriterSettings.cs @@ -16,7 +16,7 @@ public class WkbWriterSettings public WkbWriterSettings() : base() { - this.Encoding = BinaryEncoding.LittleEndian; + Encoding = BinaryEncoding.LittleEndian; } /// @@ -34,7 +34,7 @@ public BinaryEncoding Encoding set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'Encoding' property. The WkbWriterSettings instance is read-only"); } @@ -47,5 +47,4 @@ public BinaryEncoding Encoding /// Gets a value indicating whether properties of this OsmWriterSettings instance can be changed. /// protected internal bool IsReadOnly { get; internal set; } - } diff --git a/src/SpatialLite.Core/IO/WktReader.cs b/src/SpatialLite.Core/IO/WktReader.cs index 225ea47..079e8ab 100644 --- a/src/SpatialLite.Core/IO/WktReader.cs +++ b/src/SpatialLite.Core/IO/WktReader.cs @@ -1,11 +1,10 @@ -using System; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.IO; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; +using System.Linq; namespace SpatialLite.Core.IO; @@ -15,11 +14,11 @@ namespace SpatialLite.Core.IO; public class WktReader : IDisposable { - private static CultureInfo _invarianCulture = CultureInfo.InvariantCulture; + private static readonly CultureInfo _invarianCulture = CultureInfo.InvariantCulture; - private TextReader _inputReader; - private FileStream _inputFileStream; - private WktTokensBuffer _tokens; + private readonly TextReader _inputReader; + private readonly FileStream _inputFileStream; + private readonly WktTokensBuffer _tokens; private bool _disposed = false; @@ -57,7 +56,7 @@ public WktReader(string path) public static Geometry Parse(string wkt) { WktTokensBuffer tokens = new WktTokensBuffer(WktTokenizer.Tokenize(wkt)); - return WktReader.ParseGeometryTaggedText(tokens); + return ParseGeometryTaggedText(tokens); } /// @@ -68,12 +67,11 @@ public static Geometry Parse(string wkt) /// The parsed Geometry of given type. public static T Parse(string wkt) where T : Geometry { - Geometry parsed = WktReader.Parse(wkt); + Geometry parsed = Parse(wkt); if (parsed != null) { - T result = parsed as T; - if (result == null) + if (parsed is not T result) { throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); } @@ -92,7 +90,7 @@ public static T Parse(string wkt) where T : Geometry /// The geometry object read from the reader or null if no more geometries are available. public Geometry Read() { - return WktReader.ParseGeometryTaggedText(_tokens); + return ParseGeometryTaggedText(_tokens); } /// @@ -102,12 +100,11 @@ public Geometry Read() /// The geometry object of specific type read from the reader or null if no more geometries are available. public T Read() where T : Geometry { - Geometry parsed = WktReader.ParseGeometryTaggedText(_tokens); + Geometry parsed = ParseGeometryTaggedText(_tokens); if (parsed != null) { - T result = parsed as T; - if (result == null) + if (parsed is not T result) { throw new WktParseException("Input doesn't contain valid WKB representation of the specified geometry type."); } @@ -142,31 +139,31 @@ private static Geometry ParseGeometryTaggedText(WktTokensBuffer tokens) { if (t.Value.ToUpperInvariant() == "POINT") { - return WktReader.ParsePointTaggedText(tokens); + return ParsePointTaggedText(tokens); } else if (t.Value.ToUpperInvariant() == "LINESTRING") { - return WktReader.ParseLineStringTaggedText(tokens); + return ParseLineStringTaggedText(tokens); } else if (t.Value.ToUpperInvariant() == "POLYGON") { - return WktReader.ParsePolygonTaggedText(tokens); + return ParsePolygonTaggedText(tokens); } else if (t.Value.ToUpperInvariant() == "MULTIPOINT") { - return WktReader.ParseMultiPointTaggedText(tokens); + return ParseMultiPointTaggedText(tokens); } else if (t.Value.ToUpperInvariant() == "MULTILINESTRING") { - return WktReader.ParseMultiLineStringTaggedText(tokens); + return ParseMultiLineStringTaggedText(tokens); } else if (t.Value.ToUpperInvariant() == "MULTIPOLYGON") { - return WktReader.ParseMultiPolygonTaggedText(tokens); + return ParseMultiPolygonTaggedText(tokens); } else if (t.Value.ToUpperInvariant() == "GEOMETRYCOLLECTION") { - return WktReader.ParseGeometryCollectionTaggedText(tokens); + return ParseGeometryCollectionTaggedText(tokens); } } @@ -186,20 +183,20 @@ private static Geometry ParseGeometryTaggedText(WktTokensBuffer tokens) /// ::= point {z}{m} ]]> private static Point ParsePointTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("point", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect("point", tokens); + Expect(TokenType.WHITESPACE, tokens); bool is3D = false; bool isMeasured = false; WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + if (TryParseDimensions(t, out is3D, out isMeasured)) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); } - return WktReader.ParsePointText(tokens, is3D, isMeasured); + return ParsePointText(tokens, is3D, isMeasured); } /// @@ -220,9 +217,9 @@ private static Point ParsePointText(WktTokensBuffer tokens, bool is3D, bool isMe return new Point(); } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - Point result = new Point(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + Expect(TokenType.LEFT_PARENTHESIS, tokens); + Point result = new Point(ParseCoordinate(tokens, is3D, isMeasured)); + Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; } @@ -238,13 +235,13 @@ private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool i { List points = new List(); - points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); + points.Add(ParsePointText(tokens, is3D, isMeasured)); WktToken t = tokens.Peek(true); while (t.Type == TokenType.COMMA) { tokens.GetToken(true); - points.Add(WktReader.ParsePointText(tokens, is3D, isMeasured)); + points.Add(ParsePointText(tokens, is3D, isMeasured)); t = tokens.Peek(true); } @@ -261,12 +258,12 @@ private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool i /// {} {}]]> private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - WktToken t = WktReader.Expect(TokenType.NUMBER, tokens); + WktToken t = Expect(TokenType.NUMBER, tokens); double x = double.Parse(t.Value, _invarianCulture); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); - t = WktReader.Expect(TokenType.NUMBER, tokens); + t = Expect(TokenType.NUMBER, tokens); double y = double.Parse(t.Value, _invarianCulture); double z = double.NaN; @@ -274,17 +271,17 @@ private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, boo if (is3D) { - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); - t = WktReader.Expect(TokenType.NUMBER, tokens); + t = Expect(TokenType.NUMBER, tokens); z = double.Parse(t.Value, _invarianCulture); } if (isMeasured) { - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); - t = WktReader.Expect(TokenType.NUMBER, tokens); + t = Expect(TokenType.NUMBER, tokens); m = double.Parse(t.Value, _invarianCulture); } @@ -302,14 +299,14 @@ private static IEnumerable ParseCoordinates(WktTokensBuffer tokens, { List coordinates = new List(); - coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); + coordinates.Add(ParseCoordinate(tokens, is3D, isMeasured)); WktToken t = tokens.Peek(true); while (t.Type == TokenType.COMMA) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); - coordinates.Add(WktReader.ParseCoordinate(tokens, is3D, isMeasured)); + Expect(TokenType.WHITESPACE, tokens); + coordinates.Add(ParseCoordinate(tokens, is3D, isMeasured)); t = tokens.Peek(true); } @@ -324,20 +321,20 @@ private static IEnumerable ParseCoordinates(WktTokensBuffer tokens, /// ::= linestring {z}{m} ]]> private static LineString ParseLineStringTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("linestring", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect("linestring", tokens); + Expect(TokenType.WHITESPACE, tokens); bool is3D = false; bool isMeasured = false; WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + if (TryParseDimensions(t, out is3D, out isMeasured)) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); } - return WktReader.ParseLineStringText(tokens, is3D, isMeasured); + return ParseLineStringText(tokens, is3D, isMeasured); } /// @@ -358,9 +355,9 @@ private static LineString ParseLineStringText(WktTokensBuffer tokens, bool is3D, return new LineString(); } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - IEnumerable coords = WktReader.ParseCoordinates(tokens, is3D, isMeasured); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + Expect(TokenType.LEFT_PARENTHESIS, tokens); + IEnumerable coords = ParseCoordinates(tokens, is3D, isMeasured); + Expect(TokenType.RIGHT_PARENTHESIS, tokens); return new LineString(coords); } @@ -376,13 +373,13 @@ private static List ParseLineStrings(WktTokensBuffer tokens, bool is { List linestrigns = new List(); - linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); + linestrigns.Add(ParseLineStringText(tokens, is3D, isMeasured)); WktToken t = tokens.Peek(true); while (t.Type == TokenType.COMMA) { tokens.GetToken(true); - linestrigns.Add(WktReader.ParseLineStringText(tokens, is3D, isMeasured)); + linestrigns.Add(ParseLineStringText(tokens, is3D, isMeasured)); t = tokens.Peek(true); } @@ -397,20 +394,20 @@ private static List ParseLineStrings(WktTokensBuffer tokens, bool is /// ::= polygon {z}{m} ]]> private static Polygon ParsePolygonTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("polygon", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect("polygon", tokens); + Expect(TokenType.WHITESPACE, tokens); bool is3D = false; bool isMeasured = false; WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + if (TryParseDimensions(t, out is3D, out isMeasured)) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); } - return WktReader.ParsePolygonText(tokens, is3D, isMeasured); + return ParsePolygonText(tokens, is3D, isMeasured); } /// @@ -431,9 +428,9 @@ private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool return new Polygon(); } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + Expect(TokenType.LEFT_PARENTHESIS, tokens); - IEnumerable linestrings = WktReader.ParseLineStrings(tokens, is3D, isMeasured); + IEnumerable linestrings = ParseLineStrings(tokens, is3D, isMeasured); Polygon result = new Polygon(linestrings.First().Coordinates); foreach (var inner in linestrings.Skip(1)) @@ -441,7 +438,7 @@ private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool result.InteriorRings.Add(inner.Coordinates); } - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; } @@ -457,13 +454,13 @@ private static IEnumerable ParsePolygons(WktTokensBuffer tokens, bool i { List polygons = new List(); - polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); + polygons.Add(ParsePolygonText(tokens, is3D, isMeasured)); WktToken t = tokens.Peek(true); while (t.Type == TokenType.COMMA) { tokens.GetToken(true); - polygons.Add(WktReader.ParsePolygonText(tokens, is3D, isMeasured)); + polygons.Add(ParsePolygonText(tokens, is3D, isMeasured)); t = tokens.Peek(true); } @@ -478,20 +475,20 @@ private static IEnumerable ParsePolygons(WktTokensBuffer tokens, bool i /// ::= multilinestring {z}{m} ]]> private static MultiLineString ParseMultiLineStringTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("multilinestring", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect("multilinestring", tokens); + Expect(TokenType.WHITESPACE, tokens); bool is3D = false; bool isMeasured = false; WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + if (TryParseDimensions(t, out is3D, out isMeasured)) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); } - return WktReader.ParseMultiLineStringText(tokens, is3D, isMeasured); + return ParseMultiLineStringText(tokens, is3D, isMeasured); } /// @@ -512,9 +509,9 @@ private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, return new MultiLineString(); } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiLineString result = new MultiLineString(WktReader.ParseLineStrings(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiLineString result = new MultiLineString(ParseLineStrings(tokens, is3D, isMeasured)); + Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; } @@ -527,20 +524,20 @@ private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, /// ::= multipoint {z}{m} ]]> private static MultiPoint ParseMultiPointTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("multipoint", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect("multipoint", tokens); + Expect(TokenType.WHITESPACE, tokens); bool is3D = false; bool isMeasured = false; WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + if (TryParseDimensions(t, out is3D, out isMeasured)) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); } - return WktReader.ParseMultiPointText(tokens, is3D, isMeasured); + return ParseMultiPointText(tokens, is3D, isMeasured); } /// @@ -561,9 +558,9 @@ private static MultiPoint ParseMultiPointText(WktTokensBuffer tokens, bool is3D, return new MultiPoint(); } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPoint result = new MultiPoint(WktReader.ParsePoints(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiPoint result = new MultiPoint(ParsePoints(tokens, is3D, isMeasured)); + Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; } @@ -576,20 +573,20 @@ private static MultiPoint ParseMultiPointText(WktTokensBuffer tokens, bool is3D, /// ::= multipolygon {z}{m} ]]> private static MultiPolygon ParseMultiPolygonTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("multipolygon", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect("multipolygon", tokens); + Expect(TokenType.WHITESPACE, tokens); bool is3D = false; bool isMeasured = false; WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + if (TryParseDimensions(t, out is3D, out isMeasured)) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); } - return WktReader.ParseMultiPolygonText(tokens, is3D, isMeasured); + return ParseMultiPolygonText(tokens, is3D, isMeasured); } /// @@ -610,9 +607,9 @@ private static MultiPolygon ParseMultiPolygonText(WktTokensBuffer tokens, bool i return new MultiPolygon(); } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPolygon result = new MultiPolygon(WktReader.ParsePolygons(tokens, is3D, isMeasured)); - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + Expect(TokenType.LEFT_PARENTHESIS, tokens); + MultiPolygon result = new MultiPolygon(ParsePolygons(tokens, is3D, isMeasured)); + Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; } @@ -625,20 +622,20 @@ private static MultiPolygon ParseMultiPolygonText(WktTokensBuffer tokens, bool i /// ::= GeometryCollection {z}{m} ]]> private static GeometryCollection ParseGeometryCollectionTaggedText(WktTokensBuffer tokens) { - WktReader.Expect("geometrycollection", tokens); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect("geometrycollection", tokens); + Expect(TokenType.WHITESPACE, tokens); bool is3D = false; bool isMeasured = false; WktToken t = tokens.Peek(true); - if (WktReader.TryParseDimensions(t, out is3D, out isMeasured)) + if (TryParseDimensions(t, out is3D, out isMeasured)) { tokens.GetToken(true); - WktReader.Expect(TokenType.WHITESPACE, tokens); + Expect(TokenType.WHITESPACE, tokens); } - return WktReader.ParseGeometryCollectionText(tokens, is3D, isMeasured); + return ParseGeometryCollectionText(tokens, is3D, isMeasured); } /// @@ -659,20 +656,20 @@ private static GeometryCollection ParseGeometryCollectionText(WktToken return new GeometryCollection(); } - WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); + Expect(TokenType.LEFT_PARENTHESIS, tokens); GeometryCollection result = new GeometryCollection(); - result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); + result.Geometries.Add(ParseGeometryTaggedText(tokens)); t = tokens.Peek(true); while (t.Type == TokenType.COMMA) { tokens.GetToken(true); - result.Geometries.Add(WktReader.ParseGeometryTaggedText(tokens)); + result.Geometries.Add(ParseGeometryTaggedText(tokens)); t = tokens.Peek(true); } - WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); + Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; } @@ -768,7 +765,7 @@ private static bool TryParseDimensions(WktToken token, out bool is3D, out bool i /// true to release both managed and unmanaged resources; false to release only unmanaged resources. private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { if (disposing) { diff --git a/src/SpatialLite.Core/IO/WktTokenizer.cs b/src/SpatialLite.Core/IO/WktTokenizer.cs index 0744ddd..0283c55 100644 --- a/src/SpatialLite.Core/IO/WktTokenizer.cs +++ b/src/SpatialLite.Core/IO/WktTokenizer.cs @@ -19,7 +19,7 @@ internal static class WktTokenizer public static IEnumerable Tokenize(string text) { StringReader reader = new StringReader(text); - return WktTokenizer.Tokenize(reader); + return Tokenize(reader); } /// @@ -38,12 +38,12 @@ public static IEnumerable Tokenize(TextReader reader) char ch = (char)reader.Read(); stringBuffer.Append(ch); - TokenType lastToken = WktTokenizer.GetTokenType(ch); + TokenType lastToken = GetTokenType(ch); while (reader.Peek() != -1) { ch = (char)reader.Read(); - TokenType token = WktTokenizer.GetTokenType(ch); + TokenType token = GetTokenType(ch); // tokens COMMA, LEFT_PARENTHESIS and RIGHT_PARENTHESIS can not be grupped together if ((token != lastToken) || token == TokenType.COMMA || token == TokenType.LEFT_PARENTHESIS || token == TokenType.RIGHT_PARENTHESIS) diff --git a/src/SpatialLite.Core/IO/WktTokensBuffer.cs b/src/SpatialLite.Core/IO/WktTokensBuffer.cs index d8041b9..0299d3d 100644 --- a/src/SpatialLite.Core/IO/WktTokensBuffer.cs +++ b/src/SpatialLite.Core/IO/WktTokensBuffer.cs @@ -8,7 +8,7 @@ namespace SpatialLite.Core.IO; internal class WktTokensBuffer : IEnumerable { - private List _buffer; + private readonly List _buffer; /// /// Initializes a new instance of the WktTokenBuffer class that is empty. @@ -71,7 +71,7 @@ public void Clear() /// Next token form the tokens public WktToken Peek(bool ignoreWhitespace) { - if (this.Count == 0) + if (Count == 0) { return WktToken.EndOfDataToken; } @@ -137,6 +137,6 @@ public IEnumerator GetEnumerator() /// An enumerator that iterates through the collection System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } } diff --git a/src/SpatialLite.Core/IO/WktWriter.cs b/src/SpatialLite.Core/IO/WktWriter.cs index 9e3ab15..1a59c40 100644 --- a/src/SpatialLite.Core/IO/WktWriter.cs +++ b/src/SpatialLite.Core/IO/WktWriter.cs @@ -1,6 +1,6 @@ -using System; +using SpatialLite.Core.API; +using System; using System.IO; -using SpatialLite.Core.API; using System.Linq; namespace SpatialLite.Core.IO; @@ -11,11 +11,11 @@ namespace SpatialLite.Core.IO; public class WktWriter : IDisposable { - private static System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + private static readonly System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; private bool _disposed = false; - private TextWriter _writer; - private Stream _outputStream; + private readonly TextWriter _writer; + private readonly Stream _outputStream; /// /// Initializes a new instance of the WkbWriter class with specific settings. @@ -23,13 +23,8 @@ public class WktWriter : IDisposable /// The settings defining behaviour of the writer. protected WktWriter(WktWriterSettings settings) { - if (settings == null) - { - throw new ArgumentNullException(nameof(settings)); - } - - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings ?? throw new ArgumentNullException(nameof(settings)); + Settings.IsReadOnly = true; } /// @@ -76,7 +71,7 @@ public WktWriter(string path, WktWriterSettings settings) /// The geometry to write. public void Write(IGeometry geometry) { - WktWriter.Write(geometry, _writer); + Write(geometry, _writer); } /// @@ -96,7 +91,7 @@ public void Dispose() public static string WriteToString(IGeometry geometry) { StringWriter tw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); - WktWriter.Write(geometry, tw); + Write(geometry, tw); return tw.ToString(); } @@ -110,31 +105,31 @@ protected static void Write(IGeometry geometry, TextWriter writer) { if (geometry is IPoint) { - WktWriter.AppendPointTaggedText((IPoint)geometry, writer); + AppendPointTaggedText((IPoint)geometry, writer); } else if (geometry is ILineString) { - WktWriter.AppendLineStringTaggedText((ILineString)geometry, writer); + AppendLineStringTaggedText((ILineString)geometry, writer); } else if (geometry is IPolygon) { - WktWriter.AppendPolygonTaggedText((IPolygon)geometry, writer); + AppendPolygonTaggedText((IPolygon)geometry, writer); } else if (geometry is IMultiPoint) { - WktWriter.AppendMultiPointTaggedText((IMultiPoint)geometry, writer); + AppendMultiPointTaggedText((IMultiPoint)geometry, writer); } else if (geometry is IMultiLineString) { - WktWriter.AppendMultiLineStringTaggedText((IMultiLineString)geometry, writer); + AppendMultiLineStringTaggedText((IMultiLineString)geometry, writer); } else if (geometry is IMultiPolygon) { - WktWriter.AppendMultiPolygonTaggetText((IMultiPolygon)geometry, writer); + AppendMultiPolygonTaggetText((IMultiPolygon)geometry, writer); } else if (geometry is IGeometryCollection) { - WktWriter.AppendGeometryCollectionTaggedText((IGeometryCollection)geometry, writer); + AppendGeometryCollectionTaggedText((IGeometryCollection)geometry, writer); } } @@ -180,12 +175,12 @@ private static void AppendCoordinates(ICoordinateList coordinates, TextWriter wr writer.Write("("); } - WktWriter.AppendCoordinate(coordinates[0], writer); + AppendCoordinate(coordinates[0], writer); for (int i = 1; i < coordinates.Count; i++) { writer.Write(", "); - WktWriter.AppendCoordinate(coordinates[i], writer); + AppendCoordinate(coordinates[i], writer); } if (wrap) @@ -203,14 +198,14 @@ private static void AppendPointTaggedText(IPoint point, TextWriter writer) { writer.Write("point "); - string dimension = WktWriter.GetDimensionText(point); + string dimension = GetDimensionText(point); if (string.IsNullOrEmpty(dimension) == false) { writer.Write(dimension); writer.Write(" "); } - WktWriter.AppendPointText(point, writer); + AppendPointText(point, writer); } /// @@ -227,7 +222,7 @@ private static void AppendPointText(IPoint point, TextWriter writer) else { writer.Write("("); - WktWriter.AppendCoordinate(point.Position, writer); + AppendCoordinate(point.Position, writer); writer.Write(")"); } } @@ -241,14 +236,14 @@ private static void AppendLineStringTaggedText(ILineString linestring, TextWrite { writer.Write("linestring "); - string dimension = WktWriter.GetDimensionText(linestring); + string dimension = GetDimensionText(linestring); if (string.IsNullOrEmpty(dimension) == false) { writer.Write(dimension); writer.Write(" "); } - WktWriter.AppendLineStringText(linestring, writer); + AppendLineStringText(linestring, writer); } /// @@ -264,7 +259,7 @@ private static void AppendLineStringText(ILineString linestring, TextWriter writ } else { - WktWriter.AppendCoordinates(linestring.Coordinates, writer, true); + AppendCoordinates(linestring.Coordinates, writer, true); } } @@ -277,14 +272,14 @@ private static void AppendPolygonTaggedText(IPolygon polygon, TextWriter writer) { writer.Write("polygon "); - string dimension = WktWriter.GetDimensionText(polygon); + string dimension = GetDimensionText(polygon); if (string.IsNullOrEmpty(dimension) == false) { writer.Write(dimension); writer.Write(" "); } - WktWriter.AppendPolygonText(polygon, writer); + AppendPolygonText(polygon, writer); } /// @@ -301,17 +296,17 @@ private static void AppendPolygonText(IPolygon polygon, TextWriter writer) else { writer.Write("("); - WktWriter.AppendCoordinates(polygon.ExteriorRing, writer, true); + AppendCoordinates(polygon.ExteriorRing, writer, true); if (polygon.InteriorRings.Count() > 0) { writer.Write(","); - WktWriter.AppendCoordinates(polygon.InteriorRings.First(), writer, true); + AppendCoordinates(polygon.InteriorRings.First(), writer, true); foreach (var ring in polygon.InteriorRings.Skip(1)) { writer.Write(","); - WktWriter.AppendCoordinates(ring, writer, true); + AppendCoordinates(ring, writer, true); } } @@ -328,14 +323,14 @@ private static void AppendMultiPointTaggedText(IMultiPoint multipoint, TextWrite { writer.Write("multipoint "); - string dimension = WktWriter.GetDimensionText(multipoint); + string dimension = GetDimensionText(multipoint); if (string.IsNullOrEmpty(dimension) == false) { writer.Write(dimension); writer.Write(" "); } - WktWriter.AppendMultiPointText(multipoint, writer); + AppendMultiPointText(multipoint, writer); } /// @@ -355,12 +350,12 @@ private static void AppendMultiPointText(IMultiPoint multipoint, TextWriter writ if (multipoint.Geometries.Count() > 0) { - WktWriter.AppendPointText(multipoint.Geometries.First(), writer); + AppendPointText(multipoint.Geometries.First(), writer); foreach (var point in multipoint.Geometries.Skip(1)) { writer.Write(","); - WktWriter.AppendPointText(point, writer); + AppendPointText(point, writer); } } @@ -377,14 +372,14 @@ private static void AppendMultiLineStringTaggedText(IMultiLineString mls, TextWr { writer.Write("multilinestring "); - string dimension = WktWriter.GetDimensionText(mls); + string dimension = GetDimensionText(mls); if (string.IsNullOrEmpty(dimension) == false) { writer.Write(dimension); writer.Write(" "); } - WktWriter.AppendMultiLineStringText(mls, writer); + AppendMultiLineStringText(mls, writer); } /// @@ -402,12 +397,12 @@ private static void AppendMultiLineStringText(IMultiLineString mls, TextWriter w { writer.Write("("); - WktWriter.AppendLineStringText(mls.Geometries.First(), writer); + AppendLineStringText(mls.Geometries.First(), writer); foreach (var linestring in mls.Geometries.Skip(1)) { writer.Write(","); - WktWriter.AppendLineStringText(linestring, writer); + AppendLineStringText(linestring, writer); } writer.Write(")"); @@ -423,14 +418,14 @@ private static void AppendMultiPolygonTaggetText(IMultiPolygon mp, TextWriter wr { writer.Write("multipolygon "); - string dimension = WktWriter.GetDimensionText(mp); + string dimension = GetDimensionText(mp); if (string.IsNullOrEmpty(dimension) == false) { writer.Write(dimension); writer.Write(" "); } - WktWriter.AppendMultiPolygonText(mp, writer); + AppendMultiPolygonText(mp, writer); } /// @@ -448,12 +443,12 @@ private static void AppendMultiPolygonText(IMultiPolygon multipolygon, TextWrite { writer.Write("("); - WktWriter.AppendPolygonText(multipolygon.Geometries.First(), writer); + AppendPolygonText(multipolygon.Geometries.First(), writer); foreach (var polygon in multipolygon.Geometries.Skip(1)) { writer.Write(","); - WktWriter.AppendPolygonText(polygon, writer); + AppendPolygonText(polygon, writer); } writer.Write(")"); @@ -469,14 +464,14 @@ private static void AppendGeometryCollectionTaggedText(IGeometryCollection @@ -493,12 +488,12 @@ private static void AppendGeometryCollectionText(IGeometryCollection else { writer.Write("("); - WktWriter.Write(collection.Geometries.First(), writer); + Write(collection.Geometries.First(), writer); foreach (var geometry in collection.Geometries.Skip(1)) { writer.Write(","); - WktWriter.Write(geometry, writer); + Write(geometry, writer); } writer.Write(")"); diff --git a/src/SpatialLite.Core/Measurements.cs b/src/SpatialLite.Core/Measurements.cs index da6951e..336c1ca 100644 --- a/src/SpatialLite.Core/Measurements.cs +++ b/src/SpatialLite.Core/Measurements.cs @@ -1,7 +1,6 @@ -using System.Linq; - +using SpatialLite.Core.Algorithms; using SpatialLite.Core.API; -using SpatialLite.Core.Algorithms; +using System.Linq; namespace SpatialLite.Core; @@ -29,7 +28,7 @@ static Measurements() /// The IDistance calculator to be used. public Measurements(IDimensionsCalculator distanceCalculator) { - this.DimensionsCalculator = distanceCalculator; + DimensionsCalculator = distanceCalculator; } /// @@ -67,7 +66,7 @@ public static Measurements Sphere2D /// distance between two point public double ComputeDistance(Coordinate c1, Coordinate c2) { - return this.DimensionsCalculator.CalculateDistance(c1, c2); + return DimensionsCalculator.CalculateDistance(c1, c2); } /// @@ -87,7 +86,7 @@ public double ComputeDistance(IPoint point, ILineString linestring) for (int i = 1; i < linestring.Coordinates.Count; i++) { - double distance = this.DimensionsCalculator.CalculateDistance(point.Position, linestring.Coordinates[i - 1], linestring.Coordinates[i], LineMode.LineSegment); + double distance = DimensionsCalculator.CalculateDistance(point.Position, linestring.Coordinates[i - 1], linestring.Coordinates[i], LineMode.LineSegment); if (distance < minDistance) { minDistance = distance; @@ -113,7 +112,7 @@ public double ComputeDistance(IPoint point, IMultiLineString multilinestring) double minDistance = double.PositiveInfinity; foreach (var linestring in multilinestring.Geometries) { - double distance = this.ComputeDistance(point, linestring); + double distance = ComputeDistance(point, linestring); if (distance < minDistance) { minDistance = distance; @@ -136,7 +135,7 @@ public double ComputeDistance(IPoint p1, IPoint p2) return double.NaN; } - return this.DimensionsCalculator.CalculateDistance(p1.Position, p2.Position); + return DimensionsCalculator.CalculateDistance(p1.Position, p2.Position); } /// @@ -149,7 +148,7 @@ public double ComputeLength(ILineString line) double length = 0; for (int i = 1; i < line.Coordinates.Count; i++) { - length += this.DimensionsCalculator.CalculateDistance(line.Coordinates[i - 1], line.Coordinates[i]); + length += DimensionsCalculator.CalculateDistance(line.Coordinates[i - 1], line.Coordinates[i]); } return length; @@ -166,7 +165,7 @@ public double ComputeLength(IMultiLineString multilinestring) foreach (var line in multilinestring.Geometries) { - length += this.ComputeLength(line); + length += ComputeLength(line); } return length; @@ -179,11 +178,11 @@ public double ComputeLength(IMultiLineString multilinestring) /// The area of the Polygon public double ComputeArea(IPolygon polygon) { - double area = this.DimensionsCalculator.CalculateArea(polygon.ExteriorRing); + double area = DimensionsCalculator.CalculateArea(polygon.ExteriorRing); foreach (var interiorRing in polygon.InteriorRings) { - area -= this.DimensionsCalculator.CalculateArea(interiorRing); + area -= DimensionsCalculator.CalculateArea(interiorRing); } return area; @@ -200,7 +199,7 @@ public double ComputeArea(IMultiPolygon multiPolygon) foreach (var polygon in multiPolygon.Geometries) { - area += this.ComputeArea(polygon); + area += ComputeArea(polygon); } return area; diff --git a/src/SpatialLite.Core/Topology.cs b/src/SpatialLite.Core/Topology.cs index dfcab8c..1cf88cb 100644 --- a/src/SpatialLite.Core/Topology.cs +++ b/src/SpatialLite.Core/Topology.cs @@ -1,7 +1,6 @@ -using System; - -using SpatialLite.Core.Algorithms; +using SpatialLite.Core.Algorithms; using SpatialLite.Core.API; +using System; namespace SpatialLite.Core; @@ -11,7 +10,7 @@ namespace SpatialLite.Core; public class Topology { - private static Topology _euclidean2D; + private static readonly Topology _euclidean2D; /// /// Initializes static members of the Topology class. @@ -38,12 +37,7 @@ public static Topology Euclidean2D /// The IGeometryLocator object to use. public Topology(IGeometryLocator geometryLocator) { - if (geometryLocator == null) - { - throw new ArgumentNullException(nameof(geometryLocator), "GeometryLocator can't be null"); - } - - this.GeometryLocator = geometryLocator; + GeometryLocator = geometryLocator ?? throw new ArgumentNullException(nameof(geometryLocator), "GeometryLocator can't be null"); } /// @@ -60,13 +54,13 @@ public Topology(IGeometryLocator geometryLocator) /// true if coordinate lies inside outer polygon boundary and outside polygon's inner boundaries (holes), otherwise returns false. public bool IsInside(Coordinate c, IPolygon polygon, bool includeBoundaries) { - bool insideExterior = this.GeometryLocator.IsInRing(c, polygon.ExteriorRing); + bool insideExterior = GeometryLocator.IsInRing(c, polygon.ExteriorRing); if (insideExterior == false) { if (includeBoundaries) { - return this.GeometryLocator.IsOnLine(c, polygon.ExteriorRing); + return GeometryLocator.IsOnLine(c, polygon.ExteriorRing); } else { @@ -77,11 +71,11 @@ public bool IsInside(Coordinate c, IPolygon polygon, bool includeBoundaries) { foreach (var ring in polygon.InteriorRings) { - if (this.GeometryLocator.IsInRing(c, ring)) + if (GeometryLocator.IsInRing(c, ring)) { return false; } - else if (includeBoundaries && this.GeometryLocator.IsOnLine(c, ring)) + else if (includeBoundaries && GeometryLocator.IsOnLine(c, ring)) { return true; } @@ -102,7 +96,7 @@ public bool IsInside(Coordinate c, IMultiPolygon multipolygon, bool includeBound { foreach (var polygon in multipolygon.Geometries) { - if (this.IsInside(c, polygon, includeBoundaries)) + if (IsInside(c, polygon, includeBoundaries)) { return true; } @@ -119,7 +113,7 @@ public bool IsInside(Coordinate c, IMultiPolygon multipolygon, bool includeBound /// true if coordinate lies on the polyline, otherwise false. public bool IsOnLine(Coordinate c, ILineString line) { - return this.GeometryLocator.IsOnLine(c, line.Coordinates); + return GeometryLocator.IsOnLine(c, line.Coordinates); } /// @@ -132,7 +126,7 @@ public bool IsOnLine(Coordinate c, IMultiLineString multiline) { foreach (var line in multiline.Geometries) { - if (this.IsOnLine(c, line)) + if (IsOnLine(c, line)) { return true; } @@ -149,6 +143,6 @@ public bool IsOnLine(Coordinate c, IMultiLineString multiline) /// true if polylines intersets, otherwise false. public bool Intersects(ILineString line1, ILineString line2) { - return this.GeometryLocator.Intersects(line1.Coordinates, line2.Coordinates); + return GeometryLocator.Intersects(line1.Coordinates, line2.Coordinates); } } diff --git a/src/SpatialLite.Gps/Geometries/GpsPoint.cs b/src/SpatialLite.Gps/Geometries/GpsPoint.cs index bb1049e..21b2b30 100644 --- a/src/SpatialLite.Gps/Geometries/GpsPoint.cs +++ b/src/SpatialLite.Gps/Geometries/GpsPoint.cs @@ -1,6 +1,6 @@ -using System; -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; +using System; namespace SpatialLite.Gps.Geometries; diff --git a/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs b/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs index 8147326..7d3461c 100644 --- a/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs +++ b/src/SpatialLite.Gps/Geometries/GpsTrackBase.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; +using System.Collections.Generic; namespace SpatialLite.Gps.Geometries; @@ -10,7 +10,7 @@ namespace SpatialLite.Gps.Geometries; /// The type of the Gps points public class GpsTrackBase : LineString where T : IGpsPoint { - private ICoordinateList _coordinatesAdapter; + private readonly ICoordinateList _coordinatesAdapter; /// /// Creates a new instance of the GpsTrackBase class @@ -25,8 +25,8 @@ public GpsTrackBase() : this(new T[] { }) /// The points of the track public GpsTrackBase(IEnumerable points) { - this.Points = new List(points); - _coordinatesAdapter = new ReadOnlyCoordinateList(this.Points); + Points = new List(points); + _coordinatesAdapter = new ReadOnlyCoordinateList(Points); } /// diff --git a/src/SpatialLite.Gps/Geometries/GpxMetadata.cs b/src/SpatialLite.Gps/Geometries/GpxMetadata.cs index ec162d5..04706a9 100644 --- a/src/SpatialLite.Gps/Geometries/GpxMetadata.cs +++ b/src/SpatialLite.Gps/Geometries/GpxMetadata.cs @@ -8,9 +8,9 @@ namespace SpatialLite.Gps.Geometries; public abstract class GpxMetadata { /// - /// Gets or sets the name of the entity - /// - public string Name { get; set; } + /// Gets or sets the name of the entity + /// + public string Name { get; set; } /// /// Gets or sets the comment for the entity diff --git a/src/SpatialLite.Gps/Geometries/GpxPoint.cs b/src/SpatialLite.Gps/Geometries/GpxPoint.cs index 98bd2b4..c505084 100644 --- a/src/SpatialLite.Gps/Geometries/GpxPoint.cs +++ b/src/SpatialLite.Gps/Geometries/GpxPoint.cs @@ -1,5 +1,5 @@ -using System; -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System; namespace SpatialLite.Gps.Geometries; diff --git a/src/SpatialLite.Gps/Geometries/GpxTrack.cs b/src/SpatialLite.Gps/Geometries/GpxTrack.cs index e83b354..e8d4beb 100644 --- a/src/SpatialLite.Gps/Geometries/GpxTrack.cs +++ b/src/SpatialLite.Gps/Geometries/GpxTrack.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using SpatialLite.Core.Geometries; +using SpatialLite.Core.Geometries; +using System.Collections.Generic; namespace SpatialLite.Gps.Geometries; diff --git a/src/SpatialLite.Gps/GpxDocument.cs b/src/SpatialLite.Gps/GpxDocument.cs index 046fe6b..f6b5d7f 100644 --- a/src/SpatialLite.Gps/GpxDocument.cs +++ b/src/SpatialLite.Gps/GpxDocument.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using SpatialLite.Gps.Geometries; +using SpatialLite.Gps.Geometries; using SpatialLite.Gps.IO; +using System; +using System.Collections.Generic; namespace SpatialLite.Gps; @@ -15,9 +15,9 @@ public class GpxDocument /// public GpxDocument() { - this.Waypoints = new List(); - this.Routes = new List(); - this.Tracks = new List(); + Waypoints = new List(); + Routes = new List(); + Tracks = new List(); } /// @@ -28,9 +28,9 @@ public GpxDocument() /// A collection of tracks to add to the document. public GpxDocument(IEnumerable waypoints, IEnumerable routes, IEnumerable tracks) { - this.Waypoints = new List(waypoints); - this.Routes = new List(routes); - this.Tracks = new List(tracks); + Waypoints = new List(waypoints); + Routes = new List(routes); + Tracks = new List(tracks); } /// @@ -56,7 +56,7 @@ public void Save(string path) { using (GpxWriter writer = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = true })) { - this.Save(writer); + Save(writer); } } @@ -71,17 +71,17 @@ public void Save(IGpxWriter writer) throw new ArgumentNullException(nameof(writer)); } - foreach (var waypoint in this.Waypoints) + foreach (var waypoint in Waypoints) { writer.Write(waypoint); } - foreach (var route in this.Routes) + foreach (var route in Routes) { writer.Write(route); } - foreach (var track in this.Tracks) + foreach (var track in Tracks) { writer.Write(track); } @@ -93,14 +93,14 @@ public void Save(IGpxWriter writer) /// The reader to read data from private void LoadFromReader(IGpxReader reader) { - IGpxGeometry geometry = null; + IGpxGeometry geometry; while ((geometry = reader.Read()) != null) { switch (geometry.GeometryType) { - case GpxGeometryType.Waypoint: this.Waypoints.Add((GpxPoint)geometry); break; - case GpxGeometryType.Route: this.Routes.Add((GpxRoute)geometry); break; - case GpxGeometryType.Track: this.Tracks.Add((GpxTrack)geometry); break; + case GpxGeometryType.Waypoint: Waypoints.Add((GpxPoint)geometry); break; + case GpxGeometryType.Route: Routes.Add((GpxRoute)geometry); break; + case GpxGeometryType.Track: Tracks.Add((GpxTrack)geometry); break; } } } diff --git a/src/SpatialLite.Gps/IGpsPoint.cs b/src/SpatialLite.Gps/IGpsPoint.cs index 0d88f62..b460847 100644 --- a/src/SpatialLite.Gps/IGpsPoint.cs +++ b/src/SpatialLite.Gps/IGpsPoint.cs @@ -1,5 +1,5 @@ -using System; -using SpatialLite.Core.API; +using SpatialLite.Core.API; +using System; namespace SpatialLite.Gps; diff --git a/src/SpatialLite.Gps/IO/GpxReader.cs b/src/SpatialLite.Gps/IO/GpxReader.cs index 337b394..edda6b4 100644 --- a/src/SpatialLite.Gps/IO/GpxReader.cs +++ b/src/SpatialLite.Gps/IO/GpxReader.cs @@ -1,7 +1,7 @@ -using System; +using SpatialLite.Gps.Geometries; +using System; using System.IO; using System.Xml; -using SpatialLite.Gps.Geometries; namespace SpatialLite.Gps.IO; @@ -11,7 +11,7 @@ namespace SpatialLite.Gps.IO; public class GpxReader : IGpxReader, IDisposable { - private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + private readonly System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; private bool _disposed = false; private XmlReader _xmlReader; @@ -19,8 +19,8 @@ public class GpxReader : IGpxReader, IDisposable /// /// Underlaying stream to read data from /// - private Stream _input; - private bool _ownsInputStream = false; + private readonly Stream _input; + private readonly bool _ownsInputStream = false; private bool _insideGpx = false; @@ -34,9 +34,9 @@ public GpxReader(string path, GpxReaderSettings settings) _input = new FileStream(path, FileMode.Open, FileAccess.Read); _ownsInputStream = true; - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); + Settings = settings; + Settings.IsReadOnly = true; + InitializeReader(); } /// @@ -48,9 +48,9 @@ public GpxReader(Stream stream, GpxReaderSettings settings) { _input = stream; - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); + Settings = settings; + Settings.IsReadOnly = true; + InitializeReader(); } /// @@ -112,7 +112,7 @@ private GpxPoint ReadPoint(string pointElementName) DateTime timestamp = new DateTime(); GpxPointMetadata metadata = null; - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { metadata = new GpxPointMetadata(); } @@ -139,9 +139,9 @@ private GpxPoint ReadPoint(string pointElementName) elementParsed = true; } - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { - elementParsed = elementParsed || this.TryReadPointMetadata(metadata); + elementParsed = elementParsed || TryReadPointMetadata(metadata); } if (!elementParsed) @@ -171,7 +171,7 @@ private GpxTrack ReadTrack() _xmlReader.Read(); GpxTrackMetadata metadata = null; - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { metadata = new GpxTrackMetadata(); } @@ -186,9 +186,9 @@ private GpxTrack ReadTrack() elementParsed = true; } - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { - elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); + elementParsed = elementParsed || TryReadTrackMetadata(metadata); } if (!elementParsed) @@ -247,7 +247,7 @@ private GpxRoute ReadRoute() _xmlReader.Read(); GpxTrackMetadata metadata = null; - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { metadata = new GpxTrackMetadata(); } @@ -262,9 +262,9 @@ private GpxRoute ReadRoute() elementParsed = true; } - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { - elementParsed = elementParsed || this.TryReadTrackMetadata(metadata); + elementParsed = elementParsed || TryReadTrackMetadata(metadata); } if (!elementParsed) @@ -304,7 +304,7 @@ private void InitializeReader() string version = _xmlReader.GetAttribute("version"); if (version == null || (version != "1.0" && version != "1.1")) - throw new InvalidDataException(String.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); + throw new InvalidDataException(string.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); _insideGpx = true; @@ -432,7 +432,7 @@ private bool TryReadPointMetadata(GpxPointMetadata metadata) /// true to release both managed and unmanaged resources; false to release only unmanaged resources. private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { if (disposing) { diff --git a/src/SpatialLite.Gps/IO/GpxReaderSettings.cs b/src/SpatialLite.Gps/IO/GpxReaderSettings.cs index 1496ba8..088b4c4 100644 --- a/src/SpatialLite.Gps/IO/GpxReaderSettings.cs +++ b/src/SpatialLite.Gps/IO/GpxReaderSettings.cs @@ -7,15 +7,14 @@ namespace SpatialLite.Gps.IO; /// public class GpxReaderSettings { - - bool _readMetadata = true; + private bool _readMetadata = true; /// /// Initializes a new instance of the GpxReaderSettings class with default values. /// public GpxReaderSettings() { - this.ReadMetadata = true; + ReadMetadata = true; } /// @@ -29,7 +28,7 @@ public bool ReadMetadata } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'ReadMetadata' property GpxReaderSettings is read-only."); } diff --git a/src/SpatialLite.Gps/IO/GpxWriter.cs b/src/SpatialLite.Gps/IO/GpxWriter.cs index e3beeea..ccd0825 100644 --- a/src/SpatialLite.Gps/IO/GpxWriter.cs +++ b/src/SpatialLite.Gps/IO/GpxWriter.cs @@ -1,8 +1,8 @@ -using System; +using SpatialLite.Gps.Geometries; +using System; using System.IO; using System.Text; using System.Xml; -using SpatialLite.Gps.Geometries; namespace SpatialLite.Gps.IO; @@ -11,10 +11,10 @@ namespace SpatialLite.Gps.IO; /// public class GpxWriter : IDisposable, IGpxWriter { - private System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + private readonly System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; - private XmlWriter _xmlWriter; - private StreamWriter _streamWriter; + private readonly XmlWriter _xmlWriter; + private readonly StreamWriter _streamWriter; private bool _disposed = false; /// @@ -24,7 +24,7 @@ public class GpxWriter : IDisposable, IGpxWriter /// The settings defining behaviour of the writer. public GpxWriter(Stream stream, GpxWriterSettings settings) { - this.Settings = settings; + Settings = settings; settings.IsReadOnly = true; XmlWriterSettings writerSetting = new XmlWriterSettings(); @@ -44,7 +44,7 @@ public GpxWriter(Stream stream, GpxWriterSettings settings) /// If the file exists, it is overwritten, otherwise, a new file is created. public GpxWriter(string path, GpxWriterSettings settings) { - this.Settings = settings; + Settings = settings; settings.IsReadOnly = true; XmlWriterSettings writerSetting = new XmlWriterSettings(); @@ -65,7 +65,7 @@ private void StartDocument() _xmlWriter.WriteStartDocument(); _xmlWriter.WriteStartElement("gpx", "http://www.topografix.com/GPX/1/1"); _xmlWriter.WriteAttributeString("version", "1.1"); - _xmlWriter.WriteAttributeString("creator", this.Settings.GeneratorName ?? "SpatialLite"); + _xmlWriter.WriteAttributeString("creator", Settings.GeneratorName ?? "SpatialLite"); } /// @@ -94,9 +94,9 @@ public void Write(GpxRoute route) { WritePoint(route.Points[i], "rtept"); } - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { - this.WriteTrackMetadata(route.Metadata); + WriteTrackMetadata(route.Metadata); } _xmlWriter.WriteEndElement(); @@ -122,9 +122,9 @@ public void Write(GpxTrack track) _xmlWriter.WriteEndElement(); } - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { - this.WriteTrackMetadata(track.Metadata); + WriteTrackMetadata(track.Metadata); } _xmlWriter.WriteEndElement(); @@ -161,9 +161,9 @@ private void WritePoint(GpxPoint point, string pointElementName) _xmlWriter.WriteElementString("time", point.Timestamp.Value.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture)); } - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { - this.WritePointMetadata(point.Metadata); + WritePointMetadata(point.Metadata); } _xmlWriter.WriteEndElement(); @@ -187,7 +187,7 @@ private void WriteTrackMetadata(GpxTrackMetadata metadata) _xmlWriter.WriteElementString("src", metadata.Source); foreach (var link in metadata.Links) { - this.WriteLink(link); + WriteLink(link); } if (metadata.Comment != null) _xmlWriter.WriteElementString("type", metadata.Type); @@ -221,7 +221,7 @@ private void WritePointMetadata(GpxPointMetadata metadata) foreach (var link in metadata.Links) { - this.WriteLink(link); + WriteLink(link); } if (metadata.MagVar.HasValue) @@ -290,7 +290,7 @@ private void WriteLink(GpxLink link) /// true to release both managed and unmanaged resources; false to release only unmanaged resources. private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { if (disposing) { diff --git a/src/SpatialLite.Gps/IO/GpxWriterSettings.cs b/src/SpatialLite.Gps/IO/GpxWriterSettings.cs index 73c3b04..6d71928 100644 --- a/src/SpatialLite.Gps/IO/GpxWriterSettings.cs +++ b/src/SpatialLite.Gps/IO/GpxWriterSettings.cs @@ -7,9 +7,8 @@ namespace SpatialLite.Gps.IO; /// public class GpxWriterSettings { - - bool _writeMetadata = true; - string _generatorName; + private bool _writeMetadata = true; + private string _generatorName; /// /// Initializes a new instance of the GpxWriterSettings class with default values. @@ -29,7 +28,7 @@ public bool WriteMetadata } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - GpxWriterSettings is read-only."); } @@ -49,7 +48,7 @@ public string GeneratorName } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'GeneratorName' property - GpxWriterSettings is read-only."); } diff --git a/src/SpatialLite.Osm/EntityCollection.cs b/src/SpatialLite.Osm/EntityCollection.cs index 0d38bd2..3aedd08 100644 --- a/src/SpatialLite.Osm/EntityCollection.cs +++ b/src/SpatialLite.Osm/EntityCollection.cs @@ -10,7 +10,7 @@ namespace SpatialLite.Osm; public class EntityCollection : ITypedEntityCollection where T : IOsmEntity { - private Dictionary _storage = null; + private readonly Dictionary _storage = null; /// /// Initializes a new instance of the EntityCollection class that is empty. @@ -70,7 +70,7 @@ public T this[long id] return value; } - return default(T); + return default; } } @@ -176,6 +176,6 @@ public IEnumerator GetEnumerator() /// A IEnumerator that can be used to iterate through the collection. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } } diff --git a/src/SpatialLite.Osm/Geometries/Node.cs b/src/SpatialLite.Osm/Geometries/Node.cs index 1f5714a..3f2d8d8 100644 --- a/src/SpatialLite.Osm/Geometries/Node.cs +++ b/src/SpatialLite.Osm/Geometries/Node.cs @@ -60,8 +60,8 @@ public Node(long id, Coordinate position) public Node(long id, Coordinate position, TagsCollection tags) : base(position) { - this.ID = id; - this.Tags = tags; + ID = id; + Tags = tags; } /// diff --git a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs index e8baf77..f1da1dd 100644 --- a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs +++ b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs @@ -1,8 +1,7 @@ -using System; +using SpatialLite.Osm.IO; +using System; using System.Collections.Generic; -using SpatialLite.Osm.IO; - namespace SpatialLite.Osm.Geometries; /// @@ -40,7 +39,7 @@ public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferential List relations = new List(); - IEntityInfo entityInfo = null; + IEntityInfo entityInfo; while ((entityInfo = reader.Read()) != null) { switch (entityInfo.EntityType) diff --git a/src/SpatialLite.Osm/Geometries/Relation.cs b/src/SpatialLite.Osm/Geometries/Relation.cs index ff54497..575c9e2 100644 --- a/src/SpatialLite.Osm/Geometries/Relation.cs +++ b/src/SpatialLite.Osm/Geometries/Relation.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using SpatialLite.Core.Geometries; +using SpatialLite.Core.Geometries; +using System.Collections.Generic; namespace SpatialLite.Osm.Geometries; @@ -38,8 +37,8 @@ public Relation(long id, IEnumerable members) public Relation(long id, IEnumerable members, TagsCollection tags) : base(members) { - this.ID = id; - this.Tags = tags; + ID = id; + Tags = tags; } /// diff --git a/src/SpatialLite.Osm/Geometries/RelationMember.cs b/src/SpatialLite.Osm/Geometries/RelationMember.cs index af9359b..df13f56 100644 --- a/src/SpatialLite.Osm/Geometries/RelationMember.cs +++ b/src/SpatialLite.Osm/Geometries/RelationMember.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; +using System; +using System.Collections.Generic; namespace SpatialLite.Osm.Geometries; @@ -29,25 +28,20 @@ public RelationMember(IOsmGeometry member) public RelationMember(IOsmGeometry member, string role) : base() { - if (member == null) - { - throw new ArgumentNullException(nameof(member)); - } - - this.Member = member; - this.Role = role; + Member = member ?? throw new ArgumentNullException(nameof(member)); + Role = role; if (member is Node) { - this.MemberType = EntityType.Node; + MemberType = EntityType.Node; } else if (member is Way) { - this.MemberType = EntityType.Way; + MemberType = EntityType.Way; } else if (member is Relation) { - this.MemberType = EntityType.Relation; + MemberType = EntityType.Relation; } else { @@ -77,7 +71,7 @@ public override bool Is3D { get { - return ((Geometry)this.Member).Is3D; + return ((Geometry)Member).Is3D; } } @@ -88,7 +82,7 @@ public override bool IsMeasured { get { - return ((Geometry)this.Member).IsMeasured; + return ((Geometry)Member).IsMeasured; } } @@ -103,7 +97,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn { if (info.MemberType == EntityType.Unknown) { - throw new ArgumentException("info.MemberType cannot be EntityType.Unknown"); + throw new ArgumentException(null, nameof(info.MemberType cannot be EntityType.Unknown)); } if (entities.Contains(info.Reference, info.MemberType) == false) @@ -135,7 +129,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn /// public override Envelope GetEnvelope() { - return ((Geometry)this.Member).GetEnvelope(); + return ((Geometry)Member).GetEnvelope(); } /// @@ -144,6 +138,6 @@ public override Envelope GetEnvelope() /// the collection of all of this object public override IEnumerable GetCoordinates() { - return this.Member.GetCoordinates(); + return Member.GetCoordinates(); } } diff --git a/src/SpatialLite.Osm/Geometries/Way.cs b/src/SpatialLite.Osm/Geometries/Way.cs index 1814897..b26c086 100644 --- a/src/SpatialLite.Osm/Geometries/Way.cs +++ b/src/SpatialLite.Osm/Geometries/Way.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; +using System; +using System.Collections.Generic; namespace SpatialLite.Osm.Geometries; @@ -12,7 +11,7 @@ namespace SpatialLite.Osm.Geometries; public class Way : LineString, IOsmGeometry { - private WayCoordinateList _coordinatesAdapter; + private readonly WayCoordinateList _coordinatesAdapter; /// /// Initializes a new instance of the Way class with specified ID. @@ -42,11 +41,11 @@ public Way(long id, IEnumerable nodes) public Way(long id, IEnumerable nodes, TagsCollection tags) : base() { - this.ID = id; - this.Tags = tags; - this.Nodes = new List(nodes); + ID = id; + Tags = tags; + Nodes = new List(nodes); - _coordinatesAdapter = new WayCoordinateList(this.Nodes); + _coordinatesAdapter = new WayCoordinateList(Nodes); } /// @@ -102,8 +101,7 @@ public static Way FromWayInfo(WayInfo info, IEntityCollection enti result.Nodes.Capacity = info.Nodes.Count; foreach (var nodeID in info.Nodes) { - Node node = entities[nodeID, EntityType.Node] as Node; - if (node != null) + if (entities[nodeID, EntityType.Node] is Node node) { result.Nodes.Add(node); } diff --git a/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs b/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs index bb2e694..dcae5f8 100644 --- a/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs +++ b/src/SpatialLite.Osm/Geometries/WayCoordinateList.cs @@ -1,9 +1,8 @@ -using System; +using SpatialLite.Core.API; +using System; using System.Collections; using System.Collections.Generic; -using SpatialLite.Core.API; - namespace SpatialLite.Osm.Geometries; /// @@ -18,7 +17,7 @@ internal class WayCoordinateList : ICoordinateList /// The list of Nodes to be used as source for this WayCoordinateList public WayCoordinateList(IList source) { - this.Source = source; + Source = source; } /// @@ -28,7 +27,7 @@ public int Count { get { - return this.Source.Count; + return Source.Count; } } @@ -46,7 +45,7 @@ public Coordinate this[int index] { get { - return this.Source[index].Position; + return Source[index].Position; } set { @@ -106,7 +105,7 @@ public void Clear() /// The Enumerator for the CoordinateList public IEnumerator GetEnumerator() { - foreach (var node in this.Source) + foreach (var node in Source) { yield return node.Position; } @@ -118,6 +117,6 @@ public IEnumerator GetEnumerator() /// The Enumerator for the CoordinateList IEnumerator IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } } diff --git a/src/SpatialLite.Osm/IO/IOsmWriter.cs b/src/SpatialLite.Osm/IO/IOsmWriter.cs index fdab800..e467c3f 100644 --- a/src/SpatialLite.Osm/IO/IOsmWriter.cs +++ b/src/SpatialLite.Osm/IO/IOsmWriter.cs @@ -1,5 +1,5 @@ -using System; -using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.Geometries; +using System; namespace SpatialLite.Osm.IO; diff --git a/src/SpatialLite.Osm/IO/OsmReaderSettings.cs b/src/SpatialLite.Osm/IO/OsmReaderSettings.cs index 2f33853..b5eab3b 100644 --- a/src/SpatialLite.Osm/IO/OsmReaderSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmReaderSettings.cs @@ -7,15 +7,14 @@ namespace SpatialLite.Osm.IO; /// public class OsmReaderSettings { - - bool _readMetadata = true; + private bool _readMetadata = true; /// /// Initializes a new instance of the OsmReaderSettings class with default values. /// public OsmReaderSettings() { - this.ReadMetadata = true; + ReadMetadata = true; } /// @@ -29,7 +28,7 @@ public bool ReadMetadata } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'ReadMetadata' property OsmReaderSettings is read-only."); } diff --git a/src/SpatialLite.Osm/IO/OsmWriterSettings.cs b/src/SpatialLite.Osm/IO/OsmWriterSettings.cs index c456108..f371c93 100644 --- a/src/SpatialLite.Osm/IO/OsmWriterSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmWriterSettings.cs @@ -7,16 +7,15 @@ namespace SpatialLite.Osm.IO; /// public class OsmWriterSettings { - - bool _writeMetadata = true; - string _programName = "SpatialLITE"; + private bool _writeMetadata = true; + private string _programName = "SpatialLITE"; /// /// Initializes a new instance of the OsmReaderSettings class with default values. /// public OsmWriterSettings() { - this.WriteMetadata = true; + WriteMetadata = true; } /// @@ -30,7 +29,7 @@ public bool WriteMetadata } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'WriteMetadata' property - OsmWriterSettings is read-only."); } @@ -50,7 +49,7 @@ public string ProgramName } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'ProgramName' property - OsmWriterSettings is read-only."); } diff --git a/src/SpatialLite.Osm/IO/OsmXmlReader.cs b/src/SpatialLite.Osm/IO/OsmXmlReader.cs index 4b2c0c7..9bedf17 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReader.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReader.cs @@ -17,8 +17,8 @@ public class OsmXmlReader : IOsmReader /// /// Underlaying stream to read data from /// - private Stream _input; - private bool _ownsInputStream = false; + private readonly Stream _input; + private readonly bool _ownsInputStream = false; /// /// Contains bool value indicating whether XmlReader is inside osm element @@ -35,9 +35,9 @@ public OsmXmlReader(string path, OsmXmlReaderSettings settings) _input = new FileStream(path, FileMode.Open, FileAccess.Read); _ownsInputStream = true; - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); + Settings = settings; + Settings.IsReadOnly = true; + InitializeReader(); } /// @@ -49,9 +49,9 @@ public OsmXmlReader(Stream stream, OsmXmlReaderSettings settings) { _input = stream; - this.Settings = settings; - this.Settings.IsReadOnly = true; - this.InitializeReader(); + Settings = settings; + Settings.IsReadOnly = true; + InitializeReader(); } /// @@ -72,13 +72,13 @@ public IEntityInfo Read() switch (_xmlReader.Name) { case "node": - result = this.ReadNode(); + result = ReadNode(); break; case "way": - result = this.ReadWay(); + result = ReadWay(); break; case "relation": - result = this.ReadRelation(); + result = ReadRelation(); break; default: _xmlReader.Read(); @@ -132,9 +132,9 @@ private NodeInfo ReadNode() double nodeLon = double.Parse(attLon, System.Globalization.CultureInfo.InvariantCulture); EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { - additionalInfo = this.ReadMetadata(); + additionalInfo = ReadMetadata(); } NodeInfo result = new NodeInfo(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); @@ -147,7 +147,7 @@ private NodeInfo ReadNode() { if (_xmlReader.NodeType == Sys.XmlNodeType.Element && _xmlReader.Name == "tag") { - result.Tags.Add(this.ReadTag()); + result.Tags.Add(ReadTag()); } else { @@ -175,9 +175,9 @@ private WayInfo ReadWay() var wayId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { - additionalInfo = this.ReadMetadata(); + additionalInfo = ReadMetadata(); } WayInfo way = new WayInfo(wayId, new TagsCollection(), new List(), additionalInfo); @@ -194,10 +194,10 @@ private WayInfo ReadWay() switch (_xmlReader.Name) { case "nd": - way.Nodes.Add(this.ReadWayNd()); + way.Nodes.Add(ReadWayNd()); continue; case "tag": - way.Tags.Add(this.ReadTag()); + way.Tags.Add(ReadTag()); continue; default: _xmlReader.Skip(); @@ -249,9 +249,9 @@ private RelationInfo ReadRelation() var relationId = long.Parse(attId, System.Globalization.CultureInfo.InvariantCulture); EntityMetadata additionalInfo = null; - if (this.Settings.ReadMetadata) + if (Settings.ReadMetadata) { - additionalInfo = this.ReadMetadata(); + additionalInfo = ReadMetadata(); } RelationInfo relation = new RelationInfo(relationId, new TagsCollection(), new List(), additionalInfo); @@ -268,10 +268,10 @@ private RelationInfo ReadRelation() switch (_xmlReader.Name) { case "member": - relation.Members.Add(this.ReadRelationMember()); + relation.Members.Add(ReadRelationMember()); continue; case "tag": - relation.Tags.Add(this.ReadTag()); + relation.Tags.Add(ReadTag()); continue; default: _xmlReader.Skip(); @@ -368,7 +368,7 @@ private EntityMetadata ReadMetadata() string attVersion = _xmlReader.GetAttribute("version"); if (attVersion == null) { - if (this.Settings.StrictMode) + if (Settings.StrictMode) { throw new Sys.XmlException("Attribute 'version' is missing."); } @@ -382,7 +382,7 @@ private EntityMetadata ReadMetadata() string attChangeset = _xmlReader.GetAttribute("changeset"); if (attChangeset == null) { - if (this.Settings.StrictMode) + if (Settings.StrictMode) { throw new Sys.XmlException("Attribute 'changeset' is missing."); } @@ -396,7 +396,7 @@ private EntityMetadata ReadMetadata() string attUid = _xmlReader.GetAttribute("uid"); if (attUid == null) { - if (this.Settings.StrictMode) + if (Settings.StrictMode) { throw new Sys.XmlException("Attribute 'uid' is missing."); } @@ -410,7 +410,7 @@ private EntityMetadata ReadMetadata() string attrUser = _xmlReader.GetAttribute("user"); if (attrUser == null) { - if (this.Settings.StrictMode) + if (Settings.StrictMode) { throw new Sys.XmlException("Attribute 'user' is missing."); } @@ -424,7 +424,7 @@ private EntityMetadata ReadMetadata() string attVisible = _xmlReader.GetAttribute("visible"); if (attVisible == null) { - if (this.Settings.StrictMode) + if (Settings.StrictMode) { result.Visible = true; } @@ -438,7 +438,7 @@ private EntityMetadata ReadMetadata() string attTimestamp = _xmlReader.GetAttribute("timestamp"); if (attTimestamp == null) { - if (this.Settings.StrictMode) + if (Settings.StrictMode) { throw new Sys.XmlException("Attribute 'timestamp' is missing."); } @@ -490,7 +490,7 @@ private void InitializeReader() /// true to release both managed and unmanaged resources; false to release only unmanaged resources. private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { if (disposing) { diff --git a/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs b/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs index d221994..82c440e 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReaderSettings.cs @@ -29,7 +29,7 @@ public bool StrictMode } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'StrictMode' property - OsmXmlReaderSettings is read-only."); } diff --git a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs index b96df85..ba680ad 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs @@ -1,10 +1,9 @@ -using System; -using System.Text; +using SpatialLite.Osm.Geometries; +using System; using System.IO; +using System.Text; using System.Xml; -using SpatialLite.Osm.Geometries; - namespace SpatialLite.Osm.IO; /// @@ -13,16 +12,16 @@ namespace SpatialLite.Osm.IO; public class OsmXmlWriter : IOsmWriter { - private System.Globalization.CultureInfo _culture = System.Globalization.CultureInfo.InvariantCulture; - private Stream _output; - private bool _ownsOutputStream; + private readonly System.Globalization.CultureInfo _culture = System.Globalization.CultureInfo.InvariantCulture; + private readonly Stream _output; + private readonly bool _ownsOutputStream; - private XmlWriter _writer; + private readonly XmlWriter _writer; private bool _isInsideOsm = false; private bool _disposed = false; // underlaying stream writer for writing to files - private StreamWriter _streamWriter; + private readonly StreamWriter _streamWriter; /// /// Initializes a new instance of the OsmXmlWriter class that writes OSM entities to the specified stream. @@ -31,8 +30,8 @@ public class OsmXmlWriter : IOsmWriter /// The settings defining behaviour of the writer. public OsmXmlWriter(Stream stream, OsmWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings; + Settings.IsReadOnly = true; _output = stream; _ownsOutputStream = false; @@ -51,8 +50,8 @@ public OsmXmlWriter(Stream stream, OsmWriterSettings settings) /// If the file exists, it is overwritten, otherwise, a new file is created. public OsmXmlWriter(string path, OsmWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings; + Settings.IsReadOnly = true; _output = new FileStream(path, FileMode.Create, FileAccess.Write); _ownsOutputStream = true; @@ -91,14 +90,14 @@ public void Write(IOsmGeometry entity) if (_isInsideOsm == false) { - this.StartDocument(); + StartDocument(); } switch (entity.EntityType) { - case EntityType.Node: this.Write(new NodeInfo((Node)entity)); break; - case EntityType.Way: this.Write(new WayInfo((Way)entity)); break; - case EntityType.Relation: this.Write(new RelationInfo((Relation)entity)); break; + case EntityType.Node: Write(new NodeInfo((Node)entity)); break; + case EntityType.Way: Write(new WayInfo((Way)entity)); break; + case EntityType.Relation: Write(new RelationInfo((Relation)entity)); break; } } @@ -108,7 +107,7 @@ public void Write(IOsmGeometry entity) /// Entity data-transfer object to write. public void Write(IEntityInfo info) { - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { if (info.Metadata == null) { @@ -118,14 +117,14 @@ public void Write(IEntityInfo info) if (_isInsideOsm == false) { - this.StartDocument(); + StartDocument(); } switch (info.EntityType) { - case EntityType.Node: this.WriteNode((NodeInfo)info); break; - case EntityType.Way: this.WriteWay((WayInfo)info); break; - case EntityType.Relation: this.WriteRelation((RelationInfo)info); break; + case EntityType.Node: WriteNode((NodeInfo)info); break; + case EntityType.Way: WriteWay((WayInfo)info); break; + case EntityType.Relation: WriteRelation((RelationInfo)info); break; } } @@ -143,9 +142,9 @@ public void Flush() private void StartDocument() { _writer.WriteStartElement("osm"); - if (string.IsNullOrEmpty(this.Settings.ProgramName) == false) + if (string.IsNullOrEmpty(Settings.ProgramName) == false) { - _writer.WriteAttributeString("generator", this.Settings.ProgramName); + _writer.WriteAttributeString("generator", Settings.ProgramName); } _isInsideOsm = true; @@ -171,12 +170,12 @@ private void WriteNode(NodeInfo info) _writer.WriteAttributeString("lat", info.Latitude.ToString(_culture)); _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { - this.WriteMetadata(info.Metadata); + WriteMetadata(info.Metadata); } - this.WriteTags(info.Tags); + WriteTags(info.Tags); _writer.WriteEndElement(); } @@ -190,12 +189,12 @@ private void WriteWay(WayInfo info) _writer.WriteStartElement("way"); _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { - this.WriteMetadata(info.Metadata); + WriteMetadata(info.Metadata); } - this.WriteTags(info.Tags); + WriteTags(info.Tags); for (int i = 0; i < info.Nodes.Count; i++) { @@ -216,12 +215,12 @@ private void WriteRelation(RelationInfo info) _writer.WriteStartElement("relation"); _writer.WriteAttributeString("id", info.ID.ToString(_culture)); - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { - this.WriteMetadata(info.Metadata); + WriteMetadata(info.Metadata); } - this.WriteTags(info.Tags); + WriteTags(info.Tags); for (int i = 0; i < info.Members.Count; i++) { @@ -276,7 +275,7 @@ private void WriteMetadata(EntityMetadata medatata) /// true to release both managed and unmanaged resources; false to release only unmanaged resources. private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { if (_writer != null) { diff --git a/src/SpatialLite.Osm/IO/Pbf/Blob.cs b/src/SpatialLite.Osm/IO/Pbf/Blob.cs index 700e644..b7d88c8 100644 --- a/src/SpatialLite.Osm/IO/Pbf/Blob.cs +++ b/src/SpatialLite.Osm/IO/Pbf/Blob.cs @@ -26,5 +26,4 @@ internal class Blob /// [ProtoMember(3, IsRequired = false, Name = "zlib_data")] public byte[] ZlibData { get; set; } - } diff --git a/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs b/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs index 9ee372a..f1d2b96 100644 --- a/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs +++ b/src/SpatialLite.Osm/IO/Pbf/BlobHeader.cs @@ -29,5 +29,4 @@ internal class BlobHeader /// [ProtoMember(3, IsRequired = true, Name = "datasize")] public int DataSize { get; set; } - } diff --git a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs index 7698524..5089545 100644 --- a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs +++ b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs @@ -9,12 +9,12 @@ namespace SpatialLite.Osm.IO.Pbf; internal class EntityInfoBuffer : IStringTableBuilder, IEnumerable where T : class, IEntityInfo { - private List _storage = null; - private Dictionary _stringTable; + private readonly List _storage = null; + private readonly Dictionary _stringTable; private int _stringTableSize = 0; private int _estimatedEntityDataSize = 0; - private bool _writeMetadata; + private readonly bool _writeMetadata; /// /// Initializes a new instance of the EntityInfoBuffer class. @@ -31,7 +31,7 @@ public EntityInfoBuffer(bool writeMetadata) _writeMetadata = writeMetadata; //add dummy value to the string table to get rid of 0 index - this.GetStringIndex(string.Empty); + GetStringIndex(string.Empty); } /// @@ -69,8 +69,8 @@ public void Add(T item) foreach (var tag in item.Tags) { - this.GetStringIndex(tag.Key); - this.GetStringIndex(tag.Value); + GetStringIndex(tag.Key); + GetStringIndex(tag.Value); _estimatedEntityDataSize += 8; } @@ -108,7 +108,7 @@ public void Clear() _stringTableSize = 0; //add dummy value to the string table to get rid of 0 index - this.GetStringIndex(string.Empty); + GetStringIndex(string.Empty); } /// diff --git a/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs b/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs index a4c457f..6b6dbec 100644 --- a/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs +++ b/src/SpatialLite.Osm/IO/Pbf/HeaderBBox.cs @@ -32,5 +32,4 @@ internal class HeaderBBox /// [ProtoMember(3, Name = "top", IsRequired = true, DataFormat = DataFormat.ZigZag)] public long Top { get; set; } - } diff --git a/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs b/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs index a7ff43d..4825219 100644 --- a/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs +++ b/src/SpatialLite.Osm/IO/Pbf/OsmHeader.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs b/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs index 70ae85b..1780864 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfChangeset.cs @@ -14,5 +14,4 @@ public class PbfChangeset /// [ProtoMember(1, IsRequired = true, Name = "id")] public long ID { get; set; } - } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs b/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs index ae01db8..525b418 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfDenseMetadata.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs b/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs index 98c6b9c..099b05d 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfDenseNodes.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs b/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs index 4f18fe7..3a7b4bf 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfMetadata.cs @@ -38,5 +38,4 @@ internal class PbfMetadata /// [ProtoMember(1, Name = "version", IsRequired = false)] public int? Version { get; set; } - } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs b/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs index f5eedd2..b8ca5c9 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfNode.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; @@ -46,5 +45,4 @@ internal class PbfNode /// [ProtoMember(9, IsRequired = true, Name = "lon", DataFormat = DataFormat.ZigZag)] public long Longitude { get; set; } - } diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs b/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs index 25040d1..8b08401 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfRelation.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; diff --git a/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs b/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs index bb3c19a..17c43ac 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PbfWay.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; diff --git a/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs b/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs index 73f44bb..f10ff30 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PrimitiveBlock.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; diff --git a/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs b/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs index c0cd23c..3c46fac 100644 --- a/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs +++ b/src/SpatialLite.Osm/IO/Pbf/PrimitiveGroup.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using ProtoBuf; +using ProtoBuf; +using System.Collections.Generic; namespace SpatialLite.Osm.IO.Pbf; @@ -40,5 +39,4 @@ internal class PrimitiveGroup /// [ProtoMember(5, Name = "changesets")] public List Changesets { get; set; } - } diff --git a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs index 6e35567..2e6d743 100644 --- a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs +++ b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs @@ -1,9 +1,8 @@ -using System; +using ProtoBuf; +using System; using System.Collections.Generic; using System.Text; -using ProtoBuf; - namespace SpatialLite.Osm.IO.Pbf; /// @@ -35,21 +34,21 @@ public string this[int index] { get { - if (index >= this.Storage.Count) + if (index >= Storage.Count) { throw new ArgumentOutOfRangeException(nameof(index)); } - return Encoding.UTF8.GetString(this.Storage[index], 0, this.Storage[index].Length); + return Encoding.UTF8.GetString(Storage[index], 0, Storage[index].Length); } set { - if (index >= this.Storage.Count) + if (index >= Storage.Count) { throw new ArgumentOutOfRangeException(nameof(index)); } - this.Storage[index] = Encoding.UTF8.GetBytes(value); + Storage[index] = Encoding.UTF8.GetBytes(value); } } diff --git a/src/SpatialLite.Osm/IO/PbfReader.cs b/src/SpatialLite.Osm/IO/PbfReader.cs index 32c96dc..3627e30 100644 --- a/src/SpatialLite.Osm/IO/PbfReader.cs +++ b/src/SpatialLite.Osm/IO/PbfReader.cs @@ -1,9 +1,9 @@ -using System; +using ProtoBuf; +using SpatialLite.Osm.IO.Pbf; +using System; using System.Collections.Generic; -using System.Linq; using System.IO; -using ProtoBuf; -using SpatialLite.Osm.IO.Pbf; +using System.Linq; namespace SpatialLite.Osm.IO; @@ -24,9 +24,9 @@ public class PbfReader : IOsmReader public const int MaxHeaderBlockSize = 64 * 1024; private bool _disposed = false; - private Stream _input; - private Queue _cache; - private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); + private readonly Stream _input; + private readonly Queue _cache; + private readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); /// /// Initializes a new instance of the PbfReader class that read data form specified stream. @@ -38,18 +38,18 @@ public PbfReader(Stream input, OsmReaderSettings settings) _input = input; _cache = new Queue(); - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings; + Settings.IsReadOnly = true; - BlobHeader blobHeader = null; - while ((blobHeader = this.ReadBlobHeader()) != null) + BlobHeader blobHeader; + while ((blobHeader = ReadBlobHeader()) != null) { try { if (blobHeader.Type == "OSMHeader") { - OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); - this.ProcessOsmHeader(osmHeader); + OsmHeader osmHeader = (OsmHeader)ReadBlob(blobHeader); + ProcessOsmHeader(osmHeader); return; } else if (blobHeader.Type == "OSMData") @@ -80,18 +80,18 @@ public PbfReader(string path, OsmReaderSettings settings) _input = new FileStream(path, FileMode.Open, FileAccess.Read); _cache = new Queue(); - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings; + Settings.IsReadOnly = true; - BlobHeader blobHeader = null; - while ((blobHeader = this.ReadBlobHeader()) != null) + BlobHeader blobHeader; + while ((blobHeader = ReadBlobHeader()) != null) { try { if (blobHeader.Type == "OSMHeader") { - OsmHeader osmHeader = (OsmHeader)this.ReadBlob(blobHeader); - this.ProcessOsmHeader(osmHeader); + OsmHeader osmHeader = (OsmHeader)ReadBlob(blobHeader); + ProcessOsmHeader(osmHeader); return; } else if (blobHeader.Type == "OSMData") @@ -129,15 +129,14 @@ public IEntityInfo Read() } else { - BlobHeader blobHeader = null; - while (_cache.Count == 0 && (blobHeader = this.ReadBlobHeader()) != null) + BlobHeader blobHeader; + while (_cache.Count == 0 && (blobHeader = ReadBlobHeader()) != null) { - PrimitiveBlock data = this.ReadBlob(blobHeader) as PrimitiveBlock; - if (data != null) + if (ReadBlob(blobHeader) is PrimitiveBlock data) { foreach (PrimitiveGroup group in data.PrimitiveGroup) { - this.ProcessPrimitiveGroup(data, group); + ProcessPrimitiveGroup(data, group); } } } @@ -261,10 +260,10 @@ private void ProcessOsmHeader(OsmHeader header) /// The PrimitiveGroup to process. private void ProcessPrimitiveGroup(PrimitiveBlock block, PrimitiveGroup group) { - this.ProcessNodes(block, group); - this.ProcessDenseNodes(block, group); - this.ProcessWays(block, group); - this.ProcessRelations(block, group); + ProcessNodes(block, group); + ProcessDenseNodes(block, group); + ProcessWays(block, group); + ProcessRelations(block, group); } /// @@ -293,9 +292,9 @@ private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) } } - EntityMetadata metadata = this.ProcessMetadata(node.Metadata, block); + EntityMetadata metadata = ProcessMetadata(node.Metadata, block); - NodeInfo parsed = new NodeInfo((long)node.ID, lat, lon, new TagsCollection(tags), metadata); + NodeInfo parsed = new NodeInfo(node.ID, lat, lon, new TagsCollection(tags), metadata); _cache.Enqueue(parsed); } } @@ -348,7 +347,7 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) } EntityMetadata metadata = null; - if (this.Settings.ReadMetadata && group.DenseNodes.DenseInfo != null) + if (Settings.ReadMetadata && group.DenseNodes.DenseInfo != null) { timestampStore += group.DenseNodes.DenseInfo.Timestamp[i]; changesetStore += group.DenseNodes.DenseInfo.Changeset[i]; @@ -371,7 +370,7 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) } } - NodeInfo parsed = new NodeInfo((long)idStore, lat, lon, new TagsCollection(tags), metadata); + NodeInfo parsed = new NodeInfo(idStore, lat, lon, new TagsCollection(tags), metadata); _cache.Enqueue(parsed); } } @@ -395,7 +394,7 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) for (int i = 0; i < way.Refs.Count; i++) { - refStore += (long)way.Refs[i]; + refStore += way.Refs[i]; refs.Add(refStore); } @@ -408,9 +407,9 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) } } - EntityMetadata metadata = this.ProcessMetadata(way.Metadata, block); + EntityMetadata metadata = ProcessMetadata(way.Metadata, block); - WayInfo parsed = new WayInfo((long)way.ID, new TagsCollection(tags), refs, metadata); + WayInfo parsed = new WayInfo(way.ID, new TagsCollection(tags), refs, metadata); _cache.Enqueue(parsed); } } @@ -434,7 +433,7 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) List members = new List(); for (int i = 0; i < relation.MemberIds.Count; i++) { - memberRefStore += (long)relation.MemberIds[i]; + memberRefStore += relation.MemberIds[i]; string role = block.StringTable[relation.RolesIndexes[i]]; EntityType memberType = 0; @@ -457,9 +456,9 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) } } - EntityMetadata metadata = this.ProcessMetadata(relation.Metadata, block); + EntityMetadata metadata = ProcessMetadata(relation.Metadata, block); - RelationInfo parsed = new RelationInfo((long)relation.ID, new TagsCollection(tags), members, metadata); + RelationInfo parsed = new RelationInfo(relation.ID, new TagsCollection(tags), members, metadata); _cache.Enqueue(parsed); } } @@ -474,7 +473,7 @@ private EntityMetadata ProcessMetadata(PbfMetadata serializedMetadata, Primitive { EntityMetadata metadata = null; - if (this.Settings.ReadMetadata && serializedMetadata != null) + if (Settings.ReadMetadata && serializedMetadata != null) { //PBF has no field for 'visible' property, true is default value for OSM entity read from PBF file metadata = new EntityMetadata() { Visible = true }; @@ -513,7 +512,7 @@ private EntityMetadata ProcessMetadata(PbfMetadata serializedMetadata, Primitive /// true to release both managed and unmanaged resources; false to release only unmanaged resources. private void Dispose(bool disposing) { - if (!this._disposed) + if (!_disposed) { if (disposing) { diff --git a/src/SpatialLite.Osm/IO/PbfWriter.cs b/src/SpatialLite.Osm/IO/PbfWriter.cs index f227005..4dd2002 100644 --- a/src/SpatialLite.Osm/IO/PbfWriter.cs +++ b/src/SpatialLite.Osm/IO/PbfWriter.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; -using System.IO; - -using ProtoBuf; +using ProtoBuf; using SpatialLite.Osm.Geometries; using SpatialLite.Osm.IO.Pbf; +using System; +using System.Collections.Generic; +using System.IO; namespace SpatialLite.Osm.IO; @@ -19,11 +18,11 @@ public class PbfWriter : IOsmWriter /// public const int MaxDataBlockSize = 16 * 1024 * 1024; - private DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); + private readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); private bool _disposed = false; - private Stream _output; - private bool _ownsOutputStream; + private readonly Stream _output; + private readonly bool _ownsOutputStream; private EntityInfoBuffer _nodesBuffer; private EntityInfoBuffer _wayBuffer; @@ -36,13 +35,13 @@ public class PbfWriter : IOsmWriter /// The settings defining behaviour of the writer. public PbfWriter(Stream stream, PbfWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings; + Settings.IsReadOnly = true; _output = stream; _ownsOutputStream = false; - this.InitializeBuffers(); - this.WriteHeader(); + InitializeBuffers(); + WriteHeader(); } /// @@ -52,13 +51,13 @@ public PbfWriter(Stream stream, PbfWriterSettings settings) /// The settings defining behaviour of the writer. public PbfWriter(string filename, PbfWriterSettings settings) { - this.Settings = settings; - this.Settings.IsReadOnly = true; + Settings = settings; + Settings.IsReadOnly = true; _output = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite); _ownsOutputStream = true; - this.InitializeBuffers(); - this.WriteHeader(); + InitializeBuffers(); + WriteHeader(); } /// @@ -75,7 +74,7 @@ public PbfWriter(string filename, PbfWriterSettings settings) /// public void Write(IEntityInfo entity) { - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { if (entity.Metadata == null) { @@ -97,17 +96,17 @@ public void Write(IEntityInfo entity) if (_nodesBuffer.EstimatedMaxSize > MaxDataBlockSize) { - this.Flush(EntityType.Node); + Flush(EntityType.Node); } if (_wayBuffer.EstimatedMaxSize > MaxDataBlockSize) { - this.Flush(EntityType.Way); + Flush(EntityType.Way); } if (_relationBuffer.EstimatedMaxSize > MaxDataBlockSize) { - this.Flush(EntityType.Relation); + Flush(EntityType.Relation); } } @@ -127,9 +126,9 @@ public void Write(IOsmGeometry entity) switch (entity.EntityType) { - case EntityType.Node: this.Write(new NodeInfo((Geometries.Node)entity)); break; - case EntityType.Way: this.Write(new WayInfo((Geometries.Way)entity)); break; - case EntityType.Relation: this.Write(new RelationInfo((Geometries.Relation)entity)); break; + case EntityType.Node: Write(new NodeInfo((Geometries.Node)entity)); break; + case EntityType.Way: Write(new WayInfo((Geometries.Way)entity)); break; + case EntityType.Relation: Write(new RelationInfo((Geometries.Relation)entity)); break; } } @@ -138,9 +137,9 @@ public void Write(IOsmGeometry entity) /// public void Flush() { - this.Flush(EntityType.Node); - this.Flush(EntityType.Way); - this.Flush(EntityType.Relation); + Flush(EntityType.Node); + Flush(EntityType.Way); + Flush(EntityType.Relation); } /// @@ -157,9 +156,9 @@ public void Dispose() /// private void InitializeBuffers() { - _nodesBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); - _wayBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); - _relationBuffer = new EntityInfoBuffer(this.Settings.WriteMetadata); + _nodesBuffer = new EntityInfoBuffer(Settings.WriteMetadata); + _wayBuffer = new EntityInfoBuffer(Settings.WriteMetadata); + _relationBuffer = new EntityInfoBuffer(Settings.WriteMetadata); } /// @@ -168,7 +167,7 @@ private void InitializeBuffers() /// The type of entity to process private void Flush(EntityType entityType) { - PrimitiveBlock primitiveBlock = this.BuildPrimitiveBlock(entityType); + PrimitiveBlock primitiveBlock = BuildPrimitiveBlock(entityType); if (primitiveBlock == null) { return; @@ -180,7 +179,7 @@ private void Flush(EntityType entityType) //byte[] buffer = new byte[primitiveBlockStream.Length]; //Array.Copy(primitiveBlockStream.GetBuffer(), buffer, primitiveBlockStream.Length); - this.WriteBlob("OSMData", primitiveBlockStream.ToArray()); + WriteBlob("OSMData", primitiveBlockStream.ToArray()); } /// @@ -191,12 +190,12 @@ private void WriteHeader() OsmHeader header = new OsmHeader(); header.RequiredFeatures.Add("OsmSchema-V0.6"); - if (this.Settings.UseDenseFormat) + if (Settings.UseDenseFormat) { header.RequiredFeatures.Add("DenseNodes"); } - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { header.OptionalFeatures.Add("Has_Metadata"); } @@ -208,7 +207,7 @@ private void WriteHeader() //byte[] buffer = new byte[stream.Length]; //Array.Copy(stream.GetBuffer(), buffer, stream.Length); - this.WriteBlob("OSMHeader", stream.ToArray()); + WriteBlob("OSMHeader", stream.ToArray()); } } @@ -220,11 +219,11 @@ private void WriteHeader() private void WriteBlob(string blobType, byte[] blobContent) { Blob blob = new Blob(); - if (this.Settings.Compression == CompressionMode.None) + if (Settings.Compression == CompressionMode.None) { blob.Raw = blobContent; } - else if (this.Settings.Compression == CompressionMode.ZlibDeflate) + else if (Settings.Compression == CompressionMode.ZlibDeflate) { MemoryStream zlibStream = new MemoryStream(); @@ -237,7 +236,7 @@ private void WriteBlob(string blobType, byte[] blobContent) deflateSteram.Write(blobContent, 0, blobContent.Length); } - blob.RawSize = (int)blobContent.Length; + blob.RawSize = blobContent.Length; blob.ZlibData = zlibStream.ToArray(); } @@ -266,17 +265,17 @@ private PrimitiveBlock BuildPrimitiveBlock(EntityType entityType) switch (entityType) { case EntityType.Node: - entityGroup = this.BuildNodesPrimitiveGroup(result.DateGranularity, result.Granularity, result.LatOffset, result.LonOffset); + entityGroup = BuildNodesPrimitiveGroup(result.DateGranularity, result.Granularity, result.LatOffset, result.LonOffset); result.StringTable = _nodesBuffer.BuildStringTable(); _nodesBuffer.Clear(); break; case EntityType.Way: - entityGroup = this.BuildWaysPrimitiveGroup(result.DateGranularity); + entityGroup = BuildWaysPrimitiveGroup(result.DateGranularity); result.StringTable = _wayBuffer.BuildStringTable(); _wayBuffer.Clear(); break; case EntityType.Relation: - entityGroup = this.BuildRelationsPrimitiveGroup(result.DateGranularity); + entityGroup = BuildRelationsPrimitiveGroup(result.DateGranularity); result.StringTable = _relationBuffer.BuildStringTable(); _relationBuffer.Clear(); break; @@ -308,13 +307,13 @@ private PrimitiveGroup BuildNodesPrimitiveGroup(int timestampGranularity, int po { result = new PrimitiveGroup(); - if (this.Settings.UseDenseFormat) + if (Settings.UseDenseFormat) { - result.DenseNodes = this.BuildDenseNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); + result.DenseNodes = BuildDenseNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); } else { - result.Nodes = this.BuildNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); + result.Nodes = BuildNodes(timestampGranularity, positionGranularity, latOffset, lonOffset); } } @@ -334,7 +333,7 @@ private PrimitiveGroup BuildWaysPrimitiveGroup(int timestampGranularity) { result = new PrimitiveGroup(); - result.Ways = this.BuildWays(timestampGranularity); + result.Ways = BuildWays(timestampGranularity); } return result; @@ -353,7 +352,7 @@ private PrimitiveGroup BuildRelationsPrimitiveGroup(int timestampGranularity) { result = new PrimitiveGroup(); - result.Relations = this.BuildRelations(timestampGranularity); + result.Relations = BuildRelations(timestampGranularity); } return result; @@ -390,9 +389,9 @@ private List BuildNodes(int timestampGranularity, int positionGranulari } } - if (node.Metadata != null && this.Settings.WriteMetadata) + if (node.Metadata != null && Settings.WriteMetadata) { - toAdd.Metadata = this.BuildInfo(node.Metadata, timestampGranularity, _nodesBuffer); + toAdd.Metadata = BuildInfo(node.Metadata, timestampGranularity, _nodesBuffer); } result.Add(toAdd); @@ -439,9 +438,9 @@ private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGran result.KeysVals.Add(0); } - if (this.Settings.WriteMetadata) + if (Settings.WriteMetadata) { - result.DenseInfo = this.BuildDenseInfo(timestampGranularity); + result.DenseInfo = BuildDenseInfo(timestampGranularity); } return result; @@ -487,9 +486,9 @@ private List BuildWays(int timestampGranularity) } } - if (way.Metadata != null && this.Settings.WriteMetadata) + if (way.Metadata != null && Settings.WriteMetadata) { - toAdd.Metadata = this.BuildInfo(way.Metadata, timestampGranularity, _wayBuffer); + toAdd.Metadata = BuildInfo(way.Metadata, timestampGranularity, _wayBuffer); } result.Add(toAdd); @@ -542,9 +541,9 @@ private List BuildRelations(int timestampGranularity) } } - if (relation.Metadata != null && this.Settings.WriteMetadata) + if (relation.Metadata != null && Settings.WriteMetadata) { - toAdd.Metadata = this.BuildInfo(relation.Metadata, timestampGranularity, _relationBuffer); + toAdd.Metadata = BuildInfo(relation.Metadata, timestampGranularity, _relationBuffer); } result.Add(toAdd); @@ -621,7 +620,7 @@ private void Dispose(bool disposing) { if (disposing) { - this.Flush(); + Flush(); if (_output != null) { diff --git a/src/SpatialLite.Osm/IO/PbfWriterSettings.cs b/src/SpatialLite.Osm/IO/PbfWriterSettings.cs index f10d235..7e01a72 100644 --- a/src/SpatialLite.Osm/IO/PbfWriterSettings.cs +++ b/src/SpatialLite.Osm/IO/PbfWriterSettings.cs @@ -17,8 +17,8 @@ public class PbfWriterSettings : OsmWriterSettings public PbfWriterSettings() : base() { - this.UseDenseFormat = true; - this.Compression = CompressionMode.ZlibDeflate; + UseDenseFormat = true; + Compression = CompressionMode.ZlibDeflate; } /// @@ -32,7 +32,7 @@ public bool UseDenseFormat } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'UseDenseFromat' property - PbfReaderSettings is read-only"); } @@ -52,7 +52,7 @@ public CompressionMode Compression } set { - if (this.IsReadOnly) + if (IsReadOnly) { throw new InvalidOperationException("Cannot change the 'Compression' property - PbfReaderSettings is read-only"); } diff --git a/src/SpatialLite.Osm/IOsmEntity.cs b/src/SpatialLite.Osm/IOsmEntity.cs index 8204710..64d67fe 100644 --- a/src/SpatialLite.Osm/IOsmEntity.cs +++ b/src/SpatialLite.Osm/IOsmEntity.cs @@ -25,5 +25,4 @@ public interface IOsmEntity /// Gets type of the entity. /// EntityType EntityType { get; } - } diff --git a/src/SpatialLite.Osm/NodeInfo.cs b/src/SpatialLite.Osm/NodeInfo.cs index f63fa7b..cf5076a 100644 --- a/src/SpatialLite.Osm/NodeInfo.cs +++ b/src/SpatialLite.Osm/NodeInfo.cs @@ -1,6 +1,5 @@ -using System; - -using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.Geometries; +using System; namespace SpatialLite.Osm; @@ -20,11 +19,11 @@ public class NodeInfo : IEntityInfo /// The EntityMetadata structure with additinal properties. Default value is null. public NodeInfo(long id, double latitude, double longitude, TagsCollection tags, EntityMetadata additionalInfo = null) { - this.ID = id; - this.Latitude = latitude; - this.Longitude = longitude; - this.Tags = tags; - this.Metadata = additionalInfo; + ID = id; + Latitude = latitude; + Longitude = longitude; + Tags = tags; + Metadata = additionalInfo; } /// @@ -38,11 +37,11 @@ public NodeInfo(Node node) throw new ArgumentNullException(nameof(node), "Node parameter cannot be null"); } - this.ID = node.ID; - this.Longitude = node.Position.X; - this.Latitude = node.Position.Y; - this.Tags = node.Tags; - this.Metadata = node.Metadata; + ID = node.ID; + Longitude = node.Position.X; + Latitude = node.Position.Y; + Tags = node.Tags; + Metadata = node.Metadata; } /// diff --git a/src/SpatialLite.Osm/OsmDatabase.cs b/src/SpatialLite.Osm/OsmDatabase.cs index c2f3959..f737043 100644 --- a/src/SpatialLite.Osm/OsmDatabase.cs +++ b/src/SpatialLite.Osm/OsmDatabase.cs @@ -1,6 +1,6 @@ -using System; +using SpatialLite.Osm.IO; +using System; using System.Collections.Generic; -using SpatialLite.Osm.IO; namespace SpatialLite.Osm; @@ -19,9 +19,9 @@ public class OsmDatabase : IEntityCollection where T : IOsmEntity /// internal OsmDatabase() { - this.Nodes = new EntityCollection(); - this.Ways = new EntityCollection(); - this.Relations = new EntityCollection(); + Nodes = new EntityCollection(); + Ways = new EntityCollection(); + Relations = new EntityCollection(); } /// @@ -33,7 +33,7 @@ internal OsmDatabase(IEnumerable entities) { foreach (var entity in entities) { - this.Add(entity); + Add(entity); } } @@ -59,7 +59,7 @@ public int Count { get { - return this.Nodes.Count + this.Ways.Count + this.Relations.Count; + return Nodes.Count + Ways.Count + Relations.Count; } } @@ -84,22 +84,22 @@ public bool IsReadOnly { get { - if (type == EntityType.Node && this.Nodes.Contains(id)) + if (type == EntityType.Node && Nodes.Contains(id)) { - return (T)this.Nodes[id]; + return Nodes[id]; } - if (type == EntityType.Way && this.Ways.Contains(id)) + if (type == EntityType.Way && Ways.Contains(id)) { - return (T)this.Ways[id]; + return Ways[id]; } - if (type == EntityType.Relation && this.Relations.Contains(id)) + if (type == EntityType.Relation && Relations.Contains(id)) { - return (T)this.Relations[id]; + return Relations[id]; } - return default(T); + return default; } } @@ -119,19 +119,19 @@ public virtual void Save(IOsmWriter writer) /// true if entity was successfully removed from the ICollection; otherwise, false. This method also returns false if entity is not found in the original collection. public bool Remove(long id, EntityType type) { - if (this.Nodes.Contains(id)) + if (Nodes.Contains(id)) { - return this.Nodes.Remove(id); + return Nodes.Remove(id); } - if (this.Ways.Contains(id)) + if (Ways.Contains(id)) { - return this.Ways.Remove(id); + return Ways.Remove(id); } - if (this.Relations.Contains(id)) + if (Relations.Contains(id)) { - return this.Relations.Remove(id); + return Relations.Remove(id); } return false; @@ -147,9 +147,9 @@ public bool Contains(long id, EntityType type) { switch (type) { - case EntityType.Node: return this.Nodes.Contains(id); - case EntityType.Way: return this.Ways.Contains(id); - case EntityType.Relation: return this.Relations.Contains(id); + case EntityType.Node: return Nodes.Contains(id); + case EntityType.Way: return Ways.Contains(id); + case EntityType.Relation: return Relations.Contains(id); } throw new NotImplementedException(); @@ -166,16 +166,16 @@ public void Add(T entity) throw new ArgumentNullException(nameof(entity), "Cannot add null to EntityCollection"); } - if (this.Contains(entity.ID, entity.EntityType)) + if (Contains(entity.ID, entity.EntityType)) { throw new ArgumentException("An entity with the same ID has already been added."); } switch (entity.EntityType) { - case EntityType.Node: this.Nodes.Add((N)entity); break; - case EntityType.Way: this.Ways.Add((W)entity); break; - case EntityType.Relation: this.Relations.Add((R)entity); break; + case EntityType.Node: Nodes.Add((N)entity); break; + case EntityType.Way: Ways.Add((W)entity); break; + case EntityType.Relation: Relations.Add((R)entity); break; } } @@ -184,9 +184,9 @@ public void Add(T entity) /// public void Clear() { - this.Nodes.Clear(); - this.Ways.Clear(); - this.Relations.Clear(); + Nodes.Clear(); + Ways.Clear(); + Relations.Clear(); } /// @@ -201,7 +201,7 @@ public bool Contains(T item) return false; } - return this.Contains(item.ID, item.EntityType); + return Contains(item.ID, item.EntityType); } /// @@ -229,7 +229,7 @@ public bool Remove(T entity) return false; } - return this.Remove(entity.ID, entity.EntityType); + return Remove(entity.ID, entity.EntityType); } /// @@ -238,17 +238,17 @@ public bool Remove(T entity) /// A IEnumerator<T> that can be used to iterate through the collection. public IEnumerator GetEnumerator() { - foreach (var node in this.Nodes) + foreach (var node in Nodes) { yield return node; } - foreach (var way in this.Ways) + foreach (var way in Ways) { yield return way; } - foreach (var relation in this.Relations) + foreach (var relation in Relations) { yield return relation; } @@ -260,6 +260,6 @@ public IEnumerator GetEnumerator() /// A IEnumerator that can be used to iterate through the collection. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { - return this.GetEnumerator(); + return GetEnumerator(); } } diff --git a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs index 17bbff0..0b6ded7 100644 --- a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs +++ b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs @@ -1,6 +1,5 @@ -using System.Collections.Generic; - -using SpatialLite.Osm.IO; +using SpatialLite.Osm.IO; +using System.Collections.Generic; namespace SpatialLite.Osm; @@ -36,7 +35,7 @@ public static OsmEntityInfoDatabase Load(IOsmReader reader) { OsmEntityInfoDatabase db = new OsmEntityInfoDatabase(); - IEntityInfo entityInfo = null; + IEntityInfo entityInfo; while ((entityInfo = reader.Read()) != null) { switch (entityInfo.EntityType) diff --git a/src/SpatialLite.Osm/RelationInfo.cs b/src/SpatialLite.Osm/RelationInfo.cs index 8e49667..d498797 100644 --- a/src/SpatialLite.Osm/RelationInfo.cs +++ b/src/SpatialLite.Osm/RelationInfo.cs @@ -1,6 +1,6 @@ -using System; +using SpatialLite.Osm.Geometries; +using System; using System.Collections.Generic; -using SpatialLite.Osm.Geometries; namespace SpatialLite.Osm; @@ -19,10 +19,10 @@ public class RelationInfo : IEntityInfo /// The EntityMetadata structure with additinal properties. Default value is null. public RelationInfo(long id, TagsCollection tags, IList members, EntityMetadata additionalInfo = null) { - this.ID = id; - this.Tags = tags; - this.Members = members; - this.Metadata = additionalInfo; + ID = id; + Tags = tags; + Members = members; + Metadata = additionalInfo; } /// @@ -36,14 +36,14 @@ public RelationInfo(Relation source) throw new ArgumentNullException(nameof(source), "Source relation cannot be null"); } - this.ID = source.ID; - this.Tags = source.Tags; - this.Metadata = source.Metadata; + ID = source.ID; + Tags = source.Tags; + Metadata = source.Metadata; - this.Members = new List(source.Geometries.Count); + Members = new List(source.Geometries.Count); foreach (var member in source.Geometries) { - this.Members.Add(new RelationMemberInfo(member)); + Members.Add(new RelationMemberInfo(member)); } } diff --git a/src/SpatialLite.Osm/RelationMemberInfo.cs b/src/SpatialLite.Osm/RelationMemberInfo.cs index db5593c..488e79d 100644 --- a/src/SpatialLite.Osm/RelationMemberInfo.cs +++ b/src/SpatialLite.Osm/RelationMemberInfo.cs @@ -29,9 +29,8 @@ public struct RelationMemberInfo /// The RelationMember object to copy valyes from. public RelationMemberInfo(RelationMember source) { - this.Reference = source.Member.ID; - this.MemberType = source.MemberType; - this.Role = source.Role; + Reference = source.Member.ID; + MemberType = source.MemberType; + Role = source.Role; } - } diff --git a/src/SpatialLite.Osm/Tag.cs b/src/SpatialLite.Osm/Tag.cs index 9a1c7a8..b9b701f 100644 --- a/src/SpatialLite.Osm/Tag.cs +++ b/src/SpatialLite.Osm/Tag.cs @@ -8,8 +8,8 @@ namespace SpatialLite.Osm; public class Tag { - private string _key; - private string _value; + private readonly string _key; + private readonly string _value; /// /// Initializes a new instance of the Tag class with specified key and value. @@ -28,13 +28,8 @@ public Tag(string key, string value) throw new ArgumentException("Parameter 'key' can't be empty string."); } - if (value == null) - { - throw new ArgumentNullException("Parameter 'value' can't be null."); - } - _key = key; - _value = value; + _value = value ?? throw new ArgumentNullException("Parameter 'value' can't be null."); } /// @@ -71,8 +66,7 @@ public override bool Equals(object obj) return false; } - Tag other = obj as Tag; - if (other != null) + if (obj is Tag other) { return Equals(other); } diff --git a/src/SpatialLite.Osm/TagsCollection.cs b/src/SpatialLite.Osm/TagsCollection.cs index feb34bc..3421aa0 100644 --- a/src/SpatialLite.Osm/TagsCollection.cs +++ b/src/SpatialLite.Osm/TagsCollection.cs @@ -29,7 +29,7 @@ public TagsCollection(IEnumerable tags) foreach (var tag in tags) { - this.Add(tag); + Add(tag); } } @@ -68,19 +68,19 @@ public string this[string key] { get { - Tag tag = this.GetTag(key); + Tag tag = GetTag(key); return tag.Value; } set { - if (this.Contains(key)) + if (Contains(key)) { - this.Remove(key); - this.Add(new Tag(key, value)); + Remove(key); + Add(new Tag(key, value)); } else { - this.Add(new Tag(key, value)); + Add(new Tag(key, value)); } } } @@ -96,7 +96,7 @@ public void Add(Tag tag) _tags = new List(); } - if (this.Contains(tag.Key)) + if (Contains(tag.Key)) { throw new ArgumentException(string.Format("Tag with key '{0}' is already present in the collection.", tag.Key)); } @@ -211,10 +211,10 @@ public bool Remove(Tag item) /// true if item was successfully removed from the TagsCollection, otherwise false. This method also returns false if item is not found in the original TagsCollection. public bool Remove(string key) { - if (this.Contains(key)) + if (Contains(key)) { - Tag tag = this.GetTag(key); - return this.Remove(tag); + Tag tag = GetTag(key); + return Remove(tag); } else { @@ -230,7 +230,7 @@ public IEnumerator GetEnumerator() { if (_tags == null) { - return this.GetEmptyEnumerator(); + return GetEmptyEnumerator(); } else { @@ -246,7 +246,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { if (_tags == null) { - return this.GetEmptyEnumerator(); + return GetEmptyEnumerator(); } else { diff --git a/src/SpatialLite.Osm/WayInfo.cs b/src/SpatialLite.Osm/WayInfo.cs index 680b0a3..ca9716f 100644 --- a/src/SpatialLite.Osm/WayInfo.cs +++ b/src/SpatialLite.Osm/WayInfo.cs @@ -1,8 +1,7 @@ -using System; +using SpatialLite.Osm.Geometries; +using System; using System.Collections.Generic; -using SpatialLite.Osm.Geometries; - namespace SpatialLite.Osm; /// @@ -23,31 +22,31 @@ public class WayInfo : IEntityInfo /// The EntityMetadata structure with additinal properties. Default value is null. public WayInfo(long id, TagsCollection tags, IList nodes, EntityMetadata additionalInfo = null) { - this.ID = id; - this.Tags = tags; - this.Nodes = nodes; - this.Metadata = additionalInfo; + ID = id; + Tags = tags; + Nodes = nodes; + Metadata = additionalInfo; } /// /// Initializes a new instance of the WayInfo class with data from specific Way /// /// The way to get data from - public WayInfo(Way way) + public WayInfo(Way way) { if (way == null) { throw new ArgumentNullException(nameof(way), "Way parameter cannot be null"); } - this.ID = way.ID; - this.Tags = way.Tags; - this.Metadata = way.Metadata; + ID = way.ID; + Tags = way.Tags; + Metadata = way.Metadata; - this.Nodes = new List(way.Nodes.Count); + Nodes = new List(way.Nodes.Count); foreach (var node in way.Nodes) { - this.Nodes.Add(node.ID); + Nodes.Add(node.ID); } } diff --git a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs index 9b0eb3e..8051620 100644 --- a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs +++ b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs @@ -1,21 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - +using SpatialLite.Core.API; using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; namespace Tests.SpatialLite.Core.API; public class CoordinateTests { - double xCoordinate = 3.5; - double yCoordinate = 4.2; - double zCoordinate = 10.5; - double mValue = 100.4; + private readonly double xCoordinate = 3.5; + private readonly double yCoordinate = 4.2; + private readonly double zCoordinate = 10.5; + private readonly double mValue = 100.4; [Fact] public void Constructor_XY_SetsXYValuesAndZMNaN() diff --git a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs index c13b099..bb8bb02 100644 --- a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs +++ b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs @@ -1,32 +1,22 @@ -using System; +using SpatialLite.Core.API; using System.Collections.Generic; -using System.Linq; -using System.Text; - using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; namespace Tests.SpatialLite.Core.API; public class EnvelopeTests { - - Coordinate[] _coordinates = new Coordinate[] { + private readonly Coordinate[] _coordinates = new Coordinate[] { new Coordinate(1, 10, 100, 1000), new Coordinate(0, 0, 0, 0), new Coordinate(-1, -10, -100, -1000) }; + private Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); + private Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); + private Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); + private readonly double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; - Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); - Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); - Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); - - double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; - - static public IEnumerable _XYZEnvelopeDifferentBounds + public static IEnumerable _XYZEnvelopeDifferentBounds { get { diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs index 13cd7d8..32869ab 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs @@ -1,14 +1,9 @@ -using System; +using Moq; +using SpatialLite.Core.Algorithms; +using SpatialLite.Core.API; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; - using Xunit; -using Xunit.Extensions; -using Moq; - -using SpatialLite.Core.API; -using SpatialLite.Core.Algorithms; namespace Tests.SpatialLite.Core.Algorithms; diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs index 3682b72..5c183cf 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Xunit.Extensions; - +using SpatialLite.Core.Algorithms; using SpatialLite.Core.API; -using SpatialLite.Core.Algorithms; using SpatialLite.Core.Geometries; using SpatialLite.Core.IO; +using System; +using System.Collections.Generic; +using Xunit; namespace Tests.SpatialLite.Core.Algorithms; diff --git a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs index 43c3ee1..3090cff 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using SpatialLite.Core.API; +using Moq; using SpatialLite.Core.Algorithms; - +using SpatialLite.Core.API; +using System; using Xunit; -using Moq; namespace Tests.SpatialLite.Core.Algorithms; diff --git a/src/Tests.SpatialLite.Core/Data/TestDataReader.cs b/src/Tests.SpatialLite.Core/Data/TestDataReader.cs index 746544e..25e1b45 100644 --- a/src/Tests.SpatialLite.Core/Data/TestDataReader.cs +++ b/src/Tests.SpatialLite.Core/Data/TestDataReader.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.IO; using System.Reflection; -using System.Threading.Tasks; namespace Tests.SpatialLite.Core.Data; diff --git a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs index 3c97781..f7969fe 100644 --- a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs @@ -1,21 +1,14 @@ -using System; -using System.Collections.Generic; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; using System.Linq; -using System.Text; - using Xunit; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - namespace Tests.SpatialLite.Core.Geometries; public class CoordinateListTests { - - Coordinate _coordinate = new Coordinate(-10, -20, -200); - - Coordinate[] _coordinates = new Coordinate[] { + private Coordinate _coordinate = new Coordinate(-10, -20, -200); + private readonly Coordinate[] _coordinates = new Coordinate[] { new Coordinate(12,10,100), new Coordinate(22,20,200), new Coordinate(32,30,300) diff --git a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs index 1b60b0d..9fcd6a2 100644 --- a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs @@ -1,22 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; +using Xunit; namespace Tests.SpatialLite.Core.Geometries; public class GeometryCollectionTests { - - Point[] _geometries; - - Coordinate[] _coordinatesXYZM = new Coordinate[] { + private readonly Point[] _geometries; + private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { new Coordinate(12,10,100, 1000), new Coordinate(22,20,200, 2000), new Coordinate(32,30,300, 3000) diff --git a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs index 34bb3af..587da35 100644 --- a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs @@ -1,32 +1,23 @@ -using System; -using System.Collections.Generic; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; using System.Linq; -using System.Text; - using Xunit; -using SpatialLite.Core; -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; - namespace Tests.SpatialLite.Core.Geometries; public class LineStringTests { - - Coordinate[] _coordinatesXY = new Coordinate[] { + private readonly Coordinate[] _coordinatesXY = new Coordinate[] { new Coordinate(12,10), new Coordinate(22,20), new Coordinate(32,30) }; - - Coordinate[] _coordinatesXYZ = new Coordinate[] { + private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { new Coordinate(12,10,100), new Coordinate(22,20,200), new Coordinate(32,30,300) }; - - Coordinate[] _coordinatesXYZM = new Coordinate[] { + private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { new Coordinate(12,10,100, 1000), new Coordinate(22,20,200, 2000), new Coordinate(32,30,300, 3000) diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs index 74d3307..03a5059 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiLineStringTests.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tests.SpatialLite.Core.Geometries; +namespace Tests.SpatialLite.Core.Geometries; public class MultiLineStringTests { diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs index a311b60..4fc72a6 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiPointTests.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tests.SpatialLite.Core.Geometries; +namespace Tests.SpatialLite.Core.Geometries; public class MultiPointTests { diff --git a/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs index 4fc5138..f80c8a0 100644 --- a/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/MultiPolygonTests.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tests.SpatialLite.Core.Geometries; +namespace Tests.SpatialLite.Core.Geometries; public class MultiPolygonTests { diff --git a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs index da68202..1848790 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs @@ -1,25 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; +using Xunit; namespace Tests.SpatialLite.Core.Geometries; public class PointTests { - - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - double _mValue = 100.4; - - Coordinate _coordinate; + private readonly double _xOrdinate = 3.5; + private readonly double _yOrdinate = 4.2; + private readonly double _zOrdinate = 10.5; + private readonly double _mValue = 100.4; + private Coordinate _coordinate; public PointTests() { _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); diff --git a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs index 5f52c66..e3bf4dd 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs @@ -1,33 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; - -using SpatialLite.Core; -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; +using Xunit; namespace Tests.SpatialLite.Core.Geometries; public class PolygonTests { - - Coordinate[] _coordinatesXY = new Coordinate[] { + private readonly Coordinate[] _coordinatesXY = new Coordinate[] { new Coordinate(1, 2), new Coordinate(1.1, 2.1), new Coordinate(1.2, 2.2), new Coordinate(1.3, 2.3) }; - - Coordinate[] _coordinatesXYZ = new Coordinate[] { + private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { new Coordinate(1, 2, 3), new Coordinate(1.1, 2.1, 3.1), new Coordinate(1.2, 2.2, 3.2), new Coordinate(1.3, 2.3, 3.3) }; - - Coordinate[] _coordinatesXYZM = new Coordinate[] { + private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { new Coordinate(1, 2, 3, 10), new Coordinate(1.1, 2.1, 3.1, 20), new Coordinate(1.2, 2.2, 3.2, 30), new Coordinate(1.3, 2.3, 3.3, 40) }; - - CoordinateList _exteriorRing3D; - CoordinateList[] _interiorRings3D; + private readonly CoordinateList _exteriorRing3D; + private readonly CoordinateList[] _interiorRings3D; public PolygonTests() { diff --git a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs index 32c02c5..f04fa05 100644 --- a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs @@ -1,18 +1,14 @@ -using System; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; - using Xunit; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.API; - namespace Tests.SpatialLite.Core.Geometries; public class ReadOnlyCoordinateListTests { - List _points = new List(new Point[] { + private readonly List _points = new List(new Point[] { new Point(5, 1.1, 2.2), new Point(6, 10.1, -20.2), new Point(7, -30.1, 40.2) }); @@ -90,6 +86,6 @@ public void Clear_ThowsNotSupportedException() { ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); - Assert.Throws(() => target.Clear()); + Assert.Throws(target.Clear); } } diff --git a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs index 05397c6..8fc4ea6 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; - -using Xunit; -using Tests.SpatialLite.Core.Data; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; using SpatialLite.Core.IO; +using System; +using System.IO; +using Tests.SpatialLite.Core.Data; +using Xunit; namespace Tests.SpatialLite.Core.IO; @@ -35,9 +30,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() WkbReader target = new WkbReader(filename); target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -66,27 +59,27 @@ public void Read_ReturnsNullIfStreamIsEmpty() [Fact] public void Read_ReadsGeometry() { - Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + Point expected = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); Point parsed = (Point)target.Read(); - this.ComparePoints(parsed, expected); + ComparePoints(parsed, expected); } [Fact] public void Read_ReadsMultipleGeometries() { - Point expected1 = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - Point expected2 = (Point)this.ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); + Point expected1 = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + Point expected2 = (Point)ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); WkbReader target = new WkbReader(TestDataReader.Open("two-points-3DM.wkb")); Point parsed1 = (Point)target.Read(); - this.ComparePoints(parsed1, expected1); + ComparePoints(parsed1, expected1); Point parsed2 = (Point)target.Read(); - this.ComparePoints(parsed2, expected2); + ComparePoints(parsed2, expected2); } [Fact] @@ -108,7 +101,7 @@ public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { WkbReader target = new WkbReader(ms); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } } @@ -126,12 +119,12 @@ public void ReadT_ReturnsNullIfStreamIsEmpty() [Fact] public void ReadT_ReadsGeometry() { - Point expected = (Point)this.ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); + Point expected = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); Point parsed = target.Read(); - this.ComparePoints(parsed, expected); + ComparePoints(parsed, expected); } [Fact] @@ -153,7 +146,7 @@ public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { WkbReader target = new WkbReader(ms); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } } @@ -161,7 +154,7 @@ public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiecGeometryType() { WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -190,10 +183,10 @@ public void Parse_ThrowsArgumentNullExceptionIfDataIsNull() public void Parse_ReturnsParsedGeometry() { string wkt = "point m (-10.1 15.5 1000.5)"; - Point expected = (Point)this.ParseWKT(wkt); + Point expected = (Point)ParseWKT(wkt); Point parsed = (Point)WkbReader.Parse(TestDataReader.Read("point-2DM.wkb")); - this.ComparePoints(parsed, expected); + ComparePoints(parsed, expected); } [Fact] @@ -224,7 +217,7 @@ public void ParsePoint_Parses2DPoint() string wkt = "point (-10.1 15.5)"; byte[] wkb = TestDataReader.Read("point-2D.wkb"); - this.TestParsePoint(wkb, wkt); + TestParsePoint(wkb, wkt); } [Fact] @@ -233,7 +226,7 @@ public void ParsePoint_Parses2DMeasuredPoint() string wkt = "point m (-10.1 15.5 1000.5)"; byte[] wkb = TestDataReader.Read("point-2DM.wkb"); - this.TestParsePoint(wkb, wkt); + TestParsePoint(wkb, wkt); } [Fact] @@ -242,7 +235,7 @@ public void ParsePoint_Parses3DPoint() string wkt = "point z (-10.1 15.5 100.5)"; byte[] wkb = TestDataReader.Read("point-3D.wkb"); - this.TestParsePoint(wkb, wkt); + TestParsePoint(wkb, wkt); } [Fact] @@ -251,7 +244,7 @@ public void ParsePoint_Parses3DMeasuredPoint() string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; byte[] wkb = TestDataReader.Read("point-3DM.wkb"); - this.TestParsePoint(wkb, wkt); + TestParsePoint(wkb, wkt); } [Fact] @@ -260,7 +253,7 @@ public void Parse_ParsesEmptyLineString() string wkt = "linestring empty"; byte[] wkb = TestDataReader.Read("linestring-empty.wkb"); - this.TestParseLineString(wkb, wkt); + TestParseLineString(wkb, wkt); } [Fact] @@ -269,7 +262,7 @@ public void Parse_Parses2DLineString() string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; byte[] wkb = TestDataReader.Read("linestring-2D.wkb"); - this.TestParseLineString(wkb, wkt); + TestParseLineString(wkb, wkt); } [Fact] @@ -278,7 +271,7 @@ public void Parse_Parses2DMeasuredLineString() string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; byte[] wkb = TestDataReader.Read("linestring-2DM.wkb"); - this.TestParseLineString(wkb, wkt); + TestParseLineString(wkb, wkt); } [Fact] @@ -286,7 +279,7 @@ public void Parse_Parses3DLineString() { string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; byte[] wkb = TestDataReader.Read("linestring-3D.wkb"); - this.TestParseLineString(wkb, wkt); + TestParseLineString(wkb, wkt); } [Fact] @@ -295,7 +288,7 @@ public void Parse_Parses3DMeasuredLineString() string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; byte[] wkb = TestDataReader.Read("linestring-3DM.wkb"); - this.TestParseLineString(wkb, wkt); + TestParseLineString(wkb, wkt); } [Fact] @@ -304,7 +297,7 @@ public void Parse_ParsesEmptyPolygon() string wkt = "polygon empty"; byte[] wkb = TestDataReader.Read("polygon-empty.wkb"); - this.TestParsePolygon(wkb, wkt); + TestParsePolygon(wkb, wkt); } [Fact] @@ -313,7 +306,7 @@ public void Parse_Parses2DPolygonOnlyExteriorRing() string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; byte[] wkb = TestDataReader.Read("polygon-ext-2D.wkb"); - this.TestParsePolygon(wkb, wkt); + TestParsePolygon(wkb, wkt); } [Fact] @@ -322,7 +315,7 @@ public void Parse_Parses2DMeasuredPolygonOnlyExteriorRing() string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; byte[] wkb = TestDataReader.Read("polygon-ext-2DM.wkb"); - this.TestParsePolygon(wkb, wkt); + TestParsePolygon(wkb, wkt); } [Fact] @@ -331,7 +324,7 @@ public void Parse_Parses3DPolygonOnlyExteriorRing() string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; byte[] wkb = TestDataReader.Read("polygon-ext-3D.wkb"); - this.TestParsePolygon(wkb, wkt); + TestParsePolygon(wkb, wkt); } [Fact] @@ -340,7 +333,7 @@ public void Parse_Parses3DMeasuredPolygonOnlyExteriorRing() string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; byte[] wkb = TestDataReader.Read("polygon-ext-3DM.wkb"); - this.TestParsePolygon(wkb, wkt); + TestParsePolygon(wkb, wkt); } [Fact] @@ -349,7 +342,7 @@ public void Parse_Parses3DMeasuredPolygon() string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; byte[] wkb = TestDataReader.Read("polygon-3DM.wkb"); - this.TestParsePolygon(wkb, wkt); + TestParsePolygon(wkb, wkt); } [Fact] @@ -358,7 +351,7 @@ public void ParseMultiPoint_ParsesEmptyMultipoint() string wkt = "multipoint empty"; byte[] wkb = TestDataReader.Read("multipoint-empty.wkb"); - this.TestParseMultiPoint(wkb, wkt); + TestParseMultiPoint(wkb, wkt); } [Fact] @@ -367,7 +360,7 @@ public void ParseMultiPoint_Parses2DMultiPoint() string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; byte[] wkb = TestDataReader.Read("multipoint-2D.wkb"); - this.TestParseMultiPoint(wkb, wkt); + TestParseMultiPoint(wkb, wkt); } [Fact] @@ -376,7 +369,7 @@ public void ParseMultiPoint_Parses2DMeasuredMultiPoint() string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; byte[] wkb = TestDataReader.Read("multipoint-2DM.wkb"); - this.TestParseMultiPoint(wkb, wkt); + TestParseMultiPoint(wkb, wkt); } [Fact] @@ -385,7 +378,7 @@ public void ParseMultiPoint_Parses3DMultiPoint() string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; byte[] wkb = TestDataReader.Read("multipoint-3D.wkb"); - this.TestParseMultiPoint(wkb, wkt); + TestParseMultiPoint(wkb, wkt); } [Fact] @@ -394,7 +387,7 @@ public void ParseMultiPoint_Parses3DMeasuredMultiPoint() string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; byte[] wkb = TestDataReader.Read("multipoint-3DM.wkb"); - this.TestParseMultiPoint(wkb, wkt); + TestParseMultiPoint(wkb, wkt); } [Fact] @@ -403,7 +396,7 @@ public void ParseMultiLineString_ParsesEmptyMultiLineString() string wkt = "multilinestring empty"; byte[] wkb = TestDataReader.Read("multilinestring-empty.wkb"); - this.TestParseMultiLineString(wkb, wkt); + TestParseMultiLineString(wkb, wkt); } [Fact] @@ -412,7 +405,7 @@ public void ParseMultiLineString_Parses2DMultiLineString() string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; byte[] wkb = TestDataReader.Read("multilinestring-2D.wkb"); - this.TestParseMultiLineString(wkb, wkt); + TestParseMultiLineString(wkb, wkt); } [Fact] @@ -421,7 +414,7 @@ public void ParseMultiLineString_Parses2DMeasuredMultiLineString() string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; byte[] wkb = TestDataReader.Read("multilinestring-2DM.wkb"); - this.TestParseMultiLineString(wkb, wkt); + TestParseMultiLineString(wkb, wkt); } [Fact] @@ -430,7 +423,7 @@ public void ParseMultiLineString_Parses3DMultiLineString() string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; byte[] wkb = TestDataReader.Read("multilinestring-3D.wkb"); - this.TestParseMultiLineString(wkb, wkt); + TestParseMultiLineString(wkb, wkt); } [Fact] @@ -439,7 +432,7 @@ public void ParseMultiLineString_Parses3DMeasuredMultiLineString() string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; byte[] wkb = TestDataReader.Read("multilinestring-3DM.wkb"); - this.TestParseMultiLineString(wkb, wkt); + TestParseMultiLineString(wkb, wkt); } [Fact] @@ -448,7 +441,7 @@ public void ParseMultiPolygon_ParsesEmptyMultiPolygon() string wkt = "multipolygon empty"; byte[] wkb = TestDataReader.Read("multipolygon-empty.wkb"); - this.TestParseMultiPolygon(wkb, wkt); + TestParseMultiPolygon(wkb, wkt); } [Fact] @@ -457,7 +450,7 @@ public void ParseMultiPolygon_Parses2DMultiPolygon() string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; byte[] wkb = TestDataReader.Read("multipolygon-2D.wkb"); - this.TestParseMultiPolygon(wkb, wkt); + TestParseMultiPolygon(wkb, wkt); } [Fact] @@ -466,7 +459,7 @@ public void ParseMultiPolygon_Parses2DMeasuredMultiPolygon() string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; byte[] wkb = TestDataReader.Read("multipolygon-2DM.wkb"); - this.TestParseMultiPolygon(wkb, wkt); + TestParseMultiPolygon(wkb, wkt); } [Fact] @@ -475,7 +468,7 @@ public void ParseMultiPolygon_Parses3DMultiPolygon() string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; byte[] wkb = TestDataReader.Read("multipolygon-3D.wkb"); - this.TestParseMultiPolygon(wkb, wkt); + TestParseMultiPolygon(wkb, wkt); } [Fact] @@ -484,14 +477,14 @@ public void ParseMultiPolygon_Parses3DMeasuredMultiPolygon() string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; byte[] wkb = TestDataReader.Read("multipolygon-3DM.wkb"); - this.TestParseMultiPolygon(wkb, wkt); + TestParseMultiPolygon(wkb, wkt); } [Fact] public void ParseGeometryCollection_ParsesEmptyGeometryCollection() { string wkt = "geometrycollection empty"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-empty.wkb")); Assert.Empty(parsed.Geometries); @@ -501,130 +494,130 @@ public void ParseGeometryCollection_ParsesEmptyGeometryCollection() public void ParseGeometryCollection_Parses2DGeometryCollection() { string wkt = "geometrycollection (point (-10.1 15.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2D.wkb")); Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); } [Fact] public void ParseGeometryCollection_Parses2DMeasuredGeometryCollection() { string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-2DM.wkb")); Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); } [Fact] public void ParseGeometryCollection_Parses3DGeometryCollection() { string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3D.wkb")); Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); } [Fact] public void ParseGeometryCollection_Parses3DMeasuredGeometryCollection() { string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-3DM.wkb")); Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); } [Fact] public void ParseGeometryCollection_ParsesCollectionWithPointLineStringAndPolygon() { string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-pt-ls-poly.wkb")); Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); - this.CompareLineStrings((LineString)parsed.Geometries[1], (LineString)expected.Geometries[1]); - this.ComparePolygons((Polygon)parsed.Geometries[2], (Polygon)expected.Geometries[2]); + ComparePoints((Point)parsed.Geometries[0], (Point)expected.Geometries[0]); + CompareLineStrings((LineString)parsed.Geometries[1], (LineString)expected.Geometries[1]); + ComparePolygons((Polygon)parsed.Geometries[2], (Polygon)expected.Geometries[2]); } [Fact] public void ParseGeometryCollection_ParsesCollectionWithMultiGeometries() { string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-multi.wkb")); Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); - this.CompareMultiPoints((MultiPoint)parsed.Geometries[0], (MultiPoint)expected.Geometries[0]); - this.CompareMultiLineStrings((MultiLineString)parsed.Geometries[1], (MultiLineString)expected.Geometries[1]); - this.CompareMultiPolygons((MultiPolygon)parsed.Geometries[2], (MultiPolygon)expected.Geometries[2]); + CompareMultiPoints((MultiPoint)parsed.Geometries[0], (MultiPoint)expected.Geometries[0]); + CompareMultiLineStrings((MultiLineString)parsed.Geometries[1], (MultiLineString)expected.Geometries[1]); + CompareMultiPolygons((MultiPolygon)parsed.Geometries[2], (MultiPolygon)expected.Geometries[2]); } [Fact] public void ParseGeometryCollection_ParsesNestedCollection() { string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection expected = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection expected = (GeometryCollection)ParseWKT(wkt); GeometryCollection parsed = WkbReader.Parse>(TestDataReader.Read("collection-nested.wkb")); Assert.Equal(expected.Geometries.Count, parsed.Geometries.Count); Assert.Equal(((GeometryCollection)expected.Geometries[0]).Geometries.Count, ((GeometryCollection)parsed.Geometries[0]).Geometries.Count); - this.ComparePoints((Point)((GeometryCollection)parsed.Geometries[0]).Geometries[0], (Point)((GeometryCollection)expected.Geometries[0]).Geometries[0]); + ComparePoints((Point)((GeometryCollection)parsed.Geometries[0]).Geometries[0], (Point)((GeometryCollection)expected.Geometries[0]).Geometries[0]); } private void TestParsePoint(byte[] wkb, string expectedAsWkt) { - Point expected = (Point)this.ParseWKT(expectedAsWkt); + Point expected = (Point)ParseWKT(expectedAsWkt); Point parsed = WkbReader.Parse(wkb); - this.ComparePoints(parsed, expected); + ComparePoints(parsed, expected); } private void TestParseLineString(byte[] wkb, string expectedAsWkt) { - LineString expected = (LineString)this.ParseWKT(expectedAsWkt); + LineString expected = (LineString)ParseWKT(expectedAsWkt); LineString parsed = WkbReader.Parse(wkb); - this.CompareLineStrings(parsed, expected); + CompareLineStrings(parsed, expected); } private void TestParsePolygon(byte[] wkb, string expectedAsWkt) { - Polygon expected = (Polygon)this.ParseWKT(expectedAsWkt); + Polygon expected = (Polygon)ParseWKT(expectedAsWkt); Polygon parsed = WkbReader.Parse(wkb); - this.ComparePolygons(parsed, expected); + ComparePolygons(parsed, expected); } private void TestParseMultiPoint(byte[] wkb, string expectedAsWkt) { - MultiPoint expected = (MultiPoint)this.ParseWKT(expectedAsWkt); + MultiPoint expected = (MultiPoint)ParseWKT(expectedAsWkt); MultiPoint parsed = WkbReader.Parse(wkb); - this.CompareMultiPoints(parsed, expected); + CompareMultiPoints(parsed, expected); } private void TestParseMultiLineString(byte[] wkb, string expectedAsWkt) { - MultiLineString expected = (MultiLineString)this.ParseWKT(expectedAsWkt); + MultiLineString expected = (MultiLineString)ParseWKT(expectedAsWkt); MultiLineString parsed = WkbReader.Parse(wkb); - this.CompareMultiLineStrings(parsed, expected); + CompareMultiLineStrings(parsed, expected); } private void TestParseMultiPolygon(byte[] wkb, string expectedAsWkt) { - MultiPolygon expected = (MultiPolygon)this.ParseWKT(expectedAsWkt); + MultiPolygon expected = (MultiPolygon)ParseWKT(expectedAsWkt); MultiPolygon parsed = WkbReader.Parse(wkb); - this.CompareMultiPolygons(parsed, expected); + CompareMultiPolygons(parsed, expected); } private void ComparePoints(Point point, Point expected) @@ -643,17 +636,17 @@ private void CompareCoordinateLists(ICoordinateList list, ICoordinateList expect private void CompareLineStrings(LineString linestring, LineString expected) { - this.CompareCoordinateLists(linestring.Coordinates, expected.Coordinates); + CompareCoordinateLists(linestring.Coordinates, expected.Coordinates); } private void ComparePolygons(Polygon polygon, Polygon expected) { - this.CompareCoordinateLists(polygon.ExteriorRing, expected.ExteriorRing); + CompareCoordinateLists(polygon.ExteriorRing, expected.ExteriorRing); Assert.Equal(expected.InteriorRings.Count, polygon.InteriorRings.Count); for (int i = 0; i < expected.InteriorRings.Count; i++) { - this.CompareCoordinateLists(polygon.InteriorRings[i], expected.InteriorRings[i]); + CompareCoordinateLists(polygon.InteriorRings[i], expected.InteriorRings[i]); } } @@ -663,7 +656,7 @@ private void CompareMultiPoints(MultiPoint multipoint, MultiPoint expected) for (int i = 0; i < expected.Geometries.Count; i++) { - this.ComparePoints(multipoint.Geometries[i], expected.Geometries[i]); + ComparePoints(multipoint.Geometries[i], expected.Geometries[i]); } } @@ -673,7 +666,7 @@ private void CompareMultiLineStrings(MultiLineString multilinestring, MultiLineS for (int i = 0; i < expected.Geometries.Count; i++) { - this.CompareLineStrings(multilinestring.Geometries[i], expected.Geometries[i]); + CompareLineStrings(multilinestring.Geometries[i], expected.Geometries[i]); } } @@ -683,7 +676,7 @@ private void CompareMultiPolygons(MultiPolygon multipolygon, MultiPolygon expect for (int i = 0; i < expected.Geometries.Count; i++) { - this.ComparePolygons(multipolygon.Geometries[i], expected.Geometries[i]); + ComparePolygons(multipolygon.Geometries[i], expected.Geometries[i]); } } diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs index 334404d..8268aaf 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - +using SpatialLite.Core.IO; +using System; using Xunit; -using SpatialLite.Core.IO; - namespace Tests.SpatialLite.Core.IO; public class WkbWriterSettingsTests diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs index 1091397..c679924 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs @@ -1,17 +1,11 @@ -using System; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.IO; +using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; - -using Xunit; -using Xunit.Extensions; - using Tests.SpatialLite.Core.Data; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.IO; +using Xunit; namespace Tests.SpatialLite.Core.IO; @@ -98,9 +92,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() WkbWriterSettings settings = new WkbWriterSettings(); WkbWriter target = new WkbWriter(filename, settings); target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -131,14 +123,14 @@ public void WkbWriter_Write_WritesLittleEndianEncodingByte() public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() { string wkt = "point empty"; - Point point = (Point)this.ParseWKT(wkt); + Point point = (Point)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); } } @@ -146,14 +138,14 @@ public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() public void Write_Writes2DPoint() { string wkt = "point (-10.1 15.5)"; - Point point = (Point)this.ParseWKT(wkt); + Point point = (Point)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("point-2D.wkb")); } } @@ -161,14 +153,14 @@ public void Write_Writes2DPoint() public void Write_Writes2DMeasuredPoint() { string wkt = "point m (-10.1 15.5 1000.5)"; - Point point = (Point)this.ParseWKT(wkt); + Point point = (Point)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-2DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("point-2DM.wkb")); } } @@ -176,14 +168,14 @@ public void Write_Writes2DMeasuredPoint() public void Write_Writes3DPoint() { string wkt = "point z (-10.1 15.5 100.5)"; - Point point = (Point)this.ParseWKT(wkt); + Point point = (Point)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("point-3D.wkb")); } } @@ -191,14 +183,14 @@ public void Write_Writes3DPoint() public void Write_Writes3DMeasuredPoint() { string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; - Point point = (Point)this.ParseWKT(wkt); + Point point = (Point)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("point-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("point-3DM.wkb")); } } @@ -206,14 +198,14 @@ public void Write_Writes3DMeasuredPoint() public void Write_WritesEmptyLineString() { string wkt = "linestring empty"; - LineString linestring = (LineString)this.ParseWKT(wkt); + LineString linestring = (LineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-empty.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-empty.wkb")); } } @@ -221,14 +213,14 @@ public void Write_WritesEmptyLineString() public void Write_Writes2DLineString() { string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + LineString linestring = (LineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2D.wkb")); } } @@ -236,14 +228,14 @@ public void Write_Writes2DLineString() public void Write_Writes2DMeasuredLineString() { string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + LineString linestring = (LineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-2DM.wkb")); } } @@ -251,14 +243,14 @@ public void Write_Writes2DMeasuredLineString() public void Write_Writes3DLineString() { string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + LineString linestring = (LineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3D.wkb")); } } @@ -266,13 +258,13 @@ public void Write_Writes3DLineString() public void Write_Writes3DMeasuredLineString() { string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; - LineString linestring = (LineString)this.ParseWKT(wkt); + LineString linestring = (LineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("linestring-3DM.wkb")); } } @@ -280,14 +272,14 @@ public void Write_Writes3DMeasuredLineString() public void Write_WritesEmptyPolygon() { string wkt = "polygon empty"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + Polygon polygon = (Polygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-empty.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-empty.wkb")); } } @@ -295,14 +287,14 @@ public void Write_WritesEmptyPolygon() public void Write_Writes2DPolygonOnlyExteriorRing() { string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + Polygon polygon = (Polygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2D.wkb")); } } @@ -310,14 +302,14 @@ public void Write_Writes2DPolygonOnlyExteriorRing() public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() { string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + Polygon polygon = (Polygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-2DM.wkb")); } } @@ -325,14 +317,14 @@ public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() public void Write_Writes3DPolygonOnlyExteriorRing() { string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + Polygon polygon = (Polygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3D.wkb")); } } @@ -340,14 +332,14 @@ public void Write_Writes3DPolygonOnlyExteriorRing() public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() { string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + Polygon polygon = (Polygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-ext-3DM.wkb")); } } @@ -355,14 +347,14 @@ public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() public void Write_Writes3DMeasuredPolygon() { string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon polygon = (Polygon)this.ParseWKT(wkt); + Polygon polygon = (Polygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("polygon-3DM.wkb")); } } @@ -370,14 +362,14 @@ public void Write_Writes3DMeasuredPolygon() public void Write_WritesEmptyMultipoint() { string wkt = "multipoint empty"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-empty.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-empty.wkb")); } } @@ -385,14 +377,14 @@ public void Write_WritesEmptyMultipoint() public void Write_Writes2DMultiPoint() { string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2D.wkb")); } } @@ -400,14 +392,14 @@ public void Write_Writes2DMultiPoint() public void Write_Writes2DMeasuredMultiPoint() { string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-2DM.wkb")); } } @@ -415,14 +407,14 @@ public void Write_Writes2DMeasuredMultiPoint() public void Write_Writes3DMultiPoint() { string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3D.wkb")); } } @@ -430,14 +422,14 @@ public void Write_Writes3DMultiPoint() public void Write_Writes3DMeasuredMultiPoint() { string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; - MultiPoint multipoint = (MultiPoint)this.ParseWKT(wkt); + MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipoint-3DM.wkb")); } } @@ -445,14 +437,14 @@ public void Write_Writes3DMeasuredMultiPoint() public void Write_WritesEmptyMultiLineString() { string wkt = "multilinestring empty"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-empty.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-empty.wkb")); } } @@ -460,14 +452,14 @@ public void Write_WritesEmptyMultiLineString() public void Write_Writes2DMultiLineString() { string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2D.wkb")); } } @@ -475,14 +467,14 @@ public void Write_Writes2DMultiLineString() public void Write_Writes2DMeasuredMultiLineString() { string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-2DM.wkb")); } } @@ -490,14 +482,14 @@ public void Write_Writes2DMeasuredMultiLineString() public void Write_Writes3DMultiLineString() { string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3D.wkb")); } } @@ -505,14 +497,14 @@ public void Write_Writes3DMultiLineString() public void Write_Writes3DMeasuredMultiLineString() { string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; - MultiLineString multilinestring = (MultiLineString)this.ParseWKT(wkt); + MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multilinestring-3DM.wkb")); } } @@ -520,14 +512,14 @@ public void Write_Writes3DMeasuredMultiLineString() public void Write_WritesEmptyMultiPolygon() { string wkt = "multipolygon empty"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-empty.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-empty.wkb")); } } @@ -535,14 +527,14 @@ public void Write_WritesEmptyMultiPolygon() public void Write_Writes2DMultiPolygon() { string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2D.wkb")); } } @@ -550,14 +542,14 @@ public void Write_Writes2DMultiPolygon() public void Write_Writes2DMeasuredMultiPolygon() { string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-2DM.wkb")); } } @@ -565,14 +557,14 @@ public void Write_Writes2DMeasuredMultiPolygon() public void Write_Writes3DMultiPolygon() { string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3D.wkb")); } } @@ -580,14 +572,14 @@ public void Write_Writes3DMultiPolygon() public void Write_Writes3DMeasuredMultiPolygon() { string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; - MultiPolygon multipolygon = (MultiPolygon)this.ParseWKT(wkt); + MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("multipolygon-3DM.wkb")); } } @@ -595,14 +587,14 @@ public void Write_Writes3DMeasuredMultiPolygon() public void Write_WritesEmptyGeometryCollection() { string wkt = "geometrycollection empty"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-empty.wkb")); } } @@ -610,14 +602,14 @@ public void Write_WritesEmptyGeometryCollection() public void Write_Writes2DGeometryCollection() { string wkt = "geometrycollection (point (-10.1 15.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2D.wkb")); } } @@ -625,14 +617,14 @@ public void Write_Writes2DGeometryCollection() public void Write_Writes2DMeasuredGeometryCollection() { string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-2DM.wkb")); } } @@ -640,14 +632,14 @@ public void Write_Writes2DMeasuredGeometryCollection() public void Write_Writes3DGeometryCollection() { string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3D.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3D.wkb")); } } @@ -655,14 +647,14 @@ public void Write_Writes3DGeometryCollection() public void Write_Writes3DMeasuredGeometryCollection() { string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3DM.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-3DM.wkb")); } } @@ -670,14 +662,14 @@ public void Write_Writes3DMeasuredGeometryCollection() public void Write_WritesCollectionWithPointLineStringAndPolygon() { string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-pt-ls-poly.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-pt-ls-poly.wkb")); } } @@ -685,14 +677,14 @@ public void Write_WritesCollectionWithPointLineStringAndPolygon() public void Write_WritesCollectionWithMultiGeometries() { string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-multi.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-multi.wkb")); } } @@ -700,14 +692,14 @@ public void Write_WritesCollectionWithMultiGeometries() public void Write_WritesNestedCollection() { string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection collection = (GeometryCollection)this.ParseWKT(wkt); + GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); - this.CompareBytes(stream.ToArray(), TestDataReader.Read("collection-nested.wkb")); + CompareBytes(stream.ToArray(), TestDataReader.Read("collection-nested.wkb")); } } @@ -730,10 +722,10 @@ public static IEnumerable WriteToArrayTestData [MemberData(nameof(WriteToArrayTestData))] public void WriteToArray_WritesAllGeometryTypes(string wkt, byte[] expectedWkb) { - IGeometry geometry = this.ParseWKT(wkt); + IGeometry geometry = ParseWKT(wkt); byte[] wkb = WkbWriter.WriteToArray(geometry); - this.CompareBytes(wkb, expectedWkb); + CompareBytes(wkb, expectedWkb); } private void CompareBytes(byte[] array, byte[] expected) diff --git a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs index a44a7e2..01307ef 100644 --- a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs @@ -1,16 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO; - -using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Core.Geometries; using SpatialLite.Core.IO; +using System; +using System.Collections.Generic; +using System.IO; using Tests.SpatialLite.Core.Data; +using Xunit; namespace Tests.SpatialLite.Core.IO; @@ -18,23 +13,23 @@ namespace Tests.SpatialLite.Core.IO; public class WktReaderTests { - private Coordinate[] _coordinatesXY = new Coordinate[] { + private readonly Coordinate[] _coordinatesXY = new Coordinate[] { new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) }; - private Coordinate[] _coordinatesXYZ = new Coordinate[] { + private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) }; - private Coordinate[] _coordinatesXYM = new Coordinate[] { + private readonly Coordinate[] _coordinatesXYM = new Coordinate[] { new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) }; - private Coordinate[] _coordinatesXYZM = new Coordinate[] { + private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) }; - private Coordinate[] _coordinates2XYZM = new Coordinate[] { + private readonly Coordinate[] _coordinates2XYZM = new Coordinate[] { new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) }; @@ -58,9 +53,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() WktReader target = new WktReader(filename); target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -161,7 +154,7 @@ public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() { using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } } @@ -171,7 +164,7 @@ public void Parse_ParsesPoint() string wkt = "point empty"; Point parsed = (Point)WktReader.Parse(wkt); - this.CompareCoordinate(Coordinate.Empty, parsed.Position); + CompareCoordinate(Coordinate.Empty, parsed.Position); } [Fact] @@ -281,7 +274,7 @@ public void Parse_ParsesEmptyPoint() Point parsed = WktReader.Parse(wkt); - this.CompareCoordinate(Coordinate.Empty, parsed.Position); + CompareCoordinate(Coordinate.Empty, parsed.Position); } [Fact] @@ -293,7 +286,7 @@ public void Parse_Parses2DPoint() Assert.False(parsed.Is3D); Assert.False(parsed.IsMeasured); - this.CompareCoordinate(_coordinatesXY[0], parsed.Position); + CompareCoordinate(_coordinatesXY[0], parsed.Position); } [Fact] @@ -305,7 +298,7 @@ public void Parse_Parses2DMeasuredPoint() Assert.NotNull(parsed); Assert.False(parsed.Is3D); - this.CompareCoordinate(_coordinatesXYM[0], parsed.Position); + CompareCoordinate(_coordinatesXYM[0], parsed.Position); } [Fact] @@ -317,7 +310,7 @@ public void Parse_Parses3DPoint() Assert.NotNull(parsed); Assert.False(parsed.IsMeasured); - this.CompareCoordinate(_coordinatesXYZ[0], parsed.Position); + CompareCoordinate(_coordinatesXYZ[0], parsed.Position); } [Fact] @@ -328,7 +321,7 @@ public void Parse_Parses3DMeasuredPoint() Point parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinate(_coordinatesXYZM[0], parsed.Position); + CompareCoordinate(_coordinatesXYZM[0], parsed.Position); } [Fact] @@ -358,7 +351,7 @@ public void Parse_Parses2DLineString() LineString parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXY, parsed.Coordinates); + CompareCoordinates(_coordinatesXY, parsed.Coordinates); } [Fact] @@ -369,7 +362,7 @@ public void Parse_Parses2DMeasuredLineString() LineString parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYM, parsed.Coordinates); + CompareCoordinates(_coordinatesXYM, parsed.Coordinates); } [Fact] @@ -380,7 +373,7 @@ public void Parse_Parses3DLineString() LineString parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZ, parsed.Coordinates); + CompareCoordinates(_coordinatesXYZ, parsed.Coordinates); } [Fact] @@ -391,7 +384,7 @@ public void Parse_Parses3DMeasuredLineString() LineString parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.Coordinates); + CompareCoordinates(_coordinatesXYZM, parsed.Coordinates); } [Fact] @@ -422,7 +415,7 @@ public void ParsePolygon_Parses2DPolygonOnlyExteriorRing() Polygon parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXY, parsed.ExteriorRing); + CompareCoordinates(_coordinatesXY, parsed.ExteriorRing); Assert.Empty(parsed.InteriorRings); } @@ -434,7 +427,7 @@ public void ParsePolygon_Parses3DPolygonOnlyExteriorRing() Polygon parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZ, parsed.ExteriorRing); + CompareCoordinates(_coordinatesXYZ, parsed.ExteriorRing); Assert.Empty(parsed.InteriorRings); } @@ -446,7 +439,7 @@ public void ParsePolygon_Parses2DMeauredPolygonOnlyExteriorRing() Polygon parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYM, parsed.ExteriorRing); + CompareCoordinates(_coordinatesXYM, parsed.ExteriorRing); Assert.Empty(parsed.InteriorRings); } @@ -458,7 +451,7 @@ public void ParsePolygon_Parses3DMeasuredPolygonOnlyExteriorRing() Polygon parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); + CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); Assert.Empty(parsed.InteriorRings); } @@ -470,10 +463,10 @@ public void ParsePolygon_Parses3DMeasuredPolygonWithInteriorRings() Polygon parsed = WktReader.Parse(wkt); Assert.NotNull(parsed); - this.CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); + CompareCoordinates(_coordinatesXYZM, parsed.ExteriorRing); Assert.Equal(2, parsed.InteriorRings.Count); - this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[0]); - this.CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[1]); + CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[0]); + CompareCoordinates(_coordinates2XYZM, parsed.InteriorRings[1]); } [Fact] @@ -504,8 +497,8 @@ public void Parse_Parses2DMultiPoint() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXY[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXY[1], parsed.Geometries[1].Position); + CompareCoordinate(_coordinatesXY[0], parsed.Geometries[0].Position); + CompareCoordinate(_coordinatesXY[1], parsed.Geometries[1].Position); } [Fact] @@ -517,8 +510,8 @@ public void Parse_Parses2DMeasuredMultiPoint() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYM[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYM[1], parsed.Geometries[1].Position); + CompareCoordinate(_coordinatesXYM[0], parsed.Geometries[0].Position); + CompareCoordinate(_coordinatesXYM[1], parsed.Geometries[1].Position); } [Fact] @@ -530,8 +523,8 @@ public void Parse_Parses3DMultiPoint() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYZ[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYZ[1], parsed.Geometries[1].Position); + CompareCoordinate(_coordinatesXYZ[0], parsed.Geometries[0].Position); + CompareCoordinate(_coordinatesXYZ[1], parsed.Geometries[1].Position); } [Fact] @@ -543,8 +536,8 @@ public void Parse_Parses3DMeasuredMultiPoint() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXYZM[0], parsed.Geometries[0].Position); - this.CompareCoordinate(_coordinatesXYZM[1], parsed.Geometries[1].Position); + CompareCoordinate(_coordinatesXYZM[0], parsed.Geometries[0].Position); + CompareCoordinate(_coordinatesXYZM[1], parsed.Geometries[1].Position); } [Fact] @@ -575,8 +568,8 @@ public void Parse_Parses2DMultiLineString() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].Coordinates); + CompareCoordinates(_coordinatesXY, parsed.Geometries[0].Coordinates); + CompareCoordinates(_coordinatesXY, parsed.Geometries[1].Coordinates); } [Fact] @@ -588,8 +581,8 @@ public void Parse_Parses2DMeasuredMultiLineString() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].Coordinates); + CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].Coordinates); + CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].Coordinates); } [Fact] @@ -601,8 +594,8 @@ public void Parse_Parses3DMultiLineString() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].Coordinates); + CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].Coordinates); + CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].Coordinates); } [Fact] @@ -614,8 +607,8 @@ public void Parse_Parses3DMeasuredMultiLineString() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].Coordinates); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].Coordinates); + CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].Coordinates); + CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].Coordinates); } [Fact] @@ -646,8 +639,8 @@ public void Parse_Parses2DMultiPolygon() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXY, parsed.Geometries[1].ExteriorRing); + CompareCoordinates(_coordinatesXY, parsed.Geometries[0].ExteriorRing); + CompareCoordinates(_coordinatesXY, parsed.Geometries[1].ExteriorRing); } [Fact] @@ -659,8 +652,8 @@ public void Parse_Parses2DMeasuredMultiPolygon() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].ExteriorRing); + CompareCoordinates(_coordinatesXYM, parsed.Geometries[0].ExteriorRing); + CompareCoordinates(_coordinatesXYM, parsed.Geometries[1].ExteriorRing); } [Fact] @@ -672,8 +665,8 @@ public void Parse_Parses3DMultiPolygon() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].ExteriorRing); + CompareCoordinates(_coordinatesXYZ, parsed.Geometries[0].ExteriorRing); + CompareCoordinates(_coordinatesXYZ, parsed.Geometries[1].ExteriorRing); } [Fact] @@ -685,8 +678,8 @@ public void Parse_Parses3DMeasuredMultiPolygon() Assert.NotNull(parsed); Assert.Equal(2, parsed.Geometries.Count); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].ExteriorRing); - this.CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].ExteriorRing); + CompareCoordinates(_coordinatesXYZM, parsed.Geometries[0].ExteriorRing); + CompareCoordinates(_coordinatesXYZM, parsed.Geometries[1].ExteriorRing); } [Fact] @@ -717,7 +710,7 @@ public void Parse_Parses2DGeometryCollectionWithPoint() Assert.NotNull(parsed); Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); + CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); } [Fact] @@ -729,7 +722,7 @@ public void Parse_Parses2DMeasuredGeometryCollectionWithPoint() Assert.NotNull(parsed); Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYM[0], ((Point)parsed.Geometries[0]).Position); + CompareCoordinate(_coordinatesXYM[0], ((Point)parsed.Geometries[0]).Position); } [Fact] @@ -741,7 +734,7 @@ public void Parse_Parses3DGeometryCollectionWithPoint() Assert.NotNull(parsed); Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYZ[0], ((Point)parsed.Geometries[0]).Position); + CompareCoordinate(_coordinatesXYZ[0], ((Point)parsed.Geometries[0]).Position); } [Fact] @@ -753,7 +746,7 @@ public void Parse_Parses3DMeasuredGeometryCollectionWithPoint() Assert.NotNull(parsed); Assert.Single(parsed.Geometries); - this.CompareCoordinate(_coordinatesXYZM[0], ((Point)parsed.Geometries[0]).Position); + CompareCoordinate(_coordinatesXYZM[0], ((Point)parsed.Geometries[0]).Position); } [Fact] @@ -765,9 +758,9 @@ public void Parse_ParsesCollectionWithPointLineStringAndPolygon() Assert.NotNull(parsed); Assert.Equal(3, parsed.Geometries.Count); - this.CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); - this.CompareCoordinates(_coordinatesXY, ((LineString)parsed.Geometries[1]).Coordinates); - this.CompareCoordinates(_coordinatesXY, ((Polygon)parsed.Geometries[2]).ExteriorRing); + CompareCoordinate(_coordinatesXY[0], ((Point)parsed.Geometries[0]).Position); + CompareCoordinates(_coordinatesXY, ((LineString)parsed.Geometries[1]).Coordinates); + CompareCoordinates(_coordinatesXY, ((Polygon)parsed.Geometries[2]).ExteriorRing); } [Fact] @@ -780,7 +773,7 @@ public void Parse_ParsesNestedCollections() Assert.NotNull(parsed); Assert.Single(parsed.Geometries); GeometryCollection nested = (GeometryCollection)parsed.Geometries[0]; - this.CompareCoordinate(_coordinatesXY[0], ((Point)nested.Geometries[0]).Position); + CompareCoordinate(_coordinatesXY[0], ((Point)nested.Geometries[0]).Position); } [Fact] diff --git a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs index 1c239b3..1b99267 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs @@ -1,13 +1,7 @@ -using System; -using System.Collections.Generic; +using SpatialLite.Core.IO; +using System.IO; using System.Linq; -using System.Text; - using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.IO; -using System.IO; namespace Tests.SpatialLite.Core.IO; @@ -15,7 +9,7 @@ public class WktTokenizerTests { [Fact] - void Tokenize_String_ReturnsEmptyTokenForEmptyString() + private void Tokenize_String_ReturnsEmptyTokenForEmptyString() { string data = string.Empty; var tokens = WktTokenizer.Tokenize(data); @@ -33,7 +27,7 @@ void Tokenize_String_ReturnsEmptyTokenForEmptyString() [InlineData(")", TokenType.RIGHT_PARENTHESIS)] [InlineData(",", TokenType.COMMA)] [InlineData("-123456780.9", TokenType.NUMBER)] - void Tokenize_String_CorrectlyRecognizesTokenTypes(string str, TokenType expectedType) + private void Tokenize_String_CorrectlyRecognizesTokenTypes(string str, TokenType expectedType) { var tokens = WktTokenizer.Tokenize(str).ToArray(); @@ -45,7 +39,7 @@ void Tokenize_String_CorrectlyRecognizesTokenTypes(string str, TokenType expecte } [Fact] - void Tokenize_String_ProcessesComplexText() + private void Tokenize_String_ProcessesComplexText() { string data = "point z (-10 -15 -100.1)"; var tokens = WktTokenizer.Tokenize(data).ToArray(); @@ -92,7 +86,7 @@ void Tokenize_String_ProcessesComplexText() } [Fact] - void Tokenize_TextReader_ProcessesComplexText() + private void Tokenize_TextReader_ProcessesComplexText() { StringReader reader = new StringReader("point z (-10 -15 -100.1)"); diff --git a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs index 6dafd5f..1f71711 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs @@ -1,17 +1,13 @@ -using System; -using System.Collections.Generic; +using SpatialLite.Core.IO; +using System; using System.Linq; -using System.Text; - using Xunit; -using SpatialLite.Core.IO; - namespace Tests.SpatialLite.Core.IO; public class WktTokensBufferTests { - WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, + private readonly WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, new WktToken() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; [Fact] diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs index 60f9e55..91c5f84 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - +using SpatialLite.Core.IO; using Xunit; -using SpatialLite.Core.IO; - namespace Tests.SpatialLite.Core.IO; public class WktWriterSettingsTests @@ -19,5 +13,4 @@ public void Constructor__SetsDefaultValues() Assert.False(target.IsReadOnly); } - } diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs index e0421f4..f00f4e1 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs @@ -1,15 +1,10 @@ -using System; +using SpatialLite.Core.API; +using SpatialLite.Core.Geometries; +using SpatialLite.Core.IO; +using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; - using Xunit; -using Xunit.Extensions; - -using SpatialLite.Core.API; -using SpatialLite.Core.Geometries; -using SpatialLite.Core.IO; namespace Tests.SpatialLite.Core.IO; @@ -17,23 +12,23 @@ public class WktWriterTests { - private static Coordinate[] _coordinatesXY = new Coordinate[] { + private static readonly Coordinate[] _coordinatesXY = new Coordinate[] { new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) }; - private static Coordinate[] _coordinatesXYZ = new Coordinate[] { + private static readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) }; - private static Coordinate[] _coordinatesXYM = new Coordinate[] { + private static readonly Coordinate[] _coordinatesXYM = new Coordinate[] { new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) }; - private static Coordinate[] _coordinatesXYZM = new Coordinate[] { + private static readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) }; - private static Coordinate[] _coordinates2XYZM = new Coordinate[] { + private static readonly Coordinate[] _coordinates2XYZM = new Coordinate[] { new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) }; @@ -121,7 +116,7 @@ public static IEnumerable WriteToStringTestData [MemberData(nameof(WriteToStringTestData))] public void WriteToString_WritesAllGeometryTypes(Geometry toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } [Fact] @@ -132,9 +127,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() WktWriterSettings settings = new WktWriterSettings(); WktWriter target = new WktWriter(filename, settings); target.Dispose(); - - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -165,7 +158,7 @@ public static IEnumerable Write_WritesPointsOfAllDimensionsTestData [MemberData(nameof(Write_WritesPointsOfAllDimensionsTestData))] public void Write_WritesPointsOfAllDimensions(Point toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } public static IEnumerable Write_WritesLinestringOfAllDimensionsTestData @@ -184,7 +177,7 @@ public static IEnumerable Write_WritesLinestringOfAllDimensionsTestDat [MemberData(nameof(Write_WritesLinestringOfAllDimensionsTestData))] public void Write_WritesLinestringsOfAllDimensions(LineString toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } public static IEnumerable Write_WritesPolygonsOfAllDimensionsTestData @@ -203,7 +196,7 @@ public static IEnumerable Write_WritesPolygonsOfAllDimensionsTestData [MemberData(nameof(Write_WritesPolygonsOfAllDimensionsTestData))] public void Write_WritesPolygonsOfAllDimensions(Polygon toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } [Fact] @@ -214,7 +207,7 @@ public void Write_WritesComplexPolygonWitOuterAndInnerRings() polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); - this.TestWriteGeometry(polygon, wkt); + TestWriteGeometry(polygon, wkt); } public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestData @@ -233,7 +226,7 @@ public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestDat [MemberData(nameof(Write_WritesMultiPoinsOfAllDimensionsTestData))] public void Write_WritesMultiPointsOfAllDimensions(MultiPoint toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsTestData @@ -256,7 +249,7 @@ public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsT [MemberData(nameof(Write_WritesMultiLineStringsOfAllDimensionsTestData))] public void Write_WritesMultiLineStringsOfAllDimensions(MultiLineString toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTestData @@ -279,7 +272,7 @@ public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTest [MemberData(nameof(Write_WritesMultiPolygonsOfAllDimensionsTestData))] public void Write_WritesMultiPolygonsOfAllDimensions(MultiPolygon toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } public static IEnumerable Write_WritesGeometryCollectionOfAllDimensionsTestData @@ -298,7 +291,7 @@ public static IEnumerable Write_WritesGeometryCollectionOfAllDimension [MemberData(nameof(Write_WritesGeometryCollectionOfAllDimensionsTestData))] public void Write_WritesGeometryCollectionOfAllDimensions(GeometryCollection toWrite, string expectedWkt) { - this.TestWriteGeometry(toWrite, expectedWkt); + TestWriteGeometry(toWrite, expectedWkt); } [Fact] @@ -313,7 +306,7 @@ public void Write_WritesCollectionWithAllGeometryTypes() collection.Geometries.Add(new MultiLineString()); collection.Geometries.Add(new MultiPolygon()); - this.TestWriteGeometry(collection, wkt); + TestWriteGeometry(collection, wkt); } [Fact] @@ -325,7 +318,7 @@ public void Write_WritesNestedCollection() nested.Geometries.Add(new Point(_coordinatesXY[0])); collection.Geometries.Add(nested); - this.TestWriteGeometry(collection, wkt); + TestWriteGeometry(collection, wkt); } private void TestWriteGeometry(IGeometry geometry, string expectedWkt) diff --git a/src/Tests.SpatialLite.Core/MeasurementsTests.cs b/src/Tests.SpatialLite.Core/MeasurementsTests.cs index 72b7044..f1a9178 100644 --- a/src/Tests.SpatialLite.Core/MeasurementsTests.cs +++ b/src/Tests.SpatialLite.Core/MeasurementsTests.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xunit; -using Moq; - +using Moq; using SpatialLite.Core; +using SpatialLite.Core.Algorithms; using SpatialLite.Core.API; using SpatialLite.Core.Geometries; -using SpatialLite.Core.Algorithms; +using System; +using Xunit; namespace Tests.SpatialLite.Core; diff --git a/src/Tests.SpatialLite.Core/PathHelper.cs b/src/Tests.SpatialLite.Core/PathHelper.cs index b7b5bb9..1589e87 100644 --- a/src/Tests.SpatialLite.Core/PathHelper.cs +++ b/src/Tests.SpatialLite.Core/PathHelper.cs @@ -2,11 +2,11 @@ namespace Tests.SpatialLite.Core; -static class PathHelper +internal static class PathHelper { private const string TempDirectoryName = "Temp"; - private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); + private static readonly string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); public static string RealGpxFilePath => _realGpxFilePath; public static string GetTempFilePath(string filename) diff --git a/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs b/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs index 1a0da6c..05a42b6 100644 --- a/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs +++ b/src/Tests.SpatialLite.Core/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/src/Tests.SpatialLite.Core/TopologyTests.cs b/src/Tests.SpatialLite.Core/TopologyTests.cs index 5518017..eb68a40 100644 --- a/src/Tests.SpatialLite.Core/TopologyTests.cs +++ b/src/Tests.SpatialLite.Core/TopologyTests.cs @@ -1,14 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using SpatialLite.Core; -using SpatialLite.Core.API; +using SpatialLite.Core; using SpatialLite.Core.Algorithms; - using Xunit; -using Moq; namespace Tests.SpatialLite.Core; @@ -20,5 +12,4 @@ public void Euclidean2D_GetTopologyInstanceWithEuclidean2DLocator() { Assert.IsType(Topology.Euclidean2D.GeometryLocator); } - } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs index 169892c..fc0a512 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpsPointTests.cs @@ -1,20 +1,16 @@ -using System; - -using Xunit; - +using SpatialLite.Core.API; using SpatialLite.Gps.Geometries; -using SpatialLite.Core.API; +using System; +using Xunit; namespace Tests.SpatialLite.Gps.Geometries; public class GpsPointTests { - - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - - Coordinate _coordinate; + private readonly double _xOrdinate = 3.5; + private readonly double _yOrdinate = 4.2; + private readonly double _zOrdinate = 10.5; + private Coordinate _coordinate; public GpsPointTests() { diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs index e03b49e..2e10ebb 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs @@ -1,15 +1,14 @@ -using System; +using SpatialLite.Core.Geometries; +using SpatialLite.Gps.Geometries; +using System; using System.Collections.Generic; - using Xunit; -using SpatialLite.Gps.Geometries; -using SpatialLite.Core.Geometries; namespace Tests.SpatialLite.Gps.Geometries; public class GpsTrackBaseTests { - List _points; + private readonly List _points; public GpsTrackBaseTests() { @@ -57,7 +56,7 @@ public void Coordinates_GetsPositionOfPoints() public void Coordinates_GetsPositionOfPointsIfWayCastedToLineString() { GpsTrackBase line = new GpsTrackBase(_points); - LineString target = (LineString)line; + LineString target = line; Assert.Equal(_points.Count, target.Coordinates.Count); for (int i = 0; i < _points.Count; i++) diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs index ec475d8..0c6c700 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxFixHelperTests.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using SpatialLite.Gps.Geometries; +using SpatialLite.Gps.Geometries; +using System.Collections.Generic; using Xunit; namespace Tests.SpatialLite.Gps.Geometries; diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs index dd2aff7..d6f115c 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs @@ -1,6 +1,6 @@ -using System; +using SpatialLite.Gps.Geometries; +using System; using Xunit; -using SpatialLite.Gps.Geometries; namespace Tests.SpatialLite.Gps.Geometries; diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs index 8c8ca44..f4cc858 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxMetadataTests.cs @@ -1,6 +1,5 @@ -using Xunit; - -using SpatialLite.Gps.Geometries; +using SpatialLite.Gps.Geometries; +using Xunit; namespace Tests.SpatialLite.Gps.Geometries; diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs index 0f4d7ab..346ea72 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs @@ -1,21 +1,17 @@ -using System; - -using Xunit; - -using SpatialLite.Gps.Geometries; -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Gps; +using SpatialLite.Gps.Geometries; +using System; +using Xunit; namespace Tests.SpatialLite.Gps.Geometries; public class GpxPointTests { - - double _xOrdinate = 3.5; - double _yOrdinate = 4.2; - double _zOrdinate = 10.5; - - Coordinate _coordinate; + private readonly double _xOrdinate = 3.5; + private readonly double _yOrdinate = 4.2; + private readonly double _zOrdinate = 10.5; + private Coordinate _coordinate; public GpxPointTests() { _coordinate = new Coordinate(_xOrdinate, _yOrdinate, _zOrdinate); diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs index c08c8fc..ae0ad8f 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using SpatialLite.Gps; +using SpatialLite.Gps; using SpatialLite.Gps.Geometries; +using System; +using System.Collections.Generic; using Xunit; namespace Tests.SpatialLite.Gps.Geometries; diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs index 435e9ef..25e3e6c 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs @@ -1,6 +1,6 @@ -using System; +using SpatialLite.Gps.Geometries; +using System; using System.Collections.Generic; -using SpatialLite.Gps.Geometries; using Xunit; namespace Tests.SpatialLite.Gps.Geometries; diff --git a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs index 8484fe4..834bd99 100644 --- a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs +++ b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs @@ -1,15 +1,13 @@ -using System; -using System.Collections.Generic; - -using Xunit; - -using SpatialLite.Gps.IO; +using Moq; using SpatialLite.Gps; using SpatialLite.Gps.Geometries; +using SpatialLite.Gps.IO; +using System; +using System.Collections.Generic; using System.IO; using System.Xml.Linq; -using Moq; using Tests.SpatialLite.Gps.Data; +using Xunit; namespace Tests.SpatialLite.Gps; diff --git a/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs index d30399d..4fc78fc 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxReaderSettingsTests.cs @@ -1,5 +1,5 @@ -using System; -using SpatialLite.Gps.IO; +using SpatialLite.Gps.IO; +using System; using Xunit; namespace Tests.SpatialLite.Gps.IO; diff --git a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs index 3a75d1c..64566de 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs @@ -1,13 +1,13 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using SpatialLite.Core.API; +using SpatialLite.Core.API; using SpatialLite.Gps; using SpatialLite.Gps.Geometries; using SpatialLite.Gps.IO; -using Xunit; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; using Tests.SpatialLite.Gps.Data; +using Xunit; namespace Tests.SpatialLite.Gps.IO; @@ -60,7 +60,7 @@ public void Read_ThrowsExceptionIfWaypointHasntLat() { GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lat.gpx"), new GpxReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -68,14 +68,14 @@ public void Read_ThrowsExceptionIfWaypointHasntLon() { GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lon.gpx"), new GpxReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] public void Read_SetsMetadataIfReadMetadataIsTrue() { var data = TestDataReader.Open("gpx-waypoint-simple.gpx"); - var expectedCoordinate = new Coordinate(-71.119277, 42.438878); + _ = new Coordinate(-71.119277, 42.438878); GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); var result = target.Read() as GpxPoint; @@ -87,7 +87,7 @@ public void Read_SetsMetadataIfReadMetadataIsTrue() public void Read_DoesntSetMetadataIfReadMetadataIsFalse() { var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - var expectedCoordinate = new Coordinate(-71.119277, 42.438878); + _ = new Coordinate(-71.119277, 42.438878); GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxPoint; @@ -132,7 +132,7 @@ public void Read_ParsesMultipleWaypoints() GpxPoint result = null; int count = 0; - while ((result = target.Read() as GpxPoint) != null) + while ((_ = target.Read() as GpxPoint) != null) { count++; } @@ -163,7 +163,7 @@ public void Read_ReadsWaypointMetadata() Assert.Equal("WPT Name", result.Metadata.Name); Assert.Equal("WPT Source", result.Metadata.Source); - Assert.Equal(1, result.Metadata.Links.Count); + Assert.Single(result.Metadata.Links); GpxLink link = result.Metadata.Links.Single(); Assert.Equal("http://www.topografix.com", link.Url.OriginalString); Assert.Equal("Link text", link.Text); @@ -193,7 +193,7 @@ public void Read_ReadsWaypointUnsortedMetadataAndExtension() Assert.Equal("WPT Name", result.Metadata.Name); Assert.Equal("WPT Source", result.Metadata.Source); - Assert.Equal(1, result.Metadata.Links.Count); + Assert.Single(result.Metadata.Links); GpxLink link = result.Metadata.Links.Single(); Assert.Equal("http://www.topografix.com", link.Url.OriginalString); Assert.Equal("Link text", link.Text); @@ -228,8 +228,7 @@ public void Read_ParsesTrackWithSingleSegmentAndExtensions() var result = target.Read() as GpxTrack; Assert.Single(result.Geometries); - - GpxTrackSegment segment = result.Geometries[0]; + _ = result.Geometries[0]; } [Fact] @@ -387,7 +386,7 @@ public void Read_ParsesRouteWithMetadata() Assert.Equal("RTE Source", result.Metadata.Source); Assert.Equal("RTE Type", result.Metadata.Type); - Assert.Equal(1, result.Metadata.Links.Count); + Assert.Single(result.Metadata.Links); GpxLink link = result.Metadata.Links.Single(); Assert.Equal("http://www.topografix.com", link.Url.OriginalString); Assert.Equal("Link text", link.Text); diff --git a/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs index 7ddf3cf..86ed69b 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxWriterSettingsTests.cs @@ -1,5 +1,5 @@ -using System; -using SpatialLite.Gps.IO; +using SpatialLite.Gps.IO; +using System; using Xunit; namespace Tests.SpatialLite.Gps.IO; diff --git a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs index 6efb358..262604c 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs @@ -1,42 +1,38 @@ -using System; - -using Xunit; - +using SpatialLite.Core.API; using SpatialLite.Gps.Geometries; using SpatialLite.Gps.IO; +using System; using System.IO; using System.Xml.Linq; -using SpatialLite.Core.API; using Tests.SpatialLite.Gps.Data; +using Xunit; namespace Tests.SpatialLite.Gps.IO; public class GpxWriterTests { - GpxPoint _waypoint = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); - GpxPoint _waypointWithMetadata = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); - GpxPointMetadata _pointMetadata; - - GpxRoute _route = new GpxRoute(new GpxPoint[] { + private readonly GpxPoint _waypoint = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + private readonly GpxPoint _waypointWithMetadata = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + private readonly GpxPointMetadata _pointMetadata; + private readonly GpxRoute _route = new GpxRoute(new GpxPoint[] { new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) }); - GpxRoute _routeWithMetadata = new GpxRoute(new GpxPoint[] { + private readonly GpxRoute _routeWithMetadata = new GpxRoute(new GpxPoint[] { new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) }); - GpxTrackMetadata _routeMetadata; - - GpxTrackSegment _segment = new GpxTrackSegment(new GpxPoint[] { + private readonly GpxTrackMetadata _routeMetadata; + private readonly GpxTrackSegment _segment = new GpxTrackSegment(new GpxPoint[] { new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) }); - GpxTrackMetadata _trackMetadata; - GpxTrack _track; - GpxTrack _trackWithMetadata; + private readonly GpxTrackMetadata _trackMetadata; + private readonly GpxTrack _track; + private readonly GpxTrack _trackWithMetadata; public GpxWriterTests() { _pointMetadata = new GpxPointMetadata(); diff --git a/src/Tests.SpatialLite.Gps/PathHelper.cs b/src/Tests.SpatialLite.Gps/PathHelper.cs index 397b356..655cf79 100644 --- a/src/Tests.SpatialLite.Gps/PathHelper.cs +++ b/src/Tests.SpatialLite.Gps/PathHelper.cs @@ -2,11 +2,11 @@ namespace Tests.SpatialLite.Gps; -static class PathHelper +internal static class PathHelper { private const string TempDirectoryName = "Temp"; - private static string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); + private static readonly string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); public static string RealGpxFilePath => _realGpxFilePath; public static string GetTempFilePath(string filename) diff --git a/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs b/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs index 68138f3..c1b957a 100644 --- a/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs +++ b/src/Tests.SpatialLite.Gps/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following From 8e40f05cfc0ca9d29ec62e77d2f90e96bc9a97e6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 21:16:23 +0000 Subject: [PATCH 08/14] Fix formatting issues and build errors Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- src/SpatialLite.Osm/Geometries/RelationMember.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SpatialLite.Osm/Geometries/RelationMember.cs b/src/SpatialLite.Osm/Geometries/RelationMember.cs index df13f56..70d2b19 100644 --- a/src/SpatialLite.Osm/Geometries/RelationMember.cs +++ b/src/SpatialLite.Osm/Geometries/RelationMember.cs @@ -97,7 +97,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn { if (info.MemberType == EntityType.Unknown) { - throw new ArgumentException(null, nameof(info.MemberType cannot be EntityType.Unknown)); + throw new ArgumentException("MemberType cannot be EntityType.Unknown", nameof(info)); } if (entities.Contains(info.Reference, info.MemberType) == false) From 422301c689d66e358a4c4562acdc6addf15cf9e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 May 2025 21:21:14 +0000 Subject: [PATCH 09/14] Fix Assert.Equal assertions in OsmGeometryDatabaseTests.cs Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- .../Geometries/OsmGeometryDatabaseTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs index 78947a6..d7bc075 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs @@ -101,7 +101,7 @@ public void Load_LoadsWay() Assert.True(target.Nodes.Contains(2)); Assert.True(target.Nodes.Contains(3)); - Assert.Equal(1, target.Ways.Count); + Assert.Single(target.Ways); Assert.True(target.Ways.Contains(10)); } @@ -111,10 +111,10 @@ public void Load_LoadsRelation() IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(1, target.Nodes.Count); + Assert.Single(target.Nodes); Assert.True(target.Nodes.Contains(1)); - Assert.Equal(1, target.Relations.Count); + Assert.Single(target.Relations); Assert.True(target.Relations.Contains(100)); } @@ -145,8 +145,8 @@ public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndWaysNodeIsMissing( OsmGeometryDatabase target = null; target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(2, target.Nodes.Count); - Assert.Equal(0, target.Ways.Count); + Assert.Equal(2, target.Nodes.Count); + Assert.Empty(target.Ways); } [Fact] @@ -156,7 +156,7 @@ public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndRelationMemberIsMi OsmGeometryDatabase target = null; target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(1, target.Relations.Count); + Assert.Single(target.Relations); } [Fact] From 2382fabd153477e506cded3e75c393c3639f5253 Mon Sep 17 00:00:00 2001 From: Lukas Kabrt Date: Thu, 22 May 2025 23:52:14 +0200 Subject: [PATCH 10/14] Fix formatting issues --- src/Benchmark.SpatialLite.Osm/Program.cs | 43 +-- src/SpatialLite.Core/API/Coordinate.cs | 4 +- src/SpatialLite.Core/API/Envelope.cs | 2 +- .../Geometries/GeometryCollection.cs | 2 +- src/SpatialLite.Core/IO/WkbReader.cs | 16 +- src/SpatialLite.Core/IO/WkbWriter.cs | 6 +- src/SpatialLite.Core/IO/WktReader.cs | 39 ++- src/SpatialLite.Core/IO/WktToken.cs | 2 +- src/SpatialLite.Core/IO/WktTokenizer.cs | 4 +- src/SpatialLite.Core/IO/WktWriter.cs | 2 +- src/SpatialLite.Gps/GpxDocument.cs | 8 +- src/SpatialLite.Gps/IO/GpxReader.cs | 42 ++- src/SpatialLite.Gps/IO/GpxWriter.cs | 4 +- .../Geometries/OsmGeometryDatabase.cs | 9 +- src/SpatialLite.Osm/Geometries/Relation.cs | 2 +- .../Geometries/RelationMember.cs | 5 +- src/SpatialLite.Osm/Geometries/Way.cs | 5 +- src/SpatialLite.Osm/IO/OsmXmlReader.cs | 10 +- src/SpatialLite.Osm/IO/OsmXmlWriter.cs | 4 +- .../IO/Pbf/EntityInfoBuffer.cs | 2 +- src/SpatialLite.Osm/IO/Pbf/StringTable.cs | 2 +- src/SpatialLite.Osm/IO/PbfReader.cs | 24 +- src/SpatialLite.Osm/IO/PbfWriter.cs | 42 +-- src/SpatialLite.Osm/OsmEntityInfoDatabase.cs | 2 +- src/SpatialLite.Osm/Tag.cs | 4 +- src/SpatialLite.Osm/TagsCollection.cs | 7 +- .../API/CoordinateTests.cs | 70 ++--- .../API/EnvelopeTests.cs | 76 +++--- .../Algorithms/Euclidean2DCalculatorTests.cs | 62 ++--- .../Algorithms/Euclidean2DLocatorTests.cs | 122 ++++----- .../Algorithms/Sphere2DCalculatorTests.cs | 66 ++--- .../Geometries/CoordinateListTests.cs | 38 +-- .../Geometries/GeometryCollectionTests.cs | 28 +- .../Geometries/LineStringTests.cs | 54 ++-- .../Geometries/PointTests.cs | 22 +- .../Geometries/PolygonTests.cs | 28 +- .../Geometries/ReadOnlyCoordinateListTests.cs | 26 +- .../IO/WkbReaderTests.cs | 34 +-- .../IO/WkbWriterSettingsTests.cs | 4 +- .../IO/WkbWriterTests.cs | 182 ++++++------- .../IO/WktReaderTests.cs | 30 +-- .../IO/WktTokenizerTests.cs | 2 +- .../IO/WktTokensBufferTests.cs | 44 +-- .../IO/WktWriterSettingsTests.cs | 2 +- .../IO/WktWriterTests.cs | 68 ++--- .../MeasurementsTests.cs | 130 ++++----- .../Geometries/GpsTrackBaseTests.cs | 14 +- .../Geometries/GpxLinkTests.cs | 4 +- .../Geometries/GpxPointTests.cs | 2 +- .../Geometries/GpxRouteTests.cs | 9 +- .../Geometries/GpxTrackSegmentTests.cs | 7 +- .../Geometries/GpxTrackTests.cs | 8 +- src/Tests.SpatialLite.Gps/GpxDocumentTests.cs | 2 +- .../IO/GpxReaderTests.cs | 66 +++-- .../IO/GpxWriterTests.cs | 82 +++--- .../XDocumentExtensions.cs | 5 +- .../EntityCollectionTests.cs | 46 ++-- .../Geometries/NodeTests.cs | 26 +- .../Geometries/OsmGeometryDatabaseTests.cs | 16 +- .../Geometries/RelationMemberTests.cs | 48 ++-- .../Geometries/RelationTests.cs | 20 +- .../Geometries/WayCoordinateListTests.cs | 26 +- .../Geometries/WayTests.cs | 28 +- .../IO/OsmReaderSettingsTests.cs | 4 +- .../IO/OsmWriterSettingsTests.cs | 6 +- .../IO/OsmXmlReaderTests.cs | 128 ++++----- .../IO/OsmXmlWriterTests.cs | 166 ++++++------ .../IO/PbfReaderTests.cs | 114 ++++---- .../IO/PbfWriterSettingsTests.cs | 6 +- .../IO/PbfWriterTests.cs | 254 +++++++++--------- .../Pbf/OsmosisIntegrationTests.cs | 83 +++--- .../Pbf/PbfReaderPbfWriterComplianceTests.cs | 44 +-- .../Integration/Xml/OsmDatabaseTests.cs | 4 +- .../Xml/OsmosisIntegrationTests.cs | 25 +- src/Tests.SpatialLite.Osm/NodeInfoTests.cs | 14 +- src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs | 90 +++---- .../OsmEntityInfoDatabaseTests.cs | 45 ++-- .../RelationInfoTests.cs | 22 +- .../RelationMemberInfoTests.cs | 4 +- src/Tests.SpatialLite.Osm/TagTests.cs | 22 +- .../TagsCollectionTests.cs | 90 +++---- src/Tests.SpatialLite.Osm/WayInfoTests.cs | 22 +- 82 files changed, 1465 insertions(+), 1467 deletions(-) diff --git a/src/Benchmark.SpatialLite.Osm/Program.cs b/src/Benchmark.SpatialLite.Osm/Program.cs index cf5d844..f9152ba 100644 --- a/src/Benchmark.SpatialLite.Osm/Program.cs +++ b/src/Benchmark.SpatialLite.Osm/Program.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; namespace Benchmark.SpatialLite.Osm; @@ -14,7 +15,7 @@ public class Program private static void Main(string[] args) { - List> benchmarks = new List>(); + List> benchmarks = new(); benchmarks.Add(new Tuple("XmlReader with metadata", TestXmlReaderSpeed)); benchmarks.Add(new Tuple("XmlReader without metadata", TestXmlReaderSpeedWithoutMetadata)); //benchmarks.Add(new Tuple("PbfReader (no compression) with metadata", TestPbfReaderSpeedNoDenseNoCompression)); @@ -42,7 +43,7 @@ private static void Main(string[] args) foreach (var benchmark in benchmarks) { long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); - tw.WriteLine(string.Format("{0} ms \t\t{1}", avgTime, benchmark.Item1)); + tw.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} ms \t\t{1}", avgTime, benchmark.Item1)); } } } @@ -50,20 +51,20 @@ private static void Main(string[] args) private static long DoTest(Action testAction, string testName) { - Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); + Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Starting benchmark '{0}'", testName)); long totalTime = 0; for (int i = 0; i < 10; i++) { - Console.Write(string.Format("Run ({0}/{1}) ...", i + 1, 10)); - Stopwatch watch = new Stopwatch(); + Console.Write(string.Format(CultureInfo.InvariantCulture, "Run ({0}/{1}) ...", i + 1, 10)); + Stopwatch watch = new(); watch.Start(); testAction(); watch.Stop(); totalTime += watch.ElapsedMilliseconds; - Console.WriteLine(string.Format("\t\t({0} ms)", watch.ElapsedMilliseconds)); + Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "\t\t({0} ms)", watch.ElapsedMilliseconds)); } Console.WriteLine(); @@ -76,7 +77,7 @@ private static void LoadSourceData() _entities = new List(); IEntityInfo info = null; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { while ((info = reader.Read()) != null) { @@ -88,7 +89,7 @@ private static void LoadSourceData() private static void TestXmlReaderSpeed() { int entitiesRead = 0; - using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) + using (OsmXmlReader reader = new("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) { IEntityInfo info; @@ -102,7 +103,7 @@ private static void TestXmlReaderSpeed() private static void TestXmlReaderSpeedWithoutMetadata() { int entitiesRead = 0; - using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) + using (OsmXmlReader reader = new("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) { IEntityInfo info; @@ -115,7 +116,7 @@ private static void TestXmlReaderSpeedWithoutMetadata() private static void TestXmlWriterSpeed() { - using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter writer = new("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) { foreach (var entity in _entities) { @@ -126,7 +127,7 @@ private static void TestXmlWriterSpeed() private static void TestXmlWriterSpeedWithoutMetadata() { - using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter writer = new("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) { foreach (var entity in _entities) { @@ -138,7 +139,7 @@ private static void TestXmlWriterSpeedWithoutMetadata() private static void TestPbfReaderSpeedNoDenseNoCompression() { int entitiesRead = 0; - using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) { IEntityInfo info; @@ -152,7 +153,7 @@ private static void TestPbfReaderSpeedNoDenseNoCompression() private static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() { int entitiesRead = 0; - using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) + using (PbfReader reader = new("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) { IEntityInfo info; @@ -166,7 +167,7 @@ private static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() private static void TestPbfReaderSpeedDenseDeflate() { int entitiesRead = 0; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { IEntityInfo info; @@ -180,7 +181,7 @@ private static void TestPbfReaderSpeedDenseDeflate() private static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() { int entitiesRead = 0; - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) + using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) { IEntityInfo info; @@ -193,7 +194,7 @@ private static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() private static void TestPbfWriterSpeed() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) + using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) { foreach (var entity in _entities) { @@ -204,7 +205,7 @@ private static void TestPbfWriterSpeed() private static void TestPbfWriterSpeedWithoutMetadata() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) + using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) { foreach (var entity in _entities) { @@ -215,7 +216,7 @@ private static void TestPbfWriterSpeedWithoutMetadata() private static void TestPbfWriterSpeedDenseDeflate() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { foreach (var entity in _entities) { @@ -226,7 +227,7 @@ private static void TestPbfWriterSpeedDenseDeflate() private static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() { - using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { foreach (var entity in _entities) { @@ -237,7 +238,7 @@ private static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() private static void TestOsmGeometryDatabaseLoadFromPbfReader() { - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { OsmGeometryDatabase db = OsmGeometryDatabase.Load(reader, true); } @@ -245,7 +246,7 @@ private static void TestOsmGeometryDatabaseLoadFromPbfReader() private static void TestOsmEntityInfoDatabaseLoadFromPbfReader() { - using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { OsmEntityInfoDatabase db = OsmEntityInfoDatabase.Load(reader); } diff --git a/src/SpatialLite.Core/API/Coordinate.cs b/src/SpatialLite.Core/API/Coordinate.cs index c0e68cb..a0561a8 100644 --- a/src/SpatialLite.Core/API/Coordinate.cs +++ b/src/SpatialLite.Core/API/Coordinate.cs @@ -17,7 +17,7 @@ public struct Coordinate : IEquatable /// /// The empty coordinate has all coordinates equal to NaN. /// - public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + public static readonly Coordinate Empty = new(double.NaN, double.NaN, double.NaN, double.NaN); /// /// Initializes a new instance of the Coordinate struct with X, Y ordinates. @@ -139,7 +139,7 @@ public override readonly string ToString() /// /// The object to compare with the current Coordinate /// true if the specified object is equal to the current Coordinate; otherwise, false. - public override bool Equals(object obj) + public override readonly bool Equals(object obj) { Coordinate? other = obj as Coordinate?; if (other == null) diff --git a/src/SpatialLite.Core/API/Envelope.cs b/src/SpatialLite.Core/API/Envelope.cs index 38d468f..7329568 100644 --- a/src/SpatialLite.Core/API/Envelope.cs +++ b/src/SpatialLite.Core/API/Envelope.cs @@ -11,7 +11,7 @@ public class Envelope /// /// Empty Envelope, that has all it's bounds set to double.NaN /// - public static Envelope Empty = new Envelope(); + public static readonly Envelope Empty = new(); private const int XIndex = 0; private const int YIndex = 1; diff --git a/src/SpatialLite.Core/Geometries/GeometryCollection.cs b/src/SpatialLite.Core/Geometries/GeometryCollection.cs index cbd0e13..1c37ff9 100644 --- a/src/SpatialLite.Core/Geometries/GeometryCollection.cs +++ b/src/SpatialLite.Core/Geometries/GeometryCollection.cs @@ -84,7 +84,7 @@ IEnumerable IGeometryCollection.Geometries /// public override Envelope GetEnvelope() { - Envelope result = new Envelope(); + Envelope result = new(); foreach (var item in _geometries) { result.Extend(item.GetEnvelope()); diff --git a/src/SpatialLite.Core/IO/WkbReader.cs b/src/SpatialLite.Core/IO/WkbReader.cs index 524a6f8..3a21b99 100644 --- a/src/SpatialLite.Core/IO/WkbReader.cs +++ b/src/SpatialLite.Core/IO/WkbReader.cs @@ -53,9 +53,9 @@ public static Geometry Parse(byte[] wkb) throw new ArgumentNullException(nameof(wkb)); } - using (MemoryStream ms = new MemoryStream(wkb)) + using (MemoryStream ms = new(wkb)) { - using (BinaryReader reader = new BinaryReader(ms)) + using (BinaryReader reader = new(ms)) { if (reader.PeekChar() == -1) { @@ -197,7 +197,7 @@ private static IEnumerable ReadCoordinates(BinaryReader reader, bool { int pointCount = (int)reader.ReadUInt32(); - List result = new List(pointCount); + List result = new(pointCount); for (int i = 0; i < pointCount; i++) { result.Add(ReadCoordinate(reader, is3D, isMeasured)); @@ -275,7 +275,7 @@ private static Polygon ReadPolygon(BinaryReader reader, bool is3D, bool isMeasur } IEnumerable exterior = ReadCoordinates(reader, is3D, isMeasured); - Polygon result = new Polygon(new CoordinateList(exterior)); + Polygon result = new(new CoordinateList(exterior)); for (int i = 1; i < ringsCount; i++) { @@ -297,7 +297,7 @@ private static MultiPoint ReadMultiPoint(BinaryReader reader, bool is3D, bool is { int pointsCount = (int)reader.ReadUInt32(); - MultiPoint result = new MultiPoint(); + MultiPoint result = new(); for (int i = 0; i < pointsCount; i++) { result.Geometries.Add(ReadPoint(reader, is3D, isMeasured)); @@ -317,7 +317,7 @@ private static MultiLineString ReadMultiLineString(BinaryReader reader, bool is3 { int pointsCount = (int)reader.ReadUInt32(); - MultiLineString result = new MultiLineString(); + MultiLineString result = new(); for (int i = 0; i < pointsCount; i++) { result.Geometries.Add(ReadLineString(reader, is3D, isMeasured)); @@ -337,7 +337,7 @@ private static MultiPolygon ReadMultiPolygon(BinaryReader reader, bool is3D, boo { int pointsCount = (int)reader.ReadUInt32(); - MultiPolygon result = new MultiPolygon(); + MultiPolygon result = new(); for (int i = 0; i < pointsCount; i++) { result.Geometries.Add(ReadPolygon(reader, is3D, isMeasured)); @@ -357,7 +357,7 @@ private static GeometryCollection ReadGeometryCollection(BinaryReader { int pointsCount = (int)reader.ReadUInt32(); - GeometryCollection result = new GeometryCollection(); + GeometryCollection result = new(); for (int i = 0; i < pointsCount; i++) { result.Geometries.Add(ReadGeometry(reader)); diff --git a/src/SpatialLite.Core/IO/WkbWriter.cs b/src/SpatialLite.Core/IO/WkbWriter.cs index b6a2973..5af4a04 100644 --- a/src/SpatialLite.Core/IO/WkbWriter.cs +++ b/src/SpatialLite.Core/IO/WkbWriter.cs @@ -80,11 +80,11 @@ public WkbWriter(string path, WkbWriterSettings settings) /// The binary array with WKB representation of the Geometry. public static byte[] WriteToArray(IGeometry geometry) { - using (MemoryStream dataStream = new MemoryStream()) + using (MemoryStream dataStream = new()) { - using (BinaryWriter writer = new BinaryWriter(dataStream)) + using (BinaryWriter writer = new(dataStream)) { - WkbWriterSettings defaultSettings = new WkbWriterSettings(); + WkbWriterSettings defaultSettings = new(); WriteEncoding(writer, defaultSettings.Encoding); Write(geometry, writer); diff --git a/src/SpatialLite.Core/IO/WktReader.cs b/src/SpatialLite.Core/IO/WktReader.cs index 079e8ab..fa4579b 100644 --- a/src/SpatialLite.Core/IO/WktReader.cs +++ b/src/SpatialLite.Core/IO/WktReader.cs @@ -13,9 +13,6 @@ namespace SpatialLite.Core.IO; /// public class WktReader : IDisposable { - - private static readonly CultureInfo _invarianCulture = CultureInfo.InvariantCulture; - private readonly TextReader _inputReader; private readonly FileStream _inputFileStream; private readonly WktTokensBuffer _tokens; @@ -55,7 +52,7 @@ public WktReader(string path) /// The parsed Geometry. public static Geometry Parse(string wkt) { - WktTokensBuffer tokens = new WktTokensBuffer(WktTokenizer.Tokenize(wkt)); + WktTokensBuffer tokens = new(WktTokenizer.Tokenize(wkt)); return ParseGeometryTaggedText(tokens); } @@ -172,7 +169,7 @@ private static Geometry ParseGeometryTaggedText(WktTokensBuffer tokens) return null; } - throw new WktParseException(string.Format("Invalid geometry type '{0}'", t.Value)); + throw new WktParseException(string.Format(CultureInfo.InvariantCulture, "Invalid geometry type '{0}'", t.Value)); } /// @@ -218,7 +215,7 @@ private static Point ParsePointText(WktTokensBuffer tokens, bool is3D, bool isMe } Expect(TokenType.LEFT_PARENTHESIS, tokens); - Point result = new Point(ParseCoordinate(tokens, is3D, isMeasured)); + Point result = new(ParseCoordinate(tokens, is3D, isMeasured)); Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; @@ -233,7 +230,7 @@ private static Point ParsePointText(WktTokensBuffer tokens, bool is3D, bool isMe /// A list of point specified by tokens. private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List points = new List(); + List points = new(); points.Add(ParsePointText(tokens, is3D, isMeasured)); @@ -259,12 +256,12 @@ private static List ParsePoints(WktTokensBuffer tokens, bool is3D, bool i private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, bool isMeasured) { WktToken t = Expect(TokenType.NUMBER, tokens); - double x = double.Parse(t.Value, _invarianCulture); + double x = double.Parse(t.Value, CultureInfo.InvariantCulture); Expect(TokenType.WHITESPACE, tokens); t = Expect(TokenType.NUMBER, tokens); - double y = double.Parse(t.Value, _invarianCulture); + double y = double.Parse(t.Value, CultureInfo.InvariantCulture); double z = double.NaN; double m = double.NaN; @@ -274,7 +271,7 @@ private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, boo Expect(TokenType.WHITESPACE, tokens); t = Expect(TokenType.NUMBER, tokens); - z = double.Parse(t.Value, _invarianCulture); + z = double.Parse(t.Value, CultureInfo.InvariantCulture); } if (isMeasured) @@ -282,7 +279,7 @@ private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, boo Expect(TokenType.WHITESPACE, tokens); t = Expect(TokenType.NUMBER, tokens); - m = double.Parse(t.Value, _invarianCulture); + m = double.Parse(t.Value, CultureInfo.InvariantCulture); } return new Coordinate(x, y, z, m); @@ -297,7 +294,7 @@ private static Coordinate ParseCoordinate(WktTokensBuffer tokens, bool is3D, boo /// A list of coordinates specified by tokens. private static IEnumerable ParseCoordinates(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List coordinates = new List(); + List coordinates = new(); coordinates.Add(ParseCoordinate(tokens, is3D, isMeasured)); @@ -371,7 +368,7 @@ private static LineString ParseLineStringText(WktTokensBuffer tokens, bool is3D, /// A list of linestrings specified by tokens. private static List ParseLineStrings(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List linestrigns = new List(); + List linestrigns = new(); linestrigns.Add(ParseLineStringText(tokens, is3D, isMeasured)); @@ -431,7 +428,7 @@ private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool Expect(TokenType.LEFT_PARENTHESIS, tokens); IEnumerable linestrings = ParseLineStrings(tokens, is3D, isMeasured); - Polygon result = new Polygon(linestrings.First().Coordinates); + Polygon result = new(linestrings.First().Coordinates); foreach (var inner in linestrings.Skip(1)) { @@ -452,7 +449,7 @@ private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool /// A list of polygons specified by tokens. private static IEnumerable ParsePolygons(WktTokensBuffer tokens, bool is3D, bool isMeasured) { - List polygons = new List(); + List polygons = new(); polygons.Add(ParsePolygonText(tokens, is3D, isMeasured)); @@ -510,7 +507,7 @@ private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, } Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiLineString result = new MultiLineString(ParseLineStrings(tokens, is3D, isMeasured)); + MultiLineString result = new(ParseLineStrings(tokens, is3D, isMeasured)); Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; @@ -559,7 +556,7 @@ private static MultiPoint ParseMultiPointText(WktTokensBuffer tokens, bool is3D, } Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPoint result = new MultiPoint(ParsePoints(tokens, is3D, isMeasured)); + MultiPoint result = new(ParsePoints(tokens, is3D, isMeasured)); Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; @@ -608,7 +605,7 @@ private static MultiPolygon ParseMultiPolygonText(WktTokensBuffer tokens, bool i } Expect(TokenType.LEFT_PARENTHESIS, tokens); - MultiPolygon result = new MultiPolygon(ParsePolygons(tokens, is3D, isMeasured)); + MultiPolygon result = new(ParsePolygons(tokens, is3D, isMeasured)); Expect(TokenType.RIGHT_PARENTHESIS, tokens); return result; @@ -658,7 +655,7 @@ private static GeometryCollection ParseGeometryCollectionText(WktToken Expect(TokenType.LEFT_PARENTHESIS, tokens); - GeometryCollection result = new GeometryCollection(); + GeometryCollection result = new(); result.Geometries.Add(ParseGeometryTaggedText(tokens)); t = tokens.Peek(true); @@ -698,7 +695,7 @@ private static WktToken Expect(TokenType type, WktTokensBuffer tokens) case TokenType.NUMBER: expected = "NUMBER"; break; } - throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}'", expected, t.Value)); + throw new WktParseException(string.Format(CultureInfo.InvariantCulture, "Expected '{0}' but encountered '{1}'", expected, t.Value)); } return t; @@ -717,7 +714,7 @@ private static WktToken Expect(string value, WktTokensBuffer tokens) if (t.Type != TokenType.STRING || string.Equals(value, t.Value, StringComparison.OrdinalIgnoreCase) == false) { - throw new WktParseException(string.Format("Expected '{0}' but encountered '{1}", value, t.Value)); + throw new WktParseException(string.Format(CultureInfo.InvariantCulture, "Expected '{0}' but encountered '{1}", value, t.Value)); } return t; diff --git a/src/SpatialLite.Core/IO/WktToken.cs b/src/SpatialLite.Core/IO/WktToken.cs index c68599f..a04fa6d 100644 --- a/src/SpatialLite.Core/IO/WktToken.cs +++ b/src/SpatialLite.Core/IO/WktToken.cs @@ -8,7 +8,7 @@ internal struct WktToken /// /// Special token that represents end of available data. /// - public static WktToken EndOfDataToken = new WktToken() { Type = TokenType.END_OF_DATA, Value = string.Empty }; + public static WktToken EndOfDataToken = new() { Type = TokenType.END_OF_DATA, Value = string.Empty }; /// /// The type of the tooken. diff --git a/src/SpatialLite.Core/IO/WktTokenizer.cs b/src/SpatialLite.Core/IO/WktTokenizer.cs index 0283c55..0cbbda0 100644 --- a/src/SpatialLite.Core/IO/WktTokenizer.cs +++ b/src/SpatialLite.Core/IO/WktTokenizer.cs @@ -18,7 +18,7 @@ internal static class WktTokenizer /// The list of parsed tokens of the input string. public static IEnumerable Tokenize(string text) { - StringReader reader = new StringReader(text); + StringReader reader = new(text); return Tokenize(reader); } @@ -29,7 +29,7 @@ public static IEnumerable Tokenize(string text) /// The collection parsed tokens of the input string public static IEnumerable Tokenize(TextReader reader) { - StringBuilder stringBuffer = new StringBuilder(); + StringBuilder stringBuffer = new(); if (reader.Peek() == -1) { diff --git a/src/SpatialLite.Core/IO/WktWriter.cs b/src/SpatialLite.Core/IO/WktWriter.cs index 1a59c40..07374d1 100644 --- a/src/SpatialLite.Core/IO/WktWriter.cs +++ b/src/SpatialLite.Core/IO/WktWriter.cs @@ -90,7 +90,7 @@ public void Dispose() /// The WKT representation of the Geometry. public static string WriteToString(IGeometry geometry) { - StringWriter tw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); + StringWriter tw = new(System.Globalization.CultureInfo.InvariantCulture); Write(geometry, tw); return tw.ToString(); diff --git a/src/SpatialLite.Gps/GpxDocument.cs b/src/SpatialLite.Gps/GpxDocument.cs index f6b5d7f..9e482e8 100644 --- a/src/SpatialLite.Gps/GpxDocument.cs +++ b/src/SpatialLite.Gps/GpxDocument.cs @@ -54,7 +54,7 @@ public GpxDocument(IEnumerable waypoints, IEnumerable routes /// Path to the file. public void Save(string path) { - using (GpxWriter writer = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter writer = new(path, new GpxWriterSettings() { WriteMetadata = true })) { Save(writer); } @@ -112,9 +112,9 @@ private void LoadFromReader(IGpxReader reader) /// GpxDocument instance with data from GPX file public static GpxDocument Load(string path) { - GpxDocument result = new GpxDocument(); + GpxDocument result = new(); - using (GpxReader reader = new GpxReader(path, new GpxReaderSettings() { ReadMetadata = true })) + using (GpxReader reader = new(path, new GpxReaderSettings() { ReadMetadata = true })) { result.LoadFromReader(reader); } @@ -134,7 +134,7 @@ public static GpxDocument Load(IGpxReader reader) throw new ArgumentNullException(nameof(reader)); } - GpxDocument result = new GpxDocument(); + GpxDocument result = new(); result.LoadFromReader(reader); return result; } diff --git a/src/SpatialLite.Gps/IO/GpxReader.cs b/src/SpatialLite.Gps/IO/GpxReader.cs index edda6b4..59e63c2 100644 --- a/src/SpatialLite.Gps/IO/GpxReader.cs +++ b/src/SpatialLite.Gps/IO/GpxReader.cs @@ -1,5 +1,6 @@ using SpatialLite.Gps.Geometries; using System; +using System.Globalization; using System.IO; using System.Xml; @@ -10,9 +11,6 @@ namespace SpatialLite.Gps.IO; /// public class GpxReader : IGpxReader, IDisposable { - - private readonly System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; - private bool _disposed = false; private XmlReader _xmlReader; @@ -101,15 +99,15 @@ private GpxPoint ReadPoint(string pointElementName) string latValue = _xmlReader.GetAttribute("lat"); if (string.IsNullOrEmpty(latValue)) throw new InvalidDataException("Requested attribute 'lat' not found."); - double lat = double.Parse(latValue, _invariantCulture); + double lat = double.Parse(latValue, CultureInfo.InvariantCulture); string lonValue = _xmlReader.GetAttribute("lon"); if (string.IsNullOrEmpty(lonValue)) throw new InvalidDataException("Requested attribute 'lon' not found."); - double lon = double.Parse(lonValue, _invariantCulture); + double lon = double.Parse(lonValue, CultureInfo.InvariantCulture); double ele = double.NaN; - DateTime timestamp = new DateTime(); + DateTime timestamp = new(); GpxPointMetadata metadata = null; if (Settings.ReadMetadata) @@ -128,14 +126,14 @@ private GpxPoint ReadPoint(string pointElementName) if (_xmlReader.Name == "ele") { string eleValue = _xmlReader.ReadElementContentAsString(); - ele = double.Parse(eleValue, _invariantCulture); + ele = double.Parse(eleValue, CultureInfo.InvariantCulture); elementParsed = true; } if (_xmlReader.Name == "time") { string timeValue = _xmlReader.ReadElementContentAsString(); - timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture); + timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture); elementParsed = true; } @@ -152,7 +150,7 @@ private GpxPoint ReadPoint(string pointElementName) } _xmlReader.Skip(); - GpxPoint result = new GpxPoint(lon, lat, ele, timestamp); + GpxPoint result = new(lon, lat, ele, timestamp); result.Metadata = metadata; return result; @@ -164,7 +162,7 @@ private GpxPoint ReadPoint(string pointElementName) /// the track parsed form the XmlReader private GpxTrack ReadTrack() { - GpxTrack result = new GpxTrack(); + GpxTrack result = new(); if (_xmlReader.IsEmptyElement == false) { @@ -210,7 +208,7 @@ private GpxTrack ReadTrack() /// the track parsed from the XmlReader private GpxTrackSegment ReadTrackSegment() { - GpxTrackSegment result = new GpxTrackSegment(); + GpxTrackSegment result = new(); if (_xmlReader.IsEmptyElement == false) { @@ -240,7 +238,7 @@ private GpxTrackSegment ReadTrackSegment() /// the route parsed from the XmlReader private GpxRoute ReadRoute() { - GpxRoute result = new GpxRoute(); + GpxRoute result = new(); if (_xmlReader.IsEmptyElement == false) { @@ -285,7 +283,7 @@ private GpxRoute ReadRoute() /// private void InitializeReader() { - XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); + XmlReaderSettings xmlReaderSettings = new(); xmlReaderSettings.IgnoreComments = true; xmlReaderSettings.IgnoreProcessingInstructions = true; xmlReaderSettings.IgnoreWhitespace = true; @@ -304,7 +302,7 @@ private void InitializeReader() string version = _xmlReader.GetAttribute("version"); if (version == null || (version != "1.0" && version != "1.1")) - throw new InvalidDataException(string.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); + throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture, "Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); _insideGpx = true; @@ -396,28 +394,28 @@ private bool TryReadPointMetadata(GpxPointMetadata metadata) metadata.Links.Add(ReadLink()); return true; case "magvar": string magvarValue = _xmlReader.ReadElementContentAsString(); - metadata.MagVar = double.Parse(magvarValue, _invariantCulture); return true; + metadata.MagVar = double.Parse(magvarValue, CultureInfo.InvariantCulture); return true; case "geoidheight": string geoidHeightValue = _xmlReader.ReadElementContentAsString(); - metadata.GeoidHeight = double.Parse(geoidHeightValue, _invariantCulture); return true; + metadata.GeoidHeight = double.Parse(geoidHeightValue, CultureInfo.InvariantCulture); return true; case "hdop": string HdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Hdop = double.Parse(HdopValue, _invariantCulture); return true; + metadata.Hdop = double.Parse(HdopValue, CultureInfo.InvariantCulture); return true; case "vdop": string vdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Vdop = double.Parse(vdopValue, _invariantCulture); return true; + metadata.Vdop = double.Parse(vdopValue, CultureInfo.InvariantCulture); return true; case "pdop": string pdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Pdop = double.Parse(pdopValue, _invariantCulture); return true; + metadata.Pdop = double.Parse(pdopValue, CultureInfo.InvariantCulture); return true; case "ageofdgpsdata": string ageValue = _xmlReader.ReadElementContentAsString(); - metadata.AgeOfDgpsData = double.Parse(ageValue, _invariantCulture); return true; + metadata.AgeOfDgpsData = double.Parse(ageValue, CultureInfo.InvariantCulture); return true; case "sat": string satValue = _xmlReader.ReadElementContentAsString(); - metadata.SatellitesCount = int.Parse(satValue, _invariantCulture); return true; + metadata.SatellitesCount = int.Parse(satValue, CultureInfo.InvariantCulture); return true; case "dgpsid": string dgpsidValue = _xmlReader.ReadElementContentAsString(); - metadata.DgpsId = int.Parse(dgpsidValue, _invariantCulture); return true; + metadata.DgpsId = int.Parse(dgpsidValue, CultureInfo.InvariantCulture); return true; case "fix": string fixValue = _xmlReader.ReadElementContentAsString(); metadata.Fix = GpxFixHelper.ParseGpsFix(fixValue); return true; diff --git a/src/SpatialLite.Gps/IO/GpxWriter.cs b/src/SpatialLite.Gps/IO/GpxWriter.cs index ccd0825..1f03839 100644 --- a/src/SpatialLite.Gps/IO/GpxWriter.cs +++ b/src/SpatialLite.Gps/IO/GpxWriter.cs @@ -27,7 +27,7 @@ public GpxWriter(Stream stream, GpxWriterSettings settings) Settings = settings; settings.IsReadOnly = true; - XmlWriterSettings writerSetting = new XmlWriterSettings(); + XmlWriterSettings writerSetting = new(); writerSetting.Indent = true; _streamWriter = new StreamWriter(stream, new UTF8Encoding(false)); @@ -47,7 +47,7 @@ public GpxWriter(string path, GpxWriterSettings settings) Settings = settings; settings.IsReadOnly = true; - XmlWriterSettings writerSetting = new XmlWriterSettings(); + XmlWriterSettings writerSetting = new(); writerSetting.Indent = true; var fileStream = new FileStream(path, FileMode.Create); diff --git a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs index f1da1dd..908e9de 100644 --- a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs +++ b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs @@ -1,6 +1,7 @@ using SpatialLite.Osm.IO; using System; using System.Collections.Generic; +using System.Globalization; namespace SpatialLite.Osm.Geometries; @@ -35,9 +36,9 @@ public OsmGeometryDatabase(IEnumerable entities) /// New instance of the OsmDatabase class with data loaded from specified reader. public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferentialErrors) { - OsmGeometryDatabase db = new OsmGeometryDatabase(); + OsmGeometryDatabase db = new(); - List relations = new List(); + List relations = new(); IEntityInfo entityInfo; while ((entityInfo = reader.Read()) != null) @@ -51,7 +52,7 @@ public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferential { if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format("Way (ID = {0}) references missing node.", entityInfo.ID)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Way (ID = {0}) references missing node.", entityInfo.ID)); } } else @@ -79,7 +80,7 @@ public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferential { if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format("Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); } db.Relations.Remove(relation); diff --git a/src/SpatialLite.Osm/Geometries/Relation.cs b/src/SpatialLite.Osm/Geometries/Relation.cs index 575c9e2..8f151c4 100644 --- a/src/SpatialLite.Osm/Geometries/Relation.cs +++ b/src/SpatialLite.Osm/Geometries/Relation.cs @@ -73,7 +73,7 @@ public EntityType EntityType /// The Relation object created from RelationInfo or null if referenced entity is missing. public static Relation FromRelationInfo(RelationInfo info, IEntityCollection entities, bool throwOnMissing) { - Relation result = new Relation(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; + Relation result = new(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; result.Geometries.Capacity = info.Members.Count; foreach (var memberInfo in info.Members) diff --git a/src/SpatialLite.Osm/Geometries/RelationMember.cs b/src/SpatialLite.Osm/Geometries/RelationMember.cs index 70d2b19..b52c591 100644 --- a/src/SpatialLite.Osm/Geometries/RelationMember.cs +++ b/src/SpatialLite.Osm/Geometries/RelationMember.cs @@ -2,6 +2,7 @@ using SpatialLite.Core.Geometries; using System; using System.Collections.Generic; +using System.Globalization; namespace SpatialLite.Osm.Geometries; @@ -104,7 +105,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn { if (throwOnMissing) { - throw new ArgumentException(string.Format("Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); } else { @@ -112,7 +113,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn } } - RelationMember result = new RelationMember(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; + RelationMember result = new(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; if (result.Member.EntityType != info.MemberType) { throw new ArgumentException("Type of the referenced entity doesn't match type of the entity in the collection."); diff --git a/src/SpatialLite.Osm/Geometries/Way.cs b/src/SpatialLite.Osm/Geometries/Way.cs index b26c086..b1c2b6c 100644 --- a/src/SpatialLite.Osm/Geometries/Way.cs +++ b/src/SpatialLite.Osm/Geometries/Way.cs @@ -2,6 +2,7 @@ using SpatialLite.Core.Geometries; using System; using System.Collections.Generic; +using System.Globalization; namespace SpatialLite.Osm.Geometries; @@ -96,7 +97,7 @@ public EntityType EntityType /// The Way object created from WayInfo or null if referenced node is missing public static Way FromWayInfo(WayInfo info, IEntityCollection entities, bool throwOnMissing) { - Way result = new Way(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; + Way result = new(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; result.Nodes.Capacity = info.Nodes.Count; foreach (var nodeID in info.Nodes) @@ -109,7 +110,7 @@ public static Way FromWayInfo(WayInfo info, IEntityCollection enti { if (throwOnMissing) { - throw new ArgumentException(string.Format("Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); } return null; diff --git a/src/SpatialLite.Osm/IO/OsmXmlReader.cs b/src/SpatialLite.Osm/IO/OsmXmlReader.cs index 9bedf17..1073b59 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReader.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReader.cs @@ -137,7 +137,7 @@ private NodeInfo ReadNode() additionalInfo = ReadMetadata(); } - NodeInfo result = new NodeInfo(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); + NodeInfo result = new(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); if (_xmlReader.IsEmptyElement == false) { @@ -180,7 +180,7 @@ private WayInfo ReadWay() additionalInfo = ReadMetadata(); } - WayInfo way = new WayInfo(wayId, new TagsCollection(), new List(), additionalInfo); + WayInfo way = new(wayId, new TagsCollection(), new List(), additionalInfo); if (_xmlReader.IsEmptyElement == false) { @@ -254,7 +254,7 @@ private RelationInfo ReadRelation() additionalInfo = ReadMetadata(); } - RelationInfo relation = new RelationInfo(relationId, new TagsCollection(), new List(), additionalInfo); + RelationInfo relation = new(relationId, new TagsCollection(), new List(), additionalInfo); if (false == _xmlReader.IsEmptyElement) { @@ -362,7 +362,7 @@ private Tag ReadTag() /// Metadata of the entity read from the reader. private EntityMetadata ReadMetadata() { - EntityMetadata result = new EntityMetadata(); + EntityMetadata result = new(); // version string attVersion = _xmlReader.GetAttribute("version"); @@ -456,7 +456,7 @@ private EntityMetadata ReadMetadata() /// private void InitializeReader() { - Sys.XmlReaderSettings xmlReaderSettings = new Sys.XmlReaderSettings(); + Sys.XmlReaderSettings xmlReaderSettings = new(); xmlReaderSettings.IgnoreComments = true; xmlReaderSettings.IgnoreProcessingInstructions = true; xmlReaderSettings.IgnoreWhitespace = true; diff --git a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs index ba680ad..168f273 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs @@ -36,7 +36,7 @@ public OsmXmlWriter(Stream stream, OsmWriterSettings settings) _output = stream; _ownsOutputStream = false; - XmlWriterSettings writerSetting = new XmlWriterSettings(); + XmlWriterSettings writerSetting = new(); writerSetting.Indent = true; _writer = XmlWriter.Create(stream, writerSetting); @@ -56,7 +56,7 @@ public OsmXmlWriter(string path, OsmWriterSettings settings) _output = new FileStream(path, FileMode.Create, FileAccess.Write); _ownsOutputStream = true; - XmlWriterSettings writerSetting = new XmlWriterSettings(); + XmlWriterSettings writerSetting = new(); writerSetting.Indent = true; _streamWriter = new StreamWriter(_output, new UTF8Encoding(false)); diff --git a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs index 5089545..34cb399 100644 --- a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs +++ b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs @@ -138,7 +138,7 @@ public uint GetStringIndex(string str) /// The StringTable object with data from the buffer. public StringTable BuildStringTable() { - StringTable result = new StringTable(); + StringTable result = new(); result.Storage = new List(_stringTable.Count); for (int i = 0; i < _stringTable.Count; i++) { diff --git a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs index 2e6d743..4cb3db4 100644 --- a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs +++ b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs @@ -12,7 +12,7 @@ namespace SpatialLite.Osm.IO.Pbf; public class StringTable { - private List _s = new List(); + private List _s = new(); /// /// Gets or sets collection of strings serialized as byte array. diff --git a/src/SpatialLite.Osm/IO/PbfReader.cs b/src/SpatialLite.Osm/IO/PbfReader.cs index 3627e30..d482f44 100644 --- a/src/SpatialLite.Osm/IO/PbfReader.cs +++ b/src/SpatialLite.Osm/IO/PbfReader.cs @@ -26,7 +26,7 @@ public class PbfReader : IOsmReader private bool _disposed = false; private readonly Stream _input; private readonly Queue _cache; - private readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); + private readonly DateTime _unixEpoch = new(1970, 1, 1, 0, 0, 0); /// /// Initializes a new instance of the PbfReader class that read data form specified stream. @@ -194,7 +194,7 @@ private object ReadBlob(BlobHeader header) } else if (blob.ZlibData != null) { - MemoryStream deflateStreamData = new MemoryStream(blob.ZlibData); + MemoryStream deflateStreamData = new(blob.ZlibData); //skip ZLIB header deflateStreamData.Seek(2, SeekOrigin.Begin); @@ -283,7 +283,7 @@ private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) double lat = 1E-09 * (block.LatOffset + (block.Granularity * node.Latitude)); double lon = 1E-09 * (block.LonOffset + (block.Granularity * node.Longitude)); - List tags = new List(); + List tags = new(); if (node.Keys != null) { for (int i = 0; i < node.Keys.Count; i++) @@ -294,7 +294,7 @@ private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) EntityMetadata metadata = ProcessMetadata(node.Metadata, block); - NodeInfo parsed = new NodeInfo(node.ID, lat, lon, new TagsCollection(tags), metadata); + NodeInfo parsed = new(node.ID, lat, lon, new TagsCollection(tags), metadata); _cache.Enqueue(parsed); } } @@ -331,7 +331,7 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) double lat = 1E-09 * (block.LatOffset + (block.Granularity * latStore)); double lon = 1E-09 * (block.LonOffset + (block.Granularity * lonStore)); - List tags = new List(); + List tags = new(); if (group.DenseNodes.KeysVals.Count > 0) { while (group.DenseNodes.KeysVals[keyValueIndex] != 0) @@ -370,7 +370,7 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) } } - NodeInfo parsed = new NodeInfo(idStore, lat, lon, new TagsCollection(tags), metadata); + NodeInfo parsed = new(idStore, lat, lon, new TagsCollection(tags), metadata); _cache.Enqueue(parsed); } } @@ -390,7 +390,7 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) foreach (var way in group.Ways) { long refStore = 0; - List refs = new List(way.Refs.Count); + List refs = new(way.Refs.Count); for (int i = 0; i < way.Refs.Count; i++) { @@ -398,7 +398,7 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) refs.Add(refStore); } - List tags = new List(); + List tags = new(); if (way.Keys != null) { for (int i = 0; i < way.Keys.Count; i++) @@ -409,7 +409,7 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) EntityMetadata metadata = ProcessMetadata(way.Metadata, block); - WayInfo parsed = new WayInfo(way.ID, new TagsCollection(tags), refs, metadata); + WayInfo parsed = new(way.ID, new TagsCollection(tags), refs, metadata); _cache.Enqueue(parsed); } } @@ -430,7 +430,7 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) { long memberRefStore = 0; - List members = new List(); + List members = new(); for (int i = 0; i < relation.MemberIds.Count; i++) { memberRefStore += relation.MemberIds[i]; @@ -447,7 +447,7 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) members.Add(new RelationMemberInfo() { MemberType = memberType, Reference = memberRefStore, Role = role }); } - List tags = new List(); + List tags = new(); if (relation.Keys != null) { for (int i = 0; i < relation.Keys.Count; i++) @@ -458,7 +458,7 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) EntityMetadata metadata = ProcessMetadata(relation.Metadata, block); - RelationInfo parsed = new RelationInfo(relation.ID, new TagsCollection(tags), members, metadata); + RelationInfo parsed = new(relation.ID, new TagsCollection(tags), members, metadata); _cache.Enqueue(parsed); } } diff --git a/src/SpatialLite.Osm/IO/PbfWriter.cs b/src/SpatialLite.Osm/IO/PbfWriter.cs index 4dd2002..553b460 100644 --- a/src/SpatialLite.Osm/IO/PbfWriter.cs +++ b/src/SpatialLite.Osm/IO/PbfWriter.cs @@ -18,7 +18,7 @@ public class PbfWriter : IOsmWriter /// public const int MaxDataBlockSize = 16 * 1024 * 1024; - private readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); + private readonly DateTime _unixEpoch = new(1970, 1, 1, 0, 0, 0); private bool _disposed = false; private readonly Stream _output; @@ -78,12 +78,12 @@ public void Write(IEntityInfo entity) { if (entity.Metadata == null) { - throw new ArgumentException("Entity doesn't contain metadata obejct, but writer was created with WriteMetadata setting."); + throw new ArgumentException("Entity doesn't contain metadata object, but writer was created with WriteMetadata setting."); } if (entity.Metadata.User == null) { - throw new ArgumentNullException("Entity.Metadata.User cannot be null."); + throw new ArgumentException("Entity.Metadata.User cannot be null."); } } @@ -173,7 +173,7 @@ private void Flush(EntityType entityType) return; } - MemoryStream primitiveBlockStream = new MemoryStream(); + MemoryStream primitiveBlockStream = new(); Serializer.Serialize(primitiveBlockStream, primitiveBlock); //byte[] buffer = new byte[primitiveBlockStream.Length]; @@ -187,7 +187,7 @@ private void Flush(EntityType entityType) /// private void WriteHeader() { - OsmHeader header = new OsmHeader(); + OsmHeader header = new(); header.RequiredFeatures.Add("OsmSchema-V0.6"); if (Settings.UseDenseFormat) @@ -200,7 +200,7 @@ private void WriteHeader() header.OptionalFeatures.Add("Has_Metadata"); } - using (MemoryStream stream = new MemoryStream()) + using (MemoryStream stream = new()) { Serializer.Serialize(stream, header); @@ -218,20 +218,20 @@ private void WriteHeader() /// The pbf serialized content of the blob. private void WriteBlob(string blobType, byte[] blobContent) { - Blob blob = new Blob(); + Blob blob = new(); if (Settings.Compression == CompressionMode.None) { blob.Raw = blobContent; } else if (Settings.Compression == CompressionMode.ZlibDeflate) { - MemoryStream zlibStream = new MemoryStream(); + MemoryStream zlibStream = new(); //ZLIB header zlibStream.WriteByte(120); zlibStream.WriteByte(156); - using (System.IO.Compression.DeflateStream deflateSteram = new System.IO.Compression.DeflateStream(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) + using (System.IO.Compression.DeflateStream deflateSteram = new(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) { deflateSteram.Write(blobContent, 0, blobContent.Length); } @@ -240,10 +240,10 @@ private void WriteBlob(string blobType, byte[] blobContent) blob.ZlibData = zlibStream.ToArray(); } - MemoryStream blobStream = new MemoryStream(); + MemoryStream blobStream = new(); Serializer.Serialize(blobStream, blob); - BlobHeader header = new BlobHeader(); + BlobHeader header = new(); header.Type = blobType; header.DataSize = (int)blobStream.Length; Serializer.SerializeWithLengthPrefix(_output, header, PrefixStyle.Fixed32BigEndian); @@ -258,7 +258,7 @@ private void WriteBlob(string blobType, byte[] blobContent) /// PrimitiveBlock with entities of specified type or null if tokens doesn't contain any entities of specified type. private PrimitiveBlock BuildPrimitiveBlock(EntityType entityType) { - PrimitiveBlock result = new PrimitiveBlock(); + PrimitiveBlock result = new(); result.PrimitiveGroup = new List(); PrimitiveGroup entityGroup = null; @@ -368,10 +368,10 @@ private PrimitiveGroup BuildRelationsPrimitiveGroup(int timestampGranularity) /// The DenseNode obejct with data from nodes in tokens. private List BuildNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) { - List result = new List(_nodesBuffer.Count); + List result = new(_nodesBuffer.Count); foreach (var node in _nodesBuffer) { - PbfNode toAdd = new PbfNode(); + PbfNode toAdd = new(); toAdd.ID = node.ID; toAdd.Latitude = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); @@ -410,7 +410,7 @@ private List BuildNodes(int timestampGranularity, int positionGranulari /// The DenseNode obejct with data from nodes in tokens. private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) { - PbfDenseNodes result = new PbfDenseNodes(_nodesBuffer.Count); + PbfDenseNodes result = new(_nodesBuffer.Count); long lastID = 0; long lastLat = 0; @@ -453,13 +453,13 @@ private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGran /// The collection of PbfWay objects created from relations in tokens. private List BuildWays(int timestampGranularity) { - List result = new List(); + List result = new(); foreach (var way in _wayBuffer) { long lastRef = 0; - PbfWay toAdd = new PbfWay(); + PbfWay toAdd = new(); toAdd.ID = way.ID; @@ -504,11 +504,11 @@ private List BuildWays(int timestampGranularity) /// The collection of PbfRelation objects created from relations in tokens. private List BuildRelations(int timestampGranularity) { - List result = new List(); + List result = new(); foreach (var relation in _relationBuffer) { - PbfRelation toAdd = new PbfRelation(); + PbfRelation toAdd = new(); toAdd.ID = relation.ID; long lastRef = 0; @@ -559,7 +559,7 @@ private List BuildRelations(int timestampGranularity) /// DenseInfo object with metadata for noes in tokens. private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) { - PbfDenseMetadata result = new PbfDenseMetadata(_nodesBuffer.Count); + PbfDenseMetadata result = new(_nodesBuffer.Count); long lastChangeset = 0; long lastTimestamp = 0; @@ -600,7 +600,7 @@ private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) /// PbfMetadata obejct with data from specified metadata object. private PbfMetadata BuildInfo(EntityMetadata metadata, int timestampGranularity, IStringTableBuilder stringTableBuilder) { - PbfMetadata result = new PbfMetadata(); + PbfMetadata result = new(); result.Changeset = metadata.Changeset; result.Timestamp = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); result.UserID = metadata.Uid; diff --git a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs index 0b6ded7..850aec6 100644 --- a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs +++ b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs @@ -33,7 +33,7 @@ public OsmEntityInfoDatabase(IEnumerable entities) /// New instance of the OsmDAtabase class with data loaded from specified reader. public static OsmEntityInfoDatabase Load(IOsmReader reader) { - OsmEntityInfoDatabase db = new OsmEntityInfoDatabase(); + OsmEntityInfoDatabase db = new(); IEntityInfo entityInfo; while ((entityInfo = reader.Read()) != null) diff --git a/src/SpatialLite.Osm/Tag.cs b/src/SpatialLite.Osm/Tag.cs index b9b701f..e95eeb1 100644 --- a/src/SpatialLite.Osm/Tag.cs +++ b/src/SpatialLite.Osm/Tag.cs @@ -20,7 +20,7 @@ public Tag(string key, string value) { if (key == null) { - throw new ArgumentNullException("Parameter 'key' can't be null."); + throw new ArgumentNullException(nameof(key), "Parameter 'key' can't be null."); } if (key == string.Empty) @@ -29,7 +29,7 @@ public Tag(string key, string value) } _key = key; - _value = value ?? throw new ArgumentNullException("Parameter 'value' can't be null."); + _value = value ?? throw new ArgumentNullException(nameof(value), "Parameter 'value' can't be null."); } /// diff --git a/src/SpatialLite.Osm/TagsCollection.cs b/src/SpatialLite.Osm/TagsCollection.cs index 3421aa0..ab66dd8 100644 --- a/src/SpatialLite.Osm/TagsCollection.cs +++ b/src/SpatialLite.Osm/TagsCollection.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; namespace SpatialLite.Osm; @@ -98,7 +99,7 @@ public void Add(Tag tag) if (Contains(tag.Key)) { - throw new ArgumentException(string.Format("Tag with key '{0}' is already present in the collection.", tag.Key)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Tag with key '{0}' is already present in the collection.", tag.Key)); } _tags.Add(tag); @@ -175,7 +176,7 @@ public Tag GetTag(string key) { if (_tags == null) { - throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Tag with key '{0}' is not present in the collection.", key)); } for (int i = 0; i < _tags.Count; i++) @@ -186,7 +187,7 @@ public Tag GetTag(string key) } } - throw new ArgumentException(string.Format("Tag with key '{0}' is not present in the collection.", key)); + throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Tag with key '{0}' is not present in the collection.", key)); } /// diff --git a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs index 8051620..b74b34e 100644 --- a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs +++ b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs @@ -13,7 +13,7 @@ public class CoordinateTests [Fact] public void Constructor_XY_SetsXYValuesAndZMNaN() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); + Coordinate target = new(xCoordinate, yCoordinate); Assert.Equal(xCoordinate, target.X); Assert.Equal(yCoordinate, target.Y); @@ -24,7 +24,7 @@ public void Constructor_XY_SetsXYValuesAndZMNaN() [Fact] public void Constructor_XYZ_SetsXYZValuesAndMNaN() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate); Assert.Equal(xCoordinate, target.X); Assert.Equal(yCoordinate, target.Y); @@ -35,7 +35,7 @@ public void Constructor_XYZ_SetsXYZValuesAndMNaN() [Fact] public void Constructor_XYZM_SetsXYZMValues() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.Equal(xCoordinate, target.X); Assert.Equal(yCoordinate, target.Y); @@ -46,7 +46,7 @@ public void Constructor_XYZM_SetsXYZMValues() [Fact] public void Is3D_ReturnsFalseForNaNZCoordinate() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); + Coordinate target = new(xCoordinate, yCoordinate); Assert.False(target.Is3D); } @@ -54,7 +54,7 @@ public void Is3D_ReturnsFalseForNaNZCoordinate() [Fact] public void Is3D_ReturnsTrueFor3D() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate); Assert.True(target.Is3D); } @@ -62,7 +62,7 @@ public void Is3D_ReturnsTrueFor3D() [Fact] public void IsMeasured_ReturnsFalseForNaNMCoordinate() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate); + Coordinate target = new(xCoordinate, yCoordinate); Assert.False(target.IsMeasured); } @@ -70,7 +70,7 @@ public void IsMeasured_ReturnsFalseForNaNMCoordinate() [Fact] public void IsMeasured_ReturnsTrueForMeasuredCoordinate() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target.IsMeasured); } @@ -78,8 +78,8 @@ public void IsMeasured_ReturnsTrueForMeasuredCoordinate() [Fact] public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target.Equals(other)); } @@ -87,8 +87,8 @@ public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() [Fact] public void Equals_ReturnsTrueForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); Assert.True(target.Equals(other)); } @@ -96,7 +96,7 @@ public void Equals_ReturnsTrueForNaNCoordinates() [Fact] public void Equals_ReturnsFalseForNull() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); object other = null; Assert.False(target.Equals(other)); @@ -105,7 +105,7 @@ public void Equals_ReturnsFalseForNull() [Fact] public void Equals_ReturnsFalseForOtherObjectType() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); object other = "string"; Assert.False(target.Equals(other)); @@ -114,8 +114,8 @@ public void Equals_ReturnsFalseForOtherObjectType() [Fact] public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); Assert.False(target.Equals(other)); } @@ -123,8 +123,8 @@ public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() [Fact] public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target.Equals2D(other)); } @@ -132,8 +132,8 @@ public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() [Fact] public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); Assert.True(target.Equals2D(other)); } @@ -141,8 +141,8 @@ public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() [Fact] public void Equals2D_ReturnsTrueForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); Assert.True(target.Equals2D(other)); } @@ -150,8 +150,8 @@ public void Equals2D_ReturnsTrueForNaNCoordinates() [Fact] public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); Assert.False(target.Equals2D(other)); } @@ -159,8 +159,8 @@ public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() [Fact] public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target == other); } @@ -168,8 +168,8 @@ public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() [Fact] public void EqualsOperator_ReturnsTrueForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); Assert.True(target == other); } @@ -177,8 +177,8 @@ public void EqualsOperator_ReturnsTrueForNaNCoordinates() [Fact] public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); Assert.False(target == other); } @@ -186,8 +186,8 @@ public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() [Fact] public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.False(target != other); } @@ -195,8 +195,8 @@ public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() [Fact] public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() { - Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); Assert.False(target != other); } @@ -204,8 +204,8 @@ public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() [Fact] public void NotEqualsOperator_ReturnsTrueForCoordinateWithDifferentOrdinates() { - Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); Assert.True(target != other); } diff --git a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs index bb8bb02..da66706 100644 --- a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs +++ b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs @@ -7,27 +7,27 @@ namespace Tests.SpatialLite.Core.API; public class EnvelopeTests { private readonly Coordinate[] _coordinates = new Coordinate[] { - new Coordinate(1, 10, 100, 1000), - new Coordinate(0, 0, 0, 0), - new Coordinate(-1, -10, -100, -1000) + new(1, 10, 100, 1000), + new(0, 0, 0, 0), + new(-1, -10, -100, -1000) }; - private Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); - private Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); - private Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); + private Coordinate _insideCoordinate = new(0.5, 0.5, 0.5, 0.5); + private Coordinate _lowerValues = new(-2, -20, -200, -2000); + private Coordinate _higherValues = new(2, 20, 200, 2000); private readonly double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; public static IEnumerable _XYZEnvelopeDifferentBounds { get { - yield return new object[] { new Coordinate[] { new Coordinate(1 + 1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2 + 1, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100 + 1, 1000), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000 + 1), new Coordinate(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5 + 1, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6 + 1, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200 + 1, 2000) } }; - yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000 + 1) } }; + yield return new object[] { new Coordinate[] { new(1 + 1, 2, 100, 1000), new(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new(1, 2 + 1, 100, 1000), new(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new(1, 2, 100 + 1, 1000), new(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000 + 1), new(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5 + 1, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5, 6 + 1, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5, 6, 200 + 1, 2000) } }; + yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5, 6, 200, 2000 + 1) } }; } } @@ -46,7 +46,7 @@ internal void CheckBoundaries(Envelope target, double minX, double maxX, double [Fact] public void Constructor__InitializesBoundsToNaNValues() { - Envelope target = new Envelope(); + Envelope target = new(); Assert.Equal(double.NaN, target.MinX); Assert.Equal(double.NaN, target.MaxX); @@ -61,7 +61,7 @@ public void Constructor__InitializesBoundsToNaNValues() [Fact] public void Constructor_Coordinate_InitializesXYZProperties() { - Envelope target = new Envelope(_coordinates[0]); + Envelope target = new(_coordinates[0]); CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); } @@ -69,9 +69,9 @@ public void Constructor_Coordinate_InitializesXYZProperties() [Fact] public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() { - Envelope source = new Envelope(_coordinates); + Envelope source = new(_coordinates); - Envelope target = new Envelope(source); + Envelope target = new(source); CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); @@ -80,9 +80,9 @@ public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() [Fact] public void Constructor_Envelope_CopiesMinMaxValues() { - Envelope source = new Envelope(_coordinates); + Envelope source = new(_coordinates); - Envelope target = new Envelope(source); + Envelope target = new(source); CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); @@ -91,7 +91,7 @@ public void Constructor_Envelope_CopiesMinMaxValues() [Fact] public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new Envelope(); + Envelope target = new(); target.Extend(_coordinates[0]); CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, @@ -101,7 +101,7 @@ public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() [Fact] public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(Coordinate.Empty); @@ -112,7 +112,7 @@ public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() [Fact] public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(_lowerValues); @@ -122,7 +122,7 @@ public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() [Fact] public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(_higherValues); @@ -132,7 +132,7 @@ public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() [Fact] public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(_insideCoordinate); @@ -143,7 +143,7 @@ public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() [Fact] public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new Envelope(); + Envelope target = new(); target.Extend(_coordinates); @@ -154,7 +154,7 @@ public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() [Fact] public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(new Coordinate[] { }); @@ -165,7 +165,7 @@ public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() [Fact] public void Extend_IEnumerableCoordinate_ExtendsEnvelope() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(new Coordinate[] { _lowerValues, _higherValues }); @@ -175,7 +175,7 @@ public void Extend_IEnumerableCoordinate_ExtendsEnvelope() [Fact] public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new Envelope(); + Envelope target = new(); target.Extend(new Envelope(_coordinates)); @@ -186,7 +186,7 @@ public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() [Fact] public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(new Envelope(_coordinates[1])); @@ -197,7 +197,7 @@ public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() [Fact] public void Extend_Envelope_ExtendsEnvelope() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); target.Extend(new Envelope(new Coordinate[] { _lowerValues, _higherValues })); @@ -207,7 +207,7 @@ public void Extend_Envelope_ExtendsEnvelope() [Fact] public void Equals_ReturnsTrueForSameObjectInstance() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); Assert.True(target.Equals(target)); } @@ -215,8 +215,8 @@ public void Equals_ReturnsTrueForSameObjectInstance() [Fact] public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() { - Envelope target = new Envelope(_coordinates); - Envelope other = new Envelope(target); + Envelope target = new(_coordinates); + Envelope other = new(target); Assert.True(target.Equals(other)); } @@ -224,7 +224,7 @@ public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() [Fact] public void Equals_ReturnsFalseForNull() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); object other = null; Assert.False(target.Equals(other)); @@ -233,7 +233,7 @@ public void Equals_ReturnsFalseForNull() [Fact] public void Equals_ReturnsFalseForOtherObjectType() { - Envelope target = new Envelope(_coordinates); + Envelope target = new(_coordinates); object other = "string"; Assert.False(target.Equals(other)); @@ -243,8 +243,8 @@ public void Equals_ReturnsFalseForOtherObjectType() [MemberData(nameof(_XYZEnvelopeDifferentBounds))] public void Equals_ReturnsFalseForTheEnvelopeWithDifferentBounds(Coordinate[] corners) { - Envelope target = new Envelope(_coordinates); - Envelope other = new Envelope(corners); + Envelope target = new(_coordinates); + Envelope other = new(corners); Assert.False(target.Equals(other)); } diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs index 32869ab..118ee62 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs @@ -23,7 +23,7 @@ public static IEnumerable CoordinatesSameXYOrdinates [MemberData(nameof(CoordinatesSameXYOrdinates))] public void ComputeDistance_CoordinateCoordinate_ReturnsZeroForPointsWithSameXYCoordinates(Coordinate c1, Coordinate c2) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c1, c2); @@ -44,7 +44,7 @@ public static IEnumerable CoordinatesDistanceTestData [MemberData(nameof(CoordinatesDistanceTestData))] public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinates(Coordinate c1, Coordinate c2, double expectedDistance) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c1, c2); @@ -54,7 +54,7 @@ public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinat [Fact] public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(new Coordinate(-1, 0, 100), new Coordinate(1, 0, -100)); @@ -64,12 +64,12 @@ public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() [Fact] public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsDistanceToEndPointsIfPointsProjectionLiesOutsideSegment() { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(-1, -1); - Coordinate c1 = new Coordinate(1, 2); - Coordinate c2 = new Coordinate(-1, -2); + Coordinate A = new(1, 1); + Coordinate B = new(-1, -1); + Coordinate c1 = new(1, 2); + Coordinate c2 = new(-1, -2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distanceC1 = target.CalculateDistance(c1, A, B, LineMode.LineSegment); Assert.Equal(1, distanceC1); @@ -92,7 +92,7 @@ public static IEnumerable LineSegmentDistanceTestData [MemberData(nameof(LineSegmentDistanceTestData))] public void ComputeDistance_CoordinateLineLineSegmentMode_ComputesPerpendicularDistanceToLineIfPointsProjectionLiesInside(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); Assert.Equal(expectedDistance, distance); @@ -112,7 +112,7 @@ public static IEnumerable LineSegmentDistanceZeroDistanceTestData [MemberData(nameof(LineSegmentDistanceZeroDistanceTestData))] public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLiesOnLineSegment(Coordinate c, Coordinate A, Coordinate B) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); Assert.Equal(0, distance); @@ -121,11 +121,11 @@ public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLies [Fact] public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIfABAreEquals() { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(1, 1); - Coordinate c = new Coordinate(1, 2); + Coordinate A = new(1, 1); + Coordinate B = new(1, 1); + Coordinate c = new(1, 2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); Assert.Equal(1, distance); @@ -134,11 +134,11 @@ public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIf [Fact] public void ComputeDistance_CoordinateLineLineMode_ReturnsPointDistanceIfABAreEquals() { - Coordinate A = new Coordinate(1, 1); - Coordinate B = new Coordinate(1, 1); - Coordinate c = new Coordinate(1, 2); + Coordinate A = new(1, 1); + Coordinate B = new(1, 1); + Coordinate c = new(1, 2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c, A, B, LineMode.Line); Assert.Equal(1, distance); @@ -158,7 +158,7 @@ public static IEnumerable LineDistanceZeroDistanceTestData [MemberData(nameof(LineDistanceZeroDistanceTestData))] public void ComputeDistance_CoordinateLineLineMode_ReturnsZeroIfPointLiesOnLine(Coordinate c, Coordinate A, Coordinate B) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c, A, B, LineMode.Line); Assert.Equal(0, distance); @@ -178,7 +178,7 @@ public static IEnumerable LineDistanceTestData [MemberData(nameof(LineDistanceTestData))] public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistanceToLine(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) { - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double distance = target.CalculateDistance(c, A, B, LineMode.Line); Assert.Equal(expectedDistance, distance); @@ -187,9 +187,9 @@ public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistance [Fact] public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() { - Mock listM = new Mock(); + Mock listM = new(); listM.SetupGet(l => l.Count).Returns(2); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); Assert.Throws(() => target.CalculateArea(listM.Object)); } @@ -197,17 +197,17 @@ public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() [Fact] public void ComputeArea_ReturnsAreaOfConvexPolygon() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; + Coordinate[] coordinates = new Coordinate[] { new(1, 1), new(2, 0.5), new(3, 1), new(3, 2), new(1, 2) }; double expectedArea = 2.5; - Mock listM = new Mock(); + Mock listM = new(); listM.SetupGet(list => list.Count).Returns(5); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); listM.Setup(list => list[2]).Returns(coordinates[2]); listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); @@ -216,17 +216,17 @@ public void ComputeArea_ReturnsAreaOfConvexPolygon() [Fact] public void ComputeArea_ReturnsAreaOfConcavePolygon() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; + Coordinate[] coordinates = new Coordinate[] { new(1, 1), new(2, 1.5), new(3, 1), new(3, 2), new(1, 2) }; double expectedArea = 1.5; - Mock listM = new Mock(); + Mock listM = new(); listM.SetupGet(list => list.Count).Returns(5); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); listM.Setup(list => list[2]).Returns(coordinates[2]); listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); @@ -235,10 +235,10 @@ public void ComputeArea_ReturnsAreaOfConcavePolygon() [Fact] public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2), new Coordinate(1, 1) }; + Coordinate[] coordinates = new Coordinate[] { new(1, 1), new(2, 0.5), new(3, 1), new(3, 2), new(1, 2), new(1, 1) }; double expectedArea = 2.5; - Mock listM = new Mock(); + Mock listM = new(); listM.SetupGet(list => list.Count).Returns(6); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); @@ -246,7 +246,7 @@ public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); listM.Setup(list => list[5]).Returns(coordinates[5]); - Euclidean2DCalculator target = new Euclidean2DCalculator(); + Euclidean2DCalculator target = new(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs index 5c183cf..46e499c 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs @@ -14,9 +14,9 @@ public class Euclidean2DLocatorTests [Fact] public void IsOnLine_ReturnsTrueIfPointIsOnAorB() { - Coordinate a = new Coordinate(-10, 0); - Coordinate b = new Coordinate(3, 2); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate a = new(-10, 0); + Coordinate b = new(3, 2); + Euclidean2DLocator target = new(); Assert.True(target.IsOnLine(a, a, b, LineMode.Line)); Assert.True(target.IsOnLine(b, a, b, LineMode.Line)); @@ -39,7 +39,7 @@ public static IEnumerable PointsBetweenAB [MemberData(nameof(PointsBetweenAB))] public void IsOnLine_ReturnsTrueIfPointLiesBetweenAAndB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.True(target.IsOnLine(c, a, b, mode)); } @@ -57,7 +57,7 @@ public static IEnumerable PointsOnAB [MemberData(nameof(PointsOnAB))] public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coordinate a, Coordinate b) { - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.True(target.IsOnLine(c, a, b, LineMode.Line)); } @@ -66,7 +66,7 @@ public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coord [MemberData(nameof(PointsOnAB))] public void IsOnLine_ReturnsFalseIfPointLiesOnABAndModeIsLineSegment(Coordinate c, Coordinate a, Coordinate b) { - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.False(target.IsOnLine(c, a, b, LineMode.LineSegment)); } @@ -88,16 +88,16 @@ public static IEnumerable PointsNotOnAB [MemberData(nameof(PointsNotOnAB))] public void IsOnLine_ReturnsFalseIfPointDoEsNotLieOnAB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.False(target.IsOnLine(c, a, b, mode)); } [Fact] public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() { - Coordinate c = new Coordinate(0, 0); - CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(0, 0); + CoordinateList ring = new(new Coordinate[] { new(0, 1), new(1, 0) }); + Euclidean2DLocator target = new(); Assert.Throws(() => target.IsInRing(c, ring)); } @@ -105,9 +105,9 @@ public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() [Fact] public void IsInRing_ThrowsArgumentExceptionIfCoordinateListDoesNotRepresentRing() { - Coordinate c = new Coordinate(0, 0); - CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 2) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(0, 0); + CoordinateList ring = new(new Coordinate[] { new(0, 1), new(1, 0), new(1, 2) }); + Euclidean2DLocator target = new(); Assert.Throws(() => target.IsInRing(c, ring)); } @@ -118,8 +118,8 @@ public void IsInRing_ReturnsTrueIfPointIsInSimpleRing() string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(0.5, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(0.5, 0.5); + Euclidean2DLocator target = new(); Assert.True(target.IsInRing(c, ring.Coordinates)); } @@ -130,8 +130,8 @@ public void IsInRing_ReturnsTrueIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoo string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(0.5, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(0.5, 0.5); + Euclidean2DLocator target = new(); Assert.True(target.IsInRing(c, ring.Coordinates)); } @@ -142,8 +142,8 @@ public void IsInRing_ReturnsTrueIfPointIsInConcaveRing() string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(1, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(1, 0.5); + Euclidean2DLocator target = new(); Assert.True(target.IsInRing(c, ring.Coordinates)); } @@ -154,8 +154,8 @@ public void IsInRing_ReturnsFalseIfPointIsOutsideSimpleRing() string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(2, 2); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(2, 2); + Euclidean2DLocator target = new(); Assert.False(target.IsInRing(c, ring.Coordinates)); } @@ -166,8 +166,8 @@ public void IsInRing_ReturnsFalseIfPointIsOutsideRing() string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(3, 0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(3, 0); + Euclidean2DLocator target = new(); Assert.False(target.IsInRing(c, ring.Coordinates)); } @@ -178,8 +178,8 @@ public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCo string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new Coordinate(-2, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Coordinate c = new(-2, 0.5); + Euclidean2DLocator target = new(); Assert.False(target.IsInRing(c, ring.Coordinates)); } @@ -189,13 +189,13 @@ public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCo [Fact] public void Intersects_ReturnsFalseForParallelLines() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 2.0); + Coordinate A1 = new(1.0, 1.0); + Coordinate B1 = new(2.0, 2.0); - Coordinate A2 = new Coordinate(2.0, 1.0); - Coordinate B2 = new Coordinate(3.0, 2.0); + Coordinate A2 = new(2.0, 1.0); + Coordinate B2 = new(3.0, 2.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); } @@ -203,13 +203,13 @@ public void Intersects_ReturnsFalseForParallelLines() [Fact] public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + Coordinate A1 = new(1.0, 1.0); + Coordinate B1 = new(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); + Coordinate A2 = new(2.0, 0.0); + Coordinate B2 = new(3.0, 1.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.True(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); } @@ -217,13 +217,13 @@ public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() [Fact] public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment1() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + Coordinate A1 = new(1.0, 1.0); + Coordinate B1 = new(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); + Coordinate A2 = new(2.0, 0.0); + Coordinate B2 = new(3.0, 1.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.Line)); } @@ -231,13 +231,13 @@ public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLin [Fact] public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment2() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + Coordinate A1 = new(1.0, 1.0); + Coordinate B1 = new(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 0.5); + Coordinate A2 = new(2.0, 0.0); + Coordinate B2 = new(3.0, 0.5); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.LineSegment)); } @@ -245,13 +245,13 @@ public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLin [Fact] public void Intersects_ReturnsFalseForNonIntersectingLineSegments() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(2.0, 1.0); + Coordinate A1 = new(1.0, 1.0); + Coordinate B1 = new(2.0, 1.0); - Coordinate A2 = new Coordinate(2.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 1.0); + Coordinate A2 = new(2.0, 0.0); + Coordinate B2 = new(3.0, 1.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); } @@ -259,13 +259,13 @@ public void Intersects_ReturnsFalseForNonIntersectingLineSegments() [Fact] public void Intersects_ReturnsTrueForIntersectingLineSegments() { - Coordinate A1 = new Coordinate(1.0, 1.0); - Coordinate B1 = new Coordinate(3.0, 1.0); + Coordinate A1 = new(1.0, 1.0); + Coordinate B1 = new(3.0, 1.0); - Coordinate A2 = new Coordinate(1.0, 0.0); - Coordinate B2 = new Coordinate(3.0, 2.0); + Coordinate A2 = new(1.0, 0.0); + Coordinate B2 = new(3.0, 2.0); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.True(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); } @@ -273,10 +273,10 @@ public void Intersects_ReturnsTrueForIntersectingLineSegments() [Fact] public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(2.0, 0.0), new Coordinate(2.0, -1.0) }); + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new(1.0, 1.0), new(2.0, 1.0), new(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new(1.0, 0.0), new(2.0, 0.0), new(2.0, -1.0) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.False(target.Intersects(line1, line2)); } @@ -284,10 +284,10 @@ public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() [Fact] public void Intersects_LineLine_ReturnsaTrueForIntersectingLines() { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(1.5, 2.0), new Coordinate(2.0, -1.0) }); + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new(1.0, 1.0), new(2.0, 1.0), new(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new(1.0, 0.0), new(1.5, 2.0), new(2.0, -1.0) }); - Euclidean2DLocator target = new Euclidean2DLocator(); + Euclidean2DLocator target = new(); Assert.True(target.Intersects(line1, line2)); } diff --git a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs index 3090cff..156d33c 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs @@ -12,8 +12,8 @@ public class Sphere2DCalculatorTests [Fact] public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() { - Coordinate c = new Coordinate(10.1, 100.2); - Sphere2DCalculator target = new Sphere2DCalculator(); + Coordinate c = new(10.1, 100.2); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c, c); @@ -24,9 +24,9 @@ public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() [Fact] public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() { - Coordinate c1 = new Coordinate(0, 0); - Coordinate c2 = new Coordinate(0, 90); - Sphere2DCalculator target = new Sphere2DCalculator(); + Coordinate c1 = new(0, 0); + Coordinate c2 = new(0, 90); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c1, c2); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; @@ -37,9 +37,9 @@ public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() [Fact] public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegBoundary() { - Coordinate c1 = new Coordinate(-45, 0); - Coordinate c2 = new Coordinate(45, 0); - Sphere2DCalculator target = new Sphere2DCalculator(); + Coordinate c1 = new(-45, 0); + Coordinate c2 = new(45, 0); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c1, c2); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; @@ -50,9 +50,9 @@ public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegB [Fact] public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180DegBoundary() { - Coordinate c1 = new Coordinate(-135, 0); - Coordinate c2 = new Coordinate(135, 0); - Sphere2DCalculator target = new Sphere2DCalculator(); + Coordinate c1 = new(-135, 0); + Coordinate c2 = new(135, 0); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c1, c2); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; @@ -63,11 +63,11 @@ public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180De [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(120, 45); + Coordinate a = new(0, 0); + Coordinate b = new(90, 0); + Coordinate c = new(120, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c, a, b, LineMode.Line); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; @@ -78,11 +78,11 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(45, 45); + Coordinate a = new(0, 0); + Coordinate b = new(90, 0); + Coordinate c = new(45, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; @@ -93,11 +93,11 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(95, 45); + Coordinate a = new(0, 0); + Coordinate b = new(90, 0); + Coordinate c = new(95, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); double expectedDistance = target.CalculateDistance(b, c); @@ -108,11 +108,11 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsO [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment2() { - Coordinate a = new Coordinate(0, 0); - Coordinate b = new Coordinate(90, 0); - Coordinate c = new Coordinate(5, 45); + Coordinate a = new(0, 0); + Coordinate b = new(90, 0); + Coordinate c = new(5, 45); - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new(); double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); double expectedDistance = target.CalculateDistance(a, c); @@ -123,9 +123,9 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsO [Fact] public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; + Coordinate[] coordinates = new Coordinate[] { new(0, 0), new(90, 0), new(0, 90) }; - Mock listM = new Mock(); + Mock listM = new(); listM.SetupGet(list => list.Count).Returns(3); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); @@ -133,7 +133,7 @@ public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new(); double area = target.CalculateArea(listM.Object); Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); @@ -142,9 +142,9 @@ public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast [Fact] public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() { - Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; + Coordinate[] coordinates = new Coordinate[] { new(0, 0), new(90, 0), new(0, 90) }; - Mock listM = new Mock(); + Mock listM = new(); listM.SetupGet(list => list.Count).Returns(4); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); @@ -153,7 +153,7 @@ public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - Sphere2DCalculator target = new Sphere2DCalculator(); + Sphere2DCalculator target = new(); double area = target.CalculateArea(listM.Object); Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); diff --git a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs index f7969fe..52d7c76 100644 --- a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs @@ -7,17 +7,17 @@ namespace Tests.SpatialLite.Core.Geometries; public class CoordinateListTests { - private Coordinate _coordinate = new Coordinate(-10, -20, -200); + private Coordinate _coordinate = new(-10, -20, -200); private readonly Coordinate[] _coordinates = new Coordinate[] { - new Coordinate(12,10,100), - new Coordinate(22,20,200), - new Coordinate(32,30,300) + new(12,10,100), + new(22,20,200), + new(32,30,300) }; [Fact] public void Constructor__CreatesEmptyList() { - CoordinateList target = new CoordinateList(); + CoordinateList target = new(); Assert.Empty(target); } @@ -25,7 +25,7 @@ public void Constructor__CreatesEmptyList() [Fact] public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); for (int i = 0; i < _coordinates.Length; i++) { @@ -36,7 +36,7 @@ public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() [Fact] public void Indexer_GetsAndSetsValues() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); Assert.Equal(_coordinates[1], target[1]); @@ -47,7 +47,7 @@ public void Indexer_GetsAndSetsValues() [Fact] public void Count_Returns0ForEmptyList() { - CoordinateList target = new CoordinateList(); + CoordinateList target = new(); Assert.Equal(0, target.Count); } @@ -55,7 +55,7 @@ public void Count_Returns0ForEmptyList() [Fact] public void Count_ReturnsNumberOfCoordinates() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); Assert.Equal(_coordinates.Length, target.Count); } @@ -63,7 +63,7 @@ public void Count_ReturnsNumberOfCoordinates() [Fact] public void Add_AppendsCoordinateToTheEndOfList() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.Add(_coordinate); Assert.Equal(_coordinate, target.Last()); @@ -72,7 +72,7 @@ public void Add_AppendsCoordinateToTheEndOfList() [Fact] public void Add_IncresesCount() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.Add(_coordinate); Assert.Equal(_coordinates.Length + 1, target.Count); @@ -81,7 +81,7 @@ public void Add_IncresesCount() [Fact] public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() { - CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); + CoordinateList target = new(new Coordinate[] { _coordinate }); target.Add(_coordinates); for (int i = 0; i < _coordinates.Length; i++) @@ -93,7 +93,7 @@ public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() [Fact] public void Add_IncresesCount2() { - CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); + CoordinateList target = new(new Coordinate[] { _coordinate }); target.Add(_coordinates); Assert.Equal(_coordinates.Length + 1, target.Count); @@ -103,7 +103,7 @@ public void Add_IncresesCount2() public void Insert_InsertsCoordinateToSpecifiedIndex() { int index = 1; - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.Insert(index, _coordinate); Assert.Equal(_coordinate, target[index]); @@ -113,7 +113,7 @@ public void Insert_InsertsCoordinateToSpecifiedIndex() public void Insert_IncresesCount() { int index = 1; - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.Insert(index, _coordinate); Assert.Equal(_coordinates.Length + 1, target.Count); @@ -122,7 +122,7 @@ public void Insert_IncresesCount() [Fact] public void Insert_AppendsCoordinateToListIfIndexEqulasCount() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.Insert(target.Count, _coordinate); Assert.Equal(_coordinate, target.Last()); @@ -132,7 +132,7 @@ public void Insert_AppendsCoordinateToListIfIndexEqulasCount() [Fact] public void RemoveAt_RemovesCoordinateAtIndex() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.RemoveAt(1); Assert.Equal(_coordinates[0], target[0]); @@ -142,7 +142,7 @@ public void RemoveAt_RemovesCoordinateAtIndex() [Fact] public void RemoveAt_DecreasesCount() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.RemoveAt(1); Assert.Equal(_coordinates.Length - 1, target.Count); @@ -151,7 +151,7 @@ public void RemoveAt_DecreasesCount() [Fact] public void Clear_RemovesAllCoordinatesFromList() { - CoordinateList target = new CoordinateList(_coordinates); + CoordinateList target = new(_coordinates); target.Clear(); Assert.Empty(target.ToArray()); diff --git a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs index 9fcd6a2..bf646f4 100644 --- a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs @@ -8,9 +8,9 @@ public class GeometryCollectionTests { private readonly Point[] _geometries; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(12,10,100, 1000), - new Coordinate(22,20,200, 2000), - new Coordinate(32,30,300, 3000) + new(12,10,100, 1000), + new(22,20,200, 2000), + new(32,30,300, 3000) }; public GeometryCollectionTests() @@ -34,7 +34,7 @@ private void CheckGeometries(GeometryCollection target, Geometry[] geo [Fact] public void Constructor__CreatesNewEmptyCollection() { - GeometryCollection target = new GeometryCollection(); + GeometryCollection target = new(); Assert.NotNull(target.Geometries); Assert.Empty(target.Geometries); @@ -43,7 +43,7 @@ public void Constructor__CreatesNewEmptyCollection() [Fact] public void Constructor_IEnumerable_CreateNewCollectionWithData() { - GeometryCollection target = new GeometryCollection(_geometries); + GeometryCollection target = new(_geometries); CheckGeometries(target, _geometries); } @@ -51,7 +51,7 @@ public void Constructor_IEnumerable_CreateNewCollectionWithData() [Fact] public void Is3D_ReturnsFalseForEmptyCollection() { - GeometryCollection target = new GeometryCollection(); + GeometryCollection target = new(); Assert.False(target.Is3D); } @@ -60,7 +60,7 @@ public void Is3D_ReturnsFalseForEmptyCollection() public void Is3D_ReturnsFalseForCollectionOf2DObjects() { var members2d = new Geometry[] { new Point(1, 2), new Point(2, 3) }; - GeometryCollection target = new GeometryCollection(members2d); + GeometryCollection target = new(members2d); Assert.False(target.Is3D); } @@ -68,7 +68,7 @@ public void Is3D_ReturnsFalseForCollectionOf2DObjects() [Fact] public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() { - GeometryCollection target = new GeometryCollection(_geometries); + GeometryCollection target = new(_geometries); Assert.True(target.Is3D); } @@ -76,7 +76,7 @@ public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() [Fact] public void IsMeasured_ReturnsFalseForEmptyCollection() { - GeometryCollection target = new GeometryCollection(); + GeometryCollection target = new(); Assert.False(target.IsMeasured); } @@ -84,7 +84,7 @@ public void IsMeasured_ReturnsFalseForEmptyCollection() [Fact] public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() { - GeometryCollection target = new GeometryCollection(_geometries); + GeometryCollection target = new(_geometries); Assert.False(target.IsMeasured); } @@ -93,7 +93,7 @@ public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() { var members = new Geometry[] { new Point(1, 2), new Point(2, 3, 4, 5) }; - GeometryCollection target = new GeometryCollection(members); + GeometryCollection target = new(members); Assert.True(target.IsMeasured); } @@ -101,7 +101,7 @@ public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() [Fact] public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() { - GeometryCollection target = new GeometryCollection(); + GeometryCollection target = new(); Assert.Equal(Envelope.Empty, target.GetEnvelope()); } @@ -109,8 +109,8 @@ public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() [Fact] public void GetEnvelopeReturnsUnionOfMembersEnvelopes() { - GeometryCollection target = new GeometryCollection(_geometries); - Envelope expected = new Envelope(new Coordinate[] { _geometries[0].Position, _geometries[1].Position, _geometries[2].Position }); + GeometryCollection target = new(_geometries); + Envelope expected = new(new Coordinate[] { _geometries[0].Position, _geometries[1].Position, _geometries[2].Position }); Assert.Equal(expected, target.GetEnvelope()); } diff --git a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs index 587da35..8bbd9cb 100644 --- a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs @@ -8,19 +8,19 @@ namespace Tests.SpatialLite.Core.Geometries; public class LineStringTests { private readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(12,10), - new Coordinate(22,20), - new Coordinate(32,30) + new(12,10), + new(22,20), + new(32,30) }; private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(12,10,100), - new Coordinate(22,20,200), - new Coordinate(32,30,300) + new(12,10,100), + new(22,20,200), + new(32,30,300) }; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(12,10,100, 1000), - new Coordinate(22,20,200, 2000), - new Coordinate(32,30,300, 3000) + new(12,10,100, 1000), + new(22,20,200, 2000), + new(32,30,300, 3000) }; @@ -37,7 +37,7 @@ private void CheckCoordinates(LineString target, Coordinate[] expectedPoints) [Fact] public void Constructor__CreatesEmptyLineString() { - LineString target = new LineString(); + LineString target = new(); Assert.Equal(0, target.Coordinates.Count); } @@ -45,7 +45,7 @@ public void Constructor__CreatesEmptyLineString() [Fact] public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() { - LineString target = new LineString(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); CheckCoordinates(target, _coordinatesXYZ); } @@ -53,7 +53,7 @@ public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() [Fact] public void Is3D_ReturnsFalseForEmptyLineString() { - LineString target = new LineString(); + LineString target = new(); Assert.False(target.Is3D); } @@ -61,7 +61,7 @@ public void Is3D_ReturnsFalseForEmptyLineString() [Fact] public void Is3D_ReturnsFalseForAll2DCoords() { - LineString target = new LineString(_coordinatesXY); + LineString target = new(_coordinatesXY); Assert.False(target.Is3D); } @@ -69,7 +69,7 @@ public void Is3D_ReturnsFalseForAll2DCoords() [Fact] public void Is3D_ReturnsTrueForAll3DCoords() { - LineString target = new LineString(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); Assert.True(target.Is3D); } @@ -77,7 +77,7 @@ public void Is3D_ReturnsTrueForAll3DCoords() [Fact] public void IsMeasured_ReturnsFalseForEmptyLineString() { - LineString target = new LineString(); + LineString target = new(); Assert.False(target.IsMeasured); } @@ -85,7 +85,7 @@ public void IsMeasured_ReturnsFalseForEmptyLineString() [Fact] public void IsMeasured_ReturnsFalseForNonMeasuredCoords() { - LineString target = new LineString(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); Assert.False(target.IsMeasured); } @@ -93,7 +93,7 @@ public void IsMeasured_ReturnsFalseForNonMeasuredCoords() [Fact] public void IsMeasured_ReturnsTrueForMeasuredCoords() { - LineString target = new LineString(_coordinatesXYZM); + LineString target = new(_coordinatesXYZM); Assert.True(target.IsMeasured); } @@ -101,7 +101,7 @@ public void IsMeasured_ReturnsTrueForMeasuredCoords() [Fact] public void Start_ReturnsEmptyCoordinateForEmptyLineString() { - LineString target = new LineString(); + LineString target = new(); Assert.Equal(Coordinate.Empty, target.Start); } @@ -109,7 +109,7 @@ public void Start_ReturnsEmptyCoordinateForEmptyLineString() [Fact] public void Start_ReturnsFirstCoordinate() { - LineString target = new LineString(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); Assert.Equal(_coordinatesXYZ.First(), target.Start); } @@ -117,7 +117,7 @@ public void Start_ReturnsFirstCoordinate() [Fact] public void End_ReturnsEmptyCoordinateForEmptyLineString() { - LineString target = new LineString(); + LineString target = new(); Assert.Equal(Coordinate.Empty, target.End); } @@ -125,7 +125,7 @@ public void End_ReturnsEmptyCoordinateForEmptyLineString() [Fact] public void End_ReturnsLastCoordinate() { - LineString target = new LineString(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); Assert.Equal(_coordinatesXYZ.Last(), target.End); } @@ -133,7 +133,7 @@ public void End_ReturnsLastCoordinate() [Fact] public void IsClosed_ReturnsTrueForClosedLineString() { - LineString target = new LineString(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); target.Coordinates.Add(target.Coordinates[0]); Assert.True(target.IsClosed); @@ -142,7 +142,7 @@ public void IsClosed_ReturnsTrueForClosedLineString() [Fact] public void IsClosed_ReturnsFalseForOpenLineString() { - LineString target = new LineString(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); Assert.False(target.IsClosed); } @@ -150,7 +150,7 @@ public void IsClosed_ReturnsFalseForOpenLineString() [Fact] public void IsClosed_ReturnsFalseForEmptyLineString() { - LineString target = new LineString(); + LineString target = new(); Assert.False(target.IsClosed); } @@ -158,7 +158,7 @@ public void IsClosed_ReturnsFalseForEmptyLineString() [Fact] public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() { - LineString target = new LineString(); + LineString target = new(); Envelope envelope = target.GetEnvelope(); Assert.Equal(Envelope.Empty, envelope); @@ -167,8 +167,8 @@ public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() [Fact] public void GetEnvelope_ReturnsEnvelopeOfLineString() { - LineString target = new LineString(_coordinatesXYZ); - Envelope expected = new Envelope(_coordinatesXYZ); + LineString target = new(_coordinatesXYZ); + Envelope expected = new(_coordinatesXYZ); Assert.Equal(expected, target.GetEnvelope()); } diff --git a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs index 1848790..eff799b 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs @@ -27,7 +27,7 @@ private void ChenckPosition(Point target, double x, double y, double z, double m [Fact] public void Constructor__CreatesPointWithEmptyPosition() { - Point target = new Point(); + Point target = new(); Assert.Equal(Coordinate.Empty, target.Position); } @@ -35,7 +35,7 @@ public void Constructor__CreatesPointWithEmptyPosition() [Fact] public void Constructor_XY_SetsCoordinates() { - Point target = new Point(_xOrdinate, _yOrdinate); + Point target = new(_xOrdinate, _yOrdinate); ChenckPosition(target, _xOrdinate, _yOrdinate, double.NaN, double.NaN); } @@ -43,7 +43,7 @@ public void Constructor_XY_SetsCoordinates() [Fact] public void Constructor_XYZ_SetsCoordinates() { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); + Point target = new(_xOrdinate, _yOrdinate, _zOrdinate); ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, double.NaN); } @@ -51,7 +51,7 @@ public void Constructor_XYZ_SetsCoordinates() [Fact] public void Constructor_XYZM_SetsCoordinates() { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); + Point target = new(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, _mValue); } @@ -59,7 +59,7 @@ public void Constructor_XYZM_SetsCoordinates() [Fact] public void Constructor_Coordinate_SetsCoordinates() { - Point target = new Point(_coordinate); + Point target = new(_coordinate); Assert.Equal(_coordinate, target.Position); } @@ -67,7 +67,7 @@ public void Constructor_Coordinate_SetsCoordinates() [Fact] public void Is3D_ReturnsTrueFor3DPoint() { - Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); + Point target = new(_xOrdinate, _yOrdinate, _zOrdinate); Assert.True(target.Is3D); } @@ -75,7 +75,7 @@ public void Is3D_ReturnsTrueFor3DPoint() [Fact] public void Is3D_ReturnsFalseFor2DPoint() { - Point target = new Point(_xOrdinate, _yOrdinate); + Point target = new(_xOrdinate, _yOrdinate); Assert.False(target.Is3D); } @@ -83,7 +83,7 @@ public void Is3D_ReturnsFalseFor2DPoint() [Fact] public void IsMeasured_ReturnsTrueForMeasuredPoint() { - Point target = new Point(_xOrdinate, _yOrdinate, double.NaN, _mValue); + Point target = new(_xOrdinate, _yOrdinate, double.NaN, _mValue); Assert.True(target.IsMeasured); } @@ -91,7 +91,7 @@ public void IsMeasured_ReturnsTrueForMeasuredPoint() [Fact] public void IsMeasured_ReturnsFalseForNonMeasuredPoint() { - Point target = new Point(_xOrdinate, _yOrdinate); + Point target = new(_xOrdinate, _yOrdinate); Assert.False(target.IsMeasured); } @@ -99,7 +99,7 @@ public void IsMeasured_ReturnsFalseForNonMeasuredPoint() [Fact] public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() { - Point target = new Point(); + Point target = new(); Envelope envelope = target.GetEnvelope(); Assert.Equal(double.NaN, envelope.MinX); @@ -115,7 +115,7 @@ public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() [Fact] public void GetEnvelope_ReturnsEnvelopeThatCoversOnePoint() { - Point target = new Point(_coordinate); + Point target = new(_coordinate); Envelope envelope = target.GetEnvelope(); Assert.Equal(_coordinate.X, envelope.MinX); diff --git a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs index e3bf4dd..be57fe0 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs @@ -7,13 +7,13 @@ namespace Tests.SpatialLite.Core.Geometries; public class PolygonTests { private readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(1, 2), new Coordinate(1.1, 2.1), new Coordinate(1.2, 2.2), new Coordinate(1.3, 2.3) + new(1, 2), new(1.1, 2.1), new(1.2, 2.2), new(1.3, 2.3) }; private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(1, 2, 3), new Coordinate(1.1, 2.1, 3.1), new Coordinate(1.2, 2.2, 3.2), new Coordinate(1.3, 2.3, 3.3) + new(1, 2, 3), new(1.1, 2.1, 3.1), new(1.2, 2.2, 3.2), new(1.3, 2.3, 3.3) }; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(1, 2, 3, 10), new Coordinate(1.1, 2.1, 3.1, 20), new Coordinate(1.2, 2.2, 3.2, 30), new Coordinate(1.3, 2.3, 3.3, 40) + new(1, 2, 3, 10), new(1.1, 2.1, 3.1, 20), new(1.2, 2.2, 3.2, 30), new(1.3, 2.3, 3.3, 40) }; private readonly CoordinateList _exteriorRing3D; private readonly CoordinateList[] _interiorRings3D; @@ -39,7 +39,7 @@ private void CheckInteriorRings(Polygon target, CoordinateList[] expected) [Fact] public void Constructor__CreatesEmptyPolygonAndInitializesProperties() { - Polygon target = new Polygon(); + Polygon target = new(); Assert.NotNull(target.ExteriorRing); Assert.Empty(target.ExteriorRing); @@ -51,7 +51,7 @@ public void Constructor__CreatesEmptyPolygonAndInitializesProperties() [Fact] public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() { - Polygon target = new Polygon(_exteriorRing3D); + Polygon target = new(_exteriorRing3D); Assert.Same(_exteriorRing3D, target.ExteriorRing); @@ -62,7 +62,7 @@ public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() [Fact] public void Is3D_ReturnsTrueFor3DExteriorRing() { - Polygon target = new Polygon(_exteriorRing3D); + Polygon target = new(_exteriorRing3D); Assert.True(target.Is3D); } @@ -70,7 +70,7 @@ public void Is3D_ReturnsTrueFor3DExteriorRing() [Fact] public void Is3D_ReturnsFalseForEmptyPolygon() { - Polygon target = new Polygon(); + Polygon target = new(); Assert.False(target.Is3D); } @@ -78,7 +78,7 @@ public void Is3D_ReturnsFalseForEmptyPolygon() [Fact] public void Is3D_ReturnsFalseFor2DExteriorRing() { - Polygon target = new Polygon(new CoordinateList(_coordinatesXY)); + Polygon target = new(new CoordinateList(_coordinatesXY)); Assert.False(target.Is3D); } @@ -86,7 +86,7 @@ public void Is3D_ReturnsFalseFor2DExteriorRing() [Fact] public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() { - Polygon target = new Polygon(new CoordinateList(_coordinatesXYZM)); + Polygon target = new(new CoordinateList(_coordinatesXYZM)); Assert.True(target.IsMeasured); } @@ -94,7 +94,7 @@ public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() [Fact] public void IsMeasured_ReturnsFalseForEmptyPolygon() { - Polygon target = new Polygon(); + Polygon target = new(); Assert.False(target.IsMeasured); } @@ -102,7 +102,7 @@ public void IsMeasured_ReturnsFalseForEmptyPolygon() [Fact] public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() { - Polygon target = new Polygon(new CoordinateList(_coordinatesXYZ)); + Polygon target = new(new CoordinateList(_coordinatesXYZ)); Assert.False(target.IsMeasured); } @@ -110,7 +110,7 @@ public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() [Fact] public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() { - Polygon target = new Polygon(); + Polygon target = new(); Envelope envelope = target.GetEnvelope(); Assert.Equal(Envelope.Empty, envelope); @@ -119,9 +119,9 @@ public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() [Fact] public void GetEnvelopeReturnsEnvelopeOfLineString() { - Envelope expectedEnvelope = new Envelope(_coordinatesXYZ); + Envelope expectedEnvelope = new(_coordinatesXYZ); - Polygon target = new Polygon(_exteriorRing3D); + Polygon target = new(_exteriorRing3D); Envelope envelope = target.GetEnvelope(); Assert.Equal(expectedEnvelope, envelope); diff --git a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs index f04fa05..e47f6cf 100644 --- a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs @@ -8,16 +8,16 @@ namespace Tests.SpatialLite.Core.Geometries; public class ReadOnlyCoordinateListTests { - private readonly List _points = new List(new Point[] { - new Point(5, 1.1, 2.2), - new Point(6, 10.1, -20.2), - new Point(7, -30.1, 40.2) }); + private readonly List _points = new(new Point[] { + new(5, 1.1, 2.2), + new(6, 10.1, -20.2), + new(7, -30.1, 40.2) }); [Fact] public void Constructor_Source_SetsSource() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Same(_points, target.Source); } @@ -25,7 +25,7 @@ public void Constructor_Source_SetsSource() [Fact] public void Indexer_Get_ReturnsCoordinatesFromSourceList() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); for (int i = 0; i < _points.Count; i++) { @@ -36,7 +36,7 @@ public void Indexer_Get_ReturnsCoordinatesFromSourceList() [Fact] public void Indexer_Set_ThrowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); } @@ -44,7 +44,7 @@ public void Indexer_Set_ThrowsNotSupportedException() [Fact] public void Count_GetsNumberOfItemsInSourceCollection() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Equal(_points.Count, target.Count); } @@ -52,7 +52,7 @@ public void Count_GetsNumberOfItemsInSourceCollection() [Fact] public void Add_Coordinate_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Throws(() => target.Add(Coordinate.Empty)); } @@ -60,7 +60,7 @@ public void Add_Coordinate_ThowsNotSupportedException() [Fact] public void Add_Coordinates_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); } @@ -68,7 +68,7 @@ public void Add_Coordinates_ThowsNotSupportedException() [Fact] public void Insert_Index_Coordinate_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Throws(() => target.Insert(0, Coordinate.Empty)); } @@ -76,7 +76,7 @@ public void Insert_Index_Coordinate_ThowsNotSupportedException() [Fact] public void RemoveAt_Index_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Throws(() => target.RemoveAt(0)); } @@ -84,7 +84,7 @@ public void RemoveAt_Index_ThowsNotSupportedException() [Fact] public void Clear_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); + ReadOnlyCoordinateList target = new(_points); Assert.Throws(target.Clear); } diff --git a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs index 8fc4ea6..d0483ed 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs @@ -28,9 +28,9 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = "../../../Data/IO/point-3DM.wkb"; - WkbReader target = new WkbReader(filename); + WkbReader target = new(filename); target.Dispose(); - FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -39,7 +39,7 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() { var stream = TestDataReader.Open("point-3DM.wkb"); - WkbReader target = new WkbReader(stream); + WkbReader target = new(stream); target.Dispose(); Assert.False(stream.CanRead); @@ -48,9 +48,9 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() [Fact] public void Read_ReturnsNullIfStreamIsEmpty() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - WkbReader target = new WkbReader(stream); + WkbReader target = new(stream); Geometry read = target.Read(); Assert.Null(read); @@ -61,7 +61,7 @@ public void Read_ReadsGeometry() { Point expected = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); Point parsed = (Point)target.Read(); ComparePoints(parsed, expected); @@ -73,7 +73,7 @@ public void Read_ReadsMultipleGeometries() Point expected1 = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); Point expected2 = (Point)ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); - WkbReader target = new WkbReader(TestDataReader.Open("two-points-3DM.wkb")); + WkbReader target = new(TestDataReader.Open("two-points-3DM.wkb")); Point parsed1 = (Point)target.Read(); ComparePoints(parsed1, expected1); @@ -85,7 +85,7 @@ public void Read_ReadsMultipleGeometries() [Fact] public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); target.Read(); Geometry parsed = target.Read(); @@ -97,9 +97,9 @@ public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new MemoryStream(wkb)) + using (MemoryStream ms = new(wkb)) { - WkbReader target = new WkbReader(ms); + WkbReader target = new(ms); Assert.Throws(target.Read); } @@ -108,9 +108,9 @@ public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() [Fact] public void ReadT_ReturnsNullIfStreamIsEmpty() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - WkbReader target = new WkbReader(stream); + WkbReader target = new(stream); Geometry read = target.Read(); Assert.Null(read); @@ -121,7 +121,7 @@ public void ReadT_ReadsGeometry() { Point expected = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); Point parsed = target.Read(); ComparePoints(parsed, expected); @@ -130,7 +130,7 @@ public void ReadT_ReadsGeometry() [Fact] public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); target.Read(); Geometry parsed = target.Read(); @@ -142,9 +142,9 @@ public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new MemoryStream(wkb)) + using (MemoryStream ms = new(wkb)) { - WkbReader target = new WkbReader(ms); + WkbReader target = new(ms); Assert.Throws(target.Read); } @@ -153,7 +153,7 @@ public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() [Fact] public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiecGeometryType() { - WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); Assert.Throws(target.Read); } diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs index 8268aaf..c609379 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs @@ -10,7 +10,7 @@ public class WkbWriterSettingsTests [Fact] public void Constructor__SetsDefaultValues() { - WkbWriterSettings target = new WkbWriterSettings(); + WkbWriterSettings target = new(); Assert.Equal(BinaryEncoding.LittleEndian, target.Encoding); } @@ -18,7 +18,7 @@ public void Constructor__SetsDefaultValues() [Fact] public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - WkbWriterSettings target = new WkbWriterSettings(); + WkbWriterSettings target = new(); target.IsReadOnly = true; Assert.Throws(() => target.Encoding = BinaryEncoding.BigEndian); diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs index c679924..7562bc7 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs @@ -16,8 +16,8 @@ public class WkbWriterTests [Fact] public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) + WkbWriterSettings settings = new(); + using (WkbWriter target = new(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -40,8 +40,8 @@ public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNu [Fact] public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() { - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) + WkbWriterSettings settings = new(); + using (WkbWriter target = new(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -53,8 +53,8 @@ public void Constructor_PathSettings_CreatesOutputFile() { string filename = PathHelper.GetTempFilePath("wkbwriter-constructor-creates-output-test.bin"); - WkbWriterSettings settings = new WkbWriterSettings(); - using (WkbWriter target = new WkbWriter(filename, settings)) + WkbWriterSettings settings = new(); + using (WkbWriter target = new(filename, settings)) { ; } @@ -80,7 +80,7 @@ public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull [Fact] public void Constructor_ThrowsExceptionIfEncodingIsSetToBingEndian() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.BigEndian })); } @@ -89,19 +89,19 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = PathHelper.GetTempFilePath("wkbwriter-closes-output-filestream-test.bin"); - WkbWriterSettings settings = new WkbWriterSettings(); - WkbWriter target = new WkbWriter(filename, settings); + WkbWriterSettings settings = new(); + WkbWriter target = new(filename, settings); target.Dispose(); - FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } [Fact] public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - WkbWriter target = new WkbWriter(stream, new WkbWriterSettings()); + WkbWriter target = new(stream, new WkbWriterSettings()); target.Dispose(); Assert.False(stream.CanRead); @@ -110,8 +110,8 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() [Fact] public void WkbWriter_Write_WritesLittleEndianEncodingByte() { - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) { target.Write(new Point()); @@ -125,8 +125,8 @@ public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() string wkt = "point empty"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(point); @@ -140,8 +140,8 @@ public void Write_Writes2DPoint() string wkt = "point (-10.1 15.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(point); @@ -155,8 +155,8 @@ public void Write_Writes2DMeasuredPoint() string wkt = "point m (-10.1 15.5 1000.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(point); @@ -170,8 +170,8 @@ public void Write_Writes3DPoint() string wkt = "point z (-10.1 15.5 100.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(point); @@ -185,8 +185,8 @@ public void Write_Writes3DMeasuredPoint() string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(point); @@ -200,8 +200,8 @@ public void Write_WritesEmptyLineString() string wkt = "linestring empty"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -215,8 +215,8 @@ public void Write_Writes2DLineString() string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -230,8 +230,8 @@ public void Write_Writes2DMeasuredLineString() string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -245,8 +245,8 @@ public void Write_Writes3DLineString() string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -260,7 +260,7 @@ public void Write_Writes3DMeasuredLineString() string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -274,8 +274,8 @@ public void Write_WritesEmptyPolygon() string wkt = "polygon empty"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -289,8 +289,8 @@ public void Write_Writes2DPolygonOnlyExteriorRing() string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -304,8 +304,8 @@ public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -319,8 +319,8 @@ public void Write_Writes3DPolygonOnlyExteriorRing() string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -334,8 +334,8 @@ public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -349,8 +349,8 @@ public void Write_Writes3DMeasuredPolygon() string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -364,8 +364,8 @@ public void Write_WritesEmptyMultipoint() string wkt = "multipoint empty"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -379,8 +379,8 @@ public void Write_Writes2DMultiPoint() string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -394,8 +394,8 @@ public void Write_Writes2DMeasuredMultiPoint() string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -409,8 +409,8 @@ public void Write_Writes3DMultiPoint() string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -424,8 +424,8 @@ public void Write_Writes3DMeasuredMultiPoint() string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -439,8 +439,8 @@ public void Write_WritesEmptyMultiLineString() string wkt = "multilinestring empty"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -454,8 +454,8 @@ public void Write_Writes2DMultiLineString() string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -469,8 +469,8 @@ public void Write_Writes2DMeasuredMultiLineString() string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -484,8 +484,8 @@ public void Write_Writes3DMultiLineString() string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -499,8 +499,8 @@ public void Write_Writes3DMeasuredMultiLineString() string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -514,8 +514,8 @@ public void Write_WritesEmptyMultiPolygon() string wkt = "multipolygon empty"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -529,8 +529,8 @@ public void Write_Writes2DMultiPolygon() string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -544,8 +544,8 @@ public void Write_Writes2DMeasuredMultiPolygon() string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -559,8 +559,8 @@ public void Write_Writes3DMultiPolygon() string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -574,8 +574,8 @@ public void Write_Writes3DMeasuredMultiPolygon() string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -589,8 +589,8 @@ public void Write_WritesEmptyGeometryCollection() string wkt = "geometrycollection empty"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); @@ -604,8 +604,8 @@ public void Write_Writes2DGeometryCollection() string wkt = "geometrycollection (point (-10.1 15.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); @@ -619,8 +619,8 @@ public void Write_Writes2DMeasuredGeometryCollection() string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); @@ -634,8 +634,8 @@ public void Write_Writes3DGeometryCollection() string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); @@ -649,8 +649,8 @@ public void Write_Writes3DMeasuredGeometryCollection() string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); @@ -664,8 +664,8 @@ public void Write_WritesCollectionWithPointLineStringAndPolygon() string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); @@ -679,8 +679,8 @@ public void Write_WritesCollectionWithMultiGeometries() string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); @@ -694,8 +694,8 @@ public void Write_WritesNestedCollection() string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new MemoryStream(); - using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) + MemoryStream stream = new(); + using (WkbWriter target = new(stream, new WkbWriterSettings())) { target.Write(collection); diff --git a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs index 01307ef..015ed07 100644 --- a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs @@ -14,23 +14,23 @@ public class WktReaderTests { private readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) + new(-10.1, 15.5), new(20.2, -25.5), new(30.3, 35.5) }; private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) + new(-10.1, 15.5, 100.5), new(20.2, -25.5, 200.5), new(30.3, 35.5, -300.5) }; private readonly Coordinate[] _coordinatesXYM = new Coordinate[] { - new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) + new(-10.1, 15.5, double.NaN, 1000.5), new(20.2, -25.5, double.NaN, 2000.5), new(30.3, 35.5, double.NaN, -3000.5) }; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) + new(-10.1, 15.5, 100.5, 1000.5), new(20.2, -25.5, 200.5, 2000.5), new(30.3, 35.5, -300.5, -3000.5) }; private readonly Coordinate[] _coordinates2XYZM = new Coordinate[] { - new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) + new(-1.1, 1.5, 10.5, 100.5), new(2.2, -2.5, 20.5, 200.5), new(3.3, 3.5, -30.5, -300.5) }; [Fact] @@ -51,9 +51,9 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = "../../../Data/IO/wkt-point-3DM.wkt"; - WktReader target = new WktReader(filename); + WktReader target = new(filename); target.Dispose(); - FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -62,7 +62,7 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() { var stream = TestDataReader.Open("wkt-point-3DM.wkt"); - WktReader target = new WktReader(stream); + WktReader target = new(stream); target.Dispose(); Assert.False(stream.CanRead); @@ -85,7 +85,7 @@ public static IEnumerable Read_ReadsAllGeometryTypesTestData [MemberData(nameof(Read_ReadsAllGeometryTypesTestData))] public void Read_ReadsAllGeometryTypes(byte[] data) { - using (WktReader target = new WktReader(new MemoryStream(data))) + using (WktReader target = new(new MemoryStream(data))) { IGeometry readGeometry = target.Read(); Assert.NotNull(readGeometry); @@ -95,7 +95,7 @@ public void Read_ReadsAllGeometryTypes(byte[] data) [Fact] public void Read_ReturnsNullIfStreamIsEmpty() { - using (WktReader target = new WktReader(new MemoryStream())) + using (WktReader target = new(new MemoryStream())) { IGeometry readGeometry = target.Read(); @@ -106,7 +106,7 @@ public void Read_ReturnsNullIfStreamIsEmpty() [Fact] public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) + using (WktReader target = new(TestDataReader.Open("wkt-point-3DM.wkt"))) { target.Read(); IGeometry readGeometry = target.Read(); @@ -118,7 +118,7 @@ public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() [Fact] public void Read_ReadsMultipleGeometries() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) + using (WktReader target = new(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) { IGeometry readGeometry = target.Read(); Assert.True(readGeometry is Point); @@ -131,7 +131,7 @@ public void Read_ReadsMultipleGeometries() [Fact] public void ReadT_ReadsGeometry() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) + using (WktReader target = new(TestDataReader.Open("wkt-point-3DM.wkt"))) { Point read = target.Read(); Assert.NotNull(read); @@ -141,7 +141,7 @@ public void ReadT_ReadsGeometry() [Fact] public void ReadT_ReturnsNullIfStreamIsEmpty() { - using (WktReader target = new WktReader(new MemoryStream())) + using (WktReader target = new(new MemoryStream())) { IGeometry readGeometry = target.Read(); @@ -152,7 +152,7 @@ public void ReadT_ReturnsNullIfStreamIsEmpty() [Fact] public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() { - using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) + using (WktReader target = new(TestDataReader.Open("wkt-point-3DM.wkt"))) { Assert.Throws(target.Read); } diff --git a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs index 1b99267..71c2fe2 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs @@ -88,7 +88,7 @@ private void Tokenize_String_ProcessesComplexText() [Fact] private void Tokenize_TextReader_ProcessesComplexText() { - StringReader reader = new StringReader("point z (-10 -15 -100.1)"); + StringReader reader = new("point z (-10 -15 -100.1)"); var tokens = WktTokenizer.Tokenize(reader).ToArray(); diff --git a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs index 1f71711..a680ac5 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs @@ -7,13 +7,13 @@ namespace Tests.SpatialLite.Core.IO; public class WktTokensBufferTests { - private readonly WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, - new WktToken() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; + private readonly WktToken[] _testData = new WktToken[] {new() {Type = TokenType.STRING, Value = "point"}, new() {Type = TokenType.WHITESPACE, Value=" "}, + new() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; [Fact] public void Constructor__CreatesEmptyBuffer() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); Assert.Empty(target); } @@ -21,7 +21,7 @@ public void Constructor__CreatesEmptyBuffer() [Fact] public void Constructor_TextReader_CreatesBufferWithSpecificTokens() { - WktTokensBuffer target = new WktTokensBuffer(_testData); + WktTokensBuffer target = new(_testData); Assert.Equal(_testData.Length, target.Count()); for (int i = 0; i < _testData.Length; i++) @@ -33,7 +33,7 @@ public void Constructor_TextReader_CreatesBufferWithSpecificTokens() [Fact] public void Count_GetsNumberOfItemsInBufffer() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(_testData); Assert.Equal(_testData.Length, target.Count); @@ -42,7 +42,7 @@ public void Count_GetsNumberOfItemsInBufffer() [Fact] public void Add_WktToken_AddsItemToTheCollection() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(_testData[0]); Assert.Single(target); @@ -52,7 +52,7 @@ public void Add_WktToken_AddsItemToTheCollection() [Fact] public void Add_IEnumerable_AddsItemsToTheCollection() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(_testData); Assert.Equal(_testData.Length, target.Count()); @@ -65,7 +65,7 @@ public void Add_IEnumerable_AddsItemsToTheCollection() [Fact] public void Clear_RemovesAllItemsFromCollection() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(_testData); target.Clear(); @@ -76,7 +76,7 @@ public void Clear_RemovesAllItemsFromCollection() [Fact] public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(_testData[0]); var result = target.Peek(false); @@ -88,7 +88,7 @@ public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() [Fact] public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(_testData[0]); @@ -102,8 +102,8 @@ public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTr [Fact] public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); + WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new(); target.Add(whitespaceToken); target.Add(_testData[0]); @@ -116,7 +116,7 @@ public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndN [Fact] public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); var result = target.Peek(false); @@ -126,8 +126,8 @@ public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailabl [Fact] public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); + WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new(); target.Add(whitespaceToken); var result = target.Peek(true); @@ -138,7 +138,7 @@ public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAre [Fact] public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(_testData[0]); var result = target.GetToken(false); @@ -150,7 +150,7 @@ public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() [Fact] public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(_testData[0]); @@ -164,8 +164,8 @@ public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreToken [Fact] public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); + WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new(); target.Add(whitespaceToken); target.Add(_testData[0]); @@ -178,7 +178,7 @@ public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalse [Fact] public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() { - WktTokensBuffer target = new WktTokensBuffer(); + WktTokensBuffer target = new(); var result = target.GetToken(false); @@ -188,8 +188,8 @@ public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvai [Fact] public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() { - WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new WktTokensBuffer(); + WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new(); target.Add(whitespaceToken); var result = target.GetToken(true); diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs index 91c5f84..765ed2a 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs @@ -9,7 +9,7 @@ public class WktWriterSettingsTests [Fact] public void Constructor__SetsDefaultValues() { - WktWriterSettings target = new WktWriterSettings(); + WktWriterSettings target = new(); Assert.False(target.IsReadOnly); } diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs index f00f4e1..b3fba74 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs @@ -13,30 +13,30 @@ public class WktWriterTests private static readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) + new(-10.1, 15.5), new(20.2, -25.5), new(30.3, 35.5) }; private static readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) + new(-10.1, 15.5, 100.5), new(20.2, -25.5, 200.5), new(30.3, 35.5, -300.5) }; private static readonly Coordinate[] _coordinatesXYM = new Coordinate[] { - new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) + new(-10.1, 15.5, double.NaN, 1000.5), new(20.2, -25.5, double.NaN, 2000.5), new(30.3, 35.5, double.NaN, -3000.5) }; private static readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) + new(-10.1, 15.5, 100.5, 1000.5), new(20.2, -25.5, 200.5, 2000.5), new(30.3, 35.5, -300.5, -3000.5) }; private static readonly Coordinate[] _coordinates2XYZM = new Coordinate[] { - new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) + new(-1.1, 1.5, 10.5, 100.5), new(2.2, -2.5, 20.5, 200.5), new(3.3, 3.5, -30.5, -300.5) }; [Fact] public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(new MemoryStream(), settings)) + WktWriterSettings settings = new(); + using (WktWriter target = new(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -59,8 +59,8 @@ public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNu [Fact] public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() { - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(new MemoryStream(), settings)) + WktWriterSettings settings = new(); + using (WktWriter target = new(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -73,8 +73,8 @@ public void Constructor_PathSettings_CreatesOutputFile() string filename = PathHelper.GetTempFilePath("wktwriter-constructor-creates-output-test.wkt"); File.Delete(filename); - WktWriterSettings settings = new WktWriterSettings(); - using (WktWriter target = new WktWriter(filename, settings)) + WktWriterSettings settings = new(); + using (WktWriter target = new(filename, settings)) { ; } @@ -124,19 +124,19 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = PathHelper.GetTempFilePath("wktwriter-closes-output-filestream-test.wkt"); - WktWriterSettings settings = new WktWriterSettings(); - WktWriter target = new WktWriter(filename, settings); + WktWriterSettings settings = new(); + WktWriter target = new(filename, settings); target.Dispose(); - FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } [Fact] public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - WktWriter target = new WktWriter(stream, new WktWriterSettings()); + WktWriter target = new(stream, new WktWriterSettings()); target.Dispose(); Assert.False(stream.CanRead); @@ -203,7 +203,7 @@ public void Write_WritesPolygonsOfAllDimensions(Polygon toWrite, string expected public void Write_WritesComplexPolygonWitOuterAndInnerRings() { string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon polygon = new Polygon(new CoordinateList(_coordinatesXYZM)); + Polygon polygon = new(new CoordinateList(_coordinatesXYZM)); polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); @@ -215,10 +215,10 @@ public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestDat get { yield return new object[] { new MultiPoint(), "multipoint empty" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXY[0]), new Point(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYM[0]), new Point(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZ[0]), new Point(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZM[0]), new Point(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXY[0]), new(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXYM[0]), new(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXYZ[0]), new(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXYZM[0]), new(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; } } @@ -234,13 +234,13 @@ public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsT get { yield return new object[] { new MultiLineString(), "multilinestring empty" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXY), new LineString(_coordinatesXY) }), + yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXY), new(_coordinatesXY) }), "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYM), new LineString(_coordinatesXYM) }), + yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXYM), new(_coordinatesXYM) }), "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZ), new LineString(_coordinatesXYZ) }), + yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXYZ), new(_coordinatesXYZ) }), "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZM), new LineString(_coordinatesXYZM) }), + yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXYZM), new(_coordinatesXYZM) }), "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; } } @@ -257,13 +257,13 @@ public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTest get { yield return new object[] { new MultiPolygon(), "multipolygon empty" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXY)), new Polygon(new CoordinateList(_coordinatesXY)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXY)), new(new CoordinateList(_coordinatesXY)) }), "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYM)), new Polygon(new CoordinateList(_coordinatesXYM)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXYM)), new(new CoordinateList(_coordinatesXYM)) }), "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZ)), new Polygon(new CoordinateList(_coordinatesXYZ)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXYZ)), new(new CoordinateList(_coordinatesXYZ)) }), "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZM)), new Polygon(new CoordinateList(_coordinatesXYZM)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXYZM)), new(new CoordinateList(_coordinatesXYZM)) }), "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))" }; } } @@ -298,7 +298,7 @@ public void Write_WritesGeometryCollectionOfAllDimensions(GeometryCollection collection = new GeometryCollection(); + GeometryCollection collection = new(); collection.Geometries.Add(new Point(_coordinatesXY[0])); collection.Geometries.Add(new LineString(_coordinatesXY)); collection.Geometries.Add(new Polygon(new CoordinateList(_coordinatesXY))); @@ -313,8 +313,8 @@ public void Write_WritesCollectionWithAllGeometryTypes() public void Write_WritesNestedCollection() { string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection collection = new GeometryCollection(); - GeometryCollection nested = new GeometryCollection(); + GeometryCollection collection = new(); + GeometryCollection nested = new(); nested.Geometries.Add(new Point(_coordinatesXY[0])); collection.Geometries.Add(nested); @@ -323,8 +323,8 @@ public void Write_WritesNestedCollection() private void TestWriteGeometry(IGeometry geometry, string expectedWkt) { - MemoryStream stream = new MemoryStream(); - using (WktWriter writer = new WktWriter(stream, new WktWriterSettings())) + MemoryStream stream = new(); + using (WktWriter writer = new(stream, new WktWriterSettings())) { writer.Write(geometry); } diff --git a/src/Tests.SpatialLite.Core/MeasurementsTests.cs b/src/Tests.SpatialLite.Core/MeasurementsTests.cs index f1a9178..69a0f62 100644 --- a/src/Tests.SpatialLite.Core/MeasurementsTests.cs +++ b/src/Tests.SpatialLite.Core/MeasurementsTests.cs @@ -26,9 +26,9 @@ public void Sphere2D_GetsInstanceOfMeasuremntsWithTheSphere2DCalculator() [Fact] public void Constructor_SetsCalculatorObject() { - Mock calculatorM = new Mock(); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); Assert.Same(calculatorM.Object, target.DimensionsCalculator); } @@ -36,11 +36,11 @@ public void Constructor_SetsCalculatorObject() [Fact] public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCorrectParameters() { - Coordinate c1 = new Coordinate(10.1, 20.1); - Coordinate c2 = new Coordinate(10.2, 20.2); - Mock calculatorM = new Mock(); + Coordinate c1 = new(10.1, 20.1); + Coordinate c2 = new(10.2, 20.2); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(c1, c2); calculatorM.Verify(calc => calc.CalculateDistance(c1, c2), Times.Once()); @@ -49,11 +49,11 @@ public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCor [Fact] public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() { - Point p1 = new Point(Coordinate.Empty); - Point p2 = new Point(new Coordinate(10.2, 20.2)); - Mock calculatorM = new Mock(); + Point p1 = new(Coordinate.Empty); + Point p2 = new(new Coordinate(10.2, 20.2)); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(p1, p2); Assert.True(double.IsNaN(distance)); @@ -62,11 +62,11 @@ public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() [Fact] public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() { - Point p1 = new Point(new Coordinate(10.1, 20.1)); - Point p2 = new Point(Coordinate.Empty); - Mock calculatorM = new Mock(); + Point p1 = new(new Coordinate(10.1, 20.1)); + Point p2 = new(Coordinate.Empty); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(p1, p2); Assert.True(double.IsNaN(distance)); @@ -75,11 +75,11 @@ public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() [Fact] public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParameters() { - Point p1 = new Point(new Coordinate(10.1, 20.1)); - Point p2 = new Point(new Coordinate(10.2, 20.2)); - Mock calculatorM = new Mock(); + Point p1 = new(new Coordinate(10.1, 20.1)); + Point p2 = new(new Coordinate(10.2, 20.2)); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(p1, p2); calculatorM.Verify(calc => calc.CalculateDistance(p1.Position, p2.Position), Times.Once()); @@ -88,12 +88,12 @@ public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParame [Fact] public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() { - Point point = new Point(new Coordinate(10.1, 20.1)); - LineString linestring = new LineString(); + Point point = new(new Coordinate(10.1, 20.1)); + LineString linestring = new(); - Mock calculatorM = new Mock(); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(point, linestring); Assert.True(double.IsNaN(distance)); @@ -102,12 +102,12 @@ public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() [Fact] public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() { - Point point = new Point(Coordinate.Empty); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + Point point = new(Coordinate.Empty); + LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); - Mock calculatorM = new Mock(); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(point, linestring); Assert.True(double.IsNaN(distance)); @@ -116,12 +116,12 @@ public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() [Fact] public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEmpty() { - Point point = new Point(new Coordinate(10.1, 20.1)); - MultiLineString multilinestring = new MultiLineString(); + Point point = new(new Coordinate(10.1, 20.1)); + MultiLineString multilinestring = new(); - Mock calculatorM = new Mock(); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(point, multilinestring); Assert.True(double.IsNaN(distance)); @@ -130,13 +130,13 @@ public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEm [Fact] public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() { - Point point = new Point(Coordinate.Empty); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); + Point point = new(Coordinate.Empty); + LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); + MultiLineString multilinestring = new(new LineString[] { linestring, linestring }); - Mock calculatorM = new Mock(); + Mock calculatorM = new(); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double distance = target.ComputeDistance(point, multilinestring); Assert.True(double.IsNaN(distance)); @@ -145,10 +145,10 @@ public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() [Fact] public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() { - LineString linestring = new LineString(); + LineString linestring = new(); - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); + Mock calculatorM = new(); + Measurements target = new(calculatorM.Object); double length = target.ComputeLength(linestring); @@ -158,10 +158,10 @@ public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() [Fact] public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() { - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1) }); + LineString linestring = new(new Coordinate[] { new(10.1, 20.1) }); - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); + Mock calculatorM = new(); + Measurements target = new(calculatorM.Object); double length = target.ComputeLength(linestring); @@ -171,17 +171,17 @@ public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() [Fact] public void ComputeLength_LineString_RetursSumOfSegmentsLengths() { - Random generator = new Random(); + Random generator = new(); double segment1Length = generator.Next(100); double segment2Length = generator.Next(100); double sum = segment1Length + segment2Length; - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - Mock calculatorM = new Mock(); + LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); + Mock calculatorM = new(); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double length = target.ComputeLength(linestring); Assert.Equal(sum, length); @@ -190,10 +190,10 @@ public void ComputeLength_LineString_RetursSumOfSegmentsLengths() [Fact] public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMembers() { - MultiLineString multilinestring = new MultiLineString(); + MultiLineString multilinestring = new(); - Mock calculatorM = new Mock(); - Measurements target = new Measurements(calculatorM.Object); + Mock calculatorM = new(); + Measurements target = new(calculatorM.Object); double length = target.ComputeLength(multilinestring); @@ -203,19 +203,19 @@ public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMem [Fact] public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() { - Random generator = new Random(); + Random generator = new(); double segment1Length = generator.Next(100); double segment2Length = generator.Next(100); double sum = 2 * (segment1Length + segment2Length); - LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); + LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); + MultiLineString multilinestring = new(new LineString[] { linestring, linestring }); - Mock calculatorM = new Mock(); + Mock calculatorM = new(); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double length = target.ComputeLength(multilinestring); Assert.Equal(sum, length); @@ -224,13 +224,13 @@ public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() [Fact] public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator() { - Polygon polygon = new Polygon(new CoordinateList()); - Random generator = new Random(); + Polygon polygon = new(new CoordinateList()); + Random generator = new(); double expectedArea = generator.Next(100); - Mock calculatorM = new Mock(); + Mock calculatorM = new(); calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double area = target.ComputeArea(polygon); @@ -241,7 +241,7 @@ public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensio public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator() { // Create polygon with interior ring - Polygon polygon = new Polygon(new CoordinateList()); + Polygon polygon = new(new CoordinateList()); polygon.InteriorRings.Add(new CoordinateList()); // Fixed test values @@ -250,7 +250,7 @@ public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDi double expectedArea = exteriorArea - interiorArea; // Setup mock - Mock calculatorM = new Mock(); + Mock calculatorM = new(); calculatorM.Setup(calc => calc.CalculateArea(It.IsAny())) .Returns(coords => { @@ -260,7 +260,7 @@ public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDi }); // Create the object being tested - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); // Execute the method being tested double area = target.ComputeArea(polygon); @@ -272,16 +272,16 @@ public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDi [Fact] public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas() { - Random generator = new Random(); + Random generator = new(); - Polygon polygon = new Polygon(new CoordinateList()); + Polygon polygon = new(new CoordinateList()); double polygonArea = generator.Next(100); - MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon }); + MultiPolygon multipolygon = new(new Polygon[] { polygon, polygon }); - Mock calculatorM = new Mock(); + Mock calculatorM = new(); calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea); - Measurements target = new Measurements(calculatorM.Object); + Measurements target = new(calculatorM.Object); double area = target.ComputeArea(multipolygon); diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs index 2e10ebb..be3f4e5 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpsTrackBaseTests.cs @@ -13,16 +13,16 @@ public class GpsTrackBaseTests public GpsTrackBaseTests() { _points = new List { - new GpsPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), - new GpsPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), - new GpsPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; + new(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), + new(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), + new(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; } [Fact] public void Constructor__CreatesEmptyGpsTrack() { - GpsTrackBase target = new GpsTrackBase(); + GpsTrackBase target = new(); Assert.Equal(0, target.Coordinates.Count); } @@ -31,7 +31,7 @@ public void Constructor__CreatesEmptyGpsTrack() public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() { - GpsTrackBase target = new GpsTrackBase(_points); + GpsTrackBase target = new(_points); Assert.Equal(_points.Count, target.Points.Count); for (int i = 0; i < target.Points.Count; i++) @@ -43,7 +43,7 @@ public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() [Fact] public void Coordinates_GetsPositionOfPoints() { - GpsTrackBase target = new GpsTrackBase(_points); + GpsTrackBase target = new(_points); Assert.Equal(_points.Count, target.Coordinates.Count); for (int i = 0; i < _points.Count; i++) @@ -55,7 +55,7 @@ public void Coordinates_GetsPositionOfPoints() [Fact] public void Coordinates_GetsPositionOfPointsIfWayCastedToLineString() { - GpsTrackBase line = new GpsTrackBase(_points); + GpsTrackBase line = new(_points); LineString target = line; Assert.Equal(_points.Count, target.Coordinates.Count); diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs index d6f115c..ff3d5ea 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxLinkTests.cs @@ -10,9 +10,9 @@ public class GpxLinkTests [Fact] public void Constructor_Url_SetsUrl() { - Uri url = new Uri("http://spatial.litesolutions.net"); + Uri url = new("http://spatial.litesolutions.net"); - GpxLink target = new GpxLink(url); + GpxLink target = new(url); Assert.Same(url, target.Url); } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs index 346ea72..c068d7d 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxPointTests.cs @@ -58,7 +58,7 @@ public void Constructor_LonLatElevationTimestamp_CreatesPointWithPositionAndTime [Fact] public void GeometryType_ReturnsWaypoint() { - GpxPoint target = new GpxPoint(); + GpxPoint target = new(); Assert.Equal(GpxGeometryType.Waypoint, target.GeometryType); } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs index ae0ad8f..2c5770b 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxRouteTests.cs @@ -11,7 +11,7 @@ public class GpxRouteTests [Fact] public void Constructor_Parameterless_CreatesEmptyRoute() { - GpxRoute target = new GpxRoute(); + GpxRoute target = new(); Assert.Empty(target.Points); } @@ -19,12 +19,13 @@ public void Constructor_Parameterless_CreatesEmptyRoute() [Fact] public void Constructor_IEnumerablePoints_CreatesRouteWithPoints() { - List points = new List { + List points = new() + { new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - GpxRoute target = new GpxRoute(points); + GpxRoute target = new(points); Assert.Equal(points.Count, target.Points.Count); for (int i = 0; i < target.Points.Count; i++) @@ -36,7 +37,7 @@ public void Constructor_IEnumerablePoints_CreatesRouteWithPoints() [Fact] public void GeometryType_ReturnsRoute() { - GpxRoute target = new GpxRoute(); + GpxRoute target = new(); Assert.Equal(GpxGeometryType.Route, target.GeometryType); } diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs index 25e3e6c..0eca607 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackSegmentTests.cs @@ -10,7 +10,7 @@ public class GpxTrackSegmentTests [Fact] public void Constructor_CreatesEmptyGpsTrack() { - GpxTrackSegment target = new GpxTrackSegment(); + GpxTrackSegment target = new(); Assert.Empty(target.Points); } @@ -18,12 +18,13 @@ public void Constructor_CreatesEmptyGpsTrack() [Fact] public void Constructor_IEnumerablePoints_CreatesGpsTrackWithPoints() { - List points = new List { + List points = new() + { new GpxPoint(16.5, 45.9, 100, new DateTime(2011, 2, 24, 20, 00, 00)), new GpxPoint(16.6, 46.0, 110, new DateTime(2011, 2, 24, 20, 00, 10)), new GpxPoint(16.5, 46.1, 200, new DateTime(2011, 2, 24, 20, 00, 20))}; - GpxTrackSegment target = new GpxTrackSegment(points); + GpxTrackSegment target = new(points); Assert.Equal(points.Count, target.Points.Count); for (int i = 0; i < target.Points.Count; i++) diff --git a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs index bf37b5d..182c110 100644 --- a/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs +++ b/src/Tests.SpatialLite.Gps/Geometries/GpxTrackTests.cs @@ -9,7 +9,7 @@ public class GpxTrackTests [Fact] public void Constructor_Parameterless_CreateEmptyGpxTrack() { - GpxTrack target = new GpxTrack(); + GpxTrack target = new(); Assert.Empty(target.Geometries); } @@ -17,9 +17,9 @@ public void Constructor_Parameterless_CreateEmptyGpxTrack() [Fact] public void Constructor_Segments_CreateGpxTrackWithSegments() { - GpxTrackSegment[] segments = new GpxTrackSegment[] { new GpxTrackSegment(), new GpxTrackSegment(), new GpxTrackSegment() }; + GpxTrackSegment[] segments = new GpxTrackSegment[] { new(), new(), new() }; - GpxTrack target = new GpxTrack(segments); + GpxTrack target = new(segments); Assert.Equal(segments.Length, target.Geometries.Count); for (int i = 0; i < target.Geometries.Count; i++) @@ -31,7 +31,7 @@ public void Constructor_Segments_CreateGpxTrackWithSegments() [Fact] public void GeometryType_ReturnsTrack() { - GpxTrack target = new GpxTrack(); + GpxTrack target = new(); Assert.Equal(GpxGeometryType.Track, target.GeometryType); } diff --git a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs index 834bd99..a64729e 100644 --- a/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs +++ b/src/Tests.SpatialLite.Gps/GpxDocumentTests.cs @@ -129,7 +129,7 @@ public void Save_IGpxWriter_WritesDataToWriter() var route = new GpxRoute(); var track = new GpxTrack(); - Mock writerM = new Mock(); + Mock writerM = new(); writerM.Setup(w => w.Write(waypoint)).Verifiable(); writerM.Setup(w => w.Write(route)).Verifiable(); writerM.Setup(w => w.Write(track)).Verifiable(); diff --git a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs index 64566de..6220ca8 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxReaderTests.cs @@ -58,7 +58,7 @@ public void Constructor_StreamSettings_ThrowsExceptionXmlContainsInvalidRootElem [Fact] public void Read_ThrowsExceptionIfWaypointHasntLat() { - GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lat.gpx"), new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(TestDataReader.Open("gpx-waypoint-without-lat.gpx"), new GpxReaderSettings() { ReadMetadata = false }); Assert.Throws(target.Read); } @@ -66,7 +66,7 @@ public void Read_ThrowsExceptionIfWaypointHasntLat() [Fact] public void Read_ThrowsExceptionIfWaypointHasntLon() { - GpxReader target = new GpxReader(TestDataReader.Open("gpx-waypoint-without-lon.gpx"), new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(TestDataReader.Open("gpx-waypoint-without-lon.gpx"), new GpxReaderSettings() { ReadMetadata = false }); Assert.Throws(target.Read); } @@ -77,7 +77,7 @@ public void Read_SetsMetadataIfReadMetadataIsTrue() var data = TestDataReader.Open("gpx-waypoint-simple.gpx"); _ = new Coordinate(-71.119277, 42.438878); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = true }); var result = target.Read() as GpxPoint; Assert.NotNull(result.Metadata); @@ -89,7 +89,7 @@ public void Read_DoesntSetMetadataIfReadMetadataIsFalse() var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); _ = new Coordinate(-71.119277, 42.438878); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxPoint; Assert.Null(result.Metadata); @@ -99,10 +99,10 @@ public void Read_DoesntSetMetadataIfReadMetadataIsFalse() public void Read_ParsesWaypointWithLatLonElevationAndTime() { var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); - DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); + Coordinate expectedCoordinate = new(-71.119277, 42.438878, 44.586548); + DateTime expectedTime = new(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxPoint; Assert.Equal(result.Position, expectedCoordinate); @@ -113,10 +113,10 @@ public void Read_ParsesWaypointWithLatLonElevationAndTime() public void Read_ParsesWaypointWithExtensions() { var data = TestDataReader.Open("gpx-waypoint-extensions.gpx"); - Coordinate expectedCoordinate = new Coordinate(-71.119277, 42.438878, 44.586548); - DateTime expectedTime = new DateTime(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); + Coordinate expectedCoordinate = new(-71.119277, 42.438878, 44.586548); + DateTime expectedTime = new(2001, 11, 28, 21, 5, 28, DateTimeKind.Utc); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxPoint; Assert.Equal(result.Position, expectedCoordinate); @@ -128,8 +128,7 @@ public void Read_ParsesMultipleWaypoints() { var data = TestDataReader.Open("gpx-waypoint-multiple.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); - GpxPoint result = null; + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); int count = 0; while ((_ = target.Read() as GpxPoint) != null) @@ -145,7 +144,7 @@ public void Read_ReadsWaypointMetadata() { var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = true }); var result = target.Read() as GpxPoint; Assert.Equal(0.98, result.Metadata.MagVar); @@ -175,7 +174,7 @@ public void Read_ReadsWaypointUnsortedMetadataAndExtension() { var data = TestDataReader.Open("gpx-waypoint-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = true }); var result = target.Read() as GpxPoint; Assert.Equal(0.98, result.Metadata.MagVar); @@ -205,7 +204,7 @@ public void Read_ParsesTrackWithSingleSegment() { var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxTrack; Assert.Single(result.Geometries); @@ -224,7 +223,7 @@ public void Read_ParsesTrackWithSingleSegmentAndExtensions() { var data = TestDataReader.Open("gpx-track-single-track-segment.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxTrack; Assert.Single(result.Geometries); @@ -236,7 +235,7 @@ public void Read_ParsesTrackWithMultipleSegments() { var data = TestDataReader.Open("gpx-track-2-track-segments.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxTrack; //segments @@ -251,7 +250,7 @@ public void Read_ParsesMultipleTracks() { var data = TestDataReader.Open("gpx-track-multiple-tracks.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result1 = target.Read() as GpxTrack; var result2 = target.Read() as GpxTrack; @@ -272,7 +271,7 @@ public void Read_ParsesEmptyTrack() { var data = TestDataReader.Open("gpx-track-empty.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxTrack; Assert.Empty(result.Geometries); @@ -283,7 +282,7 @@ public void Read_ParsesTrackWithEmptySegment() { var data = TestDataReader.Open("gpx-track-empty-track-segment.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxTrack; Assert.Single(result.Geometries); @@ -295,7 +294,7 @@ public void Read_ParsesTrackMetadata() { var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = true }); var result = target.Read() as GpxTrack; Assert.Equal("TRK Comment", result.Metadata.Comment); @@ -315,7 +314,7 @@ public void Read_SetsTrackMetadataToNullIfReadMetadataIsFalse() { var data = TestDataReader.Open("gpx-track-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxTrack; Assert.Null(result.Metadata); @@ -325,7 +324,7 @@ public void Read_SetsTrackMetadataToNullIfReadMetadataIsFalse() public void Read_ParsesEmptyRoute() { var data = TestDataReader.Open("gpx-route-empty.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxRoute; @@ -336,7 +335,7 @@ public void Read_ParsesEmptyRoute() public void Read_ParsesSingleRoute() { var data = TestDataReader.Open("gpx-route-single-route.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxRoute; @@ -352,7 +351,7 @@ public void Read_ParsesSingleRoute() public void Read_ParsesSingleRouteWithExtensions() { var data = TestDataReader.Open("gpx-route-with-metadata-and-extensions.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxRoute; @@ -363,7 +362,7 @@ public void Read_ParsesSingleRouteWithExtensions() public void Read_ParsesMultipleRoutes() { var data = TestDataReader.Open("gpx-route-multiple-routes.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result1 = target.Read() as GpxRoute; var result2 = target.Read() as GpxRoute; @@ -376,7 +375,7 @@ public void Read_ParsesMultipleRoutes() public void Read_ParsesRouteWithMetadata() { var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = true }); var result = target.Read() as GpxRoute; @@ -397,7 +396,7 @@ public void Read_ParsesRouteWithMetadata() public void Read_SetsRouteMetadataToNullIfReadMetadataIsFalse() { var data = TestDataReader.Open("gpx-route-with-metadata.gpx"); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = false }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = false }); var result = target.Read() as GpxRoute; @@ -412,8 +411,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() var target = new GpxReader(filename, new GpxReaderSettings() { ReadMetadata = false }); target.Dispose(); - FileStream testStream = null; - testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -421,9 +419,9 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() public void Read_ReadsAllEntitiesFromRealGpxFile() { var data = TestDataReader.Open("gpx-real-file.gpx"); - List parsed = new List(); + List parsed = new(); - GpxReader target = new GpxReader(data, new GpxReaderSettings() { ReadMetadata = true }); + GpxReader target = new(data, new GpxReaderSettings() { ReadMetadata = true }); IGpxGeometry geometry = null; while ((geometry = target.Read()) != null) @@ -432,10 +430,10 @@ public void Read_ReadsAllEntitiesFromRealGpxFile() } // waypoints - Assert.Equal(3, parsed.Where(g => g.GeometryType == GpxGeometryType.Waypoint).Count()); + Assert.Equal(3, parsed.Count(g => g.GeometryType == GpxGeometryType.Waypoint)); // routes - Assert.Equal(2, parsed.Where(g => g.GeometryType == GpxGeometryType.Route).Count()); + Assert.Equal(2, parsed.Count(g => g.GeometryType == GpxGeometryType.Route)); // tracks Assert.Single(parsed.Where(g => g.GeometryType == GpxGeometryType.Track)); diff --git a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs index 262604c..328d880 100644 --- a/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs +++ b/src/Tests.SpatialLite.Gps/IO/GpxWriterTests.cs @@ -11,24 +11,24 @@ namespace Tests.SpatialLite.Gps.IO; public class GpxWriterTests { - private readonly GpxPoint _waypoint = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); - private readonly GpxPoint _waypointWithMetadata = new GpxPoint(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + private readonly GpxPoint _waypoint = new(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); + private readonly GpxPoint _waypointWithMetadata = new(-71.119277, 42.438878, 44.586548, new DateTime(2001, 11, 28, 21, 05, 28, DateTimeKind.Utc)); private readonly GpxPointMetadata _pointMetadata; - private readonly GpxRoute _route = new GpxRoute(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + private readonly GpxRoute _route = new(new GpxPoint[] { + new(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) }); - private readonly GpxRoute _routeWithMetadata = new GpxRoute(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + private readonly GpxRoute _routeWithMetadata = new(new GpxPoint[] { + new(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) }); private readonly GpxTrackMetadata _routeMetadata; - private readonly GpxTrackSegment _segment = new GpxTrackSegment(new GpxPoint[] { - new GpxPoint(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), - new GpxPoint(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) + private readonly GpxTrackSegment _segment = new(new GpxPoint[] { + new(new Coordinate(-76.638178825, 39.449270368), new DateTime(1970, 1, 1, 7, 10, 23, DateTimeKind.Utc)), + new(new Coordinate(-76.638012528, 39.449130893), new DateTime(1970, 1, 1, 7, 10, 28, DateTimeKind.Utc)), + new(new Coordinate(-76.637980342, 39.449098706), new DateTime(1970, 1, 1, 7, 10, 33, DateTimeKind.Utc)) }); private readonly GpxTrackMetadata _trackMetadata; private readonly GpxTrack _track; @@ -94,7 +94,7 @@ public void Constructor_StreamSettings_CreatesGpxFileWithRootElement() string generatorName = "SpatialLite"; var stream = new MemoryStream(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) { } @@ -137,7 +137,7 @@ public void Constructor_PathSettings_CreatesGpxFileWithRootElement() string path = PathHelper.GetTempFilePath("gpxwriter-constructor-test-2.gpx"); string generatorName = "SpatialLite"; - using (GpxWriter target = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) + using (GpxWriter target = new(path, new GpxWriterSettings() { WriteMetadata = false, GeneratorName = generatorName })) { } @@ -150,9 +150,9 @@ public void Constructor_PathSettings_CreatesGpxFileWithRootElement() [Fact] public void Write_WritesWaypointWithoutMetadataIfMetadataIsNull() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = false })) { target.Write(_waypoint); } @@ -166,9 +166,9 @@ public void Write_WritesWaypointWithoutMetadataIfMetadataIsNull() [Fact] public void Write_WritesWaypointWithoutMetadataIfWriteMetadataIsFalse() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = false })) { target.Write(_waypointWithMetadata); } @@ -182,9 +182,9 @@ public void Write_WritesWaypointWithoutMetadataIfWriteMetadataIsFalse() [Fact] public void Write_WritesWaypointWithMetadata() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = true })) { target.Write(_waypointWithMetadata); } @@ -200,9 +200,9 @@ public void Write_WritesWaypointWithoutUnnecessaryElements() { _waypointWithMetadata.Metadata.SatellitesCount = null; _waypointWithMetadata.Metadata.Name = null; - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = true })) { target.Write(_waypointWithMetadata); } @@ -216,9 +216,9 @@ public void Write_WritesWaypointWithoutUnnecessaryElements() [Fact] public void Write_WritesRouteWith3Points() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = false })) { target.Write(_route); } @@ -232,9 +232,9 @@ public void Write_WritesRouteWith3Points() [Fact] public void Write_WritesRouteWithMetadata() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = true })) { target.Write(_routeWithMetadata); } @@ -248,9 +248,9 @@ public void Write_WritesRouteWithMetadata() [Fact] public void Write_WritesRouteWithoutMetadataIfWriteMetadataIsFalse() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = false })) { target.Write(_routeWithMetadata); } @@ -265,9 +265,9 @@ public void Write_WritesRouteWithoutMetadataIfWriteMetadataIsFalse() public void Write_WritesRouteWithoutUnnecessaryElements() { _routeWithMetadata.Metadata.Source = null; - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = true })) { target.Write(_routeWithMetadata); } @@ -281,9 +281,9 @@ public void Write_WritesRouteWithoutUnnecessaryElements() [Fact] public void Write_WritesTrack() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = false })) { target.Write(_track); } @@ -297,9 +297,9 @@ public void Write_WritesTrack() [Fact] public void Write_WritesTrackWithMetadata() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = true })) { target.Write(_trackWithMetadata); } @@ -313,9 +313,9 @@ public void Write_WritesTrackWithMetadata() [Fact] public void Write_DoesntWriteTrackMetadataIfWriteMetadataIsFalse() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = false })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = false })) { target.Write(_trackWithMetadata); } @@ -329,10 +329,10 @@ public void Write_DoesntWriteTrackMetadataIfWriteMetadataIsFalse() [Fact] public void Write_TrackWithEntityDetailsButNullValues_WritesTrackWithoutUnnecessaryElements() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); _trackWithMetadata.Metadata.Source = null; - using (GpxWriter target = new GpxWriter(stream, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter target = new(stream, new GpxWriterSettings() { WriteMetadata = true })) { target.Write(_trackWithMetadata); } @@ -359,7 +359,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() [Fact] public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); var target = new GpxWriter(stream, new GpxWriterSettings()); target.Dispose(); diff --git a/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs b/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs index 430e661..0981452 100644 --- a/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs +++ b/src/Tests.SpatialLite.Gps/XDocumentExtensions.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Globalization; +using System.Linq; using System.Xml.Linq; namespace Tests.SpatialLite.Gps; @@ -28,7 +29,7 @@ public static bool XMLCompare(XElement ele1, XElement ele2) { return false; } - if (attr.Value.ToLower() != ele2.Attribute(attr.Name.LocalName).Value.ToLower()) + if (attr.Value.ToLower(CultureInfo.InvariantCulture) != ele2.Attribute(attr.Name.LocalName).Value.ToLower(CultureInfo.InvariantCulture)) { return false; } diff --git a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs index 0de9435..b8ca9f1 100644 --- a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs @@ -24,7 +24,7 @@ public EntityCollectionTests() [Fact] public void Constructor__CreatesEmptyCollection() { - EntityCollection target = new EntityCollection(); + EntityCollection target = new(); Assert.Empty(target); } @@ -32,7 +32,7 @@ public void Constructor__CreatesEmptyCollection() [Fact] public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); for (int i = 0; i < _data.Length; i++) { @@ -43,8 +43,8 @@ public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() [Fact] public void Count_ReturnsNumberOfElements() { - EntityCollection target = new EntityCollection(_data); - Mock entityM = new Mock(); + EntityCollection target = new(_data); + Mock entityM = new(); Assert.Equal(_data.Length, target.Count); } @@ -52,7 +52,7 @@ public void Count_ReturnsNumberOfElements() [Fact] public void Contains_IOsmGeometry_ReturnsFalseForEmptyCollection() { - EntityCollection target = new EntityCollection(); + EntityCollection target = new(); Assert.DoesNotContain(_data[0], target); } @@ -60,7 +60,7 @@ public void Contains_IOsmGeometry_ReturnsFalseForEmptyCollection() [Fact] public void Contains_IOsmGeometry_ReturnsFalseForNull() { - EntityCollection target = new EntityCollection(); + EntityCollection target = new(); Assert.DoesNotContain(null, target); } @@ -68,7 +68,7 @@ public void Contains_IOsmGeometry_ReturnsFalseForNull() [Fact] public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainEntity() { - EntityCollection target = new EntityCollection(_data.Skip(1)); + EntityCollection target = new(_data.Skip(1)); Assert.DoesNotContain(_data[0], target); } @@ -76,7 +76,7 @@ public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainEntity() [Fact] public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsEntity() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); Assert.Contains(_data[0], target); } @@ -84,7 +84,7 @@ public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsEntity() [Fact] public void Contains_ID_ReturnsFalseForEmptyCollection() { - EntityCollection target = new EntityCollection(); + EntityCollection target = new(); Assert.False(target.Contains(_data[0].ID)); } @@ -92,7 +92,7 @@ public void Contains_ID_ReturnsFalseForEmptyCollection() [Fact] public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainEntity() { - EntityCollection target = new EntityCollection(_data.Skip(1)); + EntityCollection target = new(_data.Skip(1)); Assert.False(target.Contains(_data[0].ID)); } @@ -100,7 +100,7 @@ public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainEntity() [Fact] public void Contains_ID_ReturnsTrueIfCollectionContainsEntity() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); Assert.True(target.Contains(_data[0].ID)); } @@ -108,7 +108,7 @@ public void Contains_ID_ReturnsTrueIfCollectionContainsEntity() [Fact] public void Clear_RemovesAllItemsFromCollection() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); target.Clear(); Assert.Empty(target); @@ -117,7 +117,7 @@ public void Clear_RemovesAllItemsFromCollection() [Fact] public void Add_AddsEntityToCollection() { - EntityCollection target = new EntityCollection(); + EntityCollection target = new(); target.Add(_data[0]); Assert.Contains(_data[0], target); @@ -126,7 +126,7 @@ public void Add_AddsEntityToCollection() [Fact] public void Add_ThrowsArgumentNullExceptionIfItemIsNull() { - EntityCollection target = new EntityCollection(); + EntityCollection target = new(); Assert.Throws(() => target.Add(null)); } @@ -134,7 +134,7 @@ public void Add_ThrowsArgumentNullExceptionIfItemIsNull() [Fact] public void Add_ThrowsExceptionWhenAddingDuplicateID() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); Assert.Throws(() => target.Add(_data[0])); } @@ -142,7 +142,7 @@ public void Add_ThrowsExceptionWhenAddingDuplicateID() [Fact] public void IsReadOnly_ReturnsFalse() { - EntityCollection target = new EntityCollection(); + EntityCollection target = new(); Assert.False(target.IsReadOnly); } @@ -150,7 +150,7 @@ public void IsReadOnly_ReturnsFalse() [Fact] public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() { - EntityCollection target = new EntityCollection(_data.Skip(1)); + EntityCollection target = new(_data.Skip(1)); bool callResult = target.Remove(_data[0]); @@ -162,7 +162,7 @@ public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfItemIsNot [Fact] public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); bool callResult = target.Remove(null); @@ -172,7 +172,7 @@ public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() [Fact] public void Remove_IOsmGeometry_ReturnsTrueAndRemovesItemFromCollection() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); bool callResult = target.Remove(_data[0]); @@ -185,7 +185,7 @@ public void Remove_IOsmGeometry_ReturnsTrueAndRemovesItemFromCollection() [Fact] public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() { - EntityCollection target = new EntityCollection(_data.Skip(1)); + EntityCollection target = new(_data.Skip(1)); bool callResult = target.Remove(_data[0].ID); @@ -197,7 +197,7 @@ public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfItemIsNotPresent() [Fact] public void Remove_ID_ReturnsTrueAndRemovesItemFromCollection() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); bool callResult = target.Remove(_data[0].ID); @@ -210,7 +210,7 @@ public void Remove_ID_ReturnsTrueAndRemovesItemFromCollection() [Fact] public void Item_ReturnsNullIfIDIsNotpResentInCollection() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); Assert.Null(target[1000]); } @@ -218,7 +218,7 @@ public void Item_ReturnsNullIfIDIsNotpResentInCollection() [Fact] public void Item_ReturnsEntityWitSpecificID() { - EntityCollection target = new EntityCollection(_data); + EntityCollection target = new(_data); IOsmGeometry entity = target[1]; Assert.Equal(1, entity.ID); diff --git a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs index 069af9c..0a7a784 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs @@ -14,7 +14,7 @@ public class NodeTests public void Constructor_int_CreatesNodeAndInitializeProperties() { int id = 11; - Node target = new Node(id); + Node target = new(id); Assert.Equal(Coordinate.Empty, target.Position); Assert.Equal(id, target.ID); @@ -26,8 +26,8 @@ public void Constructor_int_CreatesNodeAndInitializeProperties() public void Constructor_int_double_double_CreatesNodeAndInitializeProperties() { int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - Node target = new Node(id, coord.X, coord.Y); + Coordinate coord = new(-15.6, 68.7); + Node target = new(id, coord.X, coord.Y); Assert.Equal(target.Position.X, coord.X); Assert.Equal(target.Position.Y, coord.Y); @@ -40,10 +40,10 @@ public void Constructor_int_double_double_CreatesNodeAndInitializeProperties() public void Constructor_int_double_double_Tags_CreatesNodeAndInitializesProperties() { int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - TagsCollection tags = new TagsCollection(); + Coordinate coord = new(-15.6, 68.7); + TagsCollection tags = new(); - Node target = new Node(id, coord.X, coord.Y, tags); + Node target = new(id, coord.X, coord.Y, tags); Assert.Equal(target.Position.X, coord.X); Assert.Equal(target.Position.Y, coord.Y); @@ -56,8 +56,8 @@ public void Constructor_int_double_double_Tags_CreatesNodeAndInitializesProperti public void Constructor_int_Coordinate_CreatesNodeAndInitializeProperties() { int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - Node target = new Node(id, coord); + Coordinate coord = new(-15.6, 68.7); + Node target = new(id, coord); Assert.Equal(id, target.ID); Assert.Equal(target.Position.X, coord.X); @@ -69,10 +69,10 @@ public void Constructor_int_Coordinate_CreatesNodeAndInitializeProperties() public void Constructor_int_Coordinate_Tags_CreatesNodeAndInitializeProperties() { int id = 11; - Coordinate coord = new Coordinate(-15.6, 68.7); - TagsCollection tags = new TagsCollection(); + Coordinate coord = new(-15.6, 68.7); + TagsCollection tags = new(); - Node target = new Node(id, coord, tags); + Node target = new(id, coord, tags); Assert.Equal(id, target.ID); Assert.Equal(target.Position.X, coord.X); @@ -83,7 +83,7 @@ public void Constructor_int_Coordinate_Tags_CreatesNodeAndInitializeProperties() [Fact] public void Constructor_NodeInfo_CreatesNodeFromNodeInfo() { - NodeInfo info = new NodeInfo(1, 15.6, 20.4, new TagsCollection(), new EntityMetadata()); + NodeInfo info = new(1, 15.6, 20.4, new TagsCollection(), new EntityMetadata()); Node target = Node.FromNodeInfo(info); @@ -97,7 +97,7 @@ public void Constructor_NodeInfo_CreatesNodeFromNodeInfo() [Fact] public void EntityType_Returns_Node() { - Node target = new Node(1); + Node target = new(1); Assert.Equal(EntityType.Node, target.EntityType); } diff --git a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs index d7bc075..f231c74 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs @@ -29,8 +29,8 @@ public OsmGeometryDatabaseTests() _wayData[1] = new Way(11, _nodeData.Skip(1)); _relationData = new Relation[2]; - _relationData[0] = new Relation(100, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); - _relationData[1] = new Relation(101, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); + _relationData[0] = new Relation(100, new RelationMember[] { new(_wayData[0], "way"), new(_nodeData[0], "node") }); + _relationData[1] = new Relation(101, new RelationMember[] { new(_relationData[0], "relation"), new(_nodeData[0], "node") }); _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); } @@ -38,7 +38,7 @@ public OsmGeometryDatabaseTests() [Fact] public void Constructor__CreatesEmptyDatabase() { - OsmGeometryDatabase target = new OsmGeometryDatabase(); + OsmGeometryDatabase target = new(); Assert.Empty(target); Assert.Empty(target.Nodes); @@ -49,7 +49,7 @@ public void Constructor__CreatesEmptyDatabase() [Fact] public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + OsmGeometryDatabase target = new(_data); for (int i = 0; i < _data.Length; i++) { @@ -60,7 +60,7 @@ public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() [Fact] public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() { - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + OsmGeometryDatabase target = new(_data); for (int i = 0; i < _nodeData.Length; i++) { @@ -162,12 +162,12 @@ public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndRelationMemberIsMi [Fact] public void Save_CallsIOsmWriterWriteForAllEntities() { - List written = new List(); - Mock writerM = new Mock(); + List written = new(); + Mock writerM = new(); writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); - OsmGeometryDatabase target = new OsmGeometryDatabase(_data); + OsmGeometryDatabase target = new(_data); target.Save(writerM.Object); Assert.Equal(target.Count, written.Count); diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs index fc2f8e2..e845287 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs @@ -15,7 +15,7 @@ public class RelationMemberTests public RelationMemberTests() { - Mock> _nodesCollectionM = new Mock>(); + Mock> _nodesCollectionM = new(); _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); _nodesEntityCollection = _nodesCollectionM.Object; @@ -24,8 +24,8 @@ public RelationMemberTests() [Fact] public void Constructor_Member_CreatesNewRelationMembeAndSetsMember() { - Node member = new Node(11); - RelationMember target = new RelationMember(member); + Node member = new(11); + RelationMember target = new(member); Assert.Same(member, target.Member); Assert.True(string.IsNullOrEmpty(target.Role)); @@ -40,9 +40,9 @@ public void Constructor_Member_ThrowsExceptionIfMemberIsNull() [Fact] public void Constructor_Member_Role_CreatesRelationMemberAndSetsMemberAndRole() { - Node member = new Node(11); + Node member = new(11); string role = "role"; - RelationMember target = new RelationMember(member, role); + RelationMember target = new(member, role); Assert.Same(member, target.Member); Assert.Equal(role, target.Role); @@ -57,7 +57,7 @@ public void Constructor_Member_Role_ThrowsExceptionIfMemberIsNull() [Fact] public void FromRelationMemberInfo_ThrowExceptionIfTypeIsUnknown() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Unknown, Role = "role" }; + RelationMemberInfo info = new() { Reference = 1, MemberType = EntityType.Unknown, Role = "role" }; Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); } @@ -65,7 +65,7 @@ public void FromRelationMemberInfo_ThrowExceptionIfTypeIsUnknown() [Fact] public void FromRelationMemberInfo_CreatesRelationMember() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node, Role = "role" }; + RelationMemberInfo info = new() { Reference = 1, MemberType = EntityType.Node, Role = "role" }; RelationMember target = RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true); Assert.Equal(info.Reference, target.Member.ID); @@ -76,7 +76,7 @@ public void FromRelationMemberInfo_CreatesRelationMember() [Fact] public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityIsNotAvailable() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; + RelationMemberInfo info = new() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); } @@ -84,7 +84,7 @@ public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityIsNotAvailabl [Fact] public void FromRelationMemberInfo_ReturnsNullIfReferencedEntityIsNotAvailableAndThrowOnMissingIsFalse() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; + RelationMemberInfo info = new() { Reference = 10000, MemberType = EntityType.Node, Role = "role" }; Assert.Null(RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, false)); } @@ -92,7 +92,7 @@ public void FromRelationMemberInfo_ReturnsNullIfReferencedEntityIsNotAvailableAn [Fact] public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityTypeDoesntMatchMemberType() { - RelationMemberInfo info = new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Way, Role = "role" }; + RelationMemberInfo info = new() { Reference = 1, MemberType = EntityType.Way, Role = "role" }; Assert.Throws(() => RelationMember.FromRelationMemberInfo(info, _nodesEntityCollection, true)); } @@ -100,10 +100,10 @@ public void FromRelationMemberInfo_ThrowExceptionIfReferencedEntityTypeDoesntMat [Fact] public void Is3D_GetsTrueFor3DMember() { - Mock memberM = new Mock(11); + Mock memberM = new(11); memberM.SetupGet(property => property.Is3D).Returns(true); - RelationMember target = new RelationMember(memberM.Object); + RelationMember target = new(memberM.Object); Assert.Equal(memberM.Object.Is3D, target.Is3D); } @@ -111,10 +111,10 @@ public void Is3D_GetsTrueFor3DMember() [Fact] public void Is3D_GetsFalseFor2DMember() { - Mock memberM = new Mock(11); + Mock memberM = new(11); memberM.SetupGet(property => property.Is3D).Returns(false); - RelationMember target = new RelationMember(memberM.Object); + RelationMember target = new(memberM.Object); Assert.Equal(memberM.Object.Is3D, target.Is3D); } @@ -122,10 +122,10 @@ public void Is3D_GetsFalseFor2DMember() [Fact] public void IsMeasured_GetsTrueForMeasuredMember() { - Mock memberM = new Mock(11); + Mock memberM = new(11); memberM.SetupGet(property => property.IsMeasured).Returns(true); - RelationMember target = new RelationMember(memberM.Object); + RelationMember target = new(memberM.Object); Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); } @@ -133,10 +133,10 @@ public void IsMeasured_GetsTrueForMeasuredMember() [Fact] public void IsMeasured_GetFalseForNonMeasuredMember() { - Mock memberM = new Mock(11); + Mock memberM = new(11); memberM.SetupGet(property => property.IsMeasured).Returns(false); - RelationMember target = new RelationMember(memberM.Object); + RelationMember target = new(memberM.Object); Assert.Equal(memberM.Object.IsMeasured, target.IsMeasured); } @@ -144,7 +144,7 @@ public void IsMeasured_GetFalseForNonMeasuredMember() [Fact] public void MemberType_ReturnsCorrectValueForNode() { - RelationMember target = new RelationMember(new Node(11)); + RelationMember target = new(new Node(11)); Assert.Equal(EntityType.Node, target.MemberType); } @@ -152,7 +152,7 @@ public void MemberType_ReturnsCorrectValueForNode() [Fact] public void MemberType_ReturnsCorrectValueForWay() { - RelationMember target = new RelationMember(new Way(11)); + RelationMember target = new(new Way(11)); Assert.Equal(EntityType.Way, target.MemberType); } @@ -160,7 +160,7 @@ public void MemberType_ReturnsCorrectValueForWay() [Fact] public void MemberType_ReturnsCorrectValueForRelation() { - RelationMember target = new RelationMember(new Relation(11)); + RelationMember target = new(new Relation(11)); Assert.Equal(EntityType.Relation, target.MemberType); } @@ -168,11 +168,11 @@ public void MemberType_ReturnsCorrectValueForRelation() [Fact] public void GetEnvelopeReturnsMembersEnvelope() { - Envelope expectedEnvelope = new Envelope(new Coordinate(1.1, 2.2)); - Mock member = new Mock(11); + Envelope expectedEnvelope = new(new Coordinate(1.1, 2.2)); + Mock member = new(11); member.Setup(function => function.GetEnvelope()).Returns(expectedEnvelope); - RelationMember target = new RelationMember(member.Object); + RelationMember target = new(member.Object); Assert.Same(expectedEnvelope, target.GetEnvelope()); } diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs index d136d10..a92ca18 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs @@ -11,14 +11,14 @@ namespace Tests.SpatialLite.Osm.Geometries; public class RelationTests { - RelationInfo _relationEmptyInfo = new RelationInfo(100, new TagsCollection(), new List(), new EntityMetadata()); - RelationInfo _relationInfo = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); + RelationInfo _relationEmptyInfo = new(100, new TagsCollection(), new List(), new EntityMetadata()); + RelationInfo _relationInfo = new(100, new TagsCollection(), new RelationMemberInfo[] { new() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); IEntityCollection _nodesEntityCollection; public RelationTests() { - Mock> _nodesCollectionM = new Mock>(); + Mock> _nodesCollectionM = new(); _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2)); _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true); @@ -29,7 +29,7 @@ public RelationTests() public void Constructor_int_CreatesNewRelationAndInitializesProperties() { int id = 11; - Relation target = new Relation(id); + Relation target = new(id); Assert.Equal(id, target.ID); Assert.Empty(target.Tags); @@ -40,8 +40,8 @@ public void Constructor_int_CreatesNewRelationAndInitializesProperties() public void Constructor_int_IEnumerable_CreatesRelationWithMembersAndInitializesProperties() { int id = 11; - var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; - Relation target = new Relation(id, members); + var members = new RelationMember[] { new(new Node(1)), new(new Node(2)), new(new Node(3)) }; + Relation target = new(id, members); Assert.Equal(id, target.ID); Assert.Equal(members.Length, target.Geometries.Count); @@ -57,9 +57,9 @@ public void Constructor_int_IEnumerable_CreatesRelationWithMembersAndInitializes public void Constructor_int_tags_CreatesRelationAndIntializesProperties() { int id = 11; - var members = new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)), new RelationMember(new Node(3)) }; - TagsCollection tags = new TagsCollection(); - Relation target = new Relation(id, members, tags); + var members = new RelationMember[] { new(new Node(1)), new(new Node(2)), new(new Node(3)) }; + TagsCollection tags = new(); + Relation target = new(id, members, tags); Assert.Equal(id, target.ID); Assert.Equal(members.Length, target.Geometries.Count); @@ -109,7 +109,7 @@ public void FromRelationInfo_ReturnsNullIfCollectionDoesntContainReferencedEntit [Fact] public void EntityType_Returns_Relation() { - Relation target = new Relation(100); + Relation target = new(100); Assert.Equal(EntityType.Relation, target.EntityType); } diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs index fd42e1e..0fb94ca 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs @@ -11,16 +11,16 @@ namespace Tests.SpatialLite.Osm.Geometries; public class WayCoordinateListTests { - List _nodes = new List(new Node[] { - new Node(5, 1.1, 2.2), - new Node(6, 10.1, -20.2), - new Node(7, -30.1, 40.2) }); + List _nodes = new(new Node[] { + new(5, 1.1, 2.2), + new(6, 10.1, -20.2), + new(7, -30.1, 40.2) }); [Fact] public void Constructor_Source_SetsSource() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Same(_nodes, target.Source); } @@ -28,7 +28,7 @@ public void Constructor_Source_SetsSource() [Fact] public void Indexer_Get_ReturnsCoordinatesFromSourceList() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); for (int i = 0; i < _nodes.Count; i++) { @@ -39,7 +39,7 @@ public void Indexer_Get_ReturnsCoordinatesFromSourceList() [Fact] public void Indexer_Set_ThrowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); } @@ -47,7 +47,7 @@ public void Indexer_Set_ThrowsNotSupportedException() [Fact] public void Count_GetsNumberOfItemsInSourceCollection() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Equal(_nodes.Count, target.Count); } @@ -55,7 +55,7 @@ public void Count_GetsNumberOfItemsInSourceCollection() [Fact] public void Add_Coordinate_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Throws(() => target.Add(Coordinate.Empty)); } @@ -63,7 +63,7 @@ public void Add_Coordinate_ThowsNotSupportedException() [Fact] public void Add_Coordinates_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); } @@ -71,7 +71,7 @@ public void Add_Coordinates_ThowsNotSupportedException() [Fact] public void Insert_Index_Coordinate_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Throws(() => target.Insert(0, Coordinate.Empty)); } @@ -79,7 +79,7 @@ public void Insert_Index_Coordinate_ThowsNotSupportedException() [Fact] public void RemoveAt_Index_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Throws(() => target.RemoveAt(0)); } @@ -87,7 +87,7 @@ public void RemoveAt_Index_ThowsNotSupportedException() [Fact] public void Clear_ThowsNotSupportedException() { - WayCoordinateList target = new WayCoordinateList(_nodes); + WayCoordinateList target = new(_nodes); Assert.Throws(() => target.Clear()); } diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs index beaaaf4..d68f2f2 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs @@ -13,19 +13,19 @@ namespace Tests.SpatialLite.Osm.Geometries; public class WayTests { - List _nodes = new List(new Node[] { - new Node(1, 1.1, 2.2), - new Node(2, 10.1, -20.2), - new Node(3, -30.1, 40.2) }); + List _nodes = new(new Node[] { + new(1, 1.1, 2.2), + new(2, 10.1, -20.2), + new(3, -30.1, 40.2) }); - WayInfo _wayEmptyInfo = new WayInfo(10, new TagsCollection(), new List(), new EntityMetadata()); - WayInfo _wayInfo = new WayInfo(10, new TagsCollection(), new long[] { 1, 2, 3 }, new EntityMetadata()); + WayInfo _wayEmptyInfo = new(10, new TagsCollection(), new List(), new EntityMetadata()); + WayInfo _wayInfo = new(10, new TagsCollection(), new long[] { 1, 2, 3 }, new EntityMetadata()); IEntityCollection _nodesEntityCollection; public WayTests() { - Mock> _nodesCollectionM = new Mock>(); + Mock> _nodesCollectionM = new(); _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(_nodes[0]); _nodesCollectionM.SetupGet(c => c[2, EntityType.Node]).Returns(_nodes[1]); _nodesCollectionM.SetupGet(c => c[3, EntityType.Node]).Returns(_nodes[2]); @@ -37,7 +37,7 @@ public void Constructor_ID_CreatesNewEmptyWayAndInitializesProperties() { int id = 11; - Way target = new Way(id); + Way target = new(id); Assert.Equal(id, target.ID); Assert.Empty(target.Nodes); @@ -49,7 +49,7 @@ public void Constructor_ID_CreatesNewEmptyWayAndInitializesProperties() public void Constructor_ID_Nodes_CreatesWayAddsNodesAndInitializesProperties() { int id = 11; - Way target = new Way(id, _nodes); + Way target = new(id, _nodes); Assert.Equal(id, target.ID); Assert.Equal(_nodes.Count, target.Nodes.Count); @@ -66,9 +66,9 @@ public void Constructor_ID_Nodes_CreatesWayAddsNodesAndInitializesProperties() public void Constructor_ID_Nodes_Tags_CreatesWayAddsNodesAndInitializesProperties() { int id = 11; - TagsCollection tags = new TagsCollection(); + TagsCollection tags = new(); - Way target = new Way(id, _nodes, tags); + Way target = new(id, _nodes, tags); Assert.Equal(id, target.ID); Assert.Equal(_nodes.Count, target.Nodes.Count); @@ -136,7 +136,7 @@ public void WhenWayIsInitializedFromWayInfo_CoordinatesReturnsNodesCoordinates() public void Coordinates_GetsPositionOfNodes() { int id = 11; - Way target = new Way(id, _nodes); + Way target = new(id, _nodes); Assert.Equal(_nodes.Count, target.Coordinates.Count); for (int i = 0; i < _nodes.Count; i++) @@ -149,7 +149,7 @@ public void Coordinates_GetsPositionOfNodes() public void Coordinates_GetsPositionOfNodesIfWayCastedToLineString() { int id = 11; - Way way = new Way(id, _nodes); + Way way = new(id, _nodes); LineString target = (LineString)way; Assert.Equal(_nodes.Count, target.Coordinates.Count); @@ -162,7 +162,7 @@ public void Coordinates_GetsPositionOfNodesIfWayCastedToLineString() [Fact] public void EntityType_Returns_Way() { - Way target = new Way(10); + Way target = new(10); Assert.Equal(EntityType.Way, target.EntityType); } diff --git a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs index 2364f70..1807480 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs @@ -11,7 +11,7 @@ public class OsmReaderSettingsTests [Fact] public void Constructor__CreatesSettingsWithDefaultValues() { - OsmReaderSettings target = new OsmReaderSettings(); + OsmReaderSettings target = new(); Assert.True(target.ReadMetadata); } @@ -19,7 +19,7 @@ public void Constructor__CreatesSettingsWithDefaultValues() [Fact] public void ReadMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - OsmReaderSettings target = new OsmReaderSettings(); + OsmReaderSettings target = new(); target.IsReadOnly = true; Assert.Throws(() => target.ReadMetadata = true); diff --git a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs index a92f0a7..1f47e7b 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs @@ -11,7 +11,7 @@ public class OsmWriterSettingsTests [Fact] public void Constructor__CreatesSettingsWithDefaultValues() { - OsmWriterSettings target = new OsmWriterSettings(); + OsmWriterSettings target = new(); Assert.True(target.WriteMetadata); } @@ -19,7 +19,7 @@ public void Constructor__CreatesSettingsWithDefaultValues() [Fact] public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - OsmWriterSettings target = new OsmWriterSettings(); + OsmWriterSettings target = new(); target.IsReadOnly = true; Assert.Throws(() => target.WriteMetadata = true); @@ -28,7 +28,7 @@ public void WriteMetadataSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnl [Fact] public void ProgramNameSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - OsmWriterSettings target = new OsmWriterSettings(); + OsmWriterSettings target = new(); target.IsReadOnly = true; Assert.Throws(() => target.ProgramName = "TEST"); diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs index 4e9bcb0..ad607af 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs @@ -30,22 +30,22 @@ public OsmXmlReaderTests() }; _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(2, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeTags = new NodeInfo(2, 50.4, 16.2, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") })); _nodeProperties = new NodeInfo(3, 50.4, 16.2, new TagsCollection(), _details); _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(2, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), new long[] { 10, 11, 12 }); _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); _relationTags = new RelationInfo( 2, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), + new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); _relationWithoutMembers = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { }); } @@ -59,8 +59,8 @@ public void Constructor_StringSettings_ThrowsExceptionIfFileDoesnotExist() public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() { string path = "../../../Data/Xml/osm-real-file.osm"; - OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; - using (OsmXmlReader target = new OsmXmlReader(path, settings)) + OsmXmlReaderSettings settings = new() { ReadMetadata = false }; + using (OsmXmlReader target = new(path, settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -70,8 +70,8 @@ public void Constructor_StringSettings_SetsSettingsAndMakesItReadOnly() [Fact] public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() { - OsmXmlReaderSettings settings = new OsmXmlReaderSettings() { ReadMetadata = false }; - using (OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), settings)) + OsmXmlReaderSettings settings = new() { ReadMetadata = false }; + using (OsmXmlReader target = new(TestDataReader.OpenXml("osm-simple-node.osm"), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -81,7 +81,7 @@ public void Constructor_StreamSettings_SetsSettingsAndMakesItReadOnly() [Fact] public void Read_SkipsUnknownElements() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-unknown-inner-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-unknown-inner-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); IEntityInfo result = target.Read(); Assert.NotNull(result as NodeInfo); @@ -91,7 +91,7 @@ public void Read_SkipsUnknownElements() [Fact] public void Read_ThrowsExceptionIfTagHasNotKey() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-key.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-tag-without-key.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -100,7 +100,7 @@ public void Read_ThrowsExceptionIfTagHasNotKey() [Fact] public void Read_ThrowsExceptionIfTagHasNotValue() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-tag-without-value.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-tag-without-value.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -108,21 +108,21 @@ public void Read_ThrowsExceptionIfTagHasNotValue() [Fact] public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); Assert.Throws(() => target.Read()); } [Fact] public void Read_DoesNotThrowExceptionIPieceOffMetadataIsMissingAndStrictModeIsFalse() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false }); target.Read(); } [Fact] public void Read_ThrowsExceptionIfNodeHasNotID() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -130,7 +130,7 @@ public void Read_ThrowsExceptionIfNodeHasNotID() [Fact] public void Read_ThrowsExceptionIfNodeHasNotLat() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lat.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-without-lat.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -138,7 +138,7 @@ public void Read_ThrowsExceptionIfNodeHasNotLat() [Fact] public void Read_ThrowsExceptionIfNodeHasNotLon() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -146,19 +146,19 @@ public void Read_ThrowsExceptionIfNodeHasNotLon() [Fact] public void Read_ReadsSimpleNode() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-simple-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); + CompareNodes(_node, readNode); } [Fact] public void Read_ReadsNodeWithUnknownElement() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tag-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-with-tag-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); + CompareNodes(_node, readNode); // nothing more left to read in the file Assert.Null(target.Read()); @@ -167,25 +167,25 @@ public void Read_ReadsNodeWithUnknownElement() [Fact] public void Read_ReadsNodeWithTags() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeTags, readNode); + CompareNodes(_nodeTags, readNode); } [Fact] public void Read_ReadsNodeWithAllAttributes() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-node-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeProperties, readNode); + CompareNodes(_nodeProperties, readNode); } [Fact] public void Read_ThrowsExceptionIfWayHasNotID() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -193,7 +193,7 @@ public void Read_ThrowsExceptionIfWayHasNotID() [Fact] public void Read_ThrowsExceptionIfWayNDHasNotRef() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -201,52 +201,52 @@ public void Read_ThrowsExceptionIfWayNDHasNotRef() [Fact] public void Read_ReadsWayWithoutNodes() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-without-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-without-nodes.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayWithoutNodes, readWay); + CompareWays(_wayWithoutNodes, readWay); } [Fact] public void Read_ReadsSimpleWay() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-simple-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-simple-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_way, readWay); + CompareWays(_way, readWay); } [Fact] public void Read_ReadsWayWithTags() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayTags, readWay); + CompareWays(_wayTags, readWay); } [Fact] public void Read_ReadsWayWithUnknownElement() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayTags, readWay); + CompareWays(_wayTags, readWay); } [Fact] public void Read_ReadsWayWithAllAttributes() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-way-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayProperties, readWay); + CompareWays(_wayProperties, readWay); } [Fact] public void Read_ThrowsExceptionIfRelationHasNotID() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -254,7 +254,7 @@ public void Read_ThrowsExceptionIfRelationHasNotID() [Fact] public void Read_ThrowsExceptionIfRelationMemberHasNotRef() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-member-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -262,7 +262,7 @@ public void Read_ThrowsExceptionIfRelationMemberHasNotRef() [Fact] public void Read_ThrowsExceptionIfRelationMemberHasNotType() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); Assert.Throws(() => target.Read()); } @@ -270,64 +270,64 @@ public void Read_ThrowsExceptionIfRelationMemberHasNotType() [Fact] public void Read_ReadsRelationWithoutMembers() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-without-members.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-without-members.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationWithoutMembers, readRelation); + CompareRelation(_relationWithoutMembers, readRelation); } [Fact] public void Read_ReadsRelationWithNodeMember() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-node.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationNode, readRelation); + CompareRelation(_relationNode, readRelation); } [Fact] public void Read_ReadsRelationWithWayMember() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-way.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationWay, readRelation); + CompareRelation(_relationWay, readRelation); } [Fact] public void Read_ReadsRelationWithRelationMember() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationRelation, readRelation); + CompareRelation(_relationRelation, readRelation); } [Fact] public void Read_ReadsRelationWithTags() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-with-tags.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationTags, readRelation); + CompareRelation(_relationTags, readRelation); } [Fact] public void Read_ReadsRelationWithTagsAndUnknownElement() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-with-tags-and-unknown-element.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationTags, readRelation); + CompareRelation(_relationTags, readRelation); } [Fact] public void Read_ReadsRelationWithAllProperties() { - OsmXmlReader target = new OsmXmlReader(TestDataReader.OpenXml("osm-relation-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-all-properties.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationProperties, readRelation); + CompareRelation(_relationProperties, readRelation); } [Fact] @@ -335,7 +335,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = "../../../Data/Xml/osm-real-file.osm"; - OsmXmlReader target = new OsmXmlReader(filename, new OsmXmlReaderSettings() { ReadMetadata = false }); + OsmXmlReader target = new(filename, new OsmXmlReaderSettings() { ReadMetadata = false }); target.Dispose(); FileStream testStream = null; @@ -349,8 +349,8 @@ private void CompareNodes(NodeInfo expected, NodeInfo actual) Assert.Equal(expected.Longitude, actual.Longitude); Assert.Equal(expected.Latitude, actual.Latitude); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareWays(WayInfo expected, WayInfo actual) @@ -362,8 +362,8 @@ private void CompareWays(WayInfo expected, WayInfo actual) Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareRelation(RelationInfo expected, RelationInfo actual) @@ -375,8 +375,8 @@ private void CompareRelation(RelationInfo expected, RelationInfo actual) Assert.Equal(expected.Members[i], actual.Members[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareTags(TagsCollection expected, TagsCollection actual) diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs index 869451b..dfad056 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs @@ -34,30 +34,30 @@ public OsmXmlWriterTests() }; _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") })); _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), new long[] { 10, 11, 12 }); _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); _relationTags = new RelationInfo( 1, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), + new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); } [Fact] public void Constructor_StreamSettings_SetsSettingsAndMakesThemReadOnly() { - MemoryStream stream = new MemoryStream(); - OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, settings)) + MemoryStream stream = new(); + OsmWriterSettings settings = new(); + using (OsmXmlWriter target = new(stream, settings)) { Assert.Same(settings, target.Settings); Assert.True(target.Settings.IsReadOnly); @@ -69,8 +69,8 @@ public void Constructor_PathSettings_SetsSettingsAndMakesThemReadOnly() { string path = PathHelper.GetTempFilePath("xmlwriter-constructor-test.osm"); - OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(path, settings)) + OsmWriterSettings settings = new(); + using (OsmXmlWriter target = new(path, settings)) { Assert.Same(settings, target.Settings); Assert.True(target.Settings.IsReadOnly); @@ -82,8 +82,8 @@ public void Constructor_PathSettings_CreatesOutputFile() { string filename = PathHelper.GetTempFilePath("osmwriter-constructor-creates-output-test.pbf"); - OsmWriterSettings settings = new OsmWriterSettings(); - using (OsmXmlWriter target = new OsmXmlWriter(filename, settings)) + OsmWriterSettings settings = new(); + using (OsmXmlWriter target = new(filename, settings)) { ; } @@ -96,7 +96,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string path = PathHelper.GetTempFilePath("xmlwriter-closes-output-filestream-test.osm"); - OsmXmlWriter target = new OsmXmlWriter(path, new OsmWriterSettings()); + OsmXmlWriter target = new(path, new OsmWriterSettings()); target.Dispose(); FileStream testStream = null; @@ -107,9 +107,9 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() [Fact] public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = true })) { Assert.Throws(() => target.Write(_node)); } @@ -118,10 +118,10 @@ public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHav [Fact] public void Write_DoesNotThrowsExceptionIfMetadataContainsNullInsteadUsername() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); _nodeProperties.Metadata.User = null; - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = true })) { target.Write(_nodeProperties); } @@ -130,48 +130,48 @@ public void Write_DoesNotThrowsExceptionIfMetadataContainsNullInsteadUsername() [Fact] public void Write_IEntityInfo_WritesNode() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_node); } - this.TestXmlOutput(stream, _node, false); + TestXmlOutput(stream, _node, false); } [Fact] public void Write_IEntityInfo_WritesNodeWithTags() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_nodeTags); } - this.TestXmlOutput(stream, _nodeTags, false); + TestXmlOutput(stream, _nodeTags, false); } [Fact] public void Write_IEntityInfo_WritesNodeWithMetadata() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = true })) { target.Write(_nodeProperties); } - this.TestXmlOutput(stream, _nodeProperties, true); + TestXmlOutput(stream, _nodeProperties, true); } [Fact] public void Write_IEntityInfo_DoesntWriteNodeMetadataIfWriteMedataIsFalse() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_nodeProperties); } @@ -191,48 +191,48 @@ public void Write_IEntityInfo_DoesntWriteNodeMetadataIfWriteMedataIsFalse() [Fact] public void Write_IEntityInfo_WritesWay() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_way); } - this.TestXmlOutput(stream, _way, false); + TestXmlOutput(stream, _way, false); } [Fact] public void Write_IEntityInfo_WritesWayWithTags() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_wayTags); } - this.TestXmlOutput(stream, _wayTags, false); + TestXmlOutput(stream, _wayTags, false); } [Fact] public void Write_IEntityInfo_WritesWayWithMetadata() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = true })) { target.Write(_wayProperties); } - this.TestXmlOutput(stream, _wayProperties, true); + TestXmlOutput(stream, _wayProperties, true); } [Fact] public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMedataIsFalse() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_wayProperties); } @@ -252,74 +252,74 @@ public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMedataIsFalse() [Fact] public void Write_IEntityInfo_WritesRelationWithNode() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_relationNode); } - this.TestXmlOutput(stream, _relationNode, false); + TestXmlOutput(stream, _relationNode, false); } [Fact] public void Write_IEntityInfo_WritesRelationWithWay() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_relationWay); } - this.TestXmlOutput(stream, _relationWay, false); + TestXmlOutput(stream, _relationWay, false); } [Fact] public void Write_IEntityInfo_WritesRelationWithRelation() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_relationRelation); } - this.TestXmlOutput(stream, _relationRelation, false); + TestXmlOutput(stream, _relationRelation, false); } [Fact] public void Write_IEntityInfo_WritesRelationWithTags() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_relationTags); } - this.TestXmlOutput(stream, _relationTags, false); + TestXmlOutput(stream, _relationTags, false); } [Fact] public void Write_IEntityInfo_WritesRelationWithMetadata() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = true })) { target.Write(_relationNodeProperties); } - this.TestXmlOutput(stream, _relationNodeProperties, true); + TestXmlOutput(stream, _relationNodeProperties, true); } [Fact] public void Write_IEntityInfo_DoesntWriteRelationMetadataIfWriteMedataIsFalse() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(_relationNodeProperties); } @@ -339,54 +339,54 @@ public void Write_IEntityInfo_DoesntWriteRelationMetadataIfWriteMedataIsFalse() [Fact] public void Write_IOsmGeometry_WritesNode() { - Node node = new Node(1, 11.1, 12.1); + Node node = new(1, 11.1, 12.1); - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(node); } - this.TestXmlOutput(stream, new NodeInfo(node), false); + TestXmlOutput(stream, new NodeInfo(node), false); } [Fact] public void Write_IOsmGeometry_WritesWay() { - Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); + Way way = new(10, new Node[] { new(1), new(2), new(3) }); - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(way); } - this.TestXmlOutput(stream, new WayInfo(way), false); + TestXmlOutput(stream, new WayInfo(way), false); } [Fact] public void Write_IOsmGeometry_WritesRelation() { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); + Relation relation = new(100, new RelationMember[] { new(new Node(1), "test-role") }); - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { target.Write(relation); } - this.TestXmlOutput(stream, new RelationInfo(relation), false); + TestXmlOutput(stream, new RelationInfo(relation), false); } [Fact] public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (OsmXmlWriter target = new OsmXmlWriter(stream, new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter target = new(stream, new OsmWriterSettings() { WriteMetadata = false })) { IOsmGeometry entity = null; Assert.Throws(() => target.Write(entity)); @@ -404,14 +404,14 @@ private void TestXmlOutput(MemoryStream xmlStream, IEntityInfo expected, bool re xmlStream = new MemoryStream(xmlStream.ToArray()); } - OsmXmlReader reader = new OsmXmlReader(xmlStream, new OsmXmlReaderSettings() { ReadMetadata = readMetadata }); + OsmXmlReader reader = new(xmlStream, new OsmXmlReaderSettings() { ReadMetadata = readMetadata }); IEntityInfo read = reader.Read(); switch (expected.EntityType) { - case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; - case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; - case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; + case EntityType.Node: CompareNodes(expected as NodeInfo, read as NodeInfo); break; + case EntityType.Way: CompareWays(expected as WayInfo, read as WayInfo); break; + case EntityType.Relation: CompareRelation(expected as RelationInfo, read as RelationInfo); break; } } @@ -421,8 +421,8 @@ private void CompareNodes(NodeInfo expected, NodeInfo actual) Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareWays(WayInfo expected, WayInfo actual) @@ -434,8 +434,8 @@ private void CompareWays(WayInfo expected, WayInfo actual) Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareRelation(RelationInfo expected, RelationInfo actual) @@ -447,8 +447,8 @@ private void CompareRelation(RelationInfo expected, RelationInfo actual) Assert.Equal(expected.Members[i], actual.Members[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareTags(TagsCollection expected, TagsCollection actual) diff --git a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs index dddd7a7..0febddc 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs @@ -33,22 +33,22 @@ public PbfReaderTests() }; _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") })); _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), new long[] { 10, 11, 12 }); _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); _relationTags = new RelationInfo( 1, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), + new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); } [Fact] @@ -69,9 +69,9 @@ public void Constructor_StreamSettings_ThrowsExceptionIfOSMHeaderDefinedUnsuppor public void Constructor_StreamSettings_SetsSettingsAndMakesThemIsReadOnly() { var dataStream = TestDataReader.OpenPbf("pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings(); + OsmReaderSettings settings = new(); - using (PbfReader target = new PbfReader(dataStream, settings)) + using (PbfReader target = new(dataStream, settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -102,9 +102,9 @@ public void Constructor_StringSettings_ThrowsExceptionIfOSMHeaderDefinedUnsuppor public void Constructor_StringSettings_SetsSettingsAndMakesThemIsReadOnly() { string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings(); + OsmReaderSettings settings = new(); - using (PbfReader target = new PbfReader(filename, settings)) + using (PbfReader target = new(filename, settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -114,7 +114,7 @@ public void Constructor_StringSettings_SetsSettingsAndMakesThemIsReadOnly() [Fact] public void Read_ReturnsNullIfAllEntitiesHaveBeenRead() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); //read only entity IEntityInfo read = target.Read(); @@ -138,34 +138,34 @@ public void Read_ThrowInvalidDataExceptionIfOsmDataBlockSizeExceedesAllowdValue( [Fact] public void Read_ReadsNode_DenseNoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-nd-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); + CompareNodes(_node, readNode); } [Fact] public void Read_ReadsNodeWithTags_DenseNoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-nd-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeTags, readNode); + CompareNodes(_nodeTags, readNode); } [Fact] public void Read_ReadsNodeWithMetadata_DenseNoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeProperties, readNode); + CompareNodes(_nodeProperties, readNode); } [Fact] public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_DenseNoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-nd-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; Assert.Null(readNode.Metadata); @@ -174,34 +174,34 @@ public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_DenseNoCompression() [Fact] public void Read_ReadsNode_NoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_node, readNode); + CompareNodes(_node, readNode); } [Fact] public void Read_ReadsNodeWithTags_NoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-node-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeTags, readNode); + CompareNodes(_nodeTags, readNode); } [Fact] public void Read_ReadsNodeWithMetadata_NoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); NodeInfo readNode = target.Read() as NodeInfo; - this.CompareNodes(_nodeProperties, readNode); + CompareNodes(_nodeProperties, readNode); } [Fact] public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-node-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); NodeInfo readNode = target.Read() as NodeInfo; Assert.Null(readNode.Metadata); @@ -210,34 +210,34 @@ public void Read_SkipsNodeMetadataIfProcessMetadataIsFalse_NoCompression() [Fact] public void Read_ReadsWay_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_way, readWay); + CompareWays(_way, readWay); } [Fact] public void Read_ReadsWayWithTags_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-way-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayTags, readWay); + CompareWays(_wayTags, readWay); } [Fact] public void Read_ReadsWayWithMetadata_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayProperties, readWay); + CompareWays(_wayProperties, readWay); } [Fact] public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-way-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; Assert.Null(readWay.Metadata); @@ -246,61 +246,61 @@ public void Read_SkipsWayMetadataIfProcessMetadataIsFalse_NoCompresion() [Fact] public void Read_ReadsWayWithoutNodes_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-way-without-nodes.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-way-without-nodes.pbf"), new OsmReaderSettings() { ReadMetadata = false }); WayInfo readWay = target.Read() as WayInfo; - this.CompareWays(_wayWithoutNodes, readWay); + CompareWays(_wayWithoutNodes, readWay); } [Fact] public void Read_ReadsRelationWithNode_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-relation-node.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationNode, readRelation); + CompareRelation(_relationNode, readRelation); } [Fact] public void Read_ReadsRelationWithWay_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-relation-way.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationWay, readRelation); + CompareRelation(_relationWay, readRelation); } [Fact] public void Read_ReadsRelationWithRelation_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-relation.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-relation-relation.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationRelation, readRelation); + CompareRelation(_relationRelation, readRelation); } [Fact] public void Read_ReadsRelationWithTags_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-relation-tags.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationTags, readRelation); + CompareRelation(_relationTags, readRelation); } [Fact] public void Read_ReadsRelationWithAllProperties_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = true }); RelationInfo readRelation = target.Read() as RelationInfo; - this.CompareRelation(_relationProperties, readRelation); + CompareRelation(_relationProperties, readRelation); } [Fact] public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion() { - PbfReader target = new PbfReader(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); + PbfReader target = new(TestDataReader.OpenPbf("pbf-n-relation-all-properties.pbf"), new OsmReaderSettings() { ReadMetadata = false }); RelationInfo readRelation = target.Read() as RelationInfo; Assert.Null(readRelation.Metadata); @@ -310,10 +310,10 @@ public void Read_SkipsRelationMetadataIfProcessMetadataIsFalse_NoCompresion() public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = Path.Combine("..", "..", "..", "Data", "Pbf", "pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; + OsmReaderSettings settings = new() { ReadMetadata = true }; var aaa = Path.GetFullPath(filename); - PbfReader target = new PbfReader(filename, settings); + PbfReader target = new(filename, settings); target.Dispose(); FileStream testStream = null; @@ -325,9 +325,9 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() public void Dispose_ClosesOutputStreamIfWritingToStream() { var stream = TestDataReader.OpenPbf("pbf-n-node.pbf"); - OsmReaderSettings settings = new OsmReaderSettings() { ReadMetadata = true }; + OsmReaderSettings settings = new() { ReadMetadata = true }; - PbfReader target = new PbfReader(stream, settings); + PbfReader target = new(stream, settings); target.Dispose(); Assert.False(stream.CanRead); @@ -339,8 +339,8 @@ private void CompareNodes(NodeInfo expected, NodeInfo actual) Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareWays(WayInfo expected, WayInfo actual) @@ -352,8 +352,8 @@ private void CompareWays(WayInfo expected, WayInfo actual) Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareRelation(RelationInfo expected, RelationInfo actual) @@ -365,8 +365,8 @@ private void CompareRelation(RelationInfo expected, RelationInfo actual) Assert.Equal(expected.Members[i], actual.Members[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareTags(TagsCollection expected, TagsCollection actual) diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs index 7563d8a..b00c863 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs @@ -11,7 +11,7 @@ public class PbfWriterSettingsTests [Fact] public void Constructor__SetsDefaultValues() { - PbfWriterSettings target = new PbfWriterSettings(); + PbfWriterSettings target = new(); Assert.True(target.UseDenseFormat); Assert.Equal(CompressionMode.ZlibDeflate, target.Compression); @@ -21,7 +21,7 @@ public void Constructor__SetsDefaultValues() [Fact] public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - PbfWriterSettings target = new PbfWriterSettings(); + PbfWriterSettings target = new(); target.IsReadOnly = true; Assert.Throws(() => target.UseDenseFormat = false); @@ -30,7 +30,7 @@ public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOn [Fact] public void ConpressionSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - PbfWriterSettings target = new PbfWriterSettings(); + PbfWriterSettings target = new(); target.IsReadOnly = true; Assert.Throws(() => target.Compression = CompressionMode.ZlibDeflate); diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs index f9ac92c..a35cb16 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs @@ -33,22 +33,22 @@ public PbfWriterTests() }; _node = new NodeInfo(1, 50.4, 16.2, new TagsCollection()); - _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") })); + _nodeTags = new NodeInfo(1, 50.4, 16.2, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") })); _nodeProperties = new NodeInfo(1, 50.4, 16.2, new TagsCollection(), _details); _way = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }); - _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), new long[] { 10, 11, 12 }); + _wayTags = new WayInfo(1, new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), new long[] { 10, 11, 12 }); _wayProperties = new WayInfo(1, new TagsCollection(), new long[] { 10, 11, 12 }, _details); _wayWithoutNodes = new WayInfo(1, new TagsCollection(), new long[] { }); - _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); - _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); + _relationNode = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationWay = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Way, Reference = 10, Role = "test" } }); + _relationRelation = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Relation, Reference = 10, Role = "test" } }); _relationTags = new RelationInfo( 1, - new TagsCollection(new Tag[] { new Tag("name", "test"), new Tag("name-2", "test-2") }), - new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); - _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); + new TagsCollection(new Tag[] { new("name", "test"), new("name-2", "test-2") }), + new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }); + _relationNodeProperties = new RelationInfo(1, new TagsCollection(), new RelationMemberInfo[] { new() { MemberType = EntityType.Node, Reference = 10, Role = "test" } }, _details); } [Fact] @@ -56,8 +56,8 @@ public void Constructor_FilenameSettings_SetsSettingsAndMakesThemReadOnly() { string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-test.pbf"); - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) + PbfWriterSettings settings = new(); + using (PbfWriter target = new(filename, settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -69,8 +69,8 @@ public void Constructor_FilenameSettings_CreatesOutputFile() { string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-creates-output-test.pbf"); - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) + PbfWriterSettings settings = new(); + using (PbfWriter target = new(filename, settings)) { ; } @@ -83,21 +83,21 @@ public void Constructor_FilenameSettings_WritesOsmHeader() { string filename = PathHelper.GetTempFilePath("pbfwriter-constructor-writes-header-test.pbf"); - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(filename, settings)) + PbfWriterSettings settings = new(); + using (PbfWriter target = new(filename, settings)) { ; } - FileInfo fi = new FileInfo(filename); + FileInfo fi = new(filename); Assert.True(fi.Length > 0); } [Fact] public void Constructor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(new MemoryStream(), settings)) + PbfWriterSettings settings = new(); + using (PbfWriter target = new(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -107,9 +107,9 @@ public void Constructor_StreamSettings_SetsSettingsAndMakeThemReadOnly() [Fact] public void Constructor_StreamSettings_WritesOsmHeader() { - MemoryStream stream = new MemoryStream(); - PbfWriterSettings settings = new PbfWriterSettings(); - using (PbfWriter target = new PbfWriter(stream, settings)) + MemoryStream stream = new(); + PbfWriterSettings settings = new(); + using (PbfWriter target = new(stream, settings)) { ; } @@ -122,8 +122,8 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = PathHelper.GetTempFilePath("pbfwriter-closes-output-filestream-test.pbf"); - PbfWriterSettings settings = new PbfWriterSettings(); - PbfWriter target = new PbfWriter(filename, settings); + PbfWriterSettings settings = new(); + PbfWriter target = new(filename, settings); target.Dispose(); new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); @@ -132,7 +132,7 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() [Fact] public void Write_ThrowsArgumentExceptionIfWriteMetadataIsTrueButEntityDoesntHaveMetadata() { - using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) + using (PbfWriter target = new(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) { Assert.Throws(() => target.Write(_node)); } @@ -143,7 +143,7 @@ public void Write_ThrowsArgumentNullExceptionIfMetadataContainsNullInsteadUserna { _nodeProperties.Metadata.User = null; - using (PbfWriter target = new PbfWriter(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) + using (PbfWriter target = new(new MemoryStream(), new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true })) { Assert.Throws(() => target.Write(_nodeProperties)); } @@ -152,308 +152,308 @@ public void Write_ThrowsArgumentNullExceptionIfMetadataContainsNullInsteadUserna [Fact] public void Write_IEntityInfo_WritesNode() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_node); } - this.TestPbfOutput(stream, _node); + TestPbfOutput(stream, _node); } [Fact] public void Write_IEntityInfo_WritesNodeWithTags() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_nodeTags); } - this.TestPbfOutput(stream, _nodeTags); + TestPbfOutput(stream, _nodeTags); } [Fact] public void Write_IEntityInfo_WritesNodeWithMetadata() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_nodeProperties); } - this.TestPbfOutput(stream, _nodeProperties); + TestPbfOutput(stream, _nodeProperties); } [Fact] public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_nodeProperties); } - this.TestPbfOutput(stream, _node); + TestPbfOutput(stream, _node); } [Fact] public void Write_IEntityInfo_WritesNode_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_node); } - this.TestPbfOutput(stream, _node); + TestPbfOutput(stream, _node); } [Fact] public void Write_IEntityInfo_WritesNodeWithTags_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_nodeTags); } - this.TestPbfOutput(stream, _nodeTags); + TestPbfOutput(stream, _nodeTags); } [Fact] public void Write_IEntityInfo_WritesNodeWithMetadata_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_nodeProperties); } - this.TestPbfOutput(stream, _nodeProperties); + TestPbfOutput(stream, _nodeProperties); } [Fact] public void Write_IEntityInfo_DoesntWritesNodeMetadataIfWriteMetasdataSettingsIsFalse_Dense() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = true, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_nodeProperties); } - this.TestPbfOutput(stream, _node); + TestPbfOutput(stream, _node); } [Fact] public void Write_IEntityInfo_WritesWay() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_way); } - this.TestPbfOutput(stream, _way); + TestPbfOutput(stream, _way); } [Fact] public void Write_IEntityInfo_WritesWayWithTags() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_wayTags); } - this.TestPbfOutput(stream, _wayTags); + TestPbfOutput(stream, _wayTags); } [Fact] public void Write_IEntityInfo_WritesWayWithMetadata() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_wayProperties); } - this.TestPbfOutput(stream, _wayProperties); + TestPbfOutput(stream, _wayProperties); } [Fact] public void Write_IEntityInfo_DoesntWriteWayMetadataIfWriteMetadataSettingsIsFalse() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_wayProperties); } - this.TestPbfOutput(stream, _way); + TestPbfOutput(stream, _way); } [Fact] public void Write_IEntityInfo_WritesRelationWithNode() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_relationNode); } - this.TestPbfOutput(stream, _relationNode); + TestPbfOutput(stream, _relationNode); } [Fact] public void Write_IEntityInfo_WritesRelationWithWay() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_relationWay); } - this.TestPbfOutput(stream, _relationWay); + TestPbfOutput(stream, _relationWay); } [Fact] public void Write_IEntityInfo_WritesRelationWithRelation() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_relationRelation); } - this.TestPbfOutput(stream, _relationRelation); + TestPbfOutput(stream, _relationRelation); } [Fact] public void Write_IEntityInfo_WritesRelationWithTags() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_relationTags); } - this.TestPbfOutput(stream, _relationTags); + TestPbfOutput(stream, _relationTags); } [Fact] public void Write_IEntityInfo_WritesRelationWithMetadata() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = true }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_relationNodeProperties); } - this.TestPbfOutput(stream, _relationNodeProperties); + TestPbfOutput(stream, _relationNodeProperties); } [Fact] public void Write_IEntityInfo_DoesntWritesRelationMetadataIfWriteMetasdataSettingsIsFalse() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(_relationNodeProperties); } - this.TestPbfOutput(stream, _relationNode); + TestPbfOutput(stream, _relationNode); } [Fact] public void Write_IOsmGeometry_WritesNode() { - Node node = new Node(1, 11.1, 12.1); - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + Node node = new(1, 11.1, 12.1); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(node); } - this.TestPbfOutput(stream, new NodeInfo(node)); + TestPbfOutput(stream, new NodeInfo(node)); } [Fact] public void Write_IOsmGeometry_WritesWay() { - Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }); - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + Way way = new(10, new Node[] { new(1), new(2), new(3) }); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(way); } - this.TestPbfOutput(stream, new WayInfo(way)); + TestPbfOutput(stream, new WayInfo(way)); } [Fact] public void Write_IOsmGeometry_WritesRelation() { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1), "test-role") }); + Relation relation = new(100, new RelationMember[] { new(new Node(1), "test-role") }); - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { target.Write(relation); } - this.TestPbfOutput(stream, new RelationInfo(relation)); + TestPbfOutput(stream, new RelationInfo(relation)); } [Fact] public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() { - PbfWriterSettings settings = new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; - MemoryStream stream = new MemoryStream(); + PbfWriterSettings settings = new() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }; + MemoryStream stream = new(); - using (PbfWriter target = new PbfWriter(stream, settings)) + using (PbfWriter target = new(stream, settings)) { IOsmGeometry entity = null; Assert.Throws(() => target.Write(entity)); @@ -463,14 +463,14 @@ public void Write_IOsmGeometry_ThrowsExceptionIfEntityIsNull() [Fact] public void Flush_ForcesWriterToWriteDataToUnderalyingStorage() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - PbfWriter target = new PbfWriter(stream, new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }); + PbfWriter target = new(stream, new PbfWriterSettings() { UseDenseFormat = false, Compression = CompressionMode.None, WriteMetadata = false }); //1000 nodes should fit into tokens for (int i = 0; i < 1000; i++) { - NodeInfo node = new NodeInfo(i, 45.87, -126.5, new TagsCollection()); + NodeInfo node = new(i, 45.87, -126.5, new TagsCollection()); target.Write(node); } int minimalExpectedLengthIncrease = 1000 * 8; @@ -492,14 +492,14 @@ private void TestPbfOutput(MemoryStream pbfStream, IEntityInfo expected) pbfStream = new MemoryStream(pbfStream.ToArray()); } - PbfReader reader = new PbfReader(pbfStream, new OsmReaderSettings() { ReadMetadata = true }); + PbfReader reader = new(pbfStream, new OsmReaderSettings() { ReadMetadata = true }); IEntityInfo read = reader.Read(); switch (expected.EntityType) { - case EntityType.Node: this.CompareNodes(expected as NodeInfo, read as NodeInfo); break; - case EntityType.Way: this.CompareWays(expected as WayInfo, read as WayInfo); break; - case EntityType.Relation: this.CompareRelation(expected as RelationInfo, read as RelationInfo); break; + case EntityType.Node: CompareNodes(expected as NodeInfo, read as NodeInfo); break; + case EntityType.Way: CompareWays(expected as WayInfo, read as WayInfo); break; + case EntityType.Relation: CompareRelation(expected as RelationInfo, read as RelationInfo); break; } } @@ -509,8 +509,8 @@ private void CompareNodes(NodeInfo expected, NodeInfo actual) Assert.InRange(actual.Longitude, expected.Longitude - _resolution, expected.Longitude + _resolution); Assert.InRange(actual.Latitude, expected.Latitude - _resolution, expected.Latitude + _resolution); - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareWays(WayInfo expected, WayInfo actual) @@ -522,8 +522,8 @@ private void CompareWays(WayInfo expected, WayInfo actual) Assert.Equal(expected.Nodes[i], actual.Nodes[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareRelation(RelationInfo expected, RelationInfo actual) @@ -535,8 +535,8 @@ private void CompareRelation(RelationInfo expected, RelationInfo actual) Assert.Equal(expected.Members[i], actual.Members[i]); } - this.CompareTags(expected.Tags, actual.Tags); - this.CompareEntityDetails(expected.Metadata, actual.Metadata); + CompareTags(expected.Tags, actual.Tags); + CompareEntityDetails(expected.Metadata, actual.Metadata); } private void CompareTags(TagsCollection expected, TagsCollection actual) diff --git a/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs b/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs index fbe89b9..76369f1 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Pbf/OsmosisIntegrationTests.cs @@ -1,12 +1,11 @@ -using System.Collections.Generic; +using SpatialLite.Osm; +using SpatialLite.Osm.IO; +using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; - -using Xunit; - -using SpatialLite.Osm; -using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; +using Xunit; namespace Tests.SpatialLite.Osm.Integration.Pbf; @@ -21,12 +20,12 @@ public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseNoCompression() { string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file.pbf"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=none", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-pbf file={1} usedense=false compress=none", PathHelper.RealPbfFilePath, pbfFile); + CallOsmosis(osmosisArguments); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } @@ -35,12 +34,12 @@ public void PbfReaderReadsFilesCreatedByOsmosis_DenseNoCompression() { var pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-d.pbf"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=none", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-pbf file={1} usedense=true compress=none", PathHelper.RealPbfFilePath, pbfFile); + CallOsmosis(osmosisArguments); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } @@ -49,12 +48,12 @@ public void PbfReaderReadsFilesCreatedByOsmosis_NoDenseDeflateCompression() { string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-c.pbf"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=false compress=deflate", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-pbf file={1} usedense=false compress=deflate", PathHelper.RealPbfFilePath, pbfFile); + CallOsmosis(osmosisArguments); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } @@ -63,12 +62,12 @@ public void PbfReaderReadsFilesCreatedByOsmosis_DenseDeflate() { string pbfFile = PathHelper.GetTempFilePath("pbfreader-osmosis-compatibility-test-osmosis-real-file-dc.pbf"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-pbf file={1} usedense=true compress=deflate", PathHelper.RealPbfFilePath, pbfFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-pbf file={1} usedense=true compress=deflate", PathHelper.RealPbfFilePath, pbfFile); + CallOsmosis(osmosisArguments); - using (PbfReader reader = new PbfReader(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(pbfFile, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } @@ -77,17 +76,17 @@ public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseNoCompression() { string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file.pbf"); - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) + using (PbfWriter writer = new(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) { - foreach (var entityInfo in this.GetTestData()) + foreach (var entityInfo in GetTestData()) { writer.Write(entityInfo); } } string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + CallOsmosis(osmosisArguments); Assert.True(File.Exists(osmosisXmlFile)); Assert.True(new FileInfo(osmosisXmlFile).Length > 0); @@ -98,17 +97,17 @@ public void PbfWriterWritesFilesCompatibleWithOsmosis_NoDenseDeflate() { string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-c.pbf"); - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = false })) + using (PbfWriter writer = new(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = false })) { - foreach (var entityInfo in this.GetTestData()) + foreach (var entityInfo in GetTestData()) { writer.Write(entityInfo); } } string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + CallOsmosis(osmosisArguments); Assert.True(File.Exists(osmosisXmlFile)); Assert.True(new FileInfo(osmosisXmlFile).Length > 0); @@ -119,17 +118,17 @@ public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseNoCompression() { string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-d.pbf"); - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = true })) + using (PbfWriter writer = new(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = true })) { - foreach (var entityInfo in this.GetTestData()) + foreach (var entityInfo in GetTestData()) { writer.Write(entityInfo); } } string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + CallOsmosis(osmosisArguments); Assert.True(File.Exists(osmosisXmlFile)); Assert.True(new FileInfo(osmosisXmlFile).Length > 0); @@ -140,17 +139,17 @@ public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate() { string pbfFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-pbfwriter-real-file-dc.pbf"); - using (PbfWriter writer = new PbfWriter(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + using (PbfWriter writer = new(pbfFile, new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { - foreach (var entityInfo in this.GetTestData()) + foreach (var entityInfo in GetTestData()) { writer.Write(entityInfo); } } string osmosisXmlFile = PathHelper.GetTempFilePath("pbfwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-xml file={1}", pbfFile, osmosisXmlFile); + CallOsmosis(osmosisArguments); Assert.True(File.Exists(osmosisXmlFile)); Assert.True(new FileInfo(osmosisXmlFile).Length > 0); @@ -158,7 +157,7 @@ public void PbfWriterWritesFilesCompatibleWithOsmosis_DenseDeflate() private void CallOsmosis(string arguments) { - ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); + ProcessStartInfo osmosisInfo = new(PathHelper.OsmosisPath); osmosisInfo.Arguments = arguments; Process osmosis = Process.Start(osmosisInfo); @@ -169,8 +168,8 @@ private void CallOsmosis(string arguments) private void TestReader(IOsmReader reader) { - IEntityInfo info = null; int nodesCount = 0, waysCount = 0, relationsCount = 0; + IEntityInfo info; while ((info = reader.Read()) != null) { switch (info.EntityType) @@ -188,11 +187,11 @@ private void TestReader(IOsmReader reader) private IEnumerable GetTestData() { - List data = new List(); + List data = new(); using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(stream, new OsmReaderSettings() { ReadMetadata = true })) { IEntityInfo info = null; while ((info = reader.Read()) != null) diff --git a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs index bde6b0f..046de3b 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs @@ -18,11 +18,11 @@ public class PbfReaderPbfWriterComplianceTests [Fact, Trait("Category", "Osm.Integration")] public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseNoCompression() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.None })) + using (PbfWriter writer = new(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.None })) { - foreach (var info in this.GetTestData()) + foreach (var info in GetTestData()) { writer.Write(info); } @@ -30,9 +30,9 @@ public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseNoCompression() writer.Flush(); stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } } @@ -40,11 +40,11 @@ public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseNoCompression() [Fact, Trait("Category", "Osm.Integration")] public void PbfReaderCanReadFileCreatedByPbfWriter_DenseNoCompression() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.None })) + using (PbfWriter writer = new(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.None })) { - foreach (var info in this.GetTestData()) + foreach (var info in GetTestData()) { writer.Write(info); } @@ -52,9 +52,9 @@ public void PbfReaderCanReadFileCreatedByPbfWriter_DenseNoCompression() writer.Flush(); stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } } @@ -62,11 +62,11 @@ public void PbfReaderCanReadFileCreatedByPbfWriter_DenseNoCompression() [Fact, Trait("Category", "Osm.Integration")] public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.ZlibDeflate })) + using (PbfWriter writer = new(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = false, Compression = CompressionMode.ZlibDeflate })) { - foreach (var info in this.GetTestData()) + foreach (var info in GetTestData()) { writer.Write(info); } @@ -74,9 +74,9 @@ public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate() writer.Flush(); stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } } @@ -84,11 +84,11 @@ public void PbfReaderCanReadFileCreatedByPbfWriter_NoDenseDeflate() [Fact, Trait("Category", "Osm.Integration")] public void PbfReaderCanReadFileCreatedByPbfWriter_DenseDeflate() { - MemoryStream stream = new MemoryStream(); + MemoryStream stream = new(); - using (PbfWriter writer = new PbfWriter(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.ZlibDeflate })) + using (PbfWriter writer = new(stream, new PbfWriterSettings() { WriteMetadata = true, UseDenseFormat = true, Compression = CompressionMode.ZlibDeflate })) { - foreach (var info in this.GetTestData()) + foreach (var info in GetTestData()) { writer.Write(info); } @@ -96,9 +96,9 @@ public void PbfReaderCanReadFileCreatedByPbfWriter_DenseDeflate() writer.Flush(); stream.Seek(0, SeekOrigin.Begin); - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(stream, new OsmReaderSettings() { ReadMetadata = true })) { - this.TestReader(reader); + TestReader(reader); } } } @@ -124,11 +124,11 @@ private void TestReader(IOsmReader reader) private IEnumerable GetTestData() { - List data = new List(); + List data = new(); using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(stream, new OsmReaderSettings() { ReadMetadata = true })) { IEntityInfo info = null; while ((info = reader.Read()) != null) diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs index 0b2dc99..b5db2c7 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs @@ -14,7 +14,7 @@ public class OsmDatabaseTests [Fact, Trait("Category", "Osm.Integration")] public void OsmEntityInfoDatabase_LoadesRealFile() { - OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmXmlReader reader = new(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); Assert.Equal(6688, target.Nodes.Count); @@ -25,7 +25,7 @@ public void OsmEntityInfoDatabase_LoadesRealFile() [Fact, Trait("Category", "Osm.Integration")] public void OsmGeometryDatabase_LoadesRealFile() { - OsmXmlReader reader = new OsmXmlReader(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); + OsmXmlReader reader = new(TestDataReader.OpenXml("osm-real-file.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); Assert.Equal(6688, target.Nodes.Count); diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs index 9981ae6..6a75775 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs @@ -7,6 +7,7 @@ using SpatialLite.Osm; using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; +using System.Globalization; namespace Tests.SpatialLite.Osm.Integration.Xml; @@ -21,12 +22,12 @@ public class OsmosisIntegrationTests public void XmlOsmReaderReadsFilesCreatedByOsmosis() { string xmlFile = PathHelper.GetTempFilePath("xmlreader-osmosis-compatibility-test-osmosis-real-file.osm"); - string osmosisArguments = string.Format("--read-pbf file={0} --write-xml file={1}", PathHelper.RealPbfFilePath, xmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-pbf file={0} --write-xml file={1}", PathHelper.RealPbfFilePath, xmlFile); + CallOsmosis(osmosisArguments); - using (OsmXmlReader reader = new OsmXmlReader(xmlFile, new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false })) + using (OsmXmlReader reader = new(xmlFile, new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = false })) { - this.TestReader(reader); + TestReader(reader); } } @@ -34,17 +35,17 @@ public void XmlOsmReaderReadsFilesCreatedByOsmosis() public void XmlOsmWriterWritesFilesCompatibleWithOsmosis() { string xmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-xmlwriter-real-file.osm"); - using (OsmXmlWriter writer = new OsmXmlWriter(xmlFile, new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter writer = new(xmlFile, new OsmWriterSettings() { WriteMetadata = true })) { - foreach (var entityInfo in this.GetTestData()) + foreach (var entityInfo in GetTestData()) { writer.Write(entityInfo); } } string osmosisXmlFile = PathHelper.GetTempFilePath("xmlwriter-osmosis-compatibility-test-test-file.osm"); - string osmosisArguments = string.Format("--read-xml file={0} --write-xml file={1}", xmlFile, osmosisXmlFile); - this.CallOsmosis(osmosisArguments); + string osmosisArguments = string.Format(CultureInfo.InvariantCulture, "--read-xml file={0} --write-xml file={1}", xmlFile, osmosisXmlFile); + CallOsmosis(osmosisArguments); Assert.True(File.Exists(osmosisXmlFile)); Assert.True(new FileInfo(osmosisXmlFile).Length > 0); @@ -52,11 +53,11 @@ public void XmlOsmWriterWritesFilesCompatibleWithOsmosis() private IEnumerable GetTestData() { - List data = new List(); + List data = new(); using (var stream = TestDataReader.OpenPbf("pbf-real-file.pbf")) { - using (PbfReader reader = new PbfReader(stream, new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new(stream, new OsmReaderSettings() { ReadMetadata = true })) { IEntityInfo info = null; while ((info = reader.Read()) != null) @@ -71,7 +72,7 @@ private IEnumerable GetTestData() private void CallOsmosis(string arguments) { - ProcessStartInfo osmosisInfo = new ProcessStartInfo(PathHelper.OsmosisPath); + ProcessStartInfo osmosisInfo = new(PathHelper.OsmosisPath); osmosisInfo.Arguments = arguments; Process osmosis = Process.Start(osmosisInfo); @@ -82,8 +83,8 @@ private void CallOsmosis(string arguments) private void TestReader(IOsmReader reader) { - IEntityInfo info = null; int nodesCount = 0, waysCount = 0, relationsCount = 0; + IEntityInfo info; while ((info = reader.Read()) != null) { switch (info.EntityType) diff --git a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs index 5a330f1..7de95ae 100644 --- a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs @@ -16,9 +16,9 @@ public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() int id = 15; double latitude = 15.4; double longitude = -23.7; - TagsCollection tags = new TagsCollection(); + TagsCollection tags = new(); - NodeInfo target = new NodeInfo(id, latitude, longitude, tags); + NodeInfo target = new(id, latitude, longitude, tags); Assert.Equal(EntityType.Node, target.EntityType); Assert.Equal(id, target.ID); @@ -34,10 +34,10 @@ public void Constructor_Properties_SetsProperties() int id = 15; double latitude = 15.4; double longitude = -23.7; - TagsCollection tags = new TagsCollection(); - EntityMetadata details = new EntityMetadata(); + TagsCollection tags = new(); + EntityMetadata details = new(); - NodeInfo target = new NodeInfo(id, latitude, longitude, tags, details); + NodeInfo target = new(id, latitude, longitude, tags, details); Assert.Equal(EntityType.Node, target.EntityType); Assert.Equal(id, target.ID); @@ -50,9 +50,9 @@ public void Constructor_Properties_SetsProperties() [Fact] public void Constructor_Node_SetsProperties() { - Node node = new Node(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; + Node node = new(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; - NodeInfo target = new NodeInfo(node); + NodeInfo target = new(node); Assert.Equal(node.ID, target.ID); Assert.Equal(node.Position.X, target.Longitude); diff --git a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs index a97bd67..11598e6 100644 --- a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs @@ -28,8 +28,8 @@ public OsmDatabaseTests() _wayData[1] = new Way(2, _nodeData.Skip(1)); _relationData = new Relation[2]; - _relationData[0] = new Relation(1, new RelationMember[] { new RelationMember(_wayData[0], "way"), new RelationMember(_nodeData[0], "node") }); - _relationData[1] = new Relation(2, new RelationMember[] { new RelationMember(_relationData[0], "relation"), new RelationMember(_nodeData[0], "node") }); + _relationData[0] = new Relation(1, new RelationMember[] { new(_wayData[0], "way"), new(_nodeData[0], "node") }); + _relationData[1] = new Relation(2, new RelationMember[] { new(_relationData[0], "relation"), new(_nodeData[0], "node") }); _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); } @@ -37,7 +37,7 @@ public OsmDatabaseTests() [Fact] public void Constructor__CreatesEmptyDatabase() { - OsmDatabase target = new OsmDatabase(); + OsmDatabase target = new(); Assert.Empty(target); Assert.Empty(target.Nodes); @@ -48,7 +48,7 @@ public void Constructor__CreatesEmptyDatabase() [Fact] public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); for (int i = 0; i < _data.Length; i++) { @@ -59,7 +59,7 @@ public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() [Fact] public void Constructor_IEnumerable_AddEnittiesToCorrectCollections() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); for (int i = 0; i < _nodeData.Length; i++) { @@ -80,7 +80,7 @@ public void Constructor_IEnumerable_AddEnittiesToCorrectCollections() [Fact] public void Count_ReturnsNumberOfAllEntities() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.Equal(_data.Length, target.Count); } @@ -88,7 +88,7 @@ public void Count_ReturnsNumberOfAllEntities() [Fact] public void IsReadOnly_ReturnsFalse() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.False(target.IsReadOnly); } @@ -96,7 +96,7 @@ public void IsReadOnly_ReturnsFalse() [Fact] public void Item_ReturnsNullIfIDIsNotPresentInCollection() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.Null(target[10000, EntityType.Node]); } @@ -104,7 +104,7 @@ public void Item_ReturnsNullIfIDIsNotPresentInCollection() [Fact] public void Item_ReturnsNodeWithSpecificID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); IOsmGeometry entity = target[_nodeData[0].ID, EntityType.Node]; Assert.Same(_nodeData[0], entity); @@ -113,7 +113,7 @@ public void Item_ReturnsNodeWithSpecificID() [Fact] public void Item_ReturnsWayWithSpecificID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); IOsmGeometry entity = target[_wayData[0].ID, EntityType.Way]; Assert.Same(_wayData[0], entity); @@ -122,7 +122,7 @@ public void Item_ReturnsWayWithSpecificID() [Fact] public void Item_ReturnsRelationWithSpecificID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); IOsmGeometry entity = target[_relationData[0].ID, EntityType.Relation]; Assert.Same(_relationData[0], entity); @@ -131,7 +131,7 @@ public void Item_ReturnsRelationWithSpecificID() [Fact] public void Add_AddsNodeToCollection() { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + OsmDatabase target = new(_nodeData.Skip(1)); target.Add(_nodeData[0]); Assert.Contains(_nodeData[0], target); @@ -140,7 +140,7 @@ public void Add_AddsNodeToCollection() [Fact] public void Add_AddsWayToCollection() { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + OsmDatabase target = new(_wayData.Skip(1)); target.Add(_wayData[0]); Assert.Contains(_wayData[0], target); @@ -149,7 +149,7 @@ public void Add_AddsWayToCollection() [Fact] public void Add_AddsRelationToCollection() { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + OsmDatabase target = new(_relationData.Skip(1)); target.Add(_relationData[0]); Assert.Contains(_relationData[0], target); @@ -158,7 +158,7 @@ public void Add_AddsRelationToCollection() [Fact] public void Add_ThrowsArgumentNullExceptionIfItemIsNull() { - OsmDatabase target = new OsmDatabase(); + OsmDatabase target = new(); Assert.Throws(() => target.Add(null)); } @@ -166,7 +166,7 @@ public void Add_ThrowsArgumentNullExceptionIfItemIsNull() [Fact] public void Add_ThrowsExceptionWhenAddingDuplicateID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.Throws(() => target.Add(_data[0])); } @@ -174,7 +174,7 @@ public void Add_ThrowsExceptionWhenAddingDuplicateID() [Fact] public void Clear_RemovesAllItemsFromCollection() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); target.Clear(); Assert.Empty(target); @@ -186,7 +186,7 @@ public void Clear_RemovesAllItemsFromCollection() [Fact] public void Contains_IOsmGeometry_ReturnsFalseForNull() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.DoesNotContain(null, target); } @@ -194,7 +194,7 @@ public void Contains_IOsmGeometry_ReturnsFalseForNull() [Fact] public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainNode() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.DoesNotContain(new Node(10000), target); } @@ -202,7 +202,7 @@ public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainNode() [Fact] public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsNode() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.Contains(_nodeData[0], target); } @@ -210,7 +210,7 @@ public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsNode() [Fact] public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainWay() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.DoesNotContain(new Way(10000), target); } @@ -218,7 +218,7 @@ public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainWay() [Fact] public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsWay() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.Contains(_wayData[0], target); } @@ -226,7 +226,7 @@ public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsWay() [Fact] public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainRelation() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.DoesNotContain(new Relation(10000), target); } @@ -234,7 +234,7 @@ public void Contains_IOsmGeometry_ReturnsFalseIfCollectionDoesNotContainRelation [Fact] public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsRelation() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.Contains(_relationData[0], target); } @@ -242,7 +242,7 @@ public void Contains_IOsmGeometry_ReturnsTrueIfCollectionContainsRelation() [Fact] public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainNodeID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.False(target.Contains(10000, EntityType.Node)); } @@ -250,7 +250,7 @@ public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainNodeID() [Fact] public void Contains_ID_ReturnsTrueIfCollectionContainsNodeID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.True(target.Contains(_nodeData[0].ID, EntityType.Node)); } @@ -258,7 +258,7 @@ public void Contains_ID_ReturnsTrueIfCollectionContainsNodeID() [Fact] public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainWayID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.False(target.Contains(10000, EntityType.Way)); } @@ -266,7 +266,7 @@ public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainWayID() [Fact] public void Contains_ID_ReturnsTrueIfCollectionContainsWayID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.True(target.Contains(_wayData[0].ID, EntityType.Way)); } @@ -274,7 +274,7 @@ public void Contains_ID_ReturnsTrueIfCollectionContainsWayID() [Fact] public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainRelationID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.False(target.Contains(10000, EntityType.Relation)); } @@ -282,7 +282,7 @@ public void Contains_ID_ReturnsFalseIfCollectionDoesNotContainRelationID() [Fact] public void Contains_ID_ReturnsTrueIfCollectionContainsRelationID() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); Assert.True(target.Contains(_relationData[0].ID, EntityType.Relation)); } @@ -290,7 +290,7 @@ public void Contains_ID_ReturnsTrueIfCollectionContainsRelationID() [Fact] public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); bool callResult = target.Remove(null); @@ -300,7 +300,7 @@ public void Remove_IOsmGeometry_ReturnsFalseIfItemIsNull() [Fact] public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + OsmDatabase target = new(_nodeData.Skip(1)); bool callResult = target.Remove(_nodeData[0]); @@ -312,7 +312,7 @@ public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNot [Fact] public void Remove_IOsmGeometry_ReturnsTrueAndRemovesNodeFromCollection() { - OsmDatabase target = new OsmDatabase(_nodeData); + OsmDatabase target = new(_nodeData); bool callResult = target.Remove(_data[0]); @@ -325,7 +325,7 @@ public void Remove_IOsmGeometry_ReturnsTrueAndRemovesNodeFromCollection() [Fact] public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + OsmDatabase target = new(_wayData.Skip(1)); bool callResult = target.Remove(_wayData[0]); @@ -336,7 +336,7 @@ public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotP [Fact] public void Remove_IOsmGeometry_ReturnsTrueAndRemovesWayFromCollection() { - OsmDatabase target = new OsmDatabase(_wayData); + OsmDatabase target = new(_wayData); bool callResult = target.Remove(_wayData[0]); @@ -348,7 +348,7 @@ public void Remove_IOsmGeometry_ReturnsTrueAndRemovesWayFromCollection() [Fact] public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + OsmDatabase target = new(_relationData.Skip(1)); bool callResult = target.Remove(_relationData[0]); @@ -359,7 +359,7 @@ public void Remove_IOsmGeometry_ReturnsFalseAndDoesntModifyCollectionIfRelationI [Fact] public void Remove_IOsmGeometry_ReturnsTrueAndRemovesRelationFromCollection() { - OsmDatabase target = new OsmDatabase(_relationData); + OsmDatabase target = new(_relationData); bool callResult = target.Remove(_relationData[0]); @@ -371,7 +371,7 @@ public void Remove_IOsmGeometry_ReturnsTrueAndRemovesRelationFromCollection() [Fact] public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() { - OsmDatabase target = new OsmDatabase(_nodeData.Skip(1)); + OsmDatabase target = new(_nodeData.Skip(1)); bool callResult = target.Remove(_nodeData[0].ID, EntityType.Node); @@ -383,7 +383,7 @@ public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfNodeIsNotPresent() [Fact] public void Remove_ID_ReturnsTrueAndRemovesNodeFromCollection() { - OsmDatabase target = new OsmDatabase(_nodeData); + OsmDatabase target = new(_nodeData); bool callResult = target.Remove(_data[0].ID, EntityType.Node); @@ -396,7 +396,7 @@ public void Remove_ID_ReturnsTrueAndRemovesNodeFromCollection() [Fact] public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() { - OsmDatabase target = new OsmDatabase(_wayData.Skip(1)); + OsmDatabase target = new(_wayData.Skip(1)); bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); @@ -407,7 +407,7 @@ public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfWayIsNotPresent() [Fact] public void Remove_ID_ReturnsTrueAndRemovesWayFromCollection() { - OsmDatabase target = new OsmDatabase(_wayData); + OsmDatabase target = new(_wayData); bool callResult = target.Remove(_wayData[0].ID, EntityType.Way); @@ -419,7 +419,7 @@ public void Remove_ID_ReturnsTrueAndRemovesWayFromCollection() [Fact] public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresent() { - OsmDatabase target = new OsmDatabase(_relationData.Skip(1)); + OsmDatabase target = new(_relationData.Skip(1)); bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); @@ -430,7 +430,7 @@ public void Remove_ID_ReturnsFalseAndDoesntModifyCollectionIfRelationIsNotPresen [Fact] public void Remove_ID_ReturnsTrueAndRemovesRelationFromCollection() { - OsmDatabase target = new OsmDatabase(_relationData); + OsmDatabase target = new(_relationData); bool callResult = target.Remove(_relationData[0].ID, EntityType.Relation); @@ -442,7 +442,7 @@ public void Remove_ID_ReturnsTrueAndRemovesRelationFromCollection() [Fact] public void GetEnumerator_ReturnsEnumeratorThatEnumeratesAllEntities() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); IEnumerable result = target; @@ -456,7 +456,7 @@ public void GetEnumerator_ReturnsEnumeratorThatEnumeratesAllEntities() [Fact] public void CopyTo_CopiesEntitiesToArray() { - OsmDatabase target = new OsmDatabase(_data); + OsmDatabase target = new(_data); IOsmGeometry[] array = new IOsmGeometry[_data.Length]; target.CopyTo(array, 0); diff --git a/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs index d07c6bf..d12bf5a 100644 --- a/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmEntityInfoDatabaseTests.cs @@ -1,22 +1,19 @@ -using System.Collections.Generic; -using System.Linq; -using System.IO; - -using Xunit; -using Moq; - +using Moq; using SpatialLite.Osm; using SpatialLite.Osm.IO; +using System.Collections.Generic; +using System.Linq; using Tests.SpatialLite.Osm.Data; +using Xunit; -namespace Tests.SpatialLite.Osm.Geometries; +namespace Tests.SpatialLite.Osm; public class OsmEntityInfoDatabaseTests { - NodeInfo[] _nodeData; - WayInfo[] _wayData; - RelationInfo[] _relationData; - IEntityInfo[] _data; + private readonly NodeInfo[] _nodeData; + private readonly WayInfo[] _wayData; + private readonly RelationInfo[] _relationData; + private readonly IEntityInfo[] _data; public OsmEntityInfoDatabaseTests() { @@ -30,8 +27,8 @@ public OsmEntityInfoDatabaseTests() _wayData[1] = new WayInfo(11, new TagsCollection(), _nodeData.Select(n => n.ID).Skip(1).ToArray()); _relationData = new RelationInfo[2]; - _relationData[0] = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 10, Role = "way" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); - _relationData[1] = new RelationInfo(101, new TagsCollection(), new RelationMemberInfo[] { new RelationMemberInfo() { Reference = 101, Role = "relation" }, new RelationMemberInfo() { Reference = 1, Role = "node" } }); + _relationData[0] = new RelationInfo(100, new TagsCollection(), new RelationMemberInfo[] { new() { Reference = 10, Role = "way" }, new() { Reference = 1, Role = "node" } }); + _relationData[1] = new RelationInfo(101, new TagsCollection(), new RelationMemberInfo[] { new() { Reference = 101, Role = "relation" }, new() { Reference = 1, Role = "node" } }); _data = _nodeData.Concat(_wayData).Concat(_relationData).ToArray(); } @@ -39,7 +36,7 @@ public OsmEntityInfoDatabaseTests() [Fact] public void Constructor__CreatesEmptyDatabase() { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(); + OsmEntityInfoDatabase target = new(); Assert.Empty(target); Assert.Empty(target.Nodes); @@ -50,7 +47,7 @@ public void Constructor__CreatesEmptyDatabase() [Fact] public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + OsmEntityInfoDatabase target = new(_data); for (int i = 0; i < _data.Length; i++) { @@ -61,7 +58,7 @@ public void Constructor_IEnumerable_CreatesCollectionWithSpecifiedItems() [Fact] public void Constructor_IEnumerable_AddEnittiesToCorrextCollections() { - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + OsmEntityInfoDatabase target = new(_data); for (int i = 0; i < _nodeData.Length; i++) { @@ -102,7 +99,7 @@ public void Load_IOsmReader_LoadsWay() Assert.True(target.Nodes.Contains(2)); Assert.True(target.Nodes.Contains(3)); - Assert.Equal(1, target.Ways.Count); + Assert.Single(target.Ways); Assert.True(target.Ways.Contains(10)); } @@ -112,22 +109,22 @@ public void Load_IOsmReader_LoadsRelation() IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmEntityInfoDatabase target = OsmEntityInfoDatabase.Load(reader); - Assert.Equal(1, target.Nodes.Count); + Assert.Single(target.Nodes); Assert.True(target.Nodes.Contains(1)); - Assert.Equal(1, target.Relations.Count); + Assert.Single(target.Relations); Assert.True(target.Relations.Contains(100)); } [Fact] public void Save_CallsIOsmWriterWriteForAllEntities() { - List written = new List(); - Mock writerM = new Mock(); + List written = new(); + Mock writerM = new(); - writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); + writerM.Setup(w => w.Write(It.IsAny())).Callback(written.Add); - OsmEntityInfoDatabase target = new OsmEntityInfoDatabase(_data); + OsmEntityInfoDatabase target = new(_data); target.Save(writerM.Object); Assert.Equal(target.Count, written.Count); diff --git a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs index e9a7a19..f331bf0 100644 --- a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs @@ -15,10 +15,10 @@ public class RelationMemberTests public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() { int id = 45; - TagsCollection tags = new TagsCollection(); - List members = new List(); + TagsCollection tags = new(); + List members = new(); - RelationInfo target = new RelationInfo(id, tags, members); + RelationInfo target = new(id, tags, members); Assert.Equal(EntityType.Relation, target.EntityType); Assert.Equal(id, target.ID); @@ -31,11 +31,11 @@ public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() public void Constructor_Properties_SetsProperties() { int id = 45; - TagsCollection tags = new TagsCollection(); - List members = new List(); - EntityMetadata details = new EntityMetadata(); + TagsCollection tags = new(); + List members = new(); + EntityMetadata details = new(); - RelationInfo target = new RelationInfo(id, tags, members, details); + RelationInfo target = new(id, tags, members, details); Assert.Equal(EntityType.Relation, target.EntityType); Assert.Equal(id, target.ID); @@ -47,9 +47,9 @@ public void Constructor_Properties_SetsProperties() [Fact] public void Constructor_Relation_SetsProperties() { - Relation relation = new Relation(100, new RelationMember[0], new TagsCollection()) { Metadata = new EntityMetadata() }; + Relation relation = new(100, new RelationMember[0], new TagsCollection()) { Metadata = new EntityMetadata() }; - RelationInfo target = new RelationInfo(relation); + RelationInfo target = new(relation); Assert.Equal(relation.ID, target.ID); Assert.Same(relation.Tags, target.Tags); @@ -59,9 +59,9 @@ public void Constructor_Relation_SetsProperties() [Fact] public void Constructor_Relation_SetsRelationMembers() { - Relation relation = new Relation(100, new RelationMember[] { new RelationMember(new Node(1)), new RelationMember(new Node(2)) }, new TagsCollection()) { Metadata = new EntityMetadata() }; + Relation relation = new(100, new RelationMember[] { new(new Node(1)), new(new Node(2)) }, new TagsCollection()) { Metadata = new EntityMetadata() }; - RelationInfo target = new RelationInfo(relation); + RelationInfo target = new(relation); Assert.Equal(relation.Geometries.Count, target.Members.Count); for (int i = 0; i < relation.Geometries.Count; i++) diff --git a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs index 2fd6316..cfa8a89 100644 --- a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs @@ -11,9 +11,9 @@ public class RelationMemberInfoTests [Fact] public void Constructor_RelationMember_SetsProperties() { - RelationMember member = new RelationMember(new Node(1), "test-role"); + RelationMember member = new(new Node(1), "test-role"); - RelationMemberInfo target = new RelationMemberInfo(member); + RelationMemberInfo target = new(member); Assert.Equal(member.Member.ID, target.Reference); Assert.Equal(member.MemberType, target.MemberType); diff --git a/src/Tests.SpatialLite.Osm/TagTests.cs b/src/Tests.SpatialLite.Osm/TagTests.cs index 1c310d6..f630d3c 100644 --- a/src/Tests.SpatialLite.Osm/TagTests.cs +++ b/src/Tests.SpatialLite.Osm/TagTests.cs @@ -15,7 +15,7 @@ public void Constructor_TagValue_SetsKeyAndValue() string key = "test-key"; string value = "test-value"; - Tag target = new Tag(key, value); + Tag target = new(key, value); Assert.Equal(key, target.Key); Assert.Equal(value, target.Value); @@ -51,8 +51,8 @@ public void Constructor_TagValue_ThrowsExceptionIfValueIsNull() [Fact] public void Equals_ReturnTrueForSameKeyAndValue() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "test-value"); + Tag target = new("test-key", "test-value"); + Tag other = new("test-key", "test-value"); Assert.True(target.Equals(other)); } @@ -60,8 +60,8 @@ public void Equals_ReturnTrueForSameKeyAndValue() [Fact] public void Equals_ReturnTrueForSameKeyAndValueAsObject() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "test-value"); + Tag target = new("test-key", "test-value"); + Tag other = new("test-key", "test-value"); Assert.True(target.Equals((object)other)); } @@ -69,8 +69,8 @@ public void Equals_ReturnTrueForSameKeyAndValueAsObject() [Fact] public void Equals_ReturnFalseForDifferentKeys() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("different-key", "test-value"); + Tag target = new("test-key", "test-value"); + Tag other = new("different-key", "test-value"); Assert.False(target.Equals(other)); } @@ -78,8 +78,8 @@ public void Equals_ReturnFalseForDifferentKeys() [Fact] public void Equals_ReturnFalseForDifferentValues() { - Tag target = new Tag("test-key", "test-value"); - Tag other = new Tag("test-key", "different-value"); + Tag target = new("test-key", "test-value"); + Tag other = new("test-key", "different-value"); Assert.False(target.Equals(other)); } @@ -87,7 +87,7 @@ public void Equals_ReturnFalseForDifferentValues() [Fact] public void Equals_ReturnFalseForOtherObject() { - Tag target = new Tag("test-key", "test-value"); + Tag target = new("test-key", "test-value"); string other = "Test"; Assert.False(target.Equals(other)); @@ -96,7 +96,7 @@ public void Equals_ReturnFalseForOtherObject() [Fact] public void Equals_ReturnFalseForNull() { - Tag target = new Tag("test-key", "test-value"); + Tag target = new("test-key", "test-value"); object other = null; Assert.False(target.Equals(other)); diff --git a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs index 492dbd2..e90728c 100644 --- a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs @@ -11,20 +11,20 @@ namespace Tests.SpatialLite.Osm; public class TagsCollectionTests { Tag[] _tags = new Tag[] { - new Tag("test-key-1", "test-value-1"), - new Tag("test-key-2", "test-value-2"), - new Tag("test-key-3", "test-value-3") + new("test-key-1", "test-value-1"), + new("test-key-2", "test-value-2"), + new("test-key-3", "test-value-3") }; Tag[] _tagsDuplicitKeys = new Tag[] { - new Tag("test-key-1", "test-value-1"), - new Tag("test-key-1", "test-value-2") + new("test-key-1", "test-value-1"), + new("test-key-1", "test-value-2") }; [Fact] public void Constructor_CreatesEmptyTagsCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); Assert.Empty(target); } @@ -32,7 +32,7 @@ public void Constructor_CreatesEmptyTagsCollection() [Fact] public void Constructor_IEnumerable_CreatesCollectionWithGivetTags() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Equal(_tags.Count(), target.Count()); Assert.Contains(_tags[0], target); @@ -48,7 +48,7 @@ public void Constructor_IEnumerable_ThrowsExceptionWithDuplicateKeys() [Fact] public void Add_AddsTag() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); target.Add(_tags[0]); Assert.Contains(_tags[0], target); @@ -57,7 +57,7 @@ public void Add_AddsTag() [Fact] public void Add_ThrowsExceptionIfTagAlreadyPresent() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); target.Add(_tagsDuplicitKeys[0]); Assert.Throws(delegate { target.Add(_tagsDuplicitKeys[1]); }); @@ -66,7 +66,7 @@ public void Add_ThrowsExceptionIfTagAlreadyPresent() [Fact] public void Clear_DoesNothingOnEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); target.Clear(); } @@ -74,7 +74,7 @@ public void Clear_DoesNothingOnEmptyCollection() [Fact] public void Clear_RemovesAllItems() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); target.Clear(); Assert.Empty(target); @@ -83,7 +83,7 @@ public void Clear_RemovesAllItems() [Fact] public void Contains_Tag_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); Assert.DoesNotContain(new Tag("key", "value"), target); } @@ -91,16 +91,16 @@ public void Contains_Tag_ReturnsFalseForEmptyCollection() [Fact] public void Contains_Tag_ReturnsFalseIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); - Tag testTag = new Tag("test-key-1", "other-value"); + Tag testTag = new("test-key-1", "other-value"); Assert.DoesNotContain(testTag, target); } [Fact] public void Contains_Tag_ReturnsTrueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Contains(_tags[0], target); } @@ -108,7 +108,7 @@ public void Contains_Tag_ReturnsTrueIfCollectionContainsTag() [Fact] public void Contains_string_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); Assert.False(target.Contains("key")); } @@ -116,7 +116,7 @@ public void Contains_string_ReturnsFalseForEmptyCollection() [Fact] public void Contains_string_ReturnsFalseIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.False(target.Contains("non-existing-key")); } @@ -124,7 +124,7 @@ public void Contains_string_ReturnsFalseIfCollectionDoesNotContainTag() [Fact] public void Contains_string_ReturnsTrueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.True(target.Contains(_tags[0].Key)); } @@ -132,7 +132,7 @@ public void Contains_string_ReturnsTrueIfCollectionContainsTag() [Fact] public void CopyTo_ThrowsArgumentNullExceptionIfArrayIsNull() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Throws(() => target.CopyTo(null, 0)); } @@ -141,7 +141,7 @@ public void CopyTo_ThrowsArgumentNullExceptionIfArrayIsNull() public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero() { Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Throws(() => target.CopyTo(array, -4)); } @@ -150,7 +150,7 @@ public void CopyTo_ThrowsArgumentOutOfRangeExceptionIfIndexIsLessThenZero() public void CopyTo_ThrowsArgumentExceptionIfSpaceDesignedForCollectionInArrayIsShort() { Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Throws(() => target.CopyTo(array, 4)); } @@ -159,7 +159,7 @@ public void CopyTo_ThrowsArgumentExceptionIfSpaceDesignedForCollectionInArrayIsS public void CopyTo_CopiesElementsToArray() { Tag[] array = new Tag[5]; - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); target.CopyTo(array, 1); @@ -173,7 +173,7 @@ public void CopyTo_CopiesElementsToArray() [Fact] public void GetTag_ReturnsNullForEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); Assert.Throws(() => target.GetTag("other-key")); } @@ -181,7 +181,7 @@ public void GetTag_ReturnsNullForEmptyCollection() [Fact] public void GetTag_ReturnsNullIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Throws(() => target.GetTag("other-key")); } @@ -189,7 +189,7 @@ public void GetTag_ReturnsNullIfCollectionDoesNotContainTag() [Fact] public void GetTag_ReturnsTagIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Tag returned = target.GetTag(_tags[0].Key); Assert.Same(_tags[0], returned); @@ -198,7 +198,7 @@ public void GetTag_ReturnsTagIfCollectionContainsTag() [Fact] public void Remove_Tag_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); bool removed = target.Remove(new Tag("key", "value")); Assert.False(removed); @@ -207,26 +207,26 @@ public void Remove_Tag_ReturnsFalseForEmptyCollection() [Fact] public void Remove_Tag_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); - Tag testTag = new Tag("other-key", "other-value"); + Tag testTag = new("other-key", "other-value"); Assert.False(target.Remove(testTag)); - this.CompareCollections(_tags, target); + CompareCollections(_tags, target); } [Fact] public void Remove_Tag_RemovesItemAndReturnsTrueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.True(target.Remove(_tags[0])); - this.CompareCollections(_tags.Skip(1), target); + CompareCollections(_tags.Skip(1), target); } [Fact] public void Remove_string_ReturnsFalseForEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); bool removed = target.Remove("key"); Assert.False(removed); @@ -235,9 +235,9 @@ public void Remove_string_ReturnsFalseForEmptyCollection() [Fact] public void Remove_string_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag() { - Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; + Tag[] tags = new Tag[] { new("test-key-1", "test-value"), new("test-key-2", "test-value") }; - TagsCollection target = new TagsCollection(tags); + TagsCollection target = new(tags); Assert.False(target.Remove("non-existing-tag")); } @@ -245,9 +245,9 @@ public void Remove_string_DoNothingAndReturnsFalseIfCollectionDoesNotContainTag( [Fact] public void Remove_string_RemovesItemAndReturnsTrueIfCollectionContainsTag() { - Tag[] tags = new Tag[] { new Tag("test-key-1", "test-value"), new Tag("test-key-2", "test-value") }; + Tag[] tags = new Tag[] { new("test-key-1", "test-value"), new("test-key-2", "test-value") }; - TagsCollection target = new TagsCollection(tags); + TagsCollection target = new(tags); Assert.True(target.Remove(tags[1].Key)); Assert.Single(target); @@ -257,7 +257,7 @@ public void Remove_string_RemovesItemAndReturnsTrueIfCollectionContainsTag() [Fact] public void Count_ReturnsZeroForEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); Assert.Empty(target); } @@ -265,7 +265,7 @@ public void Count_ReturnsZeroForEmptyCollection() [Fact] public void Count_ReturnsTagsCount() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Equal(_tags.Length, target.Count); } @@ -273,7 +273,7 @@ public void Count_ReturnsTagsCount() [Fact] public void IsReadOnly_ReturnsFalse() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); Assert.False(target.IsReadOnly); } @@ -281,7 +281,7 @@ public void IsReadOnly_ReturnsFalse() [Fact] public void Item_Get_ThrowsExceptionForEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); Assert.Throws(() => target["other-key"]); } @@ -289,7 +289,7 @@ public void Item_Get_ThrowsExceptionForEmptyCollection() [Fact] public void Item_Get_ThrowsExceptionIfCollectionDoesNotContainTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); Assert.Throws(() => target["other-key"]); } @@ -297,7 +297,7 @@ public void Item_Get_ThrowsExceptionIfCollectionDoesNotContainTag() [Fact] public void Item_Get_ReturnsTagValueIfCollectionContainsTag() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); string returnedValue = target[_tags[0].Key]; Assert.Equal(_tags[0].Value, returnedValue); @@ -306,7 +306,7 @@ public void Item_Get_ReturnsTagValueIfCollectionContainsTag() [Fact] public void Item_Set_AddsItemToEmptyCollection() { - TagsCollection target = new TagsCollection(); + TagsCollection target = new(); target["test-key"] = "test-value"; @@ -317,7 +317,7 @@ public void Item_Set_AddsItemToEmptyCollection() [Fact] public void Item_Set_AddsItemToCollection() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); target["test-key-101"] = "test-value-101"; @@ -328,7 +328,7 @@ public void Item_Set_AddsItemToCollection() [Fact] public void Item_Set_SetsTagValue() { - TagsCollection target = new TagsCollection(_tags); + TagsCollection target = new(_tags); target[_tags[0].Key] = "new-value"; Assert.Equal("new-value", target[_tags[0].Key]); diff --git a/src/Tests.SpatialLite.Osm/WayInfoTests.cs b/src/Tests.SpatialLite.Osm/WayInfoTests.cs index 520379a..ad33876 100644 --- a/src/Tests.SpatialLite.Osm/WayInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/WayInfoTests.cs @@ -15,10 +15,10 @@ public class WayInfoTests public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() { int id = 45; - TagsCollection tags = new TagsCollection(); - List nodes = new List(); + TagsCollection tags = new(); + List nodes = new(); - WayInfo target = new WayInfo(id, tags, nodes); + WayInfo target = new(id, tags, nodes); Assert.Equal(EntityType.Way, target.EntityType); Assert.Equal(id, target.ID); @@ -31,11 +31,11 @@ public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() public void Constructor_Properties_SetsProperties() { int id = 45; - TagsCollection tags = new TagsCollection(); - List nodes = new List(); - EntityMetadata details = new EntityMetadata(); + TagsCollection tags = new(); + List nodes = new(); + EntityMetadata details = new(); - WayInfo target = new WayInfo(id, tags, nodes, details); + WayInfo target = new(id, tags, nodes, details); Assert.Equal(EntityType.Way, target.EntityType); Assert.Equal(id, target.ID); @@ -47,9 +47,9 @@ public void Constructor_Properties_SetsProperties() [Fact] public void Constructor_Way_SetsProperties() { - Way way = new Way(10, new Node[0], new TagsCollection()) { Metadata = new EntityMetadata() }; + Way way = new(10, new Node[0], new TagsCollection()) { Metadata = new EntityMetadata() }; - WayInfo target = new WayInfo(way); + WayInfo target = new(way); Assert.Equal(way.ID, target.ID); Assert.Same(way.Tags, target.Tags); @@ -59,9 +59,9 @@ public void Constructor_Way_SetsProperties() [Fact] public void Constructor_Way_SetsNodesReferences() { - Way way = new Way(10, new Node[] { new Node(1), new Node(2), new Node(3) }, new TagsCollection()) { Metadata = new EntityMetadata() }; + Way way = new(10, new Node[] { new(1), new(2), new(3) }, new TagsCollection()) { Metadata = new EntityMetadata() }; - WayInfo target = new WayInfo(way); + WayInfo target = new(way); Assert.Equal(way.Nodes.Count, target.Nodes.Count); for (int i = 0; i < way.Nodes.Count; i++) From 2ab35954176b0a63b775ab6c128e3292b34fb552 Mon Sep 17 00:00:00 2001 From: Lukas Kabrt Date: Fri, 23 May 2025 00:10:06 +0200 Subject: [PATCH 11/14] Fix formatting --- src/Benchmark.SpatialLite.Osm/Program.cs | 43 ++--- src/SpatialLite.Core/API/Coordinate.cs | 4 +- src/SpatialLite.Gps/GpxDocument.cs | 8 +- src/SpatialLite.Gps/IO/GpxReader.cs | 42 ++-- src/SpatialLite.Gps/IO/GpxWriter.cs | 4 +- .../Geometries/OsmGeometryDatabase.cs | 9 +- src/SpatialLite.Osm/Geometries/Relation.cs | 2 +- .../Geometries/RelationMember.cs | 5 +- src/SpatialLite.Osm/Geometries/Way.cs | 5 +- src/SpatialLite.Osm/IO/OsmXmlReader.cs | 10 +- src/SpatialLite.Osm/IO/OsmXmlWriter.cs | 4 +- .../IO/Pbf/EntityInfoBuffer.cs | 2 +- src/SpatialLite.Osm/IO/Pbf/StringTable.cs | 2 +- src/SpatialLite.Osm/IO/PbfReader.cs | 24 +-- src/SpatialLite.Osm/IO/PbfWriter.cs | 42 ++-- src/SpatialLite.Osm/OsmEntityInfoDatabase.cs | 2 +- .../API/CoordinateTests.cs | 70 +++---- .../API/EnvelopeTests.cs | 76 ++++---- .../Algorithms/Euclidean2DCalculatorTests.cs | 62 +++--- .../Algorithms/Euclidean2DLocatorTests.cs | 122 ++++++------ .../Algorithms/Sphere2DCalculatorTests.cs | 66 +++---- .../Geometries/CoordinateListTests.cs | 38 ++-- .../Geometries/GeometryCollectionTests.cs | 28 +-- .../Geometries/LineStringTests.cs | 54 +++--- .../Geometries/PointTests.cs | 22 +-- .../Geometries/PolygonTests.cs | 28 +-- .../Geometries/ReadOnlyCoordinateListTests.cs | 26 +-- .../IO/WkbReaderTests.cs | 34 ++-- .../IO/WkbWriterSettingsTests.cs | 4 +- .../IO/WkbWriterTests.cs | 182 +++++++++--------- .../IO/WktReaderTests.cs | 30 +-- .../IO/WktTokenizerTests.cs | 2 +- .../IO/WktTokensBufferTests.cs | 44 ++--- .../IO/WktWriterSettingsTests.cs | 2 +- .../IO/WktWriterTests.cs | 68 +++---- .../MeasurementsTests.cs | 130 ++++++------- .../EntityCollectionTests.cs | 12 +- .../Geometries/NodeTests.cs | 2 - .../Geometries/OsmGeometryDatabaseTests.cs | 29 ++- .../Geometries/RelationMemberTests.cs | 12 +- .../Geometries/RelationTests.cs | 16 +- .../Geometries/WayCoordinateListTests.cs | 11 +- .../Geometries/WayTests.cs | 21 +- .../IO/OsmReaderSettingsTests.cs | 6 +- .../IO/OsmWriterSettingsTests.cs | 6 +- .../IO/OsmXmlReaderTests.cs | 19 +- .../IO/OsmXmlWriterTests.cs | 22 +-- .../IO/PbfReaderTests.cs | 20 +- .../IO/PbfWriterSettingsTests.cs | 6 +- .../IO/PbfWriterTests.cs | 20 +- .../Pbf/PbfReaderPbfWriterComplianceTests.cs | 10 +- .../Integration/Xml/OsmDatabaseTests.cs | 5 +- .../Xml/OsmosisIntegrationTests.cs | 12 +- src/Tests.SpatialLite.Osm/NodeInfoTests.cs | 14 +- src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs | 16 +- src/Tests.SpatialLite.Osm/PathHelper.cs | 8 +- .../Properties/AssemblyInfo.cs | 1 - .../RelationInfoTests.cs | 8 +- .../RelationMemberInfoTests.cs | 5 +- src/Tests.SpatialLite.Osm/TagTests.cs | 6 +- .../TagsCollectionTests.cs | 10 +- src/Tests.SpatialLite.Osm/WayInfoTests.cs | 8 +- 62 files changed, 776 insertions(+), 825 deletions(-) diff --git a/src/Benchmark.SpatialLite.Osm/Program.cs b/src/Benchmark.SpatialLite.Osm/Program.cs index f9152ba..cf5d844 100644 --- a/src/Benchmark.SpatialLite.Osm/Program.cs +++ b/src/Benchmark.SpatialLite.Osm/Program.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Globalization; using System.IO; namespace Benchmark.SpatialLite.Osm; @@ -15,7 +14,7 @@ public class Program private static void Main(string[] args) { - List> benchmarks = new(); + List> benchmarks = new List>(); benchmarks.Add(new Tuple("XmlReader with metadata", TestXmlReaderSpeed)); benchmarks.Add(new Tuple("XmlReader without metadata", TestXmlReaderSpeedWithoutMetadata)); //benchmarks.Add(new Tuple("PbfReader (no compression) with metadata", TestPbfReaderSpeedNoDenseNoCompression)); @@ -43,7 +42,7 @@ private static void Main(string[] args) foreach (var benchmark in benchmarks) { long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); - tw.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} ms \t\t{1}", avgTime, benchmark.Item1)); + tw.WriteLine(string.Format("{0} ms \t\t{1}", avgTime, benchmark.Item1)); } } } @@ -51,20 +50,20 @@ private static void Main(string[] args) private static long DoTest(Action testAction, string testName) { - Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Starting benchmark '{0}'", testName)); + Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); long totalTime = 0; for (int i = 0; i < 10; i++) { - Console.Write(string.Format(CultureInfo.InvariantCulture, "Run ({0}/{1}) ...", i + 1, 10)); - Stopwatch watch = new(); + Console.Write(string.Format("Run ({0}/{1}) ...", i + 1, 10)); + Stopwatch watch = new Stopwatch(); watch.Start(); testAction(); watch.Stop(); totalTime += watch.ElapsedMilliseconds; - Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "\t\t({0} ms)", watch.ElapsedMilliseconds)); + Console.WriteLine(string.Format("\t\t({0} ms)", watch.ElapsedMilliseconds)); } Console.WriteLine(); @@ -77,7 +76,7 @@ private static void LoadSourceData() _entities = new List(); IEntityInfo info = null; - using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { while ((info = reader.Read()) != null) { @@ -89,7 +88,7 @@ private static void LoadSourceData() private static void TestXmlReaderSpeed() { int entitiesRead = 0; - using (OsmXmlReader reader = new("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) + using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = true })) { IEntityInfo info; @@ -103,7 +102,7 @@ private static void TestXmlReaderSpeed() private static void TestXmlReaderSpeedWithoutMetadata() { int entitiesRead = 0; - using (OsmXmlReader reader = new("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) + using (OsmXmlReader reader = new OsmXmlReader("TestFiles\\test-file.osm", new OsmXmlReaderSettings() { ReadMetadata = false })) { IEntityInfo info; @@ -116,7 +115,7 @@ private static void TestXmlReaderSpeedWithoutMetadata() private static void TestXmlWriterSpeed() { - using (OsmXmlWriter writer = new("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) + using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = true })) { foreach (var entity in _entities) { @@ -127,7 +126,7 @@ private static void TestXmlWriterSpeed() private static void TestXmlWriterSpeedWithoutMetadata() { - using (OsmXmlWriter writer = new("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) + using (OsmXmlWriter writer = new OsmXmlWriter("TestFiles\\temp.osm", new OsmWriterSettings() { WriteMetadata = false })) { foreach (var entity in _entities) { @@ -139,7 +138,7 @@ private static void TestXmlWriterSpeedWithoutMetadata() private static void TestPbfReaderSpeedNoDenseNoCompression() { int entitiesRead = 0; - using (PbfReader reader = new("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = true })) { IEntityInfo info; @@ -153,7 +152,7 @@ private static void TestPbfReaderSpeedNoDenseNoCompression() private static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() { int entitiesRead = 0; - using (PbfReader reader = new("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) + using (PbfReader reader = new PbfReader("TestFiles\\test-file.pbf", new OsmReaderSettings() { ReadMetadata = false })) { IEntityInfo info; @@ -167,7 +166,7 @@ private static void TestPbfReaderSpeedNoDenseNoCompressionWithoutMetadata() private static void TestPbfReaderSpeedDenseDeflate() { int entitiesRead = 0; - using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { IEntityInfo info; @@ -181,7 +180,7 @@ private static void TestPbfReaderSpeedDenseDeflate() private static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() { int entitiesRead = 0; - using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = false })) { IEntityInfo info; @@ -194,7 +193,7 @@ private static void TestPbfReaderSpeedDenseDeflateWithoutMetadata() private static void TestPbfWriterSpeed() { - using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.None, UseDenseFormat = false })) { foreach (var entity in _entities) { @@ -205,7 +204,7 @@ private static void TestPbfWriterSpeed() private static void TestPbfWriterSpeedWithoutMetadata() { - using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.None, UseDenseFormat = false })) { foreach (var entity in _entities) { @@ -216,7 +215,7 @@ private static void TestPbfWriterSpeedWithoutMetadata() private static void TestPbfWriterSpeedDenseDeflate() { - using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = true, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { foreach (var entity in _entities) { @@ -227,7 +226,7 @@ private static void TestPbfWriterSpeedDenseDeflate() private static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() { - using (PbfWriter writer = new("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) + using (PbfWriter writer = new PbfWriter("TestFiles\\temp.pbf", new PbfWriterSettings() { WriteMetadata = false, Compression = CompressionMode.ZlibDeflate, UseDenseFormat = true })) { foreach (var entity in _entities) { @@ -238,7 +237,7 @@ private static void TestPbfWriterSpeedDenseDeflateWithoutMetadata() private static void TestOsmGeometryDatabaseLoadFromPbfReader() { - using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { OsmGeometryDatabase db = OsmGeometryDatabase.Load(reader, true); } @@ -246,7 +245,7 @@ private static void TestOsmGeometryDatabaseLoadFromPbfReader() private static void TestOsmEntityInfoDatabaseLoadFromPbfReader() { - using (PbfReader reader = new("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) + using (PbfReader reader = new PbfReader("TestFiles\\test-file-dc.pbf", new OsmReaderSettings() { ReadMetadata = true })) { OsmEntityInfoDatabase db = OsmEntityInfoDatabase.Load(reader); } diff --git a/src/SpatialLite.Core/API/Coordinate.cs b/src/SpatialLite.Core/API/Coordinate.cs index a0561a8..c0e68cb 100644 --- a/src/SpatialLite.Core/API/Coordinate.cs +++ b/src/SpatialLite.Core/API/Coordinate.cs @@ -17,7 +17,7 @@ public struct Coordinate : IEquatable /// /// The empty coordinate has all coordinates equal to NaN. /// - public static readonly Coordinate Empty = new(double.NaN, double.NaN, double.NaN, double.NaN); + public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); /// /// Initializes a new instance of the Coordinate struct with X, Y ordinates. @@ -139,7 +139,7 @@ public override readonly string ToString() /// /// The object to compare with the current Coordinate /// true if the specified object is equal to the current Coordinate; otherwise, false. - public override readonly bool Equals(object obj) + public override bool Equals(object obj) { Coordinate? other = obj as Coordinate?; if (other == null) diff --git a/src/SpatialLite.Gps/GpxDocument.cs b/src/SpatialLite.Gps/GpxDocument.cs index 9e482e8..f6b5d7f 100644 --- a/src/SpatialLite.Gps/GpxDocument.cs +++ b/src/SpatialLite.Gps/GpxDocument.cs @@ -54,7 +54,7 @@ public GpxDocument(IEnumerable waypoints, IEnumerable routes /// Path to the file. public void Save(string path) { - using (GpxWriter writer = new(path, new GpxWriterSettings() { WriteMetadata = true })) + using (GpxWriter writer = new GpxWriter(path, new GpxWriterSettings() { WriteMetadata = true })) { Save(writer); } @@ -112,9 +112,9 @@ private void LoadFromReader(IGpxReader reader) /// GpxDocument instance with data from GPX file public static GpxDocument Load(string path) { - GpxDocument result = new(); + GpxDocument result = new GpxDocument(); - using (GpxReader reader = new(path, new GpxReaderSettings() { ReadMetadata = true })) + using (GpxReader reader = new GpxReader(path, new GpxReaderSettings() { ReadMetadata = true })) { result.LoadFromReader(reader); } @@ -134,7 +134,7 @@ public static GpxDocument Load(IGpxReader reader) throw new ArgumentNullException(nameof(reader)); } - GpxDocument result = new(); + GpxDocument result = new GpxDocument(); result.LoadFromReader(reader); return result; } diff --git a/src/SpatialLite.Gps/IO/GpxReader.cs b/src/SpatialLite.Gps/IO/GpxReader.cs index 59e63c2..edda6b4 100644 --- a/src/SpatialLite.Gps/IO/GpxReader.cs +++ b/src/SpatialLite.Gps/IO/GpxReader.cs @@ -1,6 +1,5 @@ using SpatialLite.Gps.Geometries; using System; -using System.Globalization; using System.IO; using System.Xml; @@ -11,6 +10,9 @@ namespace SpatialLite.Gps.IO; /// public class GpxReader : IGpxReader, IDisposable { + + private readonly System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + private bool _disposed = false; private XmlReader _xmlReader; @@ -99,15 +101,15 @@ private GpxPoint ReadPoint(string pointElementName) string latValue = _xmlReader.GetAttribute("lat"); if (string.IsNullOrEmpty(latValue)) throw new InvalidDataException("Requested attribute 'lat' not found."); - double lat = double.Parse(latValue, CultureInfo.InvariantCulture); + double lat = double.Parse(latValue, _invariantCulture); string lonValue = _xmlReader.GetAttribute("lon"); if (string.IsNullOrEmpty(lonValue)) throw new InvalidDataException("Requested attribute 'lon' not found."); - double lon = double.Parse(lonValue, CultureInfo.InvariantCulture); + double lon = double.Parse(lonValue, _invariantCulture); double ele = double.NaN; - DateTime timestamp = new(); + DateTime timestamp = new DateTime(); GpxPointMetadata metadata = null; if (Settings.ReadMetadata) @@ -126,14 +128,14 @@ private GpxPoint ReadPoint(string pointElementName) if (_xmlReader.Name == "ele") { string eleValue = _xmlReader.ReadElementContentAsString(); - ele = double.Parse(eleValue, CultureInfo.InvariantCulture); + ele = double.Parse(eleValue, _invariantCulture); elementParsed = true; } if (_xmlReader.Name == "time") { string timeValue = _xmlReader.ReadElementContentAsString(); - timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture); + timestamp = DateTime.ParseExact(timeValue, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _invariantCulture); elementParsed = true; } @@ -150,7 +152,7 @@ private GpxPoint ReadPoint(string pointElementName) } _xmlReader.Skip(); - GpxPoint result = new(lon, lat, ele, timestamp); + GpxPoint result = new GpxPoint(lon, lat, ele, timestamp); result.Metadata = metadata; return result; @@ -162,7 +164,7 @@ private GpxPoint ReadPoint(string pointElementName) /// the track parsed form the XmlReader private GpxTrack ReadTrack() { - GpxTrack result = new(); + GpxTrack result = new GpxTrack(); if (_xmlReader.IsEmptyElement == false) { @@ -208,7 +210,7 @@ private GpxTrack ReadTrack() /// the track parsed from the XmlReader private GpxTrackSegment ReadTrackSegment() { - GpxTrackSegment result = new(); + GpxTrackSegment result = new GpxTrackSegment(); if (_xmlReader.IsEmptyElement == false) { @@ -238,7 +240,7 @@ private GpxTrackSegment ReadTrackSegment() /// the route parsed from the XmlReader private GpxRoute ReadRoute() { - GpxRoute result = new(); + GpxRoute result = new GpxRoute(); if (_xmlReader.IsEmptyElement == false) { @@ -283,7 +285,7 @@ private GpxRoute ReadRoute() /// private void InitializeReader() { - XmlReaderSettings xmlReaderSettings = new(); + XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.IgnoreComments = true; xmlReaderSettings.IgnoreProcessingInstructions = true; xmlReaderSettings.IgnoreWhitespace = true; @@ -302,7 +304,7 @@ private void InitializeReader() string version = _xmlReader.GetAttribute("version"); if (version == null || (version != "1.0" && version != "1.1")) - throw new InvalidDataException(string.Format(CultureInfo.InvariantCulture, "Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); + throw new InvalidDataException(string.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); _insideGpx = true; @@ -394,28 +396,28 @@ private bool TryReadPointMetadata(GpxPointMetadata metadata) metadata.Links.Add(ReadLink()); return true; case "magvar": string magvarValue = _xmlReader.ReadElementContentAsString(); - metadata.MagVar = double.Parse(magvarValue, CultureInfo.InvariantCulture); return true; + metadata.MagVar = double.Parse(magvarValue, _invariantCulture); return true; case "geoidheight": string geoidHeightValue = _xmlReader.ReadElementContentAsString(); - metadata.GeoidHeight = double.Parse(geoidHeightValue, CultureInfo.InvariantCulture); return true; + metadata.GeoidHeight = double.Parse(geoidHeightValue, _invariantCulture); return true; case "hdop": string HdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Hdop = double.Parse(HdopValue, CultureInfo.InvariantCulture); return true; + metadata.Hdop = double.Parse(HdopValue, _invariantCulture); return true; case "vdop": string vdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Vdop = double.Parse(vdopValue, CultureInfo.InvariantCulture); return true; + metadata.Vdop = double.Parse(vdopValue, _invariantCulture); return true; case "pdop": string pdopValue = _xmlReader.ReadElementContentAsString(); - metadata.Pdop = double.Parse(pdopValue, CultureInfo.InvariantCulture); return true; + metadata.Pdop = double.Parse(pdopValue, _invariantCulture); return true; case "ageofdgpsdata": string ageValue = _xmlReader.ReadElementContentAsString(); - metadata.AgeOfDgpsData = double.Parse(ageValue, CultureInfo.InvariantCulture); return true; + metadata.AgeOfDgpsData = double.Parse(ageValue, _invariantCulture); return true; case "sat": string satValue = _xmlReader.ReadElementContentAsString(); - metadata.SatellitesCount = int.Parse(satValue, CultureInfo.InvariantCulture); return true; + metadata.SatellitesCount = int.Parse(satValue, _invariantCulture); return true; case "dgpsid": string dgpsidValue = _xmlReader.ReadElementContentAsString(); - metadata.DgpsId = int.Parse(dgpsidValue, CultureInfo.InvariantCulture); return true; + metadata.DgpsId = int.Parse(dgpsidValue, _invariantCulture); return true; case "fix": string fixValue = _xmlReader.ReadElementContentAsString(); metadata.Fix = GpxFixHelper.ParseGpsFix(fixValue); return true; diff --git a/src/SpatialLite.Gps/IO/GpxWriter.cs b/src/SpatialLite.Gps/IO/GpxWriter.cs index 1f03839..ccd0825 100644 --- a/src/SpatialLite.Gps/IO/GpxWriter.cs +++ b/src/SpatialLite.Gps/IO/GpxWriter.cs @@ -27,7 +27,7 @@ public GpxWriter(Stream stream, GpxWriterSettings settings) Settings = settings; settings.IsReadOnly = true; - XmlWriterSettings writerSetting = new(); + XmlWriterSettings writerSetting = new XmlWriterSettings(); writerSetting.Indent = true; _streamWriter = new StreamWriter(stream, new UTF8Encoding(false)); @@ -47,7 +47,7 @@ public GpxWriter(string path, GpxWriterSettings settings) Settings = settings; settings.IsReadOnly = true; - XmlWriterSettings writerSetting = new(); + XmlWriterSettings writerSetting = new XmlWriterSettings(); writerSetting.Indent = true; var fileStream = new FileStream(path, FileMode.Create); diff --git a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs index 908e9de..f1da1dd 100644 --- a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs +++ b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs @@ -1,7 +1,6 @@ using SpatialLite.Osm.IO; using System; using System.Collections.Generic; -using System.Globalization; namespace SpatialLite.Osm.Geometries; @@ -36,9 +35,9 @@ public OsmGeometryDatabase(IEnumerable entities) /// New instance of the OsmDatabase class with data loaded from specified reader. public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferentialErrors) { - OsmGeometryDatabase db = new(); + OsmGeometryDatabase db = new OsmGeometryDatabase(); - List relations = new(); + List relations = new List(); IEntityInfo entityInfo; while ((entityInfo = reader.Read()) != null) @@ -52,7 +51,7 @@ public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferential { if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Way (ID = {0}) references missing node.", entityInfo.ID)); + throw new ArgumentException(string.Format("Way (ID = {0}) references missing node.", entityInfo.ID)); } } else @@ -80,7 +79,7 @@ public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferential { if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); + throw new ArgumentException(string.Format("Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); } db.Relations.Remove(relation); diff --git a/src/SpatialLite.Osm/Geometries/Relation.cs b/src/SpatialLite.Osm/Geometries/Relation.cs index 8f151c4..575c9e2 100644 --- a/src/SpatialLite.Osm/Geometries/Relation.cs +++ b/src/SpatialLite.Osm/Geometries/Relation.cs @@ -73,7 +73,7 @@ public EntityType EntityType /// The Relation object created from RelationInfo or null if referenced entity is missing. public static Relation FromRelationInfo(RelationInfo info, IEntityCollection entities, bool throwOnMissing) { - Relation result = new(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; + Relation result = new Relation(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; result.Geometries.Capacity = info.Members.Count; foreach (var memberInfo in info.Members) diff --git a/src/SpatialLite.Osm/Geometries/RelationMember.cs b/src/SpatialLite.Osm/Geometries/RelationMember.cs index b52c591..70d2b19 100644 --- a/src/SpatialLite.Osm/Geometries/RelationMember.cs +++ b/src/SpatialLite.Osm/Geometries/RelationMember.cs @@ -2,7 +2,6 @@ using SpatialLite.Core.Geometries; using System; using System.Collections.Generic; -using System.Globalization; namespace SpatialLite.Osm.Geometries; @@ -105,7 +104,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn { if (throwOnMissing) { - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); + throw new ArgumentException(string.Format("Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); } else { @@ -113,7 +112,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn } } - RelationMember result = new(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; + RelationMember result = new RelationMember(entities[info.Reference, info.MemberType], info.Role) { MemberType = info.MemberType }; if (result.Member.EntityType != info.MemberType) { throw new ArgumentException("Type of the referenced entity doesn't match type of the entity in the collection."); diff --git a/src/SpatialLite.Osm/Geometries/Way.cs b/src/SpatialLite.Osm/Geometries/Way.cs index b1c2b6c..b26c086 100644 --- a/src/SpatialLite.Osm/Geometries/Way.cs +++ b/src/SpatialLite.Osm/Geometries/Way.cs @@ -2,7 +2,6 @@ using SpatialLite.Core.Geometries; using System; using System.Collections.Generic; -using System.Globalization; namespace SpatialLite.Osm.Geometries; @@ -97,7 +96,7 @@ public EntityType EntityType /// The Way object created from WayInfo or null if referenced node is missing public static Way FromWayInfo(WayInfo info, IEntityCollection entities, bool throwOnMissing) { - Way result = new(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; + Way result = new Way(info.ID) { Tags = info.Tags, Metadata = info.Metadata }; result.Nodes.Capacity = info.Nodes.Count; foreach (var nodeID in info.Nodes) @@ -110,7 +109,7 @@ public static Way FromWayInfo(WayInfo info, IEntityCollection enti { if (throwOnMissing) { - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); + throw new ArgumentException(string.Format("Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); } return null; diff --git a/src/SpatialLite.Osm/IO/OsmXmlReader.cs b/src/SpatialLite.Osm/IO/OsmXmlReader.cs index 1073b59..9bedf17 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlReader.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlReader.cs @@ -137,7 +137,7 @@ private NodeInfo ReadNode() additionalInfo = ReadMetadata(); } - NodeInfo result = new(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); + NodeInfo result = new NodeInfo(nodeId, nodeLat, nodeLon, new TagsCollection(), additionalInfo); if (_xmlReader.IsEmptyElement == false) { @@ -180,7 +180,7 @@ private WayInfo ReadWay() additionalInfo = ReadMetadata(); } - WayInfo way = new(wayId, new TagsCollection(), new List(), additionalInfo); + WayInfo way = new WayInfo(wayId, new TagsCollection(), new List(), additionalInfo); if (_xmlReader.IsEmptyElement == false) { @@ -254,7 +254,7 @@ private RelationInfo ReadRelation() additionalInfo = ReadMetadata(); } - RelationInfo relation = new(relationId, new TagsCollection(), new List(), additionalInfo); + RelationInfo relation = new RelationInfo(relationId, new TagsCollection(), new List(), additionalInfo); if (false == _xmlReader.IsEmptyElement) { @@ -362,7 +362,7 @@ private Tag ReadTag() /// Metadata of the entity read from the reader. private EntityMetadata ReadMetadata() { - EntityMetadata result = new(); + EntityMetadata result = new EntityMetadata(); // version string attVersion = _xmlReader.GetAttribute("version"); @@ -456,7 +456,7 @@ private EntityMetadata ReadMetadata() /// private void InitializeReader() { - Sys.XmlReaderSettings xmlReaderSettings = new(); + Sys.XmlReaderSettings xmlReaderSettings = new Sys.XmlReaderSettings(); xmlReaderSettings.IgnoreComments = true; xmlReaderSettings.IgnoreProcessingInstructions = true; xmlReaderSettings.IgnoreWhitespace = true; diff --git a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs index 168f273..ba680ad 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs @@ -36,7 +36,7 @@ public OsmXmlWriter(Stream stream, OsmWriterSettings settings) _output = stream; _ownsOutputStream = false; - XmlWriterSettings writerSetting = new(); + XmlWriterSettings writerSetting = new XmlWriterSettings(); writerSetting.Indent = true; _writer = XmlWriter.Create(stream, writerSetting); @@ -56,7 +56,7 @@ public OsmXmlWriter(string path, OsmWriterSettings settings) _output = new FileStream(path, FileMode.Create, FileAccess.Write); _ownsOutputStream = true; - XmlWriterSettings writerSetting = new(); + XmlWriterSettings writerSetting = new XmlWriterSettings(); writerSetting.Indent = true; _streamWriter = new StreamWriter(_output, new UTF8Encoding(false)); diff --git a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs index 34cb399..5089545 100644 --- a/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs +++ b/src/SpatialLite.Osm/IO/Pbf/EntityInfoBuffer.cs @@ -138,7 +138,7 @@ public uint GetStringIndex(string str) /// The StringTable object with data from the buffer. public StringTable BuildStringTable() { - StringTable result = new(); + StringTable result = new StringTable(); result.Storage = new List(_stringTable.Count); for (int i = 0; i < _stringTable.Count; i++) { diff --git a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs index 4cb3db4..2e6d743 100644 --- a/src/SpatialLite.Osm/IO/Pbf/StringTable.cs +++ b/src/SpatialLite.Osm/IO/Pbf/StringTable.cs @@ -12,7 +12,7 @@ namespace SpatialLite.Osm.IO.Pbf; public class StringTable { - private List _s = new(); + private List _s = new List(); /// /// Gets or sets collection of strings serialized as byte array. diff --git a/src/SpatialLite.Osm/IO/PbfReader.cs b/src/SpatialLite.Osm/IO/PbfReader.cs index d482f44..3627e30 100644 --- a/src/SpatialLite.Osm/IO/PbfReader.cs +++ b/src/SpatialLite.Osm/IO/PbfReader.cs @@ -26,7 +26,7 @@ public class PbfReader : IOsmReader private bool _disposed = false; private readonly Stream _input; private readonly Queue _cache; - private readonly DateTime _unixEpoch = new(1970, 1, 1, 0, 0, 0); + private readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); /// /// Initializes a new instance of the PbfReader class that read data form specified stream. @@ -194,7 +194,7 @@ private object ReadBlob(BlobHeader header) } else if (blob.ZlibData != null) { - MemoryStream deflateStreamData = new(blob.ZlibData); + MemoryStream deflateStreamData = new MemoryStream(blob.ZlibData); //skip ZLIB header deflateStreamData.Seek(2, SeekOrigin.Begin); @@ -283,7 +283,7 @@ private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) double lat = 1E-09 * (block.LatOffset + (block.Granularity * node.Latitude)); double lon = 1E-09 * (block.LonOffset + (block.Granularity * node.Longitude)); - List tags = new(); + List tags = new List(); if (node.Keys != null) { for (int i = 0; i < node.Keys.Count; i++) @@ -294,7 +294,7 @@ private void ProcessNodes(PrimitiveBlock block, PrimitiveGroup group) EntityMetadata metadata = ProcessMetadata(node.Metadata, block); - NodeInfo parsed = new(node.ID, lat, lon, new TagsCollection(tags), metadata); + NodeInfo parsed = new NodeInfo(node.ID, lat, lon, new TagsCollection(tags), metadata); _cache.Enqueue(parsed); } } @@ -331,7 +331,7 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) double lat = 1E-09 * (block.LatOffset + (block.Granularity * latStore)); double lon = 1E-09 * (block.LonOffset + (block.Granularity * lonStore)); - List tags = new(); + List tags = new List(); if (group.DenseNodes.KeysVals.Count > 0) { while (group.DenseNodes.KeysVals[keyValueIndex] != 0) @@ -370,7 +370,7 @@ private void ProcessDenseNodes(PrimitiveBlock block, PrimitiveGroup group) } } - NodeInfo parsed = new(idStore, lat, lon, new TagsCollection(tags), metadata); + NodeInfo parsed = new NodeInfo(idStore, lat, lon, new TagsCollection(tags), metadata); _cache.Enqueue(parsed); } } @@ -390,7 +390,7 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) foreach (var way in group.Ways) { long refStore = 0; - List refs = new(way.Refs.Count); + List refs = new List(way.Refs.Count); for (int i = 0; i < way.Refs.Count; i++) { @@ -398,7 +398,7 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) refs.Add(refStore); } - List tags = new(); + List tags = new List(); if (way.Keys != null) { for (int i = 0; i < way.Keys.Count; i++) @@ -409,7 +409,7 @@ private void ProcessWays(PrimitiveBlock block, PrimitiveGroup group) EntityMetadata metadata = ProcessMetadata(way.Metadata, block); - WayInfo parsed = new(way.ID, new TagsCollection(tags), refs, metadata); + WayInfo parsed = new WayInfo(way.ID, new TagsCollection(tags), refs, metadata); _cache.Enqueue(parsed); } } @@ -430,7 +430,7 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) { long memberRefStore = 0; - List members = new(); + List members = new List(); for (int i = 0; i < relation.MemberIds.Count; i++) { memberRefStore += relation.MemberIds[i]; @@ -447,7 +447,7 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) members.Add(new RelationMemberInfo() { MemberType = memberType, Reference = memberRefStore, Role = role }); } - List tags = new(); + List tags = new List(); if (relation.Keys != null) { for (int i = 0; i < relation.Keys.Count; i++) @@ -458,7 +458,7 @@ private void ProcessRelations(PrimitiveBlock block, PrimitiveGroup group) EntityMetadata metadata = ProcessMetadata(relation.Metadata, block); - RelationInfo parsed = new(relation.ID, new TagsCollection(tags), members, metadata); + RelationInfo parsed = new RelationInfo(relation.ID, new TagsCollection(tags), members, metadata); _cache.Enqueue(parsed); } } diff --git a/src/SpatialLite.Osm/IO/PbfWriter.cs b/src/SpatialLite.Osm/IO/PbfWriter.cs index 553b460..4dd2002 100644 --- a/src/SpatialLite.Osm/IO/PbfWriter.cs +++ b/src/SpatialLite.Osm/IO/PbfWriter.cs @@ -18,7 +18,7 @@ public class PbfWriter : IOsmWriter /// public const int MaxDataBlockSize = 16 * 1024 * 1024; - private readonly DateTime _unixEpoch = new(1970, 1, 1, 0, 0, 0); + private readonly DateTime _unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0); private bool _disposed = false; private readonly Stream _output; @@ -78,12 +78,12 @@ public void Write(IEntityInfo entity) { if (entity.Metadata == null) { - throw new ArgumentException("Entity doesn't contain metadata object, but writer was created with WriteMetadata setting."); + throw new ArgumentException("Entity doesn't contain metadata obejct, but writer was created with WriteMetadata setting."); } if (entity.Metadata.User == null) { - throw new ArgumentException("Entity.Metadata.User cannot be null."); + throw new ArgumentNullException("Entity.Metadata.User cannot be null."); } } @@ -173,7 +173,7 @@ private void Flush(EntityType entityType) return; } - MemoryStream primitiveBlockStream = new(); + MemoryStream primitiveBlockStream = new MemoryStream(); Serializer.Serialize(primitiveBlockStream, primitiveBlock); //byte[] buffer = new byte[primitiveBlockStream.Length]; @@ -187,7 +187,7 @@ private void Flush(EntityType entityType) /// private void WriteHeader() { - OsmHeader header = new(); + OsmHeader header = new OsmHeader(); header.RequiredFeatures.Add("OsmSchema-V0.6"); if (Settings.UseDenseFormat) @@ -200,7 +200,7 @@ private void WriteHeader() header.OptionalFeatures.Add("Has_Metadata"); } - using (MemoryStream stream = new()) + using (MemoryStream stream = new MemoryStream()) { Serializer.Serialize(stream, header); @@ -218,20 +218,20 @@ private void WriteHeader() /// The pbf serialized content of the blob. private void WriteBlob(string blobType, byte[] blobContent) { - Blob blob = new(); + Blob blob = new Blob(); if (Settings.Compression == CompressionMode.None) { blob.Raw = blobContent; } else if (Settings.Compression == CompressionMode.ZlibDeflate) { - MemoryStream zlibStream = new(); + MemoryStream zlibStream = new MemoryStream(); //ZLIB header zlibStream.WriteByte(120); zlibStream.WriteByte(156); - using (System.IO.Compression.DeflateStream deflateSteram = new(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) + using (System.IO.Compression.DeflateStream deflateSteram = new System.IO.Compression.DeflateStream(zlibStream, System.IO.Compression.CompressionMode.Compress, true)) { deflateSteram.Write(blobContent, 0, blobContent.Length); } @@ -240,10 +240,10 @@ private void WriteBlob(string blobType, byte[] blobContent) blob.ZlibData = zlibStream.ToArray(); } - MemoryStream blobStream = new(); + MemoryStream blobStream = new MemoryStream(); Serializer.Serialize(blobStream, blob); - BlobHeader header = new(); + BlobHeader header = new BlobHeader(); header.Type = blobType; header.DataSize = (int)blobStream.Length; Serializer.SerializeWithLengthPrefix(_output, header, PrefixStyle.Fixed32BigEndian); @@ -258,7 +258,7 @@ private void WriteBlob(string blobType, byte[] blobContent) /// PrimitiveBlock with entities of specified type or null if tokens doesn't contain any entities of specified type. private PrimitiveBlock BuildPrimitiveBlock(EntityType entityType) { - PrimitiveBlock result = new(); + PrimitiveBlock result = new PrimitiveBlock(); result.PrimitiveGroup = new List(); PrimitiveGroup entityGroup = null; @@ -368,10 +368,10 @@ private PrimitiveGroup BuildRelationsPrimitiveGroup(int timestampGranularity) /// The DenseNode obejct with data from nodes in tokens. private List BuildNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) { - List result = new(_nodesBuffer.Count); + List result = new List(_nodesBuffer.Count); foreach (var node in _nodesBuffer) { - PbfNode toAdd = new(); + PbfNode toAdd = new PbfNode(); toAdd.ID = node.ID; toAdd.Latitude = (long)Math.Round(((node.Latitude / 1E-09) - latOffset) / positionGranularity); @@ -410,7 +410,7 @@ private List BuildNodes(int timestampGranularity, int positionGranulari /// The DenseNode obejct with data from nodes in tokens. private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGranularity, long latOffset, long lonOffset) { - PbfDenseNodes result = new(_nodesBuffer.Count); + PbfDenseNodes result = new PbfDenseNodes(_nodesBuffer.Count); long lastID = 0; long lastLat = 0; @@ -453,13 +453,13 @@ private PbfDenseNodes BuildDenseNodes(int timestampGranularity, int positionGran /// The collection of PbfWay objects created from relations in tokens. private List BuildWays(int timestampGranularity) { - List result = new(); + List result = new List(); foreach (var way in _wayBuffer) { long lastRef = 0; - PbfWay toAdd = new(); + PbfWay toAdd = new PbfWay(); toAdd.ID = way.ID; @@ -504,11 +504,11 @@ private List BuildWays(int timestampGranularity) /// The collection of PbfRelation objects created from relations in tokens. private List BuildRelations(int timestampGranularity) { - List result = new(); + List result = new List(); foreach (var relation in _relationBuffer) { - PbfRelation toAdd = new(); + PbfRelation toAdd = new PbfRelation(); toAdd.ID = relation.ID; long lastRef = 0; @@ -559,7 +559,7 @@ private List BuildRelations(int timestampGranularity) /// DenseInfo object with metadata for noes in tokens. private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) { - PbfDenseMetadata result = new(_nodesBuffer.Count); + PbfDenseMetadata result = new PbfDenseMetadata(_nodesBuffer.Count); long lastChangeset = 0; long lastTimestamp = 0; @@ -600,7 +600,7 @@ private PbfDenseMetadata BuildDenseInfo(int timestampGranularity) /// PbfMetadata obejct with data from specified metadata object. private PbfMetadata BuildInfo(EntityMetadata metadata, int timestampGranularity, IStringTableBuilder stringTableBuilder) { - PbfMetadata result = new(); + PbfMetadata result = new PbfMetadata(); result.Changeset = metadata.Changeset; result.Timestamp = (long)Math.Round((metadata.Timestamp - _unixEpoch).TotalMilliseconds / timestampGranularity); result.UserID = metadata.Uid; diff --git a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs index 850aec6..0b6ded7 100644 --- a/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs +++ b/src/SpatialLite.Osm/OsmEntityInfoDatabase.cs @@ -33,7 +33,7 @@ public OsmEntityInfoDatabase(IEnumerable entities) /// New instance of the OsmDAtabase class with data loaded from specified reader. public static OsmEntityInfoDatabase Load(IOsmReader reader) { - OsmEntityInfoDatabase db = new(); + OsmEntityInfoDatabase db = new OsmEntityInfoDatabase(); IEntityInfo entityInfo; while ((entityInfo = reader.Read()) != null) diff --git a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs index b74b34e..8051620 100644 --- a/src/Tests.SpatialLite.Core/API/CoordinateTests.cs +++ b/src/Tests.SpatialLite.Core/API/CoordinateTests.cs @@ -13,7 +13,7 @@ public class CoordinateTests [Fact] public void Constructor_XY_SetsXYValuesAndZMNaN() { - Coordinate target = new(xCoordinate, yCoordinate); + Coordinate target = new Coordinate(xCoordinate, yCoordinate); Assert.Equal(xCoordinate, target.X); Assert.Equal(yCoordinate, target.Y); @@ -24,7 +24,7 @@ public void Constructor_XY_SetsXYValuesAndZMNaN() [Fact] public void Constructor_XYZ_SetsXYZValuesAndMNaN() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); Assert.Equal(xCoordinate, target.X); Assert.Equal(yCoordinate, target.Y); @@ -35,7 +35,7 @@ public void Constructor_XYZ_SetsXYZValuesAndMNaN() [Fact] public void Constructor_XYZM_SetsXYZMValues() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.Equal(xCoordinate, target.X); Assert.Equal(yCoordinate, target.Y); @@ -46,7 +46,7 @@ public void Constructor_XYZM_SetsXYZMValues() [Fact] public void Is3D_ReturnsFalseForNaNZCoordinate() { - Coordinate target = new(xCoordinate, yCoordinate); + Coordinate target = new Coordinate(xCoordinate, yCoordinate); Assert.False(target.Is3D); } @@ -54,7 +54,7 @@ public void Is3D_ReturnsFalseForNaNZCoordinate() [Fact] public void Is3D_ReturnsTrueFor3D() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate); Assert.True(target.Is3D); } @@ -62,7 +62,7 @@ public void Is3D_ReturnsTrueFor3D() [Fact] public void IsMeasured_ReturnsFalseForNaNMCoordinate() { - Coordinate target = new(xCoordinate, yCoordinate); + Coordinate target = new Coordinate(xCoordinate, yCoordinate); Assert.False(target.IsMeasured); } @@ -70,7 +70,7 @@ public void IsMeasured_ReturnsFalseForNaNMCoordinate() [Fact] public void IsMeasured_ReturnsTrueForMeasuredCoordinate() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target.IsMeasured); } @@ -78,8 +78,8 @@ public void IsMeasured_ReturnsTrueForMeasuredCoordinate() [Fact] public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target.Equals(other)); } @@ -87,8 +87,8 @@ public void Equals_ReturnsTrueForCoordinateWithTheSameOrdinates() [Fact] public void Equals_ReturnsTrueForNaNCoordinates() { - Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); Assert.True(target.Equals(other)); } @@ -96,7 +96,7 @@ public void Equals_ReturnsTrueForNaNCoordinates() [Fact] public void Equals_ReturnsFalseForNull() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); object other = null; Assert.False(target.Equals(other)); @@ -105,7 +105,7 @@ public void Equals_ReturnsFalseForNull() [Fact] public void Equals_ReturnsFalseForOtherObjectType() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); object other = "string"; Assert.False(target.Equals(other)); @@ -114,8 +114,8 @@ public void Equals_ReturnsFalseForOtherObjectType() [Fact] public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); Assert.False(target.Equals(other)); } @@ -123,8 +123,8 @@ public void Equals_ReturnsFalseForCoordinateWithDifferentOrdinates() [Fact] public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target.Equals2D(other)); } @@ -132,8 +132,8 @@ public void Equals2D_ReturnsTrueForCoordinateWithTheSameOrdinates() [Fact] public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate + 1, mValue + 1); Assert.True(target.Equals2D(other)); } @@ -141,8 +141,8 @@ public void Equals2D_ReturnsTrueForCoordinateWithTheDifferentZMOrdinates() [Fact] public void Equals2D_ReturnsTrueForNaNCoordinates() { - Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); Assert.True(target.Equals2D(other)); } @@ -150,8 +150,8 @@ public void Equals2D_ReturnsTrueForNaNCoordinates() [Fact] public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate, mValue); Assert.False(target.Equals2D(other)); } @@ -159,8 +159,8 @@ public void Equals2D_ReturnsFalseForCoordinateWithDifferentXYOrdinates() [Fact] public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.True(target == other); } @@ -168,8 +168,8 @@ public void EqualsOperator_ReturnsTrueForCoordinateWithTheSameOrdinates() [Fact] public void EqualsOperator_ReturnsTrueForNaNCoordinates() { - Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); Assert.True(target == other); } @@ -177,8 +177,8 @@ public void EqualsOperator_ReturnsTrueForNaNCoordinates() [Fact] public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); Assert.False(target == other); } @@ -186,8 +186,8 @@ public void EqualsOperator_ReturnsFalseForCoordinateWithDifferentOrdinates() [Fact] public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); Assert.False(target != other); } @@ -195,8 +195,8 @@ public void NotEqualsOperator_ReturnsFalseForCoordinateWithTheSameOrdinates() [Fact] public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() { - Coordinate target = new(double.NaN, double.NaN, double.NaN, double.NaN); - Coordinate other = new(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate target = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + Coordinate other = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); Assert.False(target != other); } @@ -204,8 +204,8 @@ public void NotEqualsOperator_ReturnsFalseForNaNCoordinates() [Fact] public void NotEqualsOperator_ReturnsTrueForCoordinateWithDifferentOrdinates() { - Coordinate target = new(xCoordinate, yCoordinate, zCoordinate, mValue); - Coordinate other = new(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); + Coordinate target = new Coordinate(xCoordinate, yCoordinate, zCoordinate, mValue); + Coordinate other = new Coordinate(xCoordinate + 1, yCoordinate + 1, zCoordinate + 1, mValue + 1); Assert.True(target != other); } diff --git a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs index da66706..bb8bb02 100644 --- a/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs +++ b/src/Tests.SpatialLite.Core/API/EnvelopeTests.cs @@ -7,27 +7,27 @@ namespace Tests.SpatialLite.Core.API; public class EnvelopeTests { private readonly Coordinate[] _coordinates = new Coordinate[] { - new(1, 10, 100, 1000), - new(0, 0, 0, 0), - new(-1, -10, -100, -1000) + new Coordinate(1, 10, 100, 1000), + new Coordinate(0, 0, 0, 0), + new Coordinate(-1, -10, -100, -1000) }; - private Coordinate _insideCoordinate = new(0.5, 0.5, 0.5, 0.5); - private Coordinate _lowerValues = new(-2, -20, -200, -2000); - private Coordinate _higherValues = new(2, 20, 200, 2000); + private Coordinate _insideCoordinate = new Coordinate(0.5, 0.5, 0.5, 0.5); + private Coordinate _lowerValues = new Coordinate(-2, -20, -200, -2000); + private Coordinate _higherValues = new Coordinate(2, 20, 200, 2000); private readonly double[] _expectedBounds = new double[] { -1, 1, -10, 10, -100, 100, -1000, 1000 }; public static IEnumerable _XYZEnvelopeDifferentBounds { get { - yield return new object[] { new Coordinate[] { new(1 + 1, 2, 100, 1000), new(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new(1, 2 + 1, 100, 1000), new(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new(1, 2, 100 + 1, 1000), new(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000 + 1), new(5, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5 + 1, 6, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5, 6 + 1, 200, 2000) } }; - yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5, 6, 200 + 1, 2000) } }; - yield return new object[] { new Coordinate[] { new(1, 2, 100, 1000), new(5, 6, 200, 2000 + 1) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1 + 1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2 + 1, 100, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100 + 1, 1000), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000 + 1), new Coordinate(5, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5 + 1, 6, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6 + 1, 200, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200 + 1, 2000) } }; + yield return new object[] { new Coordinate[] { new Coordinate(1, 2, 100, 1000), new Coordinate(5, 6, 200, 2000 + 1) } }; } } @@ -46,7 +46,7 @@ internal void CheckBoundaries(Envelope target, double minX, double maxX, double [Fact] public void Constructor__InitializesBoundsToNaNValues() { - Envelope target = new(); + Envelope target = new Envelope(); Assert.Equal(double.NaN, target.MinX); Assert.Equal(double.NaN, target.MaxX); @@ -61,7 +61,7 @@ public void Constructor__InitializesBoundsToNaNValues() [Fact] public void Constructor_Coordinate_InitializesXYZProperties() { - Envelope target = new(_coordinates[0]); + Envelope target = new Envelope(_coordinates[0]); CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, _coordinates[0].Z, _coordinates[0].Z, _coordinates[0].M, _coordinates[0].M); } @@ -69,9 +69,9 @@ public void Constructor_Coordinate_InitializesXYZProperties() [Fact] public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() { - Envelope source = new(_coordinates); + Envelope source = new Envelope(_coordinates); - Envelope target = new(source); + Envelope target = new Envelope(source); CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); @@ -80,9 +80,9 @@ public void Constructor_IEnumerableCoordinate_SetsMinMaxValues() [Fact] public void Constructor_Envelope_CopiesMinMaxValues() { - Envelope source = new(_coordinates); + Envelope source = new Envelope(_coordinates); - Envelope target = new(source); + Envelope target = new Envelope(source); CheckBoundaries(target, _expectedBounds[0], _expectedBounds[1], _expectedBounds[2], _expectedBounds[3], _expectedBounds[4], _expectedBounds[5], _expectedBounds[6], _expectedBounds[7]); @@ -91,7 +91,7 @@ public void Constructor_Envelope_CopiesMinMaxValues() [Fact] public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new(); + Envelope target = new Envelope(); target.Extend(_coordinates[0]); CheckBoundaries(target, _coordinates[0].X, _coordinates[0].X, _coordinates[0].Y, _coordinates[0].Y, @@ -101,7 +101,7 @@ public void Extend_Coordinate_SetsMinMaxValuesOnEmptyEnvelope() [Fact] public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(Coordinate.Empty); @@ -112,7 +112,7 @@ public void Extend_Coordinate_DoNothingIfCoordinateIsEmpty() [Fact] public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(_lowerValues); @@ -122,7 +122,7 @@ public void Extend_Coordinate_ExtendsEnvelopeToLowerValues() [Fact] public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(_higherValues); @@ -132,7 +132,7 @@ public void Extend_Coordinate_ExtendsEnvelopeToHigherValues() [Fact] public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(_insideCoordinate); @@ -143,7 +143,7 @@ public void Extend_Coordinate_DoNothingForCoordinateInsideEnvelope() [Fact] public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new(); + Envelope target = new Envelope(); target.Extend(_coordinates); @@ -154,7 +154,7 @@ public void Extend_IEnumerableCoordinate_SetsMinMaxValuesOnEmptyEnvelope() [Fact] public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(new Coordinate[] { }); @@ -165,7 +165,7 @@ public void Extend_IEnumerableCoordinate_DoNothingForEmptyCollection() [Fact] public void Extend_IEnumerableCoordinate_ExtendsEnvelope() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(new Coordinate[] { _lowerValues, _higherValues }); @@ -175,7 +175,7 @@ public void Extend_IEnumerableCoordinate_ExtendsEnvelope() [Fact] public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() { - Envelope target = new(); + Envelope target = new Envelope(); target.Extend(new Envelope(_coordinates)); @@ -186,7 +186,7 @@ public void Extend_Envelope_SetsMinMaxValuesOnEmptyEnvelope() [Fact] public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(new Envelope(_coordinates[1])); @@ -197,7 +197,7 @@ public void Extend_Envelope_DoNothingIfEnvelopeIsInsideTargetEnvelope() [Fact] public void Extend_Envelope_ExtendsEnvelope() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); target.Extend(new Envelope(new Coordinate[] { _lowerValues, _higherValues })); @@ -207,7 +207,7 @@ public void Extend_Envelope_ExtendsEnvelope() [Fact] public void Equals_ReturnsTrueForSameObjectInstance() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); Assert.True(target.Equals(target)); } @@ -215,8 +215,8 @@ public void Equals_ReturnsTrueForSameObjectInstance() [Fact] public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() { - Envelope target = new(_coordinates); - Envelope other = new(target); + Envelope target = new Envelope(_coordinates); + Envelope other = new Envelope(target); Assert.True(target.Equals(other)); } @@ -224,7 +224,7 @@ public void Equals_ReturnsTrueForTheEnvelopeWithTheSameBounds() [Fact] public void Equals_ReturnsFalseForNull() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); object other = null; Assert.False(target.Equals(other)); @@ -233,7 +233,7 @@ public void Equals_ReturnsFalseForNull() [Fact] public void Equals_ReturnsFalseForOtherObjectType() { - Envelope target = new(_coordinates); + Envelope target = new Envelope(_coordinates); object other = "string"; Assert.False(target.Equals(other)); @@ -243,8 +243,8 @@ public void Equals_ReturnsFalseForOtherObjectType() [MemberData(nameof(_XYZEnvelopeDifferentBounds))] public void Equals_ReturnsFalseForTheEnvelopeWithDifferentBounds(Coordinate[] corners) { - Envelope target = new(_coordinates); - Envelope other = new(corners); + Envelope target = new Envelope(_coordinates); + Envelope other = new Envelope(corners); Assert.False(target.Equals(other)); } diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs index 118ee62..32869ab 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DCalculatorTests.cs @@ -23,7 +23,7 @@ public static IEnumerable CoordinatesSameXYOrdinates [MemberData(nameof(CoordinatesSameXYOrdinates))] public void ComputeDistance_CoordinateCoordinate_ReturnsZeroForPointsWithSameXYCoordinates(Coordinate c1, Coordinate c2) { - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c1, c2); @@ -44,7 +44,7 @@ public static IEnumerable CoordinatesDistanceTestData [MemberData(nameof(CoordinatesDistanceTestData))] public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinates(Coordinate c1, Coordinate c2, double expectedDistance) { - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c1, c2); @@ -54,7 +54,7 @@ public void ComputeDistance_CoordinateCoordinate_ReturnsDistanceBetweenCoordinat [Fact] public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() { - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(new Coordinate(-1, 0, 100), new Coordinate(1, 0, -100)); @@ -64,12 +64,12 @@ public void ComputeDistance_CoordinateCoordinate_IgnoresZOrdinate() [Fact] public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsDistanceToEndPointsIfPointsProjectionLiesOutsideSegment() { - Coordinate A = new(1, 1); - Coordinate B = new(-1, -1); - Coordinate c1 = new(1, 2); - Coordinate c2 = new(-1, -2); + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(-1, -1); + Coordinate c1 = new Coordinate(1, 2); + Coordinate c2 = new Coordinate(-1, -2); - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distanceC1 = target.CalculateDistance(c1, A, B, LineMode.LineSegment); Assert.Equal(1, distanceC1); @@ -92,7 +92,7 @@ public static IEnumerable LineSegmentDistanceTestData [MemberData(nameof(LineSegmentDistanceTestData))] public void ComputeDistance_CoordinateLineLineSegmentMode_ComputesPerpendicularDistanceToLineIfPointsProjectionLiesInside(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) { - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); Assert.Equal(expectedDistance, distance); @@ -112,7 +112,7 @@ public static IEnumerable LineSegmentDistanceZeroDistanceTestData [MemberData(nameof(LineSegmentDistanceZeroDistanceTestData))] public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLiesOnLineSegment(Coordinate c, Coordinate A, Coordinate B) { - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); Assert.Equal(0, distance); @@ -121,11 +121,11 @@ public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsZeroIfPointLies [Fact] public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIfABAreEquals() { - Coordinate A = new(1, 1); - Coordinate B = new(1, 1); - Coordinate c = new(1, 2); + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(1, 1); + Coordinate c = new Coordinate(1, 2); - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c, A, B, LineMode.LineSegment); Assert.Equal(1, distance); @@ -134,11 +134,11 @@ public void ComputeDistance_CoordinateLineLineSegmentMode_ReturnsPointDistanceIf [Fact] public void ComputeDistance_CoordinateLineLineMode_ReturnsPointDistanceIfABAreEquals() { - Coordinate A = new(1, 1); - Coordinate B = new(1, 1); - Coordinate c = new(1, 2); + Coordinate A = new Coordinate(1, 1); + Coordinate B = new Coordinate(1, 1); + Coordinate c = new Coordinate(1, 2); - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c, A, B, LineMode.Line); Assert.Equal(1, distance); @@ -158,7 +158,7 @@ public static IEnumerable LineDistanceZeroDistanceTestData [MemberData(nameof(LineDistanceZeroDistanceTestData))] public void ComputeDistance_CoordinateLineLineMode_ReturnsZeroIfPointLiesOnLine(Coordinate c, Coordinate A, Coordinate B) { - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c, A, B, LineMode.Line); Assert.Equal(0, distance); @@ -178,7 +178,7 @@ public static IEnumerable LineDistanceTestData [MemberData(nameof(LineDistanceTestData))] public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistanceToLine(Coordinate c, Coordinate A, Coordinate B, double expectedDistance) { - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double distance = target.CalculateDistance(c, A, B, LineMode.Line); Assert.Equal(expectedDistance, distance); @@ -187,9 +187,9 @@ public void ComputeDistance_CoordinateLineLineMode_ComputesPerpendicularDistance [Fact] public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() { - Mock listM = new(); + Mock listM = new Mock(); listM.SetupGet(l => l.Count).Returns(2); - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); Assert.Throws(() => target.CalculateArea(listM.Object)); } @@ -197,17 +197,17 @@ public void ComputeArea_ThrowsExceptionIfNumberOfVerticesIsLesserThen3() [Fact] public void ComputeArea_ReturnsAreaOfConvexPolygon() { - Coordinate[] coordinates = new Coordinate[] { new(1, 1), new(2, 0.5), new(3, 1), new(3, 2), new(1, 2) }; + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; double expectedArea = 2.5; - Mock listM = new(); + Mock listM = new Mock(); listM.SetupGet(list => list.Count).Returns(5); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); listM.Setup(list => list[2]).Returns(coordinates[2]); listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); @@ -216,17 +216,17 @@ public void ComputeArea_ReturnsAreaOfConvexPolygon() [Fact] public void ComputeArea_ReturnsAreaOfConcavePolygon() { - Coordinate[] coordinates = new Coordinate[] { new(1, 1), new(2, 1.5), new(3, 1), new(3, 2), new(1, 2) }; + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 1.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2) }; double expectedArea = 1.5; - Mock listM = new(); + Mock listM = new Mock(); listM.SetupGet(list => list.Count).Returns(5); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); listM.Setup(list => list[2]).Returns(coordinates[2]); listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); @@ -235,10 +235,10 @@ public void ComputeArea_ReturnsAreaOfConcavePolygon() [Fact] public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() { - Coordinate[] coordinates = new Coordinate[] { new(1, 1), new(2, 0.5), new(3, 1), new(3, 2), new(1, 2), new(1, 1) }; + Coordinate[] coordinates = new Coordinate[] { new Coordinate(1, 1), new Coordinate(2, 0.5), new Coordinate(3, 1), new Coordinate(3, 2), new Coordinate(1, 2), new Coordinate(1, 1) }; double expectedArea = 2.5; - Mock listM = new(); + Mock listM = new Mock(); listM.SetupGet(list => list.Count).Returns(6); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); @@ -246,7 +246,7 @@ public void ComputeArea_ReturnsCorrectAreaIfLastCoordinateIsSameAsFirst() listM.Setup(list => list[3]).Returns(coordinates[3]); listM.Setup(list => list[4]).Returns(coordinates[4]); listM.Setup(list => list[5]).Returns(coordinates[5]); - Euclidean2DCalculator target = new(); + Euclidean2DCalculator target = new Euclidean2DCalculator(); double area = target.CalculateArea(listM.Object); Assert.Equal(expectedArea, area); diff --git a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs index 46e499c..5c183cf 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Euclidean2DLocatorTests.cs @@ -14,9 +14,9 @@ public class Euclidean2DLocatorTests [Fact] public void IsOnLine_ReturnsTrueIfPointIsOnAorB() { - Coordinate a = new(-10, 0); - Coordinate b = new(3, 2); - Euclidean2DLocator target = new(); + Coordinate a = new Coordinate(-10, 0); + Coordinate b = new Coordinate(3, 2); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsOnLine(a, a, b, LineMode.Line)); Assert.True(target.IsOnLine(b, a, b, LineMode.Line)); @@ -39,7 +39,7 @@ public static IEnumerable PointsBetweenAB [MemberData(nameof(PointsBetweenAB))] public void IsOnLine_ReturnsTrueIfPointLiesBetweenAAndB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsOnLine(c, a, b, mode)); } @@ -57,7 +57,7 @@ public static IEnumerable PointsOnAB [MemberData(nameof(PointsOnAB))] public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coordinate a, Coordinate b) { - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsOnLine(c, a, b, LineMode.Line)); } @@ -66,7 +66,7 @@ public void IsOnLine_ReturnsTrueIfPointLiesOnABAndModeIsLine(Coordinate c, Coord [MemberData(nameof(PointsOnAB))] public void IsOnLine_ReturnsFalseIfPointLiesOnABAndModeIsLineSegment(Coordinate c, Coordinate a, Coordinate b) { - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.IsOnLine(c, a, b, LineMode.LineSegment)); } @@ -88,16 +88,16 @@ public static IEnumerable PointsNotOnAB [MemberData(nameof(PointsNotOnAB))] public void IsOnLine_ReturnsFalseIfPointDoEsNotLieOnAB(Coordinate c, Coordinate a, Coordinate b, LineMode mode) { - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.IsOnLine(c, a, b, mode)); } [Fact] public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() { - Coordinate c = new(0, 0); - CoordinateList ring = new(new Coordinate[] { new(0, 1), new(1, 0) }); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(0, 0); + CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0) }); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.Throws(() => target.IsInRing(c, ring)); } @@ -105,9 +105,9 @@ public void IsInRing_ThrowsArgumentExceptionIfRingHasLessThen3Points() [Fact] public void IsInRing_ThrowsArgumentExceptionIfCoordinateListDoesNotRepresentRing() { - Coordinate c = new(0, 0); - CoordinateList ring = new(new Coordinate[] { new(0, 1), new(1, 0), new(1, 2) }); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(0, 0); + CoordinateList ring = new CoordinateList(new Coordinate[] { new Coordinate(0, 1), new Coordinate(1, 0), new Coordinate(1, 2) }); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.Throws(() => target.IsInRing(c, ring)); } @@ -118,8 +118,8 @@ public void IsInRing_ReturnsTrueIfPointIsInSimpleRing() string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new(0.5, 0.5); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(0.5, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsInRing(c, ring.Coordinates)); } @@ -130,8 +130,8 @@ public void IsInRing_ReturnsTrueIfPointIsInRingAndCYCoordinateIsSameAsVertexYCoo string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new(0.5, 0.5); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(0.5, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsInRing(c, ring.Coordinates)); } @@ -142,8 +142,8 @@ public void IsInRing_ReturnsTrueIfPointIsInConcaveRing() string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new(1, 0.5); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(1, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.IsInRing(c, ring.Coordinates)); } @@ -154,8 +154,8 @@ public void IsInRing_ReturnsFalseIfPointIsOutsideSimpleRing() string wktRing = "linestring (-1 -1, 1 -1, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new(2, 2); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(2, 2); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.IsInRing(c, ring.Coordinates)); } @@ -166,8 +166,8 @@ public void IsInRing_ReturnsFalseIfPointIsOutsideRing() string wktRing = "linestring (0 0, 2 0, 1 1, 1 2, 0 0)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new(3, 0); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(3, 0); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.IsInRing(c, ring.Coordinates)); } @@ -178,8 +178,8 @@ public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCo string wktRing = "linestring (-1 -1, 1 -1, 1 0.5, 1 1, -1 1, -1 -1)"; LineString ring = WktReader.Parse(wktRing); - Coordinate c = new(-2, 0.5); - Euclidean2DLocator target = new(); + Coordinate c = new Coordinate(-2, 0.5); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.IsInRing(c, ring.Coordinates)); } @@ -189,13 +189,13 @@ public void IsInRing_ReturnsFalseIfPointIsInRingAndCYCoordinateIsSameAsVertexYCo [Fact] public void Intersects_ReturnsFalseForParallelLines() { - Coordinate A1 = new(1.0, 1.0); - Coordinate B1 = new(2.0, 2.0); + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 2.0); - Coordinate A2 = new(2.0, 1.0); - Coordinate B2 = new(3.0, 2.0); + Coordinate A2 = new Coordinate(2.0, 1.0); + Coordinate B2 = new Coordinate(3.0, 2.0); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); } @@ -203,13 +203,13 @@ public void Intersects_ReturnsFalseForParallelLines() [Fact] public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() { - Coordinate A1 = new(1.0, 1.0); - Coordinate B1 = new(2.0, 1.0); + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new(2.0, 0.0); - Coordinate B2 = new(3.0, 1.0); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.Line)); } @@ -217,13 +217,13 @@ public void Intersects_ReturnsTrueForLinesThatIntersectsOutsideLineSegments() [Fact] public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment1() { - Coordinate A1 = new(1.0, 1.0); - Coordinate B1 = new(2.0, 1.0); + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new(2.0, 0.0); - Coordinate B2 = new(3.0, 1.0); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.Line)); } @@ -231,13 +231,13 @@ public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLin [Fact] public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLineSegment2() { - Coordinate A1 = new(1.0, 1.0); - Coordinate B1 = new(2.0, 1.0); + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new(2.0, 0.0); - Coordinate B2 = new(3.0, 0.5); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 0.5); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.Intersects(A1, B1, LineMode.Line, A2, B2, LineMode.LineSegment)); } @@ -245,13 +245,13 @@ public void Intersects_ReturnsFalseForLineAndLineSegmentThatIntersectsOutsideLin [Fact] public void Intersects_ReturnsFalseForNonIntersectingLineSegments() { - Coordinate A1 = new(1.0, 1.0); - Coordinate B1 = new(2.0, 1.0); + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(2.0, 1.0); - Coordinate A2 = new(2.0, 0.0); - Coordinate B2 = new(3.0, 1.0); + Coordinate A2 = new Coordinate(2.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 1.0); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); } @@ -259,13 +259,13 @@ public void Intersects_ReturnsFalseForNonIntersectingLineSegments() [Fact] public void Intersects_ReturnsTrueForIntersectingLineSegments() { - Coordinate A1 = new(1.0, 1.0); - Coordinate B1 = new(3.0, 1.0); + Coordinate A1 = new Coordinate(1.0, 1.0); + Coordinate B1 = new Coordinate(3.0, 1.0); - Coordinate A2 = new(1.0, 0.0); - Coordinate B2 = new(3.0, 2.0); + Coordinate A2 = new Coordinate(1.0, 0.0); + Coordinate B2 = new Coordinate(3.0, 2.0); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.Intersects(A1, B1, LineMode.LineSegment, A2, B2, LineMode.LineSegment)); } @@ -273,10 +273,10 @@ public void Intersects_ReturnsTrueForIntersectingLineSegments() [Fact] public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new(1.0, 1.0), new(2.0, 1.0), new(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new(1.0, 0.0), new(2.0, 0.0), new(2.0, -1.0) }); + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(2.0, 0.0), new Coordinate(2.0, -1.0) }); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.False(target.Intersects(line1, line2)); } @@ -284,10 +284,10 @@ public void Intersects_LineLine_ReturnsaFalseForNonIntersectingLines() [Fact] public void Intersects_LineLine_ReturnsaTrueForIntersectingLines() { - ICoordinateList line1 = new CoordinateList(new Coordinate[] { new(1.0, 1.0), new(2.0, 1.0), new(2.0, 2.0) }); - ICoordinateList line2 = new CoordinateList(new Coordinate[] { new(1.0, 0.0), new(1.5, 2.0), new(2.0, -1.0) }); + ICoordinateList line1 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 1.0), new Coordinate(2.0, 1.0), new Coordinate(2.0, 2.0) }); + ICoordinateList line2 = new CoordinateList(new Coordinate[] { new Coordinate(1.0, 0.0), new Coordinate(1.5, 2.0), new Coordinate(2.0, -1.0) }); - Euclidean2DLocator target = new(); + Euclidean2DLocator target = new Euclidean2DLocator(); Assert.True(target.Intersects(line1, line2)); } diff --git a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs index 156d33c..3090cff 100644 --- a/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs +++ b/src/Tests.SpatialLite.Core/Algorithms/Sphere2DCalculatorTests.cs @@ -12,8 +12,8 @@ public class Sphere2DCalculatorTests [Fact] public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() { - Coordinate c = new(10.1, 100.2); - Sphere2DCalculator target = new(); + Coordinate c = new Coordinate(10.1, 100.2); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c, c); @@ -24,9 +24,9 @@ public void CalculateDistance_CoordinateCoordinate_Returns0ForSameCoordinate() [Fact] public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() { - Coordinate c1 = new(0, 0); - Coordinate c2 = new(0, 90); - Sphere2DCalculator target = new(); + Coordinate c1 = new Coordinate(0, 0); + Coordinate c2 = new Coordinate(0, 90); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c1, c2); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; @@ -37,9 +37,9 @@ public void CalculateDistance_CoordinateCoordinate_ReturnsDistanceOf2Points() [Fact] public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegBoundary() { - Coordinate c1 = new(-45, 0); - Coordinate c2 = new(45, 0); - Sphere2DCalculator target = new(); + Coordinate c1 = new Coordinate(-45, 0); + Coordinate c2 = new Coordinate(45, 0); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c1, c2); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; @@ -50,9 +50,9 @@ public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross0DegB [Fact] public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180DegBoundary() { - Coordinate c1 = new(-135, 0); - Coordinate c2 = new(135, 0); - Sphere2DCalculator target = new(); + Coordinate c1 = new Coordinate(-135, 0); + Coordinate c2 = new Coordinate(135, 0); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c1, c2); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 4; @@ -63,11 +63,11 @@ public void CalculateDsitance_CoordinateCoordinate_CalculateDistancesAcross180De [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() { - Coordinate a = new(0, 0); - Coordinate b = new(90, 0); - Coordinate c = new(120, 45); + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(120, 45); - Sphere2DCalculator target = new(); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c, a, b, LineMode.Line); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; @@ -78,11 +78,11 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToInfiniteLine() [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() { - Coordinate a = new(0, 0); - Coordinate b = new(90, 0); - Coordinate c = new(45, 45); + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(45, 45); - Sphere2DCalculator target = new(); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); double expectedDistance = Math.PI * 2 * Sphere2DCalculator.EarthRadius / 8; @@ -93,11 +93,11 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToLineSegment() [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment() { - Coordinate a = new(0, 0); - Coordinate b = new(90, 0); - Coordinate c = new(95, 45); + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(95, 45); - Sphere2DCalculator target = new(); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); double expectedDistance = target.CalculateDistance(b, c); @@ -108,11 +108,11 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsO [Fact] public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsOutsideLineSegment2() { - Coordinate a = new(0, 0); - Coordinate b = new(90, 0); - Coordinate c = new(5, 45); + Coordinate a = new Coordinate(0, 0); + Coordinate b = new Coordinate(90, 0); + Coordinate c = new Coordinate(5, 45); - Sphere2DCalculator target = new(); + Sphere2DCalculator target = new Sphere2DCalculator(); double distance = target.CalculateDistance(c, a, b, LineMode.LineSegment); double expectedDistance = target.CalculateDistance(a, c); @@ -123,9 +123,9 @@ public void CalculateDistance_LineCoordinate_ReturnsDistanceToEndPointIfPointIsO [Fact] public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast() { - Coordinate[] coordinates = new Coordinate[] { new(0, 0), new(90, 0), new(0, 90) }; + Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; - Mock listM = new(); + Mock listM = new Mock(); listM.SetupGet(list => list.Count).Returns(3); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); @@ -133,7 +133,7 @@ public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - Sphere2DCalculator target = new(); + Sphere2DCalculator target = new Sphere2DCalculator(); double area = target.CalculateArea(listM.Object); Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); @@ -142,9 +142,9 @@ public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointDoesNotEqualLast [Fact] public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() { - Coordinate[] coordinates = new Coordinate[] { new(0, 0), new(90, 0), new(0, 90) }; + Coordinate[] coordinates = new Coordinate[] { new Coordinate(0, 0), new Coordinate(90, 0), new Coordinate(0, 90) }; - Mock listM = new(); + Mock listM = new Mock(); listM.SetupGet(list => list.Count).Returns(4); listM.Setup(list => list[0]).Returns(coordinates[0]); listM.Setup(list => list[1]).Returns(coordinates[1]); @@ -153,7 +153,7 @@ public void CalculateArea_CalculatesAreaOfPolygonPointFirstPointEqualsLast() double expectedArea = 4 * Math.PI * Sphere2DCalculator.EarthRadius * Sphere2DCalculator.EarthRadius / 8; - Sphere2DCalculator target = new(); + Sphere2DCalculator target = new Sphere2DCalculator(); double area = target.CalculateArea(listM.Object); Assert.InRange(area, expectedArea * 0.995, expectedArea * 1.005); diff --git a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs index 52d7c76..f7969fe 100644 --- a/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/CoordinateListTests.cs @@ -7,17 +7,17 @@ namespace Tests.SpatialLite.Core.Geometries; public class CoordinateListTests { - private Coordinate _coordinate = new(-10, -20, -200); + private Coordinate _coordinate = new Coordinate(-10, -20, -200); private readonly Coordinate[] _coordinates = new Coordinate[] { - new(12,10,100), - new(22,20,200), - new(32,30,300) + new Coordinate(12,10,100), + new Coordinate(22,20,200), + new Coordinate(32,30,300) }; [Fact] public void Constructor__CreatesEmptyList() { - CoordinateList target = new(); + CoordinateList target = new CoordinateList(); Assert.Empty(target); } @@ -25,7 +25,7 @@ public void Constructor__CreatesEmptyList() [Fact] public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); for (int i = 0; i < _coordinates.Length; i++) { @@ -36,7 +36,7 @@ public void Constructor_IEnumerable_CreatesListWithSpecifiedItems() [Fact] public void Indexer_GetsAndSetsValues() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); Assert.Equal(_coordinates[1], target[1]); @@ -47,7 +47,7 @@ public void Indexer_GetsAndSetsValues() [Fact] public void Count_Returns0ForEmptyList() { - CoordinateList target = new(); + CoordinateList target = new CoordinateList(); Assert.Equal(0, target.Count); } @@ -55,7 +55,7 @@ public void Count_Returns0ForEmptyList() [Fact] public void Count_ReturnsNumberOfCoordinates() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); Assert.Equal(_coordinates.Length, target.Count); } @@ -63,7 +63,7 @@ public void Count_ReturnsNumberOfCoordinates() [Fact] public void Add_AppendsCoordinateToTheEndOfList() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.Add(_coordinate); Assert.Equal(_coordinate, target.Last()); @@ -72,7 +72,7 @@ public void Add_AppendsCoordinateToTheEndOfList() [Fact] public void Add_IncresesCount() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.Add(_coordinate); Assert.Equal(_coordinates.Length + 1, target.Count); @@ -81,7 +81,7 @@ public void Add_IncresesCount() [Fact] public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() { - CoordinateList target = new(new Coordinate[] { _coordinate }); + CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); target.Add(_coordinates); for (int i = 0; i < _coordinates.Length; i++) @@ -93,7 +93,7 @@ public void Add_AppendsCollectionOfCoordinatesToTheEndOfList() [Fact] public void Add_IncresesCount2() { - CoordinateList target = new(new Coordinate[] { _coordinate }); + CoordinateList target = new CoordinateList(new Coordinate[] { _coordinate }); target.Add(_coordinates); Assert.Equal(_coordinates.Length + 1, target.Count); @@ -103,7 +103,7 @@ public void Add_IncresesCount2() public void Insert_InsertsCoordinateToSpecifiedIndex() { int index = 1; - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.Insert(index, _coordinate); Assert.Equal(_coordinate, target[index]); @@ -113,7 +113,7 @@ public void Insert_InsertsCoordinateToSpecifiedIndex() public void Insert_IncresesCount() { int index = 1; - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.Insert(index, _coordinate); Assert.Equal(_coordinates.Length + 1, target.Count); @@ -122,7 +122,7 @@ public void Insert_IncresesCount() [Fact] public void Insert_AppendsCoordinateToListIfIndexEqulasCount() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.Insert(target.Count, _coordinate); Assert.Equal(_coordinate, target.Last()); @@ -132,7 +132,7 @@ public void Insert_AppendsCoordinateToListIfIndexEqulasCount() [Fact] public void RemoveAt_RemovesCoordinateAtIndex() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.RemoveAt(1); Assert.Equal(_coordinates[0], target[0]); @@ -142,7 +142,7 @@ public void RemoveAt_RemovesCoordinateAtIndex() [Fact] public void RemoveAt_DecreasesCount() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.RemoveAt(1); Assert.Equal(_coordinates.Length - 1, target.Count); @@ -151,7 +151,7 @@ public void RemoveAt_DecreasesCount() [Fact] public void Clear_RemovesAllCoordinatesFromList() { - CoordinateList target = new(_coordinates); + CoordinateList target = new CoordinateList(_coordinates); target.Clear(); Assert.Empty(target.ToArray()); diff --git a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs index bf646f4..9fcd6a2 100644 --- a/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/GeometryCollectionTests.cs @@ -8,9 +8,9 @@ public class GeometryCollectionTests { private readonly Point[] _geometries; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new(12,10,100, 1000), - new(22,20,200, 2000), - new(32,30,300, 3000) + new Coordinate(12,10,100, 1000), + new Coordinate(22,20,200, 2000), + new Coordinate(32,30,300, 3000) }; public GeometryCollectionTests() @@ -34,7 +34,7 @@ private void CheckGeometries(GeometryCollection target, Geometry[] geo [Fact] public void Constructor__CreatesNewEmptyCollection() { - GeometryCollection target = new(); + GeometryCollection target = new GeometryCollection(); Assert.NotNull(target.Geometries); Assert.Empty(target.Geometries); @@ -43,7 +43,7 @@ public void Constructor__CreatesNewEmptyCollection() [Fact] public void Constructor_IEnumerable_CreateNewCollectionWithData() { - GeometryCollection target = new(_geometries); + GeometryCollection target = new GeometryCollection(_geometries); CheckGeometries(target, _geometries); } @@ -51,7 +51,7 @@ public void Constructor_IEnumerable_CreateNewCollectionWithData() [Fact] public void Is3D_ReturnsFalseForEmptyCollection() { - GeometryCollection target = new(); + GeometryCollection target = new GeometryCollection(); Assert.False(target.Is3D); } @@ -60,7 +60,7 @@ public void Is3D_ReturnsFalseForEmptyCollection() public void Is3D_ReturnsFalseForCollectionOf2DObjects() { var members2d = new Geometry[] { new Point(1, 2), new Point(2, 3) }; - GeometryCollection target = new(members2d); + GeometryCollection target = new GeometryCollection(members2d); Assert.False(target.Is3D); } @@ -68,7 +68,7 @@ public void Is3D_ReturnsFalseForCollectionOf2DObjects() [Fact] public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() { - GeometryCollection target = new(_geometries); + GeometryCollection target = new GeometryCollection(_geometries); Assert.True(target.Is3D); } @@ -76,7 +76,7 @@ public void Is3D_ReturnsTrueForCollectionWithAtLeastOne3DObject() [Fact] public void IsMeasured_ReturnsFalseForEmptyCollection() { - GeometryCollection target = new(); + GeometryCollection target = new GeometryCollection(); Assert.False(target.IsMeasured); } @@ -84,7 +84,7 @@ public void IsMeasured_ReturnsFalseForEmptyCollection() [Fact] public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() { - GeometryCollection target = new(_geometries); + GeometryCollection target = new GeometryCollection(_geometries); Assert.False(target.IsMeasured); } @@ -93,7 +93,7 @@ public void IsMeasured_ReturnsFalseForCollectionOfNonMeasuredObjects() public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() { var members = new Geometry[] { new Point(1, 2), new Point(2, 3, 4, 5) }; - GeometryCollection target = new(members); + GeometryCollection target = new GeometryCollection(members); Assert.True(target.IsMeasured); } @@ -101,7 +101,7 @@ public void IsMeasured_ReturnsTrueForCollectionWithAtLeastOneMeasuredObject() [Fact] public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() { - GeometryCollection target = new(); + GeometryCollection target = new GeometryCollection(); Assert.Equal(Envelope.Empty, target.GetEnvelope()); } @@ -109,8 +109,8 @@ public void GetEnvelopeReturnsEmptyEnvelopeForEmptyCollection() [Fact] public void GetEnvelopeReturnsUnionOfMembersEnvelopes() { - GeometryCollection target = new(_geometries); - Envelope expected = new(new Coordinate[] { _geometries[0].Position, _geometries[1].Position, _geometries[2].Position }); + GeometryCollection target = new GeometryCollection(_geometries); + Envelope expected = new Envelope(new Coordinate[] { _geometries[0].Position, _geometries[1].Position, _geometries[2].Position }); Assert.Equal(expected, target.GetEnvelope()); } diff --git a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs index 8bbd9cb..587da35 100644 --- a/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/LineStringTests.cs @@ -8,19 +8,19 @@ namespace Tests.SpatialLite.Core.Geometries; public class LineStringTests { private readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new(12,10), - new(22,20), - new(32,30) + new Coordinate(12,10), + new Coordinate(22,20), + new Coordinate(32,30) }; private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new(12,10,100), - new(22,20,200), - new(32,30,300) + new Coordinate(12,10,100), + new Coordinate(22,20,200), + new Coordinate(32,30,300) }; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new(12,10,100, 1000), - new(22,20,200, 2000), - new(32,30,300, 3000) + new Coordinate(12,10,100, 1000), + new Coordinate(22,20,200, 2000), + new Coordinate(32,30,300, 3000) }; @@ -37,7 +37,7 @@ private void CheckCoordinates(LineString target, Coordinate[] expectedPoints) [Fact] public void Constructor__CreatesEmptyLineString() { - LineString target = new(); + LineString target = new LineString(); Assert.Equal(0, target.Coordinates.Count); } @@ -45,7 +45,7 @@ public void Constructor__CreatesEmptyLineString() [Fact] public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() { - LineString target = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); CheckCoordinates(target, _coordinatesXYZ); } @@ -53,7 +53,7 @@ public void Constructor_IEnumerable_CreatesLineStringFromCoordinates() [Fact] public void Is3D_ReturnsFalseForEmptyLineString() { - LineString target = new(); + LineString target = new LineString(); Assert.False(target.Is3D); } @@ -61,7 +61,7 @@ public void Is3D_ReturnsFalseForEmptyLineString() [Fact] public void Is3D_ReturnsFalseForAll2DCoords() { - LineString target = new(_coordinatesXY); + LineString target = new LineString(_coordinatesXY); Assert.False(target.Is3D); } @@ -69,7 +69,7 @@ public void Is3D_ReturnsFalseForAll2DCoords() [Fact] public void Is3D_ReturnsTrueForAll3DCoords() { - LineString target = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); Assert.True(target.Is3D); } @@ -77,7 +77,7 @@ public void Is3D_ReturnsTrueForAll3DCoords() [Fact] public void IsMeasured_ReturnsFalseForEmptyLineString() { - LineString target = new(); + LineString target = new LineString(); Assert.False(target.IsMeasured); } @@ -85,7 +85,7 @@ public void IsMeasured_ReturnsFalseForEmptyLineString() [Fact] public void IsMeasured_ReturnsFalseForNonMeasuredCoords() { - LineString target = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); Assert.False(target.IsMeasured); } @@ -93,7 +93,7 @@ public void IsMeasured_ReturnsFalseForNonMeasuredCoords() [Fact] public void IsMeasured_ReturnsTrueForMeasuredCoords() { - LineString target = new(_coordinatesXYZM); + LineString target = new LineString(_coordinatesXYZM); Assert.True(target.IsMeasured); } @@ -101,7 +101,7 @@ public void IsMeasured_ReturnsTrueForMeasuredCoords() [Fact] public void Start_ReturnsEmptyCoordinateForEmptyLineString() { - LineString target = new(); + LineString target = new LineString(); Assert.Equal(Coordinate.Empty, target.Start); } @@ -109,7 +109,7 @@ public void Start_ReturnsEmptyCoordinateForEmptyLineString() [Fact] public void Start_ReturnsFirstCoordinate() { - LineString target = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); Assert.Equal(_coordinatesXYZ.First(), target.Start); } @@ -117,7 +117,7 @@ public void Start_ReturnsFirstCoordinate() [Fact] public void End_ReturnsEmptyCoordinateForEmptyLineString() { - LineString target = new(); + LineString target = new LineString(); Assert.Equal(Coordinate.Empty, target.End); } @@ -125,7 +125,7 @@ public void End_ReturnsEmptyCoordinateForEmptyLineString() [Fact] public void End_ReturnsLastCoordinate() { - LineString target = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); Assert.Equal(_coordinatesXYZ.Last(), target.End); } @@ -133,7 +133,7 @@ public void End_ReturnsLastCoordinate() [Fact] public void IsClosed_ReturnsTrueForClosedLineString() { - LineString target = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); target.Coordinates.Add(target.Coordinates[0]); Assert.True(target.IsClosed); @@ -142,7 +142,7 @@ public void IsClosed_ReturnsTrueForClosedLineString() [Fact] public void IsClosed_ReturnsFalseForOpenLineString() { - LineString target = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); Assert.False(target.IsClosed); } @@ -150,7 +150,7 @@ public void IsClosed_ReturnsFalseForOpenLineString() [Fact] public void IsClosed_ReturnsFalseForEmptyLineString() { - LineString target = new(); + LineString target = new LineString(); Assert.False(target.IsClosed); } @@ -158,7 +158,7 @@ public void IsClosed_ReturnsFalseForEmptyLineString() [Fact] public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() { - LineString target = new(); + LineString target = new LineString(); Envelope envelope = target.GetEnvelope(); Assert.Equal(Envelope.Empty, envelope); @@ -167,8 +167,8 @@ public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyLineString() [Fact] public void GetEnvelope_ReturnsEnvelopeOfLineString() { - LineString target = new(_coordinatesXYZ); - Envelope expected = new(_coordinatesXYZ); + LineString target = new LineString(_coordinatesXYZ); + Envelope expected = new Envelope(_coordinatesXYZ); Assert.Equal(expected, target.GetEnvelope()); } diff --git a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs index eff799b..1848790 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PointTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PointTests.cs @@ -27,7 +27,7 @@ private void ChenckPosition(Point target, double x, double y, double z, double m [Fact] public void Constructor__CreatesPointWithEmptyPosition() { - Point target = new(); + Point target = new Point(); Assert.Equal(Coordinate.Empty, target.Position); } @@ -35,7 +35,7 @@ public void Constructor__CreatesPointWithEmptyPosition() [Fact] public void Constructor_XY_SetsCoordinates() { - Point target = new(_xOrdinate, _yOrdinate); + Point target = new Point(_xOrdinate, _yOrdinate); ChenckPosition(target, _xOrdinate, _yOrdinate, double.NaN, double.NaN); } @@ -43,7 +43,7 @@ public void Constructor_XY_SetsCoordinates() [Fact] public void Constructor_XYZ_SetsCoordinates() { - Point target = new(_xOrdinate, _yOrdinate, _zOrdinate); + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, double.NaN); } @@ -51,7 +51,7 @@ public void Constructor_XYZ_SetsCoordinates() [Fact] public void Constructor_XYZM_SetsCoordinates() { - Point target = new(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate, _mValue); ChenckPosition(target, _xOrdinate, _yOrdinate, _zOrdinate, _mValue); } @@ -59,7 +59,7 @@ public void Constructor_XYZM_SetsCoordinates() [Fact] public void Constructor_Coordinate_SetsCoordinates() { - Point target = new(_coordinate); + Point target = new Point(_coordinate); Assert.Equal(_coordinate, target.Position); } @@ -67,7 +67,7 @@ public void Constructor_Coordinate_SetsCoordinates() [Fact] public void Is3D_ReturnsTrueFor3DPoint() { - Point target = new(_xOrdinate, _yOrdinate, _zOrdinate); + Point target = new Point(_xOrdinate, _yOrdinate, _zOrdinate); Assert.True(target.Is3D); } @@ -75,7 +75,7 @@ public void Is3D_ReturnsTrueFor3DPoint() [Fact] public void Is3D_ReturnsFalseFor2DPoint() { - Point target = new(_xOrdinate, _yOrdinate); + Point target = new Point(_xOrdinate, _yOrdinate); Assert.False(target.Is3D); } @@ -83,7 +83,7 @@ public void Is3D_ReturnsFalseFor2DPoint() [Fact] public void IsMeasured_ReturnsTrueForMeasuredPoint() { - Point target = new(_xOrdinate, _yOrdinate, double.NaN, _mValue); + Point target = new Point(_xOrdinate, _yOrdinate, double.NaN, _mValue); Assert.True(target.IsMeasured); } @@ -91,7 +91,7 @@ public void IsMeasured_ReturnsTrueForMeasuredPoint() [Fact] public void IsMeasured_ReturnsFalseForNonMeasuredPoint() { - Point target = new(_xOrdinate, _yOrdinate); + Point target = new Point(_xOrdinate, _yOrdinate); Assert.False(target.IsMeasured); } @@ -99,7 +99,7 @@ public void IsMeasured_ReturnsFalseForNonMeasuredPoint() [Fact] public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() { - Point target = new(); + Point target = new Point(); Envelope envelope = target.GetEnvelope(); Assert.Equal(double.NaN, envelope.MinX); @@ -115,7 +115,7 @@ public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPoint() [Fact] public void GetEnvelope_ReturnsEnvelopeThatCoversOnePoint() { - Point target = new(_coordinate); + Point target = new Point(_coordinate); Envelope envelope = target.GetEnvelope(); Assert.Equal(_coordinate.X, envelope.MinX); diff --git a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs index be57fe0..e3bf4dd 100644 --- a/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/PolygonTests.cs @@ -7,13 +7,13 @@ namespace Tests.SpatialLite.Core.Geometries; public class PolygonTests { private readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new(1, 2), new(1.1, 2.1), new(1.2, 2.2), new(1.3, 2.3) + new Coordinate(1, 2), new Coordinate(1.1, 2.1), new Coordinate(1.2, 2.2), new Coordinate(1.3, 2.3) }; private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new(1, 2, 3), new(1.1, 2.1, 3.1), new(1.2, 2.2, 3.2), new(1.3, 2.3, 3.3) + new Coordinate(1, 2, 3), new Coordinate(1.1, 2.1, 3.1), new Coordinate(1.2, 2.2, 3.2), new Coordinate(1.3, 2.3, 3.3) }; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new(1, 2, 3, 10), new(1.1, 2.1, 3.1, 20), new(1.2, 2.2, 3.2, 30), new(1.3, 2.3, 3.3, 40) + new Coordinate(1, 2, 3, 10), new Coordinate(1.1, 2.1, 3.1, 20), new Coordinate(1.2, 2.2, 3.2, 30), new Coordinate(1.3, 2.3, 3.3, 40) }; private readonly CoordinateList _exteriorRing3D; private readonly CoordinateList[] _interiorRings3D; @@ -39,7 +39,7 @@ private void CheckInteriorRings(Polygon target, CoordinateList[] expected) [Fact] public void Constructor__CreatesEmptyPolygonAndInitializesProperties() { - Polygon target = new(); + Polygon target = new Polygon(); Assert.NotNull(target.ExteriorRing); Assert.Empty(target.ExteriorRing); @@ -51,7 +51,7 @@ public void Constructor__CreatesEmptyPolygonAndInitializesProperties() [Fact] public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() { - Polygon target = new(_exteriorRing3D); + Polygon target = new Polygon(_exteriorRing3D); Assert.Same(_exteriorRing3D, target.ExteriorRing); @@ -62,7 +62,7 @@ public void Constructor_ExteriorRing_CreatesPolygonWithExteriorBoundary() [Fact] public void Is3D_ReturnsTrueFor3DExteriorRing() { - Polygon target = new(_exteriorRing3D); + Polygon target = new Polygon(_exteriorRing3D); Assert.True(target.Is3D); } @@ -70,7 +70,7 @@ public void Is3D_ReturnsTrueFor3DExteriorRing() [Fact] public void Is3D_ReturnsFalseForEmptyPolygon() { - Polygon target = new(); + Polygon target = new Polygon(); Assert.False(target.Is3D); } @@ -78,7 +78,7 @@ public void Is3D_ReturnsFalseForEmptyPolygon() [Fact] public void Is3D_ReturnsFalseFor2DExteriorRing() { - Polygon target = new(new CoordinateList(_coordinatesXY)); + Polygon target = new Polygon(new CoordinateList(_coordinatesXY)); Assert.False(target.Is3D); } @@ -86,7 +86,7 @@ public void Is3D_ReturnsFalseFor2DExteriorRing() [Fact] public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() { - Polygon target = new(new CoordinateList(_coordinatesXYZM)); + Polygon target = new Polygon(new CoordinateList(_coordinatesXYZM)); Assert.True(target.IsMeasured); } @@ -94,7 +94,7 @@ public void IsMeasured_ReturnsTrueForMeasuredExteriorRing() [Fact] public void IsMeasured_ReturnsFalseForEmptyPolygon() { - Polygon target = new(); + Polygon target = new Polygon(); Assert.False(target.IsMeasured); } @@ -102,7 +102,7 @@ public void IsMeasured_ReturnsFalseForEmptyPolygon() [Fact] public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() { - Polygon target = new(new CoordinateList(_coordinatesXYZ)); + Polygon target = new Polygon(new CoordinateList(_coordinatesXYZ)); Assert.False(target.IsMeasured); } @@ -110,7 +110,7 @@ public void IsMeasured_ReturnsFalseForNonMeasuredExteriorRing() [Fact] public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() { - Polygon target = new(); + Polygon target = new Polygon(); Envelope envelope = target.GetEnvelope(); Assert.Equal(Envelope.Empty, envelope); @@ -119,9 +119,9 @@ public void GetEnvelope_ReturnsEmptyEnvelopeForEmptyPolygon() [Fact] public void GetEnvelopeReturnsEnvelopeOfLineString() { - Envelope expectedEnvelope = new(_coordinatesXYZ); + Envelope expectedEnvelope = new Envelope(_coordinatesXYZ); - Polygon target = new(_exteriorRing3D); + Polygon target = new Polygon(_exteriorRing3D); Envelope envelope = target.GetEnvelope(); Assert.Equal(expectedEnvelope, envelope); diff --git a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs index e47f6cf..f04fa05 100644 --- a/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Core/Geometries/ReadOnlyCoordinateListTests.cs @@ -8,16 +8,16 @@ namespace Tests.SpatialLite.Core.Geometries; public class ReadOnlyCoordinateListTests { - private readonly List _points = new(new Point[] { - new(5, 1.1, 2.2), - new(6, 10.1, -20.2), - new(7, -30.1, 40.2) }); + private readonly List _points = new List(new Point[] { + new Point(5, 1.1, 2.2), + new Point(6, 10.1, -20.2), + new Point(7, -30.1, 40.2) }); [Fact] public void Constructor_Source_SetsSource() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Same(_points, target.Source); } @@ -25,7 +25,7 @@ public void Constructor_Source_SetsSource() [Fact] public void Indexer_Get_ReturnsCoordinatesFromSourceList() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); for (int i = 0; i < _points.Count; i++) { @@ -36,7 +36,7 @@ public void Indexer_Get_ReturnsCoordinatesFromSourceList() [Fact] public void Indexer_Set_ThrowsNotSupportedException() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Throws(() => target[0] = new Coordinate(10.1, 11.2)); } @@ -44,7 +44,7 @@ public void Indexer_Set_ThrowsNotSupportedException() [Fact] public void Count_GetsNumberOfItemsInSourceCollection() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Equal(_points.Count, target.Count); } @@ -52,7 +52,7 @@ public void Count_GetsNumberOfItemsInSourceCollection() [Fact] public void Add_Coordinate_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Throws(() => target.Add(Coordinate.Empty)); } @@ -60,7 +60,7 @@ public void Add_Coordinate_ThowsNotSupportedException() [Fact] public void Add_Coordinates_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Throws(() => target.Add(new Coordinate[] { Coordinate.Empty })); } @@ -68,7 +68,7 @@ public void Add_Coordinates_ThowsNotSupportedException() [Fact] public void Insert_Index_Coordinate_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Throws(() => target.Insert(0, Coordinate.Empty)); } @@ -76,7 +76,7 @@ public void Insert_Index_Coordinate_ThowsNotSupportedException() [Fact] public void RemoveAt_Index_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Throws(() => target.RemoveAt(0)); } @@ -84,7 +84,7 @@ public void RemoveAt_Index_ThowsNotSupportedException() [Fact] public void Clear_ThowsNotSupportedException() { - ReadOnlyCoordinateList target = new(_points); + ReadOnlyCoordinateList target = new ReadOnlyCoordinateList(_points); Assert.Throws(target.Clear); } diff --git a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs index d0483ed..8fc4ea6 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbReaderTests.cs @@ -28,9 +28,9 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = "../../../Data/IO/point-3DM.wkb"; - WkbReader target = new(filename); + WkbReader target = new WkbReader(filename); target.Dispose(); - FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -39,7 +39,7 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() { var stream = TestDataReader.Open("point-3DM.wkb"); - WkbReader target = new(stream); + WkbReader target = new WkbReader(stream); target.Dispose(); Assert.False(stream.CanRead); @@ -48,9 +48,9 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() [Fact] public void Read_ReturnsNullIfStreamIsEmpty() { - MemoryStream stream = new(); + MemoryStream stream = new MemoryStream(); - WkbReader target = new(stream); + WkbReader target = new WkbReader(stream); Geometry read = target.Read(); Assert.Null(read); @@ -61,7 +61,7 @@ public void Read_ReadsGeometry() { Point expected = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); Point parsed = (Point)target.Read(); ComparePoints(parsed, expected); @@ -73,7 +73,7 @@ public void Read_ReadsMultipleGeometries() Point expected1 = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); Point expected2 = (Point)ParseWKT("point zm (-10.2 15.6 100.6 1000.6)"); - WkbReader target = new(TestDataReader.Open("two-points-3DM.wkb")); + WkbReader target = new WkbReader(TestDataReader.Open("two-points-3DM.wkb")); Point parsed1 = (Point)target.Read(); ComparePoints(parsed1, expected1); @@ -85,7 +85,7 @@ public void Read_ReadsMultipleGeometries() [Fact] public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() { - WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); target.Read(); Geometry parsed = target.Read(); @@ -97,9 +97,9 @@ public void Read_ReturnsNullIfNoMoreGeometriesAreAvailable() public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new(wkb)) + using (MemoryStream ms = new MemoryStream(wkb)) { - WkbReader target = new(ms); + WkbReader target = new WkbReader(ms); Assert.Throws(target.Read); } @@ -108,9 +108,9 @@ public void Read_ThrowsExceptionIfWKBDoesNotRepresentGeometry() [Fact] public void ReadT_ReturnsNullIfStreamIsEmpty() { - MemoryStream stream = new(); + MemoryStream stream = new MemoryStream(); - WkbReader target = new(stream); + WkbReader target = new WkbReader(stream); Geometry read = target.Read(); Assert.Null(read); @@ -121,7 +121,7 @@ public void ReadT_ReadsGeometry() { Point expected = (Point)ParseWKT("point zm (-10.1 15.5 100.5 1000.5)"); - WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); Point parsed = target.Read(); ComparePoints(parsed, expected); @@ -130,7 +130,7 @@ public void ReadT_ReadsGeometry() [Fact] public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() { - WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); target.Read(); Geometry parsed = target.Read(); @@ -142,9 +142,9 @@ public void ReadT_ReturnsNullIfNoMoreGeometriesAreAvailable() public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() { byte[] wkb = new byte[] { 12, 0, 0, 45, 78, 124, 36, 0 }; - using (MemoryStream ms = new(wkb)) + using (MemoryStream ms = new MemoryStream(wkb)) { - WkbReader target = new(ms); + WkbReader target = new WkbReader(ms); Assert.Throws(target.Read); } @@ -153,7 +153,7 @@ public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentGeometry() [Fact] public void ReadT_ThrowsExceptionIfWKBDoesNotRepresentSpecifiecGeometryType() { - WkbReader target = new(TestDataReader.Open("point-3DM.wkb")); + WkbReader target = new WkbReader(TestDataReader.Open("point-3DM.wkb")); Assert.Throws(target.Read); } diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs index c609379..8268aaf 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterSettingsTests.cs @@ -10,7 +10,7 @@ public class WkbWriterSettingsTests [Fact] public void Constructor__SetsDefaultValues() { - WkbWriterSettings target = new(); + WkbWriterSettings target = new WkbWriterSettings(); Assert.Equal(BinaryEncoding.LittleEndian, target.Encoding); } @@ -18,7 +18,7 @@ public void Constructor__SetsDefaultValues() [Fact] public void UseDenseFormatSetter_ThrowInvaldOperationExceptionIfSettingsIsReadOnly() { - WkbWriterSettings target = new(); + WkbWriterSettings target = new WkbWriterSettings(); target.IsReadOnly = true; Assert.Throws(() => target.Encoding = BinaryEncoding.BigEndian); diff --git a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs index 7562bc7..c679924 100644 --- a/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WkbWriterTests.cs @@ -16,8 +16,8 @@ public class WkbWriterTests [Fact] public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - WkbWriterSettings settings = new(); - using (WkbWriter target = new(new MemoryStream(), settings)) + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -40,8 +40,8 @@ public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNu [Fact] public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() { - WkbWriterSettings settings = new(); - using (WkbWriter target = new(new MemoryStream(), settings)) + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -53,8 +53,8 @@ public void Constructor_PathSettings_CreatesOutputFile() { string filename = PathHelper.GetTempFilePath("wkbwriter-constructor-creates-output-test.bin"); - WkbWriterSettings settings = new(); - using (WkbWriter target = new(filename, settings)) + WkbWriterSettings settings = new WkbWriterSettings(); + using (WkbWriter target = new WkbWriter(filename, settings)) { ; } @@ -80,7 +80,7 @@ public void Constructor_PathSettings_ThrowsArgumentNullExceptionIfSettingsIsNull [Fact] public void Constructor_ThrowsExceptionIfEncodingIsSetToBingEndian() { - MemoryStream stream = new(); + MemoryStream stream = new MemoryStream(); Assert.Throws(() => new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.BigEndian })); } @@ -89,19 +89,19 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = PathHelper.GetTempFilePath("wkbwriter-closes-output-filestream-test.bin"); - WkbWriterSettings settings = new(); - WkbWriter target = new(filename, settings); + WkbWriterSettings settings = new WkbWriterSettings(); + WkbWriter target = new WkbWriter(filename, settings); target.Dispose(); - FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } [Fact] public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new(); + MemoryStream stream = new MemoryStream(); - WkbWriter target = new(stream, new WkbWriterSettings()); + WkbWriter target = new WkbWriter(stream, new WkbWriterSettings()); target.Dispose(); Assert.False(stream.CanRead); @@ -110,8 +110,8 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() [Fact] public void WkbWriter_Write_WritesLittleEndianEncodingByte() { - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings() { Encoding = BinaryEncoding.LittleEndian })) { target.Write(new Point()); @@ -125,8 +125,8 @@ public void Write_WritesEmptyPointAsEmptyGeoemtryCollection() string wkt = "point empty"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); @@ -140,8 +140,8 @@ public void Write_Writes2DPoint() string wkt = "point (-10.1 15.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); @@ -155,8 +155,8 @@ public void Write_Writes2DMeasuredPoint() string wkt = "point m (-10.1 15.5 1000.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); @@ -170,8 +170,8 @@ public void Write_Writes3DPoint() string wkt = "point z (-10.1 15.5 100.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); @@ -185,8 +185,8 @@ public void Write_Writes3DMeasuredPoint() string wkt = "point zm (-10.1 15.5 100.5 1000.5)"; Point point = (Point)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(point); @@ -200,8 +200,8 @@ public void Write_WritesEmptyLineString() string wkt = "linestring empty"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -215,8 +215,8 @@ public void Write_Writes2DLineString() string wkt = "linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -230,8 +230,8 @@ public void Write_Writes2DMeasuredLineString() string wkt = "linestring m (-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -245,8 +245,8 @@ public void Write_Writes3DLineString() string wkt = "linestring z (-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -260,7 +260,7 @@ public void Write_Writes3DMeasuredLineString() string wkt = "linestring zm (-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)"; LineString linestring = (LineString)ParseWKT(wkt); - MemoryStream stream = new(); using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(linestring); @@ -274,8 +274,8 @@ public void Write_WritesEmptyPolygon() string wkt = "polygon empty"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -289,8 +289,8 @@ public void Write_Writes2DPolygonOnlyExteriorRing() string wkt = "polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -304,8 +304,8 @@ public void Write_Writes2DMeasuredPolygonOnlyExteriorRing() string wkt = "polygon m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -319,8 +319,8 @@ public void Write_Writes3DPolygonOnlyExteriorRing() string wkt = "polygon z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -334,8 +334,8 @@ public void Write_Writes3DMeasuredPolygonOnlyExteriorRing() string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -349,8 +349,8 @@ public void Write_Writes3DMeasuredPolygon() string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; Polygon polygon = (Polygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(polygon); @@ -364,8 +364,8 @@ public void Write_WritesEmptyMultipoint() string wkt = "multipoint empty"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -379,8 +379,8 @@ public void Write_Writes2DMultiPoint() string wkt = "multipoint ((-10.1 15.5),(20.2 -25.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -394,8 +394,8 @@ public void Write_Writes2DMeasuredMultiPoint() string wkt = "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -409,8 +409,8 @@ public void Write_Writes3DMultiPoint() string wkt = "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -424,8 +424,8 @@ public void Write_Writes3DMeasuredMultiPoint() string wkt = "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))"; MultiPoint multipoint = (MultiPoint)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipoint); @@ -439,8 +439,8 @@ public void Write_WritesEmptyMultiLineString() string wkt = "multilinestring empty"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -454,8 +454,8 @@ public void Write_Writes2DMultiLineString() string wkt = "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -469,8 +469,8 @@ public void Write_Writes2DMeasuredMultiLineString() string wkt = "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -484,8 +484,8 @@ public void Write_Writes3DMultiLineString() string wkt = "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -499,8 +499,8 @@ public void Write_Writes3DMeasuredMultiLineString() string wkt = "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))"; MultiLineString multilinestring = (MultiLineString)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multilinestring); @@ -514,8 +514,8 @@ public void Write_WritesEmptyMultiPolygon() string wkt = "multipolygon empty"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -529,8 +529,8 @@ public void Write_Writes2DMultiPolygon() string wkt = "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -544,8 +544,8 @@ public void Write_Writes2DMeasuredMultiPolygon() string wkt = "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -559,8 +559,8 @@ public void Write_Writes3DMultiPolygon() string wkt = "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -574,8 +574,8 @@ public void Write_Writes3DMeasuredMultiPolygon() string wkt = "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))"; MultiPolygon multipolygon = (MultiPolygon)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(multipolygon); @@ -589,8 +589,8 @@ public void Write_WritesEmptyGeometryCollection() string wkt = "geometrycollection empty"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); @@ -604,8 +604,8 @@ public void Write_Writes2DGeometryCollection() string wkt = "geometrycollection (point (-10.1 15.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); @@ -619,8 +619,8 @@ public void Write_Writes2DMeasuredGeometryCollection() string wkt = "geometrycollection m (point m (-10.1 15.5 1000.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); @@ -634,8 +634,8 @@ public void Write_Writes3DGeometryCollection() string wkt = "geometrycollection z (point z (-10.1 15.5 100.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); @@ -649,8 +649,8 @@ public void Write_Writes3DMeasuredGeometryCollection() string wkt = "geometrycollection zm (point zm (-10.1 15.5 100.5 1000.5))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); @@ -664,8 +664,8 @@ public void Write_WritesCollectionWithPointLineStringAndPolygon() string wkt = "geometrycollection (point (-10.1 15.5),linestring (-10.1 15.5, 20.2 -25.5, 30.3 35.5),polygon ((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); @@ -679,8 +679,8 @@ public void Write_WritesCollectionWithMultiGeometries() string wkt = "geometrycollection (multipoint empty,multilinestring empty,multipolygon empty)"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); @@ -694,8 +694,8 @@ public void Write_WritesNestedCollection() string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; GeometryCollection collection = (GeometryCollection)ParseWKT(wkt); - MemoryStream stream = new(); - using (WkbWriter target = new(stream, new WkbWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WkbWriter target = new WkbWriter(stream, new WkbWriterSettings())) { target.Write(collection); diff --git a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs index 015ed07..01307ef 100644 --- a/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktReaderTests.cs @@ -14,23 +14,23 @@ public class WktReaderTests { private readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new(-10.1, 15.5), new(20.2, -25.5), new(30.3, 35.5) + new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) }; private readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new(-10.1, 15.5, 100.5), new(20.2, -25.5, 200.5), new(30.3, 35.5, -300.5) + new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) }; private readonly Coordinate[] _coordinatesXYM = new Coordinate[] { - new(-10.1, 15.5, double.NaN, 1000.5), new(20.2, -25.5, double.NaN, 2000.5), new(30.3, 35.5, double.NaN, -3000.5) + new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) }; private readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new(-10.1, 15.5, 100.5, 1000.5), new(20.2, -25.5, 200.5, 2000.5), new(30.3, 35.5, -300.5, -3000.5) + new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) }; private readonly Coordinate[] _coordinates2XYZM = new Coordinate[] { - new(-1.1, 1.5, 10.5, 100.5), new(2.2, -2.5, 20.5, 200.5), new(3.3, 3.5, -30.5, -300.5) + new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) }; [Fact] @@ -51,9 +51,9 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = "../../../Data/IO/wkt-point-3DM.wkt"; - WktReader target = new(filename); + WktReader target = new WktReader(filename); target.Dispose(); - FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } @@ -62,7 +62,7 @@ public void Dispose_ClosesOutputStreamIfWritingToStream() { var stream = TestDataReader.Open("wkt-point-3DM.wkt"); - WktReader target = new(stream); + WktReader target = new WktReader(stream); target.Dispose(); Assert.False(stream.CanRead); @@ -85,7 +85,7 @@ public static IEnumerable Read_ReadsAllGeometryTypesTestData [MemberData(nameof(Read_ReadsAllGeometryTypesTestData))] public void Read_ReadsAllGeometryTypes(byte[] data) { - using (WktReader target = new(new MemoryStream(data))) + using (WktReader target = new WktReader(new MemoryStream(data))) { IGeometry readGeometry = target.Read(); Assert.NotNull(readGeometry); @@ -95,7 +95,7 @@ public void Read_ReadsAllGeometryTypes(byte[] data) [Fact] public void Read_ReturnsNullIfStreamIsEmpty() { - using (WktReader target = new(new MemoryStream())) + using (WktReader target = new WktReader(new MemoryStream())) { IGeometry readGeometry = target.Read(); @@ -106,7 +106,7 @@ public void Read_ReturnsNullIfStreamIsEmpty() [Fact] public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() { - using (WktReader target = new(TestDataReader.Open("wkt-point-3DM.wkt"))) + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { target.Read(); IGeometry readGeometry = target.Read(); @@ -118,7 +118,7 @@ public void Read_ReturnsNullIfNoMoreGeometriesAreAvailableInInputStream() [Fact] public void Read_ReadsMultipleGeometries() { - using (WktReader target = new(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-and-linestring-3DM.wkt"))) { IGeometry readGeometry = target.Read(); Assert.True(readGeometry is Point); @@ -131,7 +131,7 @@ public void Read_ReadsMultipleGeometries() [Fact] public void ReadT_ReadsGeometry() { - using (WktReader target = new(TestDataReader.Open("wkt-point-3DM.wkt"))) + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { Point read = target.Read(); Assert.NotNull(read); @@ -141,7 +141,7 @@ public void ReadT_ReadsGeometry() [Fact] public void ReadT_ReturnsNullIfStreamIsEmpty() { - using (WktReader target = new(new MemoryStream())) + using (WktReader target = new WktReader(new MemoryStream())) { IGeometry readGeometry = target.Read(); @@ -152,7 +152,7 @@ public void ReadT_ReturnsNullIfStreamIsEmpty() [Fact] public void ReadT_ThrowsExceptionIfWKTDoesNotRepresentGeometryOfSpecificType() { - using (WktReader target = new(TestDataReader.Open("wkt-point-3DM.wkt"))) + using (WktReader target = new WktReader(TestDataReader.Open("wkt-point-3DM.wkt"))) { Assert.Throws(target.Read); } diff --git a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs index 71c2fe2..1b99267 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokenizerTests.cs @@ -88,7 +88,7 @@ private void Tokenize_String_ProcessesComplexText() [Fact] private void Tokenize_TextReader_ProcessesComplexText() { - StringReader reader = new("point z (-10 -15 -100.1)"); + StringReader reader = new StringReader("point z (-10 -15 -100.1)"); var tokens = WktTokenizer.Tokenize(reader).ToArray(); diff --git a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs index a680ac5..1f71711 100644 --- a/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktTokensBufferTests.cs @@ -7,13 +7,13 @@ namespace Tests.SpatialLite.Core.IO; public class WktTokensBufferTests { - private readonly WktToken[] _testData = new WktToken[] {new() {Type = TokenType.STRING, Value = "point"}, new() {Type = TokenType.WHITESPACE, Value=" "}, - new() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; + private readonly WktToken[] _testData = new WktToken[] {new WktToken() {Type = TokenType.STRING, Value = "point"}, new WktToken() {Type = TokenType.WHITESPACE, Value=" "}, + new WktToken() {Type = TokenType.LEFT_PARENTHESIS, Value = "("}}; [Fact] public void Constructor__CreatesEmptyBuffer() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); Assert.Empty(target); } @@ -21,7 +21,7 @@ public void Constructor__CreatesEmptyBuffer() [Fact] public void Constructor_TextReader_CreatesBufferWithSpecificTokens() { - WktTokensBuffer target = new(_testData); + WktTokensBuffer target = new WktTokensBuffer(_testData); Assert.Equal(_testData.Length, target.Count()); for (int i = 0; i < _testData.Length; i++) @@ -33,7 +33,7 @@ public void Constructor_TextReader_CreatesBufferWithSpecificTokens() [Fact] public void Count_GetsNumberOfItemsInBufffer() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(_testData); Assert.Equal(_testData.Length, target.Count); @@ -42,7 +42,7 @@ public void Count_GetsNumberOfItemsInBufffer() [Fact] public void Add_WktToken_AddsItemToTheCollection() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(_testData[0]); Assert.Single(target); @@ -52,7 +52,7 @@ public void Add_WktToken_AddsItemToTheCollection() [Fact] public void Add_IEnumerable_AddsItemsToTheCollection() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(_testData); Assert.Equal(_testData.Length, target.Count()); @@ -65,7 +65,7 @@ public void Add_IEnumerable_AddsItemsToTheCollection() [Fact] public void Clear_RemovesAllItemsFromCollection() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(_testData); target.Clear(); @@ -76,7 +76,7 @@ public void Clear_RemovesAllItemsFromCollection() [Fact] public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(_testData[0]); var result = target.Peek(false); @@ -88,7 +88,7 @@ public void Peek_IgnoreWhitespace_GetsNextTokenFromBufferAndLeavesItThere() [Fact] public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(_testData[0]); @@ -102,8 +102,8 @@ public void Peek_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTr [Fact] public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() { - WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new(); + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); target.Add(whitespaceToken); target.Add(_testData[0]); @@ -116,7 +116,7 @@ public void Peek_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndN [Fact] public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); var result = target.Peek(false); @@ -126,8 +126,8 @@ public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailabl [Fact] public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() { - WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new(); + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); target.Add(whitespaceToken); var result = target.Peek(true); @@ -138,7 +138,7 @@ public void Peek_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAre [Fact] public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(_testData[0]); var result = target.GetToken(false); @@ -150,7 +150,7 @@ public void GetToken_IgnoreWhitespace_GetsNextTokenFromBufferAndRemoveIt() [Fact] public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreTokenIsTrue() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(new WktToken() { Type = TokenType.WHITESPACE, Value = " " }); target.Add(_testData[0]); @@ -164,8 +164,8 @@ public void GetToken_IgnoreWhitespace_IgnoresWhitespacesBeforeTokenIfIgnoreToken [Fact] public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalseAndNextTokenIsWhitespace() { - WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new(); + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); target.Add(whitespaceToken); target.Add(_testData[0]); @@ -178,7 +178,7 @@ public void GetToken_IgnoreWhitespace_ReturnsWhitespaceIfIgnoreWhitespaceIsFalse [Fact] public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvailable() { - WktTokensBuffer target = new(); + WktTokensBuffer target = new WktTokensBuffer(); var result = target.GetToken(false); @@ -188,8 +188,8 @@ public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfNoMoreTokensAreAvai [Fact] public void GetToken_IgnoreWhitespace_ReturnsEndOfDataTokenIfOnlyWhitespaceTokensAreAvailalbleAndIgnoreWhitespaceIsTrue() { - WktToken whitespaceToken = new() { Type = TokenType.WHITESPACE, Value = " " }; - WktTokensBuffer target = new(); + WktToken whitespaceToken = new WktToken() { Type = TokenType.WHITESPACE, Value = " " }; + WktTokensBuffer target = new WktTokensBuffer(); target.Add(whitespaceToken); var result = target.GetToken(true); diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs index 765ed2a..91c5f84 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterSettingsTests.cs @@ -9,7 +9,7 @@ public class WktWriterSettingsTests [Fact] public void Constructor__SetsDefaultValues() { - WktWriterSettings target = new(); + WktWriterSettings target = new WktWriterSettings(); Assert.False(target.IsReadOnly); } diff --git a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs index b3fba74..f00f4e1 100644 --- a/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs +++ b/src/Tests.SpatialLite.Core/IO/WktWriterTests.cs @@ -13,30 +13,30 @@ public class WktWriterTests private static readonly Coordinate[] _coordinatesXY = new Coordinate[] { - new(-10.1, 15.5), new(20.2, -25.5), new(30.3, 35.5) + new Coordinate(-10.1, 15.5), new Coordinate(20.2, -25.5), new Coordinate(30.3, 35.5) }; private static readonly Coordinate[] _coordinatesXYZ = new Coordinate[] { - new(-10.1, 15.5, 100.5), new(20.2, -25.5, 200.5), new(30.3, 35.5, -300.5) + new Coordinate(-10.1, 15.5, 100.5), new Coordinate(20.2, -25.5, 200.5), new Coordinate(30.3, 35.5, -300.5) }; private static readonly Coordinate[] _coordinatesXYM = new Coordinate[] { - new(-10.1, 15.5, double.NaN, 1000.5), new(20.2, -25.5, double.NaN, 2000.5), new(30.3, 35.5, double.NaN, -3000.5) + new Coordinate(-10.1, 15.5, double.NaN, 1000.5), new Coordinate(20.2, -25.5, double.NaN, 2000.5), new Coordinate(30.3, 35.5, double.NaN, -3000.5) }; private static readonly Coordinate[] _coordinatesXYZM = new Coordinate[] { - new(-10.1, 15.5, 100.5, 1000.5), new(20.2, -25.5, 200.5, 2000.5), new(30.3, 35.5, -300.5, -3000.5) + new Coordinate(-10.1, 15.5, 100.5, 1000.5), new Coordinate(20.2, -25.5, 200.5, 2000.5), new Coordinate(30.3, 35.5, -300.5, -3000.5) }; private static readonly Coordinate[] _coordinates2XYZM = new Coordinate[] { - new(-1.1, 1.5, 10.5, 100.5), new(2.2, -2.5, 20.5, 200.5), new(3.3, 3.5, -30.5, -300.5) + new Coordinate(-1.1, 1.5, 10.5, 100.5), new Coordinate(2.2, -2.5, 20.5, 200.5), new Coordinate(3.3, 3.5, -30.5, -300.5) }; [Fact] public void Construcotor_StreamSettings_SetsSettingsAndMakeThemReadOnly() { - WktWriterSettings settings = new(); - using (WktWriter target = new(new MemoryStream(), settings)) + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -59,8 +59,8 @@ public void Constructor_StreamSettings_ThrowsArgumentNullExceptionIfSettingsIsNu [Fact] public void Construcotor_PathSettings_SetsSettingsAndMakeThemReadOnly() { - WktWriterSettings settings = new(); - using (WktWriter target = new(new MemoryStream(), settings)) + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(new MemoryStream(), settings)) { Assert.Same(settings, target.Settings); Assert.True(settings.IsReadOnly); @@ -73,8 +73,8 @@ public void Constructor_PathSettings_CreatesOutputFile() string filename = PathHelper.GetTempFilePath("wktwriter-constructor-creates-output-test.wkt"); File.Delete(filename); - WktWriterSettings settings = new(); - using (WktWriter target = new(filename, settings)) + WktWriterSettings settings = new WktWriterSettings(); + using (WktWriter target = new WktWriter(filename, settings)) { ; } @@ -124,19 +124,19 @@ public void Dispose_ClosesOutputStreamIfWritingToFiles() { string filename = PathHelper.GetTempFilePath("wktwriter-closes-output-filestream-test.wkt"); - WktWriterSettings settings = new(); - WktWriter target = new(filename, settings); + WktWriterSettings settings = new WktWriterSettings(); + WktWriter target = new WktWriter(filename, settings); target.Dispose(); - FileStream testStream = new(filename, FileMode.Open, FileAccess.ReadWrite); + FileStream testStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite); testStream.Dispose(); } [Fact] public void Dispose_ClosesOutputStreamIfWritingToStream() { - MemoryStream stream = new(); + MemoryStream stream = new MemoryStream(); - WktWriter target = new(stream, new WktWriterSettings()); + WktWriter target = new WktWriter(stream, new WktWriterSettings()); target.Dispose(); Assert.False(stream.CanRead); @@ -203,7 +203,7 @@ public void Write_WritesPolygonsOfAllDimensions(Polygon toWrite, string expected public void Write_WritesComplexPolygonWitOuterAndInnerRings() { string wkt = "polygon zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5),(-1.1 1.5 10.5 100.5, 2.2 -2.5 20.5 200.5, 3.3 3.5 -30.5 -300.5))"; - Polygon polygon = new(new CoordinateList(_coordinatesXYZM)); + Polygon polygon = new Polygon(new CoordinateList(_coordinatesXYZM)); polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); polygon.InteriorRings.Add(new CoordinateList(_coordinates2XYZM)); @@ -215,10 +215,10 @@ public static IEnumerable Write_WritesMultiPoinsOfAllDimensionsTestDat get { yield return new object[] { new MultiPoint(), "multipoint empty" }; - yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXY[0]), new(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXYM[0]), new(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXYZ[0]), new(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; - yield return new object[] { new MultiPoint(new Point[] { new(_coordinatesXYZM[0]), new(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXY[0]), new Point(_coordinatesXY[1]) }), "multipoint ((-10.1 15.5),(20.2 -25.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYM[0]), new Point(_coordinatesXYM[1]) }), "multipoint m ((-10.1 15.5 1000.5),(20.2 -25.5 2000.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZ[0]), new Point(_coordinatesXYZ[1]) }), "multipoint z ((-10.1 15.5 100.5),(20.2 -25.5 200.5))" }; + yield return new object[] { new MultiPoint(new Point[] { new Point(_coordinatesXYZM[0]), new Point(_coordinatesXYZM[1]) }), "multipoint zm ((-10.1 15.5 100.5 1000.5),(20.2 -25.5 200.5 2000.5))" }; } } @@ -234,13 +234,13 @@ public static IEnumerable Write_WritesMultiLineStringsOfAllDimensionsT get { yield return new object[] { new MultiLineString(), "multilinestring empty" }; - yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXY), new(_coordinatesXY) }), + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXY), new LineString(_coordinatesXY) }), "multilinestring ((-10.1 15.5, 20.2 -25.5, 30.3 35.5),(-10.1 15.5, 20.2 -25.5, 30.3 35.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXYM), new(_coordinatesXYM) }), + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYM), new LineString(_coordinatesXYM) }), "multilinestring m ((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5),(-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXYZ), new(_coordinatesXYZ) }), + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZ), new LineString(_coordinatesXYZ) }), "multilinestring z ((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5),(-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5))" }; - yield return new object[] { new MultiLineString(new LineString[] { new(_coordinatesXYZM), new(_coordinatesXYZM) }), + yield return new object[] { new MultiLineString(new LineString[] { new LineString(_coordinatesXYZM), new LineString(_coordinatesXYZM) }), "multilinestring zm ((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5),(-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5))" }; } } @@ -257,13 +257,13 @@ public static IEnumerable Write_WritesMultiPolygonsOfAllDimensionsTest get { yield return new object[] { new MultiPolygon(), "multipolygon empty" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXY)), new(new CoordinateList(_coordinatesXY)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXY)), new Polygon(new CoordinateList(_coordinatesXY)) }), "multipolygon (((-10.1 15.5, 20.2 -25.5, 30.3 35.5)),((-10.1 15.5, 20.2 -25.5, 30.3 35.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXYM)), new(new CoordinateList(_coordinatesXYM)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYM)), new Polygon(new CoordinateList(_coordinatesXYM)) }), "multipolygon m (((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)),((-10.1 15.5 1000.5, 20.2 -25.5 2000.5, 30.3 35.5 -3000.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXYZ)), new(new CoordinateList(_coordinatesXYZ)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZ)), new Polygon(new CoordinateList(_coordinatesXYZ)) }), "multipolygon z (((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)),((-10.1 15.5 100.5, 20.2 -25.5 200.5, 30.3 35.5 -300.5)))" }; - yield return new object[] { new MultiPolygon(new Polygon[] { new(new CoordinateList(_coordinatesXYZM)), new(new CoordinateList(_coordinatesXYZM)) }), + yield return new object[] { new MultiPolygon(new Polygon[] { new Polygon(new CoordinateList(_coordinatesXYZM)), new Polygon(new CoordinateList(_coordinatesXYZM)) }), "multipolygon zm (((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)),((-10.1 15.5 100.5 1000.5, 20.2 -25.5 200.5 2000.5, 30.3 35.5 -300.5 -3000.5)))" }; } } @@ -298,7 +298,7 @@ public void Write_WritesGeometryCollectionOfAllDimensions(GeometryCollection collection = new(); + GeometryCollection collection = new GeometryCollection(); collection.Geometries.Add(new Point(_coordinatesXY[0])); collection.Geometries.Add(new LineString(_coordinatesXY)); collection.Geometries.Add(new Polygon(new CoordinateList(_coordinatesXY))); @@ -313,8 +313,8 @@ public void Write_WritesCollectionWithAllGeometryTypes() public void Write_WritesNestedCollection() { string wkt = "geometrycollection (geometrycollection (point (-10.1 15.5)))"; - GeometryCollection collection = new(); - GeometryCollection nested = new(); + GeometryCollection collection = new GeometryCollection(); + GeometryCollection nested = new GeometryCollection(); nested.Geometries.Add(new Point(_coordinatesXY[0])); collection.Geometries.Add(nested); @@ -323,8 +323,8 @@ public void Write_WritesNestedCollection() private void TestWriteGeometry(IGeometry geometry, string expectedWkt) { - MemoryStream stream = new(); - using (WktWriter writer = new(stream, new WktWriterSettings())) + MemoryStream stream = new MemoryStream(); + using (WktWriter writer = new WktWriter(stream, new WktWriterSettings())) { writer.Write(geometry); } diff --git a/src/Tests.SpatialLite.Core/MeasurementsTests.cs b/src/Tests.SpatialLite.Core/MeasurementsTests.cs index 69a0f62..f1a9178 100644 --- a/src/Tests.SpatialLite.Core/MeasurementsTests.cs +++ b/src/Tests.SpatialLite.Core/MeasurementsTests.cs @@ -26,9 +26,9 @@ public void Sphere2D_GetsInstanceOfMeasuremntsWithTheSphere2DCalculator() [Fact] public void Constructor_SetsCalculatorObject() { - Mock calculatorM = new(); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); Assert.Same(calculatorM.Object, target.DimensionsCalculator); } @@ -36,11 +36,11 @@ public void Constructor_SetsCalculatorObject() [Fact] public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCorrectParameters() { - Coordinate c1 = new(10.1, 20.1); - Coordinate c2 = new(10.2, 20.2); - Mock calculatorM = new(); + Coordinate c1 = new Coordinate(10.1, 20.1); + Coordinate c2 = new Coordinate(10.2, 20.2); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(c1, c2); calculatorM.Verify(calc => calc.CalculateDistance(c1, c2), Times.Once()); @@ -49,11 +49,11 @@ public void ComputeDistance_CoordinateCoordinate_CallsIDistanceCalculatorWithCor [Fact] public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() { - Point p1 = new(Coordinate.Empty); - Point p2 = new(new Coordinate(10.2, 20.2)); - Mock calculatorM = new(); + Point p1 = new Point(Coordinate.Empty); + Point p2 = new Point(new Coordinate(10.2, 20.2)); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(p1, p2); Assert.True(double.IsNaN(distance)); @@ -62,11 +62,11 @@ public void ComputeDistance_PointPoint_ReturnsNaNIfPoint1IsEmpty() [Fact] public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() { - Point p1 = new(new Coordinate(10.1, 20.1)); - Point p2 = new(Coordinate.Empty); - Mock calculatorM = new(); + Point p1 = new Point(new Coordinate(10.1, 20.1)); + Point p2 = new Point(Coordinate.Empty); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(p1, p2); Assert.True(double.IsNaN(distance)); @@ -75,11 +75,11 @@ public void ComputeDistance_PointPoint_ReturnsNaNIfPoint2IsEmpty() [Fact] public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParameters() { - Point p1 = new(new Coordinate(10.1, 20.1)); - Point p2 = new(new Coordinate(10.2, 20.2)); - Mock calculatorM = new(); + Point p1 = new Point(new Coordinate(10.1, 20.1)); + Point p2 = new Point(new Coordinate(10.2, 20.2)); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(p1, p2); calculatorM.Verify(calc => calc.CalculateDistance(p1.Position, p2.Position), Times.Once()); @@ -88,12 +88,12 @@ public void ComputeDistance_PointPoint_CallsIDistanceCalculatorWithCorrectParame [Fact] public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() { - Point point = new(new Coordinate(10.1, 20.1)); - LineString linestring = new(); + Point point = new Point(new Coordinate(10.1, 20.1)); + LineString linestring = new LineString(); - Mock calculatorM = new(); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(point, linestring); Assert.True(double.IsNaN(distance)); @@ -102,12 +102,12 @@ public void ComputeDistance_PointLineString_ReturnsNaNIfLineStringIsEmpty() [Fact] public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() { - Point point = new(Coordinate.Empty); - LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); + Point point = new Point(Coordinate.Empty); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); - Mock calculatorM = new(); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(point, linestring); Assert.True(double.IsNaN(distance)); @@ -116,12 +116,12 @@ public void ComputeDistance_PointLineString_ReturnsNaNIfPointIsEmpty() [Fact] public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEmpty() { - Point point = new(new Coordinate(10.1, 20.1)); - MultiLineString multilinestring = new(); + Point point = new Point(new Coordinate(10.1, 20.1)); + MultiLineString multilinestring = new MultiLineString(); - Mock calculatorM = new(); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(point, multilinestring); Assert.True(double.IsNaN(distance)); @@ -130,13 +130,13 @@ public void ComputeDistance_PointMultiLineString_ReturnsNaNIfMultiLineStringIsEm [Fact] public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() { - Point point = new(Coordinate.Empty); - LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); - MultiLineString multilinestring = new(new LineString[] { linestring, linestring }); + Point point = new Point(Coordinate.Empty); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); - Mock calculatorM = new(); + Mock calculatorM = new Mock(); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double distance = target.ComputeDistance(point, multilinestring); Assert.True(double.IsNaN(distance)); @@ -145,10 +145,10 @@ public void ComputeDistance_PointMultiLineString_ReturnsNaNIfPointIsEmpty() [Fact] public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() { - LineString linestring = new(); + LineString linestring = new LineString(); - Mock calculatorM = new(); - Measurements target = new(calculatorM.Object); + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); double length = target.ComputeLength(linestring); @@ -158,10 +158,10 @@ public void ComputeLength_LineString_RetursZeroForLineStringWithoutPoints() [Fact] public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() { - LineString linestring = new(new Coordinate[] { new(10.1, 20.1) }); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1) }); - Mock calculatorM = new(); - Measurements target = new(calculatorM.Object); + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); double length = target.ComputeLength(linestring); @@ -171,17 +171,17 @@ public void ComputeLength_LineString_RetursZeroForLineStringWithoutOne() [Fact] public void ComputeLength_LineString_RetursSumOfSegmentsLengths() { - Random generator = new(); + Random generator = new Random(); double segment1Length = generator.Next(100); double segment2Length = generator.Next(100); double sum = segment1Length + segment2Length; - LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); - Mock calculatorM = new(); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + Mock calculatorM = new Mock(); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double length = target.ComputeLength(linestring); Assert.Equal(sum, length); @@ -190,10 +190,10 @@ public void ComputeLength_LineString_RetursSumOfSegmentsLengths() [Fact] public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMembers() { - MultiLineString multilinestring = new(); + MultiLineString multilinestring = new MultiLineString(); - Mock calculatorM = new(); - Measurements target = new(calculatorM.Object); + Mock calculatorM = new Mock(); + Measurements target = new Measurements(calculatorM.Object); double length = target.ComputeLength(multilinestring); @@ -203,19 +203,19 @@ public void ComputeLength_MultiLineString_RetursZeroForMultiLineStringWithoutMem [Fact] public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() { - Random generator = new(); + Random generator = new Random(); double segment1Length = generator.Next(100); double segment2Length = generator.Next(100); double sum = 2 * (segment1Length + segment2Length); - LineString linestring = new(new Coordinate[] { new(10.1, 20.1), new(10.2, 20.2), new(10.3, 20.3) }); - MultiLineString multilinestring = new(new LineString[] { linestring, linestring }); + LineString linestring = new LineString(new Coordinate[] { new Coordinate(10.1, 20.1), new Coordinate(10.2, 20.2), new Coordinate(10.3, 20.3) }); + MultiLineString multilinestring = new MultiLineString(new LineString[] { linestring, linestring }); - Mock calculatorM = new(); + Mock calculatorM = new Mock(); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[0], linestring.Coordinates[1])).Returns(segment1Length); calculatorM.Setup(calc => calc.CalculateDistance(linestring.Coordinates[1], linestring.Coordinates[2])).Returns(segment2Length); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double length = target.ComputeLength(multilinestring); Assert.Equal(sum, length); @@ -224,13 +224,13 @@ public void ComputeLength_MultiLineString_RetursSumOfLineStringsLengths() [Fact] public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensionsCalculator() { - Polygon polygon = new(new CoordinateList()); - Random generator = new(); + Polygon polygon = new Polygon(new CoordinateList()); + Random generator = new Random(); double expectedArea = generator.Next(100); - Mock calculatorM = new(); + Mock calculatorM = new Mock(); calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(expectedArea); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double area = target.ComputeArea(polygon); @@ -241,7 +241,7 @@ public void ComputeArea_IPolygon_ReturnsAreaOfSimplePolygonCalculatedByIDimensio public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDimensionsCalculator() { // Create polygon with interior ring - Polygon polygon = new(new CoordinateList()); + Polygon polygon = new Polygon(new CoordinateList()); polygon.InteriorRings.Add(new CoordinateList()); // Fixed test values @@ -250,7 +250,7 @@ public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDi double expectedArea = exteriorArea - interiorArea; // Setup mock - Mock calculatorM = new(); + Mock calculatorM = new Mock(); calculatorM.Setup(calc => calc.CalculateArea(It.IsAny())) .Returns(coords => { @@ -260,7 +260,7 @@ public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDi }); // Create the object being tested - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); // Execute the method being tested double area = target.ComputeArea(polygon); @@ -272,16 +272,16 @@ public void ComputeArea_IPolygon_ReturnsAreaOfPolygonWithoutHolesCalculatedByIDi [Fact] public void ComputeArea_IMultiPolygon_ReturnsSumOfPolygonAreas() { - Random generator = new(); + Random generator = new Random(); - Polygon polygon = new(new CoordinateList()); + Polygon polygon = new Polygon(new CoordinateList()); double polygonArea = generator.Next(100); - MultiPolygon multipolygon = new(new Polygon[] { polygon, polygon }); + MultiPolygon multipolygon = new MultiPolygon(new Polygon[] { polygon, polygon }); - Mock calculatorM = new(); + Mock calculatorM = new Mock(); calculatorM.Setup(calc => calc.CalculateArea(polygon.ExteriorRing)).Returns(() => polygonArea); - Measurements target = new(calculatorM.Object); + Measurements target = new Measurements(calculatorM.Object); double area = target.ComputeArea(multipolygon); diff --git a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs index b8ca9f1..b27ee2e 100644 --- a/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/EntityCollectionTests.cs @@ -1,17 +1,15 @@ -using System; -using System.Linq; - -using Xunit; -using Moq; - +using Moq; using SpatialLite.Osm; using SpatialLite.Osm.Geometries; +using System; +using System.Linq; +using Xunit; namespace Tests.SpatialLite.Osm; public class EntityCollectionTests { - IOsmGeometry[] _data; + private readonly IOsmGeometry[] _data; public EntityCollectionTests() { diff --git a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs index 0a7a784..367ef58 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs @@ -1,6 +1,4 @@ using Xunit; - -using SpatialLite.Core; using SpatialLite.Core.API; using SpatialLite.Osm; using SpatialLite.Osm.Geometries; diff --git a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs index f231c74..ffde51c 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs @@ -1,22 +1,21 @@ -using System; +using Moq; +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.IO; +using System; using System.Collections.Generic; using System.Linq; -using System.IO; - -using Xunit; -using Moq; -using SpatialLite.Osm.IO; -using SpatialLite.Osm.Geometries; using Tests.SpatialLite.Osm.Data; +using Xunit; namespace Tests.SpatialLite.Osm.Geometries; public class OsmGeometryDatabaseTests { - Node[] _nodeData; - Way[] _wayData; - Relation[] _relationData; - IOsmGeometry[] _data; + private readonly Node[] _nodeData; + private readonly Way[] _wayData; + private readonly Relation[] _relationData; + private readonly IOsmGeometry[] _data; + public OsmGeometryDatabaseTests() { _nodeData = new Node[3]; @@ -101,7 +100,7 @@ public void Load_LoadsWay() Assert.True(target.Nodes.Contains(2)); Assert.True(target.Nodes.Contains(3)); - Assert.Single(target.Ways); + Assert.Single(target.Ways); Assert.True(target.Ways.Contains(10)); } @@ -111,10 +110,10 @@ public void Load_LoadsRelation() IOsmReader reader = new OsmXmlReader(TestDataReader.OpenOsmDB("osm-relation.osm"), new OsmXmlReaderSettings() { ReadMetadata = true }); OsmGeometryDatabase target = OsmGeometryDatabase.Load(reader, true); - Assert.Single(target.Nodes); + Assert.Single(target.Nodes); Assert.True(target.Nodes.Contains(1)); - Assert.Single(target.Relations); + Assert.Single(target.Relations); Assert.True(target.Relations.Contains(100)); } @@ -145,7 +144,7 @@ public void Load_DoesNotThrowExceptionIfIgnoreMissingIsTrueAndWaysNodeIsMissing( OsmGeometryDatabase target = null; target = OsmGeometryDatabase.Load(reader, true); - Assert.Equal(2, target.Nodes.Count); + Assert.Equal(2, target.Nodes.Count); Assert.Empty(target.Ways); } diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs index e845287..ae2c7ee 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationMemberTests.cs @@ -1,17 +1,15 @@ -using System; - -using Xunit; -using Moq; - -using SpatialLite.Osm.Geometries; +using Moq; using SpatialLite.Core.API; using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using System; +using Xunit; namespace Tests.SpatialLite.Osm.Geometries; public class RelationMemberTests { - IEntityCollection _nodesEntityCollection; + private readonly IEntityCollection _nodesEntityCollection; public RelationMemberTests() { diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs index a92ca18..d99f684 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs @@ -1,20 +1,18 @@ -using System; +using Moq; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using System; using System.Collections.Generic; - using Xunit; -using Moq; - -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; namespace Tests.SpatialLite.Osm.Geometries; public class RelationTests { - RelationInfo _relationEmptyInfo = new(100, new TagsCollection(), new List(), new EntityMetadata()); - RelationInfo _relationInfo = new(100, new TagsCollection(), new RelationMemberInfo[] { new() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); + private readonly RelationInfo _relationEmptyInfo = new(100, new TagsCollection(), new List(), new EntityMetadata()); + private readonly RelationInfo _relationInfo = new(100, new TagsCollection(), new RelationMemberInfo[] { new() { Reference = 1, MemberType = EntityType.Node } }, new EntityMetadata()); - IEntityCollection _nodesEntityCollection; + private readonly IEntityCollection _nodesEntityCollection; public RelationTests() { diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs index 0fb94ca..b7d5da7 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs @@ -1,17 +1,14 @@ -using System; +using SpatialLite.Core.API; +using SpatialLite.Osm.Geometries; +using System; using System.Collections.Generic; -using System.Linq; - using Xunit; -using SpatialLite.Core.API; -using SpatialLite.Osm.Geometries; - namespace Tests.SpatialLite.Osm.Geometries; public class WayCoordinateListTests { - List _nodes = new(new Node[] { + private readonly List _nodes = new(new Node[] { new(5, 1.1, 2.2), new(6, 10.1, -20.2), new(7, -30.1, 40.2) }); diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs index d68f2f2..c94e940 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs @@ -1,27 +1,24 @@ -using System; -using System.Collections.Generic; - -using Xunit; -using Moq; - -using SpatialLite.Core; +using Moq; using SpatialLite.Core.Geometries; -using SpatialLite.Osm.Geometries; using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using System; +using System.Collections.Generic; +using Xunit; namespace Tests.SpatialLite.Osm.Geometries; public class WayTests { - List _nodes = new(new Node[] { + private readonly List _nodes = new(new Node[] { new(1, 1.1, 2.2), new(2, 10.1, -20.2), new(3, -30.1, 40.2) }); - WayInfo _wayEmptyInfo = new(10, new TagsCollection(), new List(), new EntityMetadata()); - WayInfo _wayInfo = new(10, new TagsCollection(), new long[] { 1, 2, 3 }, new EntityMetadata()); + private readonly WayInfo _wayEmptyInfo = new(10, new TagsCollection(), new List(), new EntityMetadata()); + private readonly WayInfo _wayInfo = new(10, new TagsCollection(), new long[] { 1, 2, 3 }, new EntityMetadata()); - IEntityCollection _nodesEntityCollection; + private readonly IEntityCollection _nodesEntityCollection; public WayTests() { diff --git a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs index 1807480..a9af74f 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmReaderSettingsTests.cs @@ -1,9 +1,7 @@ -using System; - +using SpatialLite.Osm.IO; +using System; using Xunit; -using SpatialLite.Osm.IO; - namespace Tests.SpatialLite.Osm.IO; public class OsmReaderSettingsTests diff --git a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs index 1f47e7b..eba0dfe 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmWriterSettingsTests.cs @@ -1,9 +1,7 @@ -using System; - +using SpatialLite.Osm.IO; +using System; using Xunit; -using SpatialLite.Osm.IO; - namespace Tests.SpatialLite.Osm.IO; public class OsmWriterSettingsTests diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs index ad607af..0fb9f5e 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs @@ -1,21 +1,20 @@ -using System; -using System.Linq; +using SpatialLite.Osm; +using SpatialLite.Osm.IO; +using System; using System.IO; +using System.Linq; using System.Xml; - -using Xunit; -using SpatialLite.Osm.IO; -using SpatialLite.Osm; using Tests.SpatialLite.Osm.Data; +using Xunit; namespace Tests.SpatialLite.Osm.IO; public class OsmXmlReaderTests { - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationTags, _relationProperties, _relationWithoutMembers; + private readonly EntityMetadata _details; + private readonly NodeInfo _node, _nodeTags, _nodeProperties; + private readonly WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private readonly RelationInfo _relationNode, _relationWay, _relationRelation, _relationTags, _relationProperties, _relationWithoutMembers; public OsmXmlReaderTests() { diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs index dfad056..ab0d9ab 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs @@ -1,13 +1,11 @@ -using System; -using System.Linq; -using System.IO; - -using Xunit; - +using SpatialLite.Osm; using SpatialLite.Osm.Geometries; -using System.Xml.Linq; using SpatialLite.Osm.IO; -using SpatialLite.Osm; +using System; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using Xunit; namespace Tests.SpatialLite.Osm.IO; @@ -16,10 +14,10 @@ public class OsmXmlWriterTests //resolution for default granularity private const double _resolution = 1E-07; - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; + private readonly EntityMetadata _details; + private readonly NodeInfo _node, _nodeTags, _nodeProperties; + private readonly WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private readonly RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; public OsmXmlWriterTests() { diff --git a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs index 0febddc..8285cbf 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs @@ -1,12 +1,10 @@ -using System; -using System.Linq; -using System.IO; - -using Xunit; - -using SpatialLite.Osm; +using SpatialLite.Osm; using SpatialLite.Osm.IO; +using System; +using System.IO; +using System.Linq; using Tests.SpatialLite.Osm.Data; +using Xunit; namespace Tests.SpatialLite.Osm.IO; @@ -15,10 +13,10 @@ public class PbfReaderTests //resolution for default granularity private const double _resolution = 1E-07; - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationProperties, _relationTags; + private readonly EntityMetadata _details; + private readonly NodeInfo _node, _nodeTags, _nodeProperties; + private readonly WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private readonly RelationInfo _relationNode, _relationWay, _relationRelation, _relationProperties, _relationTags; public PbfReaderTests() { diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs index b00c863..c0efdd2 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterSettingsTests.cs @@ -1,9 +1,7 @@ -using System; - +using SpatialLite.Osm.IO; +using System; using Xunit; -using SpatialLite.Osm.IO; - namespace Tests.SpatialLite.Osm.IO; public class PbfWriterSettingsTests diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs index a35cb16..8f935c7 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs @@ -1,13 +1,11 @@ -using System; -using System.Linq; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.IO; +using System; using System.IO; - +using System.Linq; using Xunit; -using SpatialLite.Osm.IO; -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; - namespace Tests.SpatialLite.Osm.IO; public class PbfWriterTests @@ -15,10 +13,10 @@ public class PbfWriterTests //resolution for default granularity private const double _resolution = 1E-07; - private EntityMetadata _details; - private NodeInfo _node, _nodeTags, _nodeProperties; - private WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; - private RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; + private readonly EntityMetadata _details; + private readonly NodeInfo _node, _nodeTags, _nodeProperties; + private readonly WayInfo _way, _wayTags, _wayProperties, _wayWithoutNodes; + private readonly RelationInfo _relationNode, _relationWay, _relationRelation, _relationNodeProperties, _relationTags; public PbfWriterTests() { diff --git a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs index 046de3b..6074dc4 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Pbf/PbfReaderPbfWriterComplianceTests.cs @@ -1,11 +1,9 @@ -using System.Collections.Generic; -using System.IO; - -using Xunit; - -using SpatialLite.Osm; +using SpatialLite.Osm; using SpatialLite.Osm.IO; +using System.Collections.Generic; +using System.IO; using Tests.SpatialLite.Osm.Data; +using Xunit; namespace Tests.SpatialLite.Osm.Integration.Pbf; diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs index b5db2c7..3766c9f 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmDatabaseTests.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using SpatialLite.Osm; +using SpatialLite.Osm; using SpatialLite.Osm.Geometries; using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; diff --git a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs index 6a75775..f2658fc 100644 --- a/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs +++ b/src/Tests.SpatialLite.Osm/Integration/Xml/OsmosisIntegrationTests.cs @@ -1,13 +1,11 @@ -using System.Collections.Generic; +using SpatialLite.Osm; +using SpatialLite.Osm.IO; +using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.IO; - -using Xunit; - -using SpatialLite.Osm; -using SpatialLite.Osm.IO; using Tests.SpatialLite.Osm.Data; -using System.Globalization; +using Xunit; namespace Tests.SpatialLite.Osm.Integration.Xml; diff --git a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs index 7de95ae..5a330f1 100644 --- a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs @@ -16,9 +16,9 @@ public void Constructor_PropertiesWithoutEntityDetails_SetsProperties() int id = 15; double latitude = 15.4; double longitude = -23.7; - TagsCollection tags = new(); + TagsCollection tags = new TagsCollection(); - NodeInfo target = new(id, latitude, longitude, tags); + NodeInfo target = new NodeInfo(id, latitude, longitude, tags); Assert.Equal(EntityType.Node, target.EntityType); Assert.Equal(id, target.ID); @@ -34,10 +34,10 @@ public void Constructor_Properties_SetsProperties() int id = 15; double latitude = 15.4; double longitude = -23.7; - TagsCollection tags = new(); - EntityMetadata details = new(); + TagsCollection tags = new TagsCollection(); + EntityMetadata details = new EntityMetadata(); - NodeInfo target = new(id, latitude, longitude, tags, details); + NodeInfo target = new NodeInfo(id, latitude, longitude, tags, details); Assert.Equal(EntityType.Node, target.EntityType); Assert.Equal(id, target.ID); @@ -50,9 +50,9 @@ public void Constructor_Properties_SetsProperties() [Fact] public void Constructor_Node_SetsProperties() { - Node node = new(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; + Node node = new Node(1, 10.1, 12.1, new TagsCollection()) { Metadata = new EntityMetadata() }; - NodeInfo target = new(node); + NodeInfo target = new NodeInfo(node); Assert.Equal(node.ID, target.ID); Assert.Equal(node.Position.X, target.Longitude); diff --git a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs index 11598e6..c6ba6d3 100644 --- a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs @@ -1,20 +1,18 @@ -using System; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using System; using System.Collections.Generic; using System.Linq; - using Xunit; -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; - namespace Tests.SpatialLite.Osm; public class OsmDatabaseTests { - Node[] _nodeData; - Way[] _wayData; - Relation[] _relationData; - IOsmGeometry[] _data; + private readonly Node[] _nodeData; + private readonly Way[] _wayData; + private readonly Relation[] _relationData; + private readonly IOsmGeometry[] _data; public OsmDatabaseTests() { diff --git a/src/Tests.SpatialLite.Osm/PathHelper.cs b/src/Tests.SpatialLite.Osm/PathHelper.cs index fda0327..241b96a 100644 --- a/src/Tests.SpatialLite.Osm/PathHelper.cs +++ b/src/Tests.SpatialLite.Osm/PathHelper.cs @@ -2,18 +2,18 @@ namespace Tests.SpatialLite.Osm; -static class PathHelper +internal static class PathHelper { private const string TempDirectoryName = "Temp"; - private static string _osmosisPath = Path.GetFullPath(Path.Combine("Utils", "Osmosis", "bin", "osmosis.bat")); + private static readonly string _osmosisPath = Path.GetFullPath(Path.Combine("Utils", "Osmosis", "bin", "osmosis.bat")); public static string OsmosisPath => _osmosisPath; - private static string _realXmlFilePath = Path.GetFullPath(Path.Combine("Data", "Xml", "osm-real-file.osm")); + private static readonly string _realXmlFilePath = Path.GetFullPath(Path.Combine("Data", "Xml", "osm-real-file.osm")); public static string RealXmlFilePath => _realXmlFilePath; - private static string _realPbfFilePath = Path.GetFullPath(Path.Combine("Data", "Pbf", "pbf-real-file.pbf")); + private static readonly string _realPbfFilePath = Path.GetFullPath(Path.Combine("Data", "Pbf", "pbf-real-file.pbf")); public static string RealPbfFilePath => _realPbfFilePath; public static string GetTempFilePath(string filename) diff --git a/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs b/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs index b1b700a..01a3102 100644 --- a/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs +++ b/src/Tests.SpatialLite.Osm/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs index f331bf0..931d443 100644 --- a/src/Tests.SpatialLite.Osm/RelationInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationInfoTests.cs @@ -1,11 +1,9 @@ -using System; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using System; using System.Collections.Generic; - using Xunit; -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; - namespace Tests.SpatialLite.Osm; public class RelationMemberTests diff --git a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs index cfa8a89..c3b938d 100644 --- a/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/RelationMemberInfoTests.cs @@ -1,7 +1,6 @@ -using Xunit; - -using SpatialLite.Osm; +using SpatialLite.Osm; using SpatialLite.Osm.Geometries; +using Xunit; namespace Tests.SpatialLite.Osm; diff --git a/src/Tests.SpatialLite.Osm/TagTests.cs b/src/Tests.SpatialLite.Osm/TagTests.cs index f630d3c..580f249 100644 --- a/src/Tests.SpatialLite.Osm/TagTests.cs +++ b/src/Tests.SpatialLite.Osm/TagTests.cs @@ -1,9 +1,7 @@ -using System; - +using SpatialLite.Osm; +using System; using Xunit; -using SpatialLite.Osm; - namespace Tests.SpatialLite.Osm; public class TagTests diff --git a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs index e90728c..92dc0ca 100644 --- a/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs +++ b/src/Tests.SpatialLite.Osm/TagsCollectionTests.cs @@ -1,22 +1,20 @@ -using System; +using SpatialLite.Osm; +using System; using System.Collections.Generic; using System.Linq; - using Xunit; -using SpatialLite.Osm; - namespace Tests.SpatialLite.Osm; public class TagsCollectionTests { - Tag[] _tags = new Tag[] { + private readonly Tag[] _tags = new Tag[] { new("test-key-1", "test-value-1"), new("test-key-2", "test-value-2"), new("test-key-3", "test-value-3") }; - Tag[] _tagsDuplicitKeys = new Tag[] { + private readonly Tag[] _tagsDuplicitKeys = new Tag[] { new("test-key-1", "test-value-1"), new("test-key-1", "test-value-2") }; diff --git a/src/Tests.SpatialLite.Osm/WayInfoTests.cs b/src/Tests.SpatialLite.Osm/WayInfoTests.cs index ad33876..6039014 100644 --- a/src/Tests.SpatialLite.Osm/WayInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/WayInfoTests.cs @@ -1,11 +1,9 @@ -using System; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using System; using System.Collections.Generic; - using Xunit; -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; - namespace Tests.SpatialLite.Osm; public class WayInfoTests From 4d07ad06e5e4099df5410e34c41cc6428d54d674 Mon Sep 17 00:00:00 2001 From: Lukas Kabrt Date: Fri, 23 May 2025 00:13:21 +0200 Subject: [PATCH 12/14] Fix formatting --- src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs | 6 ++++-- src/Tests.SpatialLite.Osm/NodeInfoTests.cs | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs index 367ef58..5f75128 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/NodeTests.cs @@ -1,9 +1,11 @@ -using Xunit; + + using SpatialLite.Core.API; using SpatialLite.Osm; using SpatialLite.Osm.Geometries; +using Xunit; -namespace Tests.SpatialLite.Osm.Geometry; +namespace Tests.SpatialLite.Osm.Geometries; public class NodeTests { diff --git a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs index 5a330f1..5d6a8f2 100644 --- a/src/Tests.SpatialLite.Osm/NodeInfoTests.cs +++ b/src/Tests.SpatialLite.Osm/NodeInfoTests.cs @@ -1,9 +1,7 @@ -using System; - -using Xunit; - +using SpatialLite.Osm; using SpatialLite.Osm.Geometries; -using SpatialLite.Osm; +using System; +using Xunit; namespace Tests.SpatialLite.Osm; From 8aacb5be4697dcb47248c110d28af125727db11d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 May 2025 06:32:33 +0000 Subject: [PATCH 13/14] Fix formatting issues according to .editorconfig rules Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- src/Benchmark.SpatialLite.Osm/Program.cs | 8 ++-- src/SpatialLite.Core/API/Coordinate.cs | 4 +- src/SpatialLite.Core/IO/WktWriter.cs | 38 +++++++++---------- src/SpatialLite.Core/Measurements.cs | 12 +++--- src/SpatialLite.Core/Topology.cs | 6 +-- src/SpatialLite.Gps/IO/GpxReader.cs | 2 +- .../Geometries/OsmGeometryDatabase.cs | 4 +- .../Geometries/RelationMember.cs | 2 +- src/SpatialLite.Osm/Geometries/Way.cs | 2 +- src/SpatialLite.Osm/IO/OsmXmlWriter.cs | 6 +-- src/SpatialLite.Osm/IO/PbfReader.cs | 2 +- src/SpatialLite.Osm/IO/PbfWriter.cs | 2 +- src/SpatialLite.Osm/RelationMemberInfo.cs | 6 +-- src/Tests.SpatialLite.Gps/PathHelper.cs | 4 +- .../Geometries/OsmGeometryDatabaseTests.cs | 2 +- .../Geometries/RelationTests.cs | 1 - .../Geometries/WayCoordinateListTests.cs | 2 +- .../Geometries/WayTests.cs | 2 +- .../IO/OsmXmlReaderTests.cs | 24 ++++++------ .../IO/OsmXmlWriterTests.cs | 2 +- .../IO/PbfReaderTests.cs | 2 +- .../IO/PbfWriterTests.cs | 2 +- src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs | 1 - src/Tests.SpatialLite.Osm/TagTests.cs | 1 - 24 files changed, 67 insertions(+), 70 deletions(-) diff --git a/src/Benchmark.SpatialLite.Osm/Program.cs b/src/Benchmark.SpatialLite.Osm/Program.cs index cf5d844..7f70e55 100644 --- a/src/Benchmark.SpatialLite.Osm/Program.cs +++ b/src/Benchmark.SpatialLite.Osm/Program.cs @@ -42,7 +42,7 @@ private static void Main(string[] args) foreach (var benchmark in benchmarks) { long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); - tw.WriteLine(string.Format("{0} ms \t\t{1}", avgTime, benchmark.Item1)); + tw.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} ms \t\t{1}", avgTime, benchmark.Item1)); } } } @@ -50,12 +50,12 @@ private static void Main(string[] args) private static long DoTest(Action testAction, string testName) { - Console.WriteLine(string.Format("Starting benchmark '{0}'", testName)); + Console.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Starting benchmark '{0}'", testName)); long totalTime = 0; for (int i = 0; i < 10; i++) { - Console.Write(string.Format("Run ({0}/{1}) ...", i + 1, 10)); + Console.Write(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Run ({0}/{1}) ...", i + 1, 10)); Stopwatch watch = new Stopwatch(); watch.Start(); @@ -63,7 +63,7 @@ private static long DoTest(Action testAction, string testName) watch.Stop(); totalTime += watch.ElapsedMilliseconds; - Console.WriteLine(string.Format("\t\t({0} ms)", watch.ElapsedMilliseconds)); + Console.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "\t\t({0} ms)", watch.ElapsedMilliseconds)); } Console.WriteLine(); diff --git a/src/SpatialLite.Core/API/Coordinate.cs b/src/SpatialLite.Core/API/Coordinate.cs index c0e68cb..7c290b8 100644 --- a/src/SpatialLite.Core/API/Coordinate.cs +++ b/src/SpatialLite.Core/API/Coordinate.cs @@ -17,7 +17,7 @@ public struct Coordinate : IEquatable /// /// The empty coordinate has all coordinates equal to NaN. /// - public static Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); + public static readonly Coordinate Empty = new Coordinate(double.NaN, double.NaN, double.NaN, double.NaN); /// /// Initializes a new instance of the Coordinate struct with X, Y ordinates. @@ -139,7 +139,7 @@ public override readonly string ToString() /// /// The object to compare with the current Coordinate /// true if the specified object is equal to the current Coordinate; otherwise, false. - public override bool Equals(object obj) + public override readonly bool Equals(object obj) { Coordinate? other = obj as Coordinate?; if (other == null) diff --git a/src/SpatialLite.Core/IO/WktWriter.cs b/src/SpatialLite.Core/IO/WktWriter.cs index 07374d1..810f2c8 100644 --- a/src/SpatialLite.Core/IO/WktWriter.cs +++ b/src/SpatialLite.Core/IO/WktWriter.cs @@ -11,7 +11,7 @@ namespace SpatialLite.Core.IO; public class WktWriter : IDisposable { - private static readonly System.Globalization.CultureInfo _invariantCulture = System.Globalization.CultureInfo.InvariantCulture; + private static readonly System.Globalization.CultureInfo InvariantCulture = System.Globalization.CultureInfo.InvariantCulture; private bool _disposed = false; private readonly TextWriter _writer; @@ -103,33 +103,33 @@ public static string WriteToString(IGeometry geometry) /// The output Stream the Geometry will be written to. protected static void Write(IGeometry geometry, TextWriter writer) { - if (geometry is IPoint) + if (geometry is IPoint point) { - AppendPointTaggedText((IPoint)geometry, writer); + AppendPointTaggedText(point, writer); } - else if (geometry is ILineString) + else if (geometry is ILineString lineString) { - AppendLineStringTaggedText((ILineString)geometry, writer); + AppendLineStringTaggedText(lineString, writer); } - else if (geometry is IPolygon) + else if (geometry is IPolygon polygon) { - AppendPolygonTaggedText((IPolygon)geometry, writer); + AppendPolygonTaggedText(polygon, writer); } - else if (geometry is IMultiPoint) + else if (geometry is IMultiPoint multiPoint) { - AppendMultiPointTaggedText((IMultiPoint)geometry, writer); + AppendMultiPointTaggedText(multiPoint, writer); } - else if (geometry is IMultiLineString) + else if (geometry is IMultiLineString multiLineString) { - AppendMultiLineStringTaggedText((IMultiLineString)geometry, writer); + AppendMultiLineStringTaggedText(multiLineString, writer); } - else if (geometry is IMultiPolygon) + else if (geometry is IMultiPolygon multiPolygon) { - AppendMultiPolygonTaggetText((IMultiPolygon)geometry, writer); + AppendMultiPolygonTaggetText(multiPolygon, writer); } - else if (geometry is IGeometryCollection) + else if (geometry is IGeometryCollection geometryCollection) { - AppendGeometryCollectionTaggedText((IGeometryCollection)geometry, writer); + AppendGeometryCollectionTaggedText(geometryCollection, writer); } } @@ -140,20 +140,20 @@ protected static void Write(IGeometry geometry, TextWriter writer) /// The output Stream to Appent WKT representation to. private static void AppendCoordinate(Coordinate coordinate, TextWriter writer) { - writer.Write(coordinate.X.ToString(_invariantCulture)); + writer.Write(coordinate.X.ToString(InvariantCulture)); writer.Write(' '); - writer.Write(coordinate.Y.ToString(_invariantCulture)); + writer.Write(coordinate.Y.ToString(InvariantCulture)); if (coordinate.Is3D) { writer.Write(' '); - writer.Write(coordinate.Z.ToString(_invariantCulture)); + writer.Write(coordinate.Z.ToString(InvariantCulture)); } if (coordinate.IsMeasured) { writer.Write(' '); - writer.Write(coordinate.M.ToString(_invariantCulture)); + writer.Write(coordinate.M.ToString(InvariantCulture)); } } diff --git a/src/SpatialLite.Core/Measurements.cs b/src/SpatialLite.Core/Measurements.cs index 336c1ca..c2a3193 100644 --- a/src/SpatialLite.Core/Measurements.cs +++ b/src/SpatialLite.Core/Measurements.cs @@ -10,16 +10,16 @@ namespace SpatialLite.Core; public class Measurements { - private static readonly Measurements _euclidean2D; - private static readonly Measurements _sphere2D; + private static readonly Measurements euclidean2DInstance; + private static readonly Measurements sphere2DInstance; /// /// Initializes static members of the Measurements class. /// static Measurements() { - _euclidean2D = new Measurements(new Euclidean2DCalculator()); - _sphere2D = new Measurements(new Sphere2DCalculator()); + euclidean2DInstance = new Measurements(new Euclidean2DCalculator()); + sphere2DInstance = new Measurements(new Sphere2DCalculator()); } /// @@ -38,7 +38,7 @@ public static Measurements Euclidean2D { get { - return _euclidean2D; + return euclidean2DInstance; } } @@ -49,7 +49,7 @@ public static Measurements Sphere2D { get { - return _sphere2D; + return sphere2DInstance; } } diff --git a/src/SpatialLite.Core/Topology.cs b/src/SpatialLite.Core/Topology.cs index 1cf88cb..05b4b7d 100644 --- a/src/SpatialLite.Core/Topology.cs +++ b/src/SpatialLite.Core/Topology.cs @@ -10,14 +10,14 @@ namespace SpatialLite.Core; public class Topology { - private static readonly Topology _euclidean2D; + private static readonly Topology euclidean2DInstance; /// /// Initializes static members of the Topology class. /// static Topology() { - _euclidean2D = new Topology(new Euclidean2DLocator()); + euclidean2DInstance = new Topology(new Euclidean2DLocator()); } /// @@ -27,7 +27,7 @@ public static Topology Euclidean2D { get { - return _euclidean2D; + return euclidean2DInstance; } } diff --git a/src/SpatialLite.Gps/IO/GpxReader.cs b/src/SpatialLite.Gps/IO/GpxReader.cs index edda6b4..23a638e 100644 --- a/src/SpatialLite.Gps/IO/GpxReader.cs +++ b/src/SpatialLite.Gps/IO/GpxReader.cs @@ -304,7 +304,7 @@ private void InitializeReader() string version = _xmlReader.GetAttribute("version"); if (version == null || (version != "1.0" && version != "1.1")) - throw new InvalidDataException(string.Format("Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); + throw new InvalidDataException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Invalid version of GPX document. Expected '1.0' or '1.1' found {0}.", version)); _insideGpx = true; diff --git a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs index f1da1dd..2f1d05a 100644 --- a/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs +++ b/src/SpatialLite.Osm/Geometries/OsmGeometryDatabase.cs @@ -51,7 +51,7 @@ public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferential { if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format("Way (ID = {0}) references missing node.", entityInfo.ID)); + throw new ArgumentException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Way (ID = {0}) references missing node.", entityInfo.ID)); } } else @@ -79,7 +79,7 @@ public static OsmGeometryDatabase Load(IOsmReader reader, bool ignoreReferential { if (!ignoreReferentialErrors) { - throw new ArgumentException(string.Format("Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); + throw new ArgumentException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Relation (ID = {0}) references missing OSM entity.", memberInfo.Reference)); } db.Relations.Remove(relation); diff --git a/src/SpatialLite.Osm/Geometries/RelationMember.cs b/src/SpatialLite.Osm/Geometries/RelationMember.cs index 70d2b19..8fcdef7 100644 --- a/src/SpatialLite.Osm/Geometries/RelationMember.cs +++ b/src/SpatialLite.Osm/Geometries/RelationMember.cs @@ -104,7 +104,7 @@ public static RelationMember FromRelationMemberInfo(RelationMemberInfo info, IEn { if (throwOnMissing) { - throw new ArgumentException(string.Format("Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); + throw new ArgumentException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Referenced Entity (ID = {0}, type = {1}) not found in entities collection.", info.Reference, info.MemberType), "info.Reference"); } else { diff --git a/src/SpatialLite.Osm/Geometries/Way.cs b/src/SpatialLite.Osm/Geometries/Way.cs index b26c086..9b53f27 100644 --- a/src/SpatialLite.Osm/Geometries/Way.cs +++ b/src/SpatialLite.Osm/Geometries/Way.cs @@ -109,7 +109,7 @@ public static Way FromWayInfo(WayInfo info, IEntityCollection enti { if (throwOnMissing) { - throw new ArgumentException(string.Format("Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); + throw new ArgumentException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Referenced Node (ID = {0}) not found in entities collection.", nodeID), "info.ID"); } return null; diff --git a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs index ba680ad..dad4308 100644 --- a/src/SpatialLite.Osm/IO/OsmXmlWriter.cs +++ b/src/SpatialLite.Osm/IO/OsmXmlWriter.cs @@ -227,7 +227,7 @@ private void WriteRelation(RelationInfo info) _writer.WriteStartElement("member"); _writer.WriteAttributeString("ref", info.Members[i].Reference.ToString(_culture)); _writer.WriteAttributeString("role", info.Members[i].Role); - _writer.WriteAttributeString("type", info.Members[i].MemberType.ToString().ToLower()); + _writer.WriteAttributeString("type", info.Members[i].MemberType.ToString().ToLower(_culture)); _writer.WriteEndElement(); } @@ -265,8 +265,8 @@ private void WriteMetadata(EntityMetadata medatata) _writer.WriteAttributeString("user", medatata.User); } - _writer.WriteAttributeString("visible", medatata.Visible.ToString().ToLower()); - _writer.WriteAttributeString("timestamp", medatata.Timestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'")); + _writer.WriteAttributeString("visible", medatata.Visible.ToString().ToLower(_culture)); + _writer.WriteAttributeString("timestamp", medatata.Timestamp.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", _culture)); } /// diff --git a/src/SpatialLite.Osm/IO/PbfReader.cs b/src/SpatialLite.Osm/IO/PbfReader.cs index 3627e30..f0f38cf 100644 --- a/src/SpatialLite.Osm/IO/PbfReader.cs +++ b/src/SpatialLite.Osm/IO/PbfReader.cs @@ -248,7 +248,7 @@ private void ProcessOsmHeader(OsmHeader header) { if (supportedFeatures.Contains(required) == false) { - throw new NotSupportedException(string.Format("Processing specified PBF file requires '{0}' feature which isn't supported by PbfReader.", required)); + throw new NotSupportedException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Processing specified PBF file requires '{0}' feature which isn't supported by PbfReader.", required)); } } } diff --git a/src/SpatialLite.Osm/IO/PbfWriter.cs b/src/SpatialLite.Osm/IO/PbfWriter.cs index 4dd2002..f147d98 100644 --- a/src/SpatialLite.Osm/IO/PbfWriter.cs +++ b/src/SpatialLite.Osm/IO/PbfWriter.cs @@ -83,7 +83,7 @@ public void Write(IEntityInfo entity) if (entity.Metadata.User == null) { - throw new ArgumentNullException("Entity.Metadata.User cannot be null."); + throw new ArgumentNullException(nameof(entity), "Entity.Metadata.User cannot be null."); } } diff --git a/src/SpatialLite.Osm/RelationMemberInfo.cs b/src/SpatialLite.Osm/RelationMemberInfo.cs index 488e79d..4ba0c3a 100644 --- a/src/SpatialLite.Osm/RelationMemberInfo.cs +++ b/src/SpatialLite.Osm/RelationMemberInfo.cs @@ -11,17 +11,17 @@ public struct RelationMemberInfo /// /// The type of the member (node, way, relation) /// - public EntityType MemberType; + public EntityType MemberType { get; set; } /// /// The role of the member in relation /// - public string Role; + public string Role { get; set; } /// /// The ID of the member entity /// - public long Reference; + public long Reference { get; set; } /// /// Initializes a new instance of the RelationMemberInfo structure with values from specific RelationMember. diff --git a/src/Tests.SpatialLite.Gps/PathHelper.cs b/src/Tests.SpatialLite.Gps/PathHelper.cs index 655cf79..a52e9d1 100644 --- a/src/Tests.SpatialLite.Gps/PathHelper.cs +++ b/src/Tests.SpatialLite.Gps/PathHelper.cs @@ -6,8 +6,8 @@ internal static class PathHelper { private const string TempDirectoryName = "Temp"; - private static readonly string _realGpxFilePath = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); - public static string RealGpxFilePath => _realGpxFilePath; + private static readonly string RealGpxFilePathValue = Path.GetFullPath(Path.Combine("Data", "Gpx", "gpx-real-file.gpx")); + public static string RealGpxFilePath => RealGpxFilePathValue; public static string GetTempFilePath(string filename) { diff --git a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs index ffde51c..80dd312 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/OsmGeometryDatabaseTests.cs @@ -164,7 +164,7 @@ public void Save_CallsIOsmWriterWriteForAllEntities() List written = new(); Mock writerM = new(); - writerM.Setup(w => w.Write(It.IsAny())).Callback((e) => written.Add(e)); + writerM.Setup(w => w.Write(It.IsAny())).Callback(written.Add); OsmGeometryDatabase target = new(_data); target.Save(writerM.Object); diff --git a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs index d99f684..b0ef8eb 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/RelationTests.cs @@ -111,5 +111,4 @@ public void EntityType_Returns_Relation() Assert.Equal(EntityType.Relation, target.EntityType); } - } diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs index b7d5da7..03c4ce2 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayCoordinateListTests.cs @@ -86,6 +86,6 @@ public void Clear_ThowsNotSupportedException() { WayCoordinateList target = new(_nodes); - Assert.Throws(() => target.Clear()); + Assert.Throws(target.Clear); } } diff --git a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs index c94e940..587327d 100644 --- a/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs +++ b/src/Tests.SpatialLite.Osm/Geometries/WayTests.cs @@ -147,7 +147,7 @@ public void Coordinates_GetsPositionOfNodesIfWayCastedToLineString() { int id = 11; Way way = new(id, _nodes); - LineString target = (LineString)way; + LineString target = way; Assert.Equal(_nodes.Count, target.Coordinates.Count); for (int i = 0; i < _nodes.Count; i++) diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs index 0fb9f5e..7e97abf 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlReaderTests.cs @@ -92,7 +92,7 @@ public void Read_ThrowsExceptionIfTagHasNotKey() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-tag-without-key.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } //Tested only on Nodes - code for parsing Tags is shared among functions parsing Node, Way and Relation @@ -101,14 +101,14 @@ public void Read_ThrowsExceptionIfTagHasNotValue() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-tag-without-value.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] public void Read_ThrowsExceptionIPieceOffMetadataIsMissingAndStrictModeIsTrue() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-missing-timestamp.osm"), new OsmXmlReaderSettings() { ReadMetadata = true, StrictMode = true }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -123,7 +123,7 @@ public void Read_ThrowsExceptionIfNodeHasNotID() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -131,7 +131,7 @@ public void Read_ThrowsExceptionIfNodeHasNotLat() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-without-lat.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -139,7 +139,7 @@ public void Read_ThrowsExceptionIfNodeHasNotLon() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-node-without-lon.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -186,7 +186,7 @@ public void Read_ThrowsExceptionIfWayHasNotID() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -194,7 +194,7 @@ public void Read_ThrowsExceptionIfWayNDHasNotRef() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-way-nd-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -247,7 +247,7 @@ public void Read_ThrowsExceptionIfRelationHasNotID() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-without-id.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -255,7 +255,7 @@ public void Read_ThrowsExceptionIfRelationMemberHasNotRef() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-member-without-ref.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -263,7 +263,7 @@ public void Read_ThrowsExceptionIfRelationMemberHasNotType() { OsmXmlReader target = new(TestDataReader.OpenXml("osm-relation-member-without-type.osm"), new OsmXmlReaderSettings() { ReadMetadata = false }); - Assert.Throws(() => target.Read()); + Assert.Throws(target.Read); } [Fact] @@ -386,7 +386,7 @@ private void CompareTags(TagsCollection expected, TagsCollection actual) } Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + Assert.True(expected.All(actual.Contains)); } private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) diff --git a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs index ab0d9ab..f23ce4b 100644 --- a/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/OsmXmlWriterTests.cs @@ -457,7 +457,7 @@ private void CompareTags(TagsCollection expected, TagsCollection actual) } Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + Assert.True(expected.All(actual.Contains)); } private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) diff --git a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs index 8285cbf..9588d16 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfReaderTests.cs @@ -375,7 +375,7 @@ private void CompareTags(TagsCollection expected, TagsCollection actual) } Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + Assert.True(expected.All(actual.Contains)); } private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) diff --git a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs index 8f935c7..4c6b7c0 100644 --- a/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs +++ b/src/Tests.SpatialLite.Osm/IO/PbfWriterTests.cs @@ -545,7 +545,7 @@ private void CompareTags(TagsCollection expected, TagsCollection actual) } Assert.Equal(expected.Count, actual.Count); - Assert.True(expected.All(tag => actual.Contains(tag))); + Assert.True(expected.All(actual.Contains)); } private void CompareEntityDetails(EntityMetadata expected, EntityMetadata actual) diff --git a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs index c6ba6d3..46aa3a0 100644 --- a/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs +++ b/src/Tests.SpatialLite.Osm/OsmDatabaseTests.cs @@ -464,5 +464,4 @@ public void CopyTo_CopiesEntitiesToArray() Assert.Same(_data[i], array[i]); } } - } diff --git a/src/Tests.SpatialLite.Osm/TagTests.cs b/src/Tests.SpatialLite.Osm/TagTests.cs index 580f249..71d3bd9 100644 --- a/src/Tests.SpatialLite.Osm/TagTests.cs +++ b/src/Tests.SpatialLite.Osm/TagTests.cs @@ -99,5 +99,4 @@ public void Equals_ReturnFalseForNull() Assert.False(target.Equals(other)); } - } From 9280ef0214fd1bec43e899cea3b4d2a6e1701d05 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 May 2025 06:55:42 +0000 Subject: [PATCH 14/14] Add System.Globalization using and simplify CultureInfo access Co-authored-by: lukaskabrt <2894161+lukaskabrt@users.noreply.github.com> --- src/Benchmark.SpatialLite.Osm/Program.cs | 23 +++++------ src/SpatialLite.Core/IO/WktWriter.cs | 49 ++++++++++++------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/Benchmark.SpatialLite.Osm/Program.cs b/src/Benchmark.SpatialLite.Osm/Program.cs index 7f70e55..26f9e9e 100644 --- a/src/Benchmark.SpatialLite.Osm/Program.cs +++ b/src/Benchmark.SpatialLite.Osm/Program.cs @@ -1,9 +1,10 @@ -using SpatialLite.Osm; -using SpatialLite.Osm.Geometries; -using SpatialLite.Osm.IO; -using System; -using System.Collections.Generic; -using System.Diagnostics; +using SpatialLite.Osm; +using SpatialLite.Osm.Geometries; +using SpatialLite.Osm.IO; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; using System.IO; namespace Benchmark.SpatialLite.Osm; @@ -41,8 +42,8 @@ private static void Main(string[] args) { foreach (var benchmark in benchmarks) { - long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); - tw.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} ms \t\t{1}", avgTime, benchmark.Item1)); + long avgTime = avgTime = DoTest(benchmark.Item2, benchmark.Item1); + tw.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0} ms \t\t{1}", avgTime, benchmark.Item1)); } } } @@ -50,12 +51,12 @@ private static void Main(string[] args) private static long DoTest(Action testAction, string testName) { - Console.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Starting benchmark '{0}'", testName)); + Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Starting benchmark '{0}'", testName)); long totalTime = 0; for (int i = 0; i < 10; i++) { - Console.Write(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Run ({0}/{1}) ...", i + 1, 10)); + Console.Write(string.Format(CultureInfo.InvariantCulture, "Run ({0}/{1}) ...", i + 1, 10)); Stopwatch watch = new Stopwatch(); watch.Start(); @@ -63,7 +64,7 @@ private static long DoTest(Action testAction, string testName) watch.Stop(); totalTime += watch.ElapsedMilliseconds; - Console.WriteLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "\t\t({0} ms)", watch.ElapsedMilliseconds)); + Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "\t\t({0} ms)", watch.ElapsedMilliseconds)); } Console.WriteLine(); diff --git a/src/SpatialLite.Core/IO/WktWriter.cs b/src/SpatialLite.Core/IO/WktWriter.cs index 810f2c8..88ef0f5 100644 --- a/src/SpatialLite.Core/IO/WktWriter.cs +++ b/src/SpatialLite.Core/IO/WktWriter.cs @@ -1,6 +1,7 @@ -using SpatialLite.Core.API; -using System; -using System.IO; +using SpatialLite.Core.API; +using System; +using System.Globalization; +using System.IO; using System.Linq; namespace SpatialLite.Core.IO; @@ -8,11 +9,9 @@ namespace SpatialLite.Core.IO; /// /// Provides methods for writing Geomerty objects into WKT format. /// -public class WktWriter : IDisposable +public class WktWriter : IDisposable { - private static readonly System.Globalization.CultureInfo InvariantCulture = System.Globalization.CultureInfo.InvariantCulture; - private bool _disposed = false; private readonly TextWriter _writer; private readonly Stream _outputStream; @@ -88,9 +87,9 @@ public void Dispose() /// /// The Geometry to be written. /// The WKT representation of the Geometry. - public static string WriteToString(IGeometry geometry) - { - StringWriter tw = new(System.Globalization.CultureInfo.InvariantCulture); + public static string WriteToString(IGeometry geometry) + { + StringWriter tw = new(CultureInfo.InvariantCulture); Write(geometry, tw); return tw.ToString(); @@ -138,22 +137,22 @@ protected static void Write(IGeometry geometry, TextWriter writer) /// /// The Coordinate to be converted. /// The output Stream to Appent WKT representation to. - private static void AppendCoordinate(Coordinate coordinate, TextWriter writer) - { - writer.Write(coordinate.X.ToString(InvariantCulture)); - writer.Write(' '); - writer.Write(coordinate.Y.ToString(InvariantCulture)); - - if (coordinate.Is3D) - { - writer.Write(' '); - writer.Write(coordinate.Z.ToString(InvariantCulture)); - } - - if (coordinate.IsMeasured) - { - writer.Write(' '); - writer.Write(coordinate.M.ToString(InvariantCulture)); + private static void AppendCoordinate(Coordinate coordinate, TextWriter writer) + { + writer.Write(coordinate.X.ToString(CultureInfo.InvariantCulture)); + writer.Write(' '); + writer.Write(coordinate.Y.ToString(CultureInfo.InvariantCulture)); + + if (coordinate.Is3D) + { + writer.Write(' '); + writer.Write(coordinate.Z.ToString(CultureInfo.InvariantCulture)); + } + + if (coordinate.IsMeasured) + { + writer.Write(' '); + writer.Write(coordinate.M.ToString(CultureInfo.InvariantCulture)); } }