diff --git a/.editorconfig b/.editorconfig
index 61536f81..e3771e59 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,4 +1,4 @@
-# Remove the line below if you want to inherit .editorconfig settings from higher directories
+# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# All files
@@ -131,7 +131,7 @@ csharp_prefer_simple_using_statement = false
csharp_prefer_system_threading_lock = true
csharp_style_namespace_declarations = file_scoped
csharp_style_prefer_method_group_conversion = false
-csharp_style_prefer_primary_constructors = true
+csharp_style_prefer_primary_constructors = false
csharp_style_prefer_top_level_statements = false
# Expression-level preferences
diff --git a/.github/actions/documentation/docfx-build/action.yml b/.github/actions/documentation/docfx-build/action.yml
index 2b9ba79f..e21ced83 100644
--- a/.github/actions/documentation/docfx-build/action.yml
+++ b/.github/actions/documentation/docfx-build/action.yml
@@ -22,7 +22,7 @@ runs:
using: composite
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Dotnet Setup
uses: actions/setup-dotnet@v4
with:
@@ -41,7 +41,7 @@ runs:
run: docfx build ${{ inputs.docfx-json-manifest }}
shell: bash
- name: Upload artifact
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.output-directory }}
diff --git a/.github/actions/documentation/docfx-metadata/action.yml b/.github/actions/documentation/docfx-metadata/action.yml
index bcfb67d2..bbcd6383 100644
--- a/.github/actions/documentation/docfx-metadata/action.yml
+++ b/.github/actions/documentation/docfx-metadata/action.yml
@@ -26,7 +26,7 @@ runs:
using: composite
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Dotnet Setup
uses: actions/setup-dotnet@v4
with:
@@ -59,7 +59,7 @@ runs:
mkdir -p ${{ inputs.output-directory }}
cp -r ${{ inputs.temporary-directory }}/* ${{ inputs.output-directory }}
- name: 'Upload artifact'
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.output-directory }}
diff --git a/.github/actions/git/push-changes/action.yml b/.github/actions/git/push-changes/action.yml
index a5799d2a..31ddd3f2 100644
--- a/.github/actions/git/push-changes/action.yml
+++ b/.github/actions/git/push-changes/action.yml
@@ -28,7 +28,7 @@ runs:
using: "composite"
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Dotnet Setup
uses: actions/setup-dotnet@v4
@@ -37,7 +37,7 @@ runs:
- name: Download a single artifact
if: ${{ inputs.artifact-name != '' }}
- uses: actions/download-artifact@v4
+ uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.working-directory }}
diff --git a/.github/actions/github/create-release/action.yml b/.github/actions/github/create-release/action.yml
index f714fc5b..0e0015ce 100644
--- a/.github/actions/github/create-release/action.yml
+++ b/.github/actions/github/create-release/action.yml
@@ -1,4 +1,4 @@
-name: 'Create GitHub release'
+name: 'Create GitHub release'
author: 'Pete Sramek'
description: 'Create GitHub release.'
inputs:
@@ -17,7 +17,7 @@ runs:
using: composite
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- run: |
echo "release-version=${{ inputs.release-version }}"
echo "is-preview=${{ inputs.is-preview }}"
@@ -25,6 +25,10 @@ runs:
echo "notes-start-tag=${{ inputs.notes-start-tag }}"
echo "notes-start-tag-argument="${{ inputs.notes-start-tag != '' && '--notes-start-tag $(inputs.notes-start-tag)' || '' }}"
shell: bash
+ - name: 'Create git tag ${{ env.release-version }}'
+ shell: bash
+ run: |
+ git tag -a ${{ env.release-version }} -m "${{ env.release-version }}"
- name: 'Create GitHub release PolylineAlgorithm ${{ env.release-version }}'
shell: bash
env:
diff --git a/.github/actions/github/write-file-to-summary/action.yml b/.github/actions/github/write-file-to-summary/action.yml
index ac682f6d..c185ce4b 100644
--- a/.github/actions/github/write-file-to-summary/action.yml
+++ b/.github/actions/github/write-file-to-summary/action.yml
@@ -1,4 +1,4 @@
-name: 'Write file to step summary'
+name: 'Write file to step summary'
author: 'Pete Sramek'
description: 'Writes file contents to step summary.'
inputs:
@@ -17,7 +17,7 @@ runs:
using: composite
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Writing ${{ inputs.file }} to step summary
shell: bash
diff --git a/.github/actions/nuget/publish-package/action.yml b/.github/actions/nuget/publish-package/action.yml
index 64b4885a..eec82f65 100644
--- a/.github/actions/nuget/publish-package/action.yml
+++ b/.github/actions/nuget/publish-package/action.yml
@@ -38,10 +38,10 @@ runs:
exit 1
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Download package artifact
- uses: actions/download-artifact@v5
+ uses: actions/download-artifact@v8
with:
name: ${{ inputs.package-artifact-name }}
diff --git a/.github/actions/source/compile/action.yml b/.github/actions/source/compile/action.yml
index 2a59e696..0af331ee 100644
--- a/.github/actions/source/compile/action.yml
+++ b/.github/actions/source/compile/action.yml
@@ -50,7 +50,7 @@ runs:
using: "composite"
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}'
uses: actions/setup-dotnet@v4
@@ -68,7 +68,7 @@ runs:
- name: 'Upload build artifacts'
if: ${{ inputs.upload-build-artifacts == 'true' }}
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: ${{ inputs.build-artifacts-name }}
path: ${{ inputs.build-artifacts-glob-pattern }}
diff --git a/.github/actions/source/format/action.yml b/.github/actions/source/format/action.yml
index 5ce79d8f..de2536c2 100644
--- a/.github/actions/source/format/action.yml
+++ b/.github/actions/source/format/action.yml
@@ -32,7 +32,7 @@ runs:
using: "composite"
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}'
uses: actions/setup-dotnet@v4
diff --git a/.github/actions/testing/code-coverage/action.yml b/.github/actions/testing/code-coverage/action.yml
index 1e42d2ca..8751a7b2 100644
--- a/.github/actions/testing/code-coverage/action.yml
+++ b/.github/actions/testing/code-coverage/action.yml
@@ -24,7 +24,7 @@ runs:
using: composite
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}'
uses: actions/setup-dotnet@v4
diff --git a/.github/actions/testing/test-report/action.yml b/.github/actions/testing/test-report/action.yml
index 6dc55d81..40e66385 100644
--- a/.github/actions/testing/test-report/action.yml
+++ b/.github/actions/testing/test-report/action.yml
@@ -25,7 +25,7 @@ runs:
using: composite
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}'
uses: actions/setup-dotnet@v4
diff --git a/.github/actions/versioning/extract-version/action.yml b/.github/actions/versioning/extract-version/action.yml
index faad6a35..40229ad8 100644
--- a/.github/actions/versioning/extract-version/action.yml
+++ b/.github/actions/versioning/extract-version/action.yml
@@ -28,7 +28,7 @@ runs:
using: "composite"
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}'
uses: actions/setup-dotnet@v4
diff --git a/.github/actions/versioning/format-version/action.yml b/.github/actions/versioning/format-version/action.yml
index 2b3d11c0..70289ee0 100644
--- a/.github/actions/versioning/format-version/action.yml
+++ b/.github/actions/versioning/format-version/action.yml
@@ -45,7 +45,7 @@ runs:
using: "composite"
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ inputs.dotnet_sdk_version }}'
uses: actions/setup-dotnet@v4
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d0044504..047d4afd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -54,7 +54,7 @@ jobs:
release-version: ${{ steps.format-version.outputs.release-version }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
uses: actions/setup-dotnet@v5
with:
@@ -102,7 +102,7 @@ jobs:
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Format source code'
uses: ./.github/actions/source/format
@@ -121,7 +121,7 @@ jobs:
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Compile source code'
uses: ./.github/actions/source/compile
@@ -138,7 +138,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET'
uses: actions/setup-dotnet@v5
@@ -184,7 +184,7 @@ jobs:
package-artifact-name: ${{ env.package-artifact-name }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
@@ -192,7 +192,7 @@ jobs:
dotnet-version: ${{ env.dotnet-sdk-version }}
- name: Download Build
- uses: actions/download-artifact@v5
+ uses: actions/download-artifact@v8
with:
name: build
@@ -201,7 +201,7 @@ jobs:
dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.release-version }} /p:Version=${{ env.assembly-version }} /p:AssemblyInformationalVersion=${{ env.assembly-informational-version }} /p:FileVersion=${{ env.file-version }} --output ${{ runner.temp }}/${{ env.nuget-packages-directory }}
- name: Upload Package
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: ${{ env.package-artifact-name }}
path: |
@@ -217,7 +217,7 @@ jobs:
environment: 'Development'
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
@@ -242,7 +242,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Generate assembly metadata'
uses: ./.github/actions/documentation/docfx-metadata
with:
diff --git a/.github/workflows/promote-branch.yml b/.github/workflows/promote-branch.yml
index 21d999f1..03df4b47 100644
--- a/.github/workflows/promote-branch.yml
+++ b/.github/workflows/promote-branch.yml
@@ -39,7 +39,7 @@ jobs:
friendly-version: ${{ steps.extract-version.outputs.version }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
uses: actions/setup-dotnet@v5
with:
@@ -153,7 +153,7 @@ jobs:
target-branch: ${{ env.target-branch }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Check promotion type'
if: ${{ (env.promotion-type != 'release') && (env.promotion-type != 'preview') }}
run: |
@@ -192,7 +192,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
uses: actions/setup-dotnet@v5
with:
diff --git a/.github/workflows/publish-documentation.yml b/.github/workflows/publish-documentation.yml
index 7f9af8e3..9134bbbe 100644
--- a/.github/workflows/publish-documentation.yml
+++ b/.github/workflows/publish-documentation.yml
@@ -1,4 +1,4 @@
-name: 'Publish documentation'
+name: 'Publish documentation'
on:
workflow_dispatch:
@@ -35,7 +35,7 @@ jobs:
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
with:
fetch-depth: 0 # Ensure the full git history is available for versioning
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
@@ -56,7 +56,7 @@ jobs:
friendly-version: ${{ needs.versioning.outputs.friendly-version }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Generate documentation'
uses: ./.github/actions/documentation/docfx-build
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index 85c21862..8fb4448b 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -55,7 +55,7 @@ jobs:
release-version: ${{ steps.format-version.outputs.release-version }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
uses: actions/setup-dotnet@v5
with:
@@ -109,7 +109,7 @@ jobs:
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Compile source code'
uses: ./.github/actions/source/compile
@@ -126,7 +126,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET'
uses: actions/setup-dotnet@v5
@@ -172,7 +172,7 @@ jobs:
package-artifact-name: ${{ env.package-artifact-name }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
@@ -180,7 +180,7 @@ jobs:
dotnet-version: ${{ env.dotnet-sdk-version }}
- name: Download Build
- uses: actions/download-artifact@v5
+ uses: actions/download-artifact@v8
with:
name: build
@@ -189,7 +189,7 @@ jobs:
dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.release-version }} /p:Version=${{ env.assembly-version }} /p:AssemblyInformationalVersion=${{ env.assembly-informational-version }} /p:FileVersion=${{ env.file-version }} --output ${{ runner.temp }}/${{ env.nuget-packages-directory }}
- name: Upload Package
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: ${{ env.package-artifact-name }}
path: |
@@ -205,7 +205,7 @@ jobs:
environment: 'Development'
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
@@ -232,7 +232,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Install .NET SDK
uses: actions/setup-dotnet@v5
with:
@@ -240,14 +240,14 @@ jobs:
8.x
10.x
- name: Download Build
- uses: actions/download-artifact@v5
+ uses: actions/download-artifact@v8
with:
name: build
- name: Benchmark
working-directory: ${{ vars.BENCHMARKDOTNET_WORKING_DIRECTORY }}
run: dotnet run --configuration ${{ env.build-configuration }} /p:Platform=${{ env.build-platform }} --framework ${{ vars.DEFAULT_BUILD_FRAMEWORK }} --runtimes ${{ vars.BENCHMARKDOTNET_RUNTIMES }} --filter ${{ vars.BENCHMARKDOTNET_FILTER }} --artifacts ${{ runner.temp }}/benchmarks/ --exporters GitHub --memory --iterationTime 100 --join
- name: Upload Benchmark Results
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: benchmark-${{ matrix.os }}
path: |
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6d3066a1..dadaba02 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -19,7 +19,7 @@ concurrency:
cancel-in-progress: false
env:
- dotnet-sdk-version: '10.x'
+ dotnet-sdk-version: '9.x'
build-configuration: 'Release'
build-platform: 'Any CPU'
git-version: '6.0.x'
@@ -65,7 +65,7 @@ jobs:
release-version: ${{ steps.format-version.outputs.release-version }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
uses: actions/setup-dotnet@v5
with:
@@ -119,7 +119,7 @@ jobs:
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Compile source code'
uses: ./.github/actions/source/compile
@@ -136,7 +136,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Setup .NET'
uses: actions/setup-dotnet@v5
@@ -182,7 +182,7 @@ jobs:
package-artifact-name: ${{ env.package-artifact-name }}
steps:
- name: 'Checkout ${{ github.base_ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
@@ -190,7 +190,7 @@ jobs:
dotnet-version: ${{ env.dotnet-sdk-version }}
- name: Download Build
- uses: actions/download-artifact@v5
+ uses: actions/download-artifact@v8
with:
name: build
@@ -199,7 +199,7 @@ jobs:
dotnet pack ${{ vars.SRC_DEFAULT_GLOB_PATTERN }} --configuration ${{ env.build-configuration }} /p:Platform="${{ env.build-platform }}" /p:PackageVersion=${{ env.release-version }} /p:Version=${{ env.assembly-version }} /p:AssemblyInformationalVersion=${{ env.assembly-informational-version }} /p:FileVersion=${{ env.file-version }} --output ${{ runner.temp }}/${{ env.nuget-packages-directory }}
- name: Upload Package
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
with:
name: ${{ env.package-artifact-name }}
path: |
@@ -215,7 +215,7 @@ jobs:
environment: 'NuGet'
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
@@ -242,7 +242,7 @@ jobs:
notes-start-tag: ${{ needs.workflow-variables.outputs.notes-start-tag }}
steps:
- name: 'Checkout ${{ github.head_ref || github.ref }}'
- uses: actions/checkout@v5
+ uses: actions/checkout@v6
- name: 'Determine notes start tag'
id: determine-notes-start-tag
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 00000000..cb8bb32a
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,93 @@
+# Polyline Algorithm Agents Instructions
+
+## Purpose
+
+Instructions for automated agents (bots, CI, and code review tools) and contributors interacting with the Polyline Algorithm library.
+
+---
+
+## General Guidelines
+
+- All contributions and automation **must adhere to code style** (`.editorconfig`, `dotnet format`).
+- **Unit tests** are required for new features and bug fixes (`tests/` directory).
+- **Benchmarks** must be updated for performance-impacting changes (`benchmarks/` directory).
+
+---
+
+## Pull Requests
+
+Agents and contributors should:
+
+- **Attach benchmark results** for encoding/decoding performance changes
+- Document **public API changes** in XML comments and verify updates at [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/)
+- Run format and static analysis tools before submitting (`dotnet format`, analyzers)
+- Update **README.md** and `/samples` for public API changes
+
+---
+
+## Error Handling and Logging
+
+- Throw **descriptive exceptions** for invalid input/edge cases
+- Use internal logging helpers for operational status (`LogInfoExtensions`, `LogWarningExtensions`)
+
+---
+
+## Encoding/Decoding Agents
+
+- Use abstraction interfaces (`IPolylineEncoder`, `IPolylineDecoder` if available)
+- Prefer extension methods for collections and arrays
+- Validate latitude/longitude ranges
+
+---
+
+## Issue and PR Templates
+
+Agents should reference standardized templates from `.github`. Contributors must use them for new issues or PRs.
+
+---
+
+## Extensibility
+
+- Add encoding schemes or coordinate types in **separate classes/files**
+- Register via factory pattern if supporting multiple algorithms
+- Do not mix logic between different polyline versions
+
+---
+
+## Future-proofing
+
+- Support for precision or custom coordinate fields: update `PolylineEncodingOptions` with clear doc comments
+
+---
+
+## Documentation
+
+- Keep XML doc comments up-to-date in source files
+- API reference is auto-generated and hosted at
+ [https://petesramek.github.io/polyline-algorithm-csharp/](https://petesramek.github.io/polyline-algorithm-csharp/)
+- After public API changes, verify docs render correctly on the website
+- Add usage samples in XML comments and `/samples` directory
+
+---
+
+## Agent File Format (for `.github/agents`)
+
+Each agent instruction file should specify:
+
+```
+# AGENT INSTRUCTIONS
+
+- Purpose and scope
+- Required tools/commands
+- Coding and testing requirements
+- Logging/error handling expectations
+- Documentation or samples to update
+```
+
+---
+
+## Contact & Questions
+
+Questions or clarifications: open a GitHub issue and tag `@petesramek`.
+
+---
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..274dcb87
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,37 @@
+# Contributing to PolylineAlgorithm
+
+Thank you for your interest in improving this library!
+
+## Guidelines
+
+- **Follow code style:** Use `.editorconfig` and run `dotnet format`.
+- **Add unit tests:** Place all tests in `/tests`, following naming conventions.
+- **Benchmark updates:** Add or update `/benchmarks` for major changes.
+
+## Issue and PR Templates
+
+Please use the provided templates in `.github` for all new issues or pull requests.
+
+## API Documentation
+
+API reference is auto-generated from XML comments and published at
+👉 [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/)
+
+- All public classes, interfaces, and methods require XML doc comments.
+- After merging, verify that documentation renders correctly.
+- Add usage samples where applicable.
+
+## Submitting a Change
+
+1. Fork the repo and create a new branch.
+2. Implement your changes, tests, and update doc comments.
+3. Run `dotnet format`, and all tests/benchmarks.
+4. Submit a pull request, using the provided template.
+
+## Contact
+
+For help or questions, open an issue and tag `@petesramek`.
+
+## License
+
+MIT License © Pete Sramek
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..96ebb124
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,25 @@
+
+
+
+ 14.0
+ enable
+ enable
+ true
+ en
+
+
+
+ latest
+ All
+ true
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/PolylineAlgorithm.slnx b/PolylineAlgorithm.slnx
index 5eac2683..29fa9445 100644
--- a/PolylineAlgorithm.slnx
+++ b/PolylineAlgorithm.slnx
@@ -1,4 +1,7 @@
+
+
+
diff --git a/README.md b/README.md
index 156a8f2a..b235ecaa 100644
--- a/README.md
+++ b/README.md
@@ -1,29 +1,213 @@
-# PolylineAlgorithm for .NET
+# PolylineAlgorithm for .NET
-[](https://www.nuget.org/packages/PolylineAlgorithm/)
-[](https://opensource.org/licenses/MIT)
-[](https://github.com/sramekpete/polyline-algorithm-csharp/actions/workflows/build.yml)
+Lightweight .NET Standard 2.1 library implementing Google-compliant Encoded Polyline Algorithm with strong input validation, modern API patterns, and extensibility for custom coordinate types.
-Lightweight .NET Standard 2.1 library implementing Google Encoded Polyline Algorithm.
-Package should be primarily used as baseline for libraries that implement polyline encoding/decoding functionality.
+## Table of Contents
-More info about the algorithm can be found at [Google Developers](https://developers.google.com/maps/documentation/utilities/polylinealgorithm).
+- [Features](#features)
+- [Installation](#installation)
+- [Usage](#usage)
+- [API Reference](#api-reference)
+- [Benchmarks](#benchmarks)
+- [FAQ](#faq)
+- [Contributing](#contributing)
+- [Support](#support)
+- [License](#license)
-## Prerequisites
+## Features
-PolylineAlgorithm for .NET is available as a NuGet package targeting .NET Standard 2.1.
+- Fully compliant Google Encoded Polyline Algorithm for .NET Standard 2.1+
+- Immutable, strongly-typed coordinate and polyline data structures
+- Predefined encoder and decoder types for quick usage, extensibility for custom coordinate types
+- Robust input validation with descriptive exceptions for malformed/invalid data
+- Simple, extensible encoding and decoding APIs (`IPolylineEncoder`, `IPolylineDecoder`, `AbstractPolylineEncoder`, `AbstractPolylineDecoder`)
+- Default encoding and decoding implementations (`PolylineEncoder`, `PolylineDecoder`)
+- Advanced configuration via `PolylineEncodingOptions` (buffer size, logging, etc.)
+- Internal logging and diagnostic supports logging for CI/CD and developer diagnostics
+- Thorough unit tests and benchmarks for correctness and performance
+- Auto-generated API documentation ([API Reference](https://petesramek.github.io/polyline-algorithm-csharp/))
+- Support for .NET Core, .NET 5+, Xamarin, Unity, Blazor, and other platforms supporting `netstandard2.1`
-.NET CLI: `dotnet add package PolylineAlgorithm`
+## Installation
-Package Manager Console: `Install-Package PolylineAlgorithm`
+Using dotnet tool
-## How to use it
+```shell
+dotnet add package PolylineAlgorithm
+```
-In the majority of cases you would like to inherit `AbstractPolylineDecoder` and `AbstractPolylineEncoder` classes and implement abstract methods that are mainly responsible for extracting data from your coordinate and polyline types and creating new instances of them.
+or via NuGet
-In some cases you may want to implement your own decoder and encoder from scratch.
-In that case you can use `PolylineEncoding` static class that offers static methods for encoding and decoding polyline segments.
+```powershell
+Install-Package PolylineAlgorithm
+```
-## Documentation
+## Usage
-Documentation is can be found at [https://sramekpete.github.io/polyline-algorithm-csharp/](https://sramekpete.github.io/polyline-algorithm-csharp/).
\ No newline at end of file
+### PolylineEncoder and PolylineDecoder (predefined `Coordinate` and `Polyline` types)
+
+#### Encoding
+
+```csharp
+using PolylineAlgorithm;
+
+var coordinates = new List
+{
+ new Coordinate(48.858370, 2.294481),
+ new Coordinate(51.500729, -0.124625)
+};
+
+var encoder = new PolylineEncoder();
+Polyline encoded = encoder.Encode(coordinates);
+
+Console.WriteLine(encoded.ToString());
+```
+
+#### Decoding
+
+```csharp
+using PolylineAlgorithm;
+
+Polyline polyline = Polyline.FromString("yseiHoc_MwacOjnwM");
+
+var decoder = new PolylineDecoder();
+IEnumerable decoded = decoder.Decode(polyline);
+```
+
+### Custom encoder and decoder (user-defined coordinate and polyline types)
+
+#### Encoding
+
+Custom encoder implementation.
+
+```csharp
+public sealed class MyPolylineEncoder : AbstractPolylineEncoder<(double Latitude, double Longitude), string> {
+ public PolylineEncoder()
+ : base() { }
+
+ public PolylineEncoder(PolylineEncodingOptions options)
+ : base(options) { }
+
+ protected override double GetLatitude((double Latitude, double Longitude) coordinate) {
+ return coordinate.Latitude;
+ }
+
+ protected override double GetLongitude((double Latitude, double Longitude) coordinate) {
+ return coordinate.Longitude;
+ }
+
+ protected override string CreatePolyline(ReadOnlyMemory polyline) {
+ return polyline.ToString();
+ }
+}
+```
+
+Custom encoder usage.
+
+```csharp
+using PolylineAlgorithm;
+
+var coordinates = new List<(double Latitude, double Longitude)>
+{
+ (48.858370, 2.294481),
+ (51.500729, -0.124625)
+};
+
+var encoder = new MyPolylineEncoder();
+string encoded = encoder.Encode(coordinates);
+
+Console.WriteLine(encoded.ToString());
+```
+
+#### Decoding
+
+Custom decoder implementation.
+
+```csharp
+public sealed class MyPolylineDecoder : AbstractPolylineDecoder {
+ public PolylineDecoder()
+ : base() { }
+
+ public PolylineDecoder(PolylineEncodingOptions options)
+ : base(options) { }
+
+ protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude) {
+ return (latitude, longitude);
+ }
+
+ protected override ReadOnlyMemory GetReadOnlyMemory(ref string polyline) {
+ return polyline.AsMemory();
+ }
+}
+```
+
+Custom decoder usage.
+
+```csharp
+using PolylineAlgorithm;
+
+string encoded = "yseiHoc_MwacOjnwM";
+
+var decoder = new MyPolylineDecoder();
+IEnumerable<(double Latitude, double Longitude)> decoded = decoder.Decode(encoded);
+```
+
+> **Note:**
+> If you need low-level utilities for normalization, validation, encoding and decoding, use static methods from the `PolylineEncoding` class.
+
+## API Reference
+
+Full API docs and guides (auto-generated from source) are available at [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/)
+
+## Benchmarks
+
+- See `/benchmarks` in the repo for performance evaluation.
+- Contributors: Update benchmarks and document results for performance-impacting PRs.
+
+## FAQ
+
+**Q: What coordinate ranges are valid?**
+A: Latitude must be -90..90; longitude -180..180. Out-of-range input throws `ArgumentOutOfRangeException`.
+
+**Q: Which .NET versions are supported?**
+A: All platforms supporting `netstandard2.1` (including .NET Core and .NET 5+).
+
+**Q: What happens if I pass invalid or malformed input to the decoder?**
+A: The decoder will throw descriptive exceptions for malformed polyline strings. Check exception handling in your application.
+
+**Q: How do I customize encoding options (e.g., buffer size, logging)?**
+A: Use the PolylineEncodingOptionsBuilder to set custom options and pass to the PolylineEncoder constructor.
+
+**Q: Is the library thread-safe?**
+A: Yes, the main encoding and decoding APIs are stateless and thread-safe. If using mutable shared resources, manage synchronization in your code.
+
+**Q: Can the library be used in Unity, Xamarin, Blazor, or other .NET-compatible platforms?**
+A: Yes! Any environment supporting netstandard2.1 can use this library.
+
+**Q: Where can I report bugs or request features?**
+A: Open a GitHub issue using the provided templates in the repository and tag @petesramek.
+
+**Q: Is there support for elevation, time stamps, or third coordinate values?**
+A: Not currently, not planned to be added, but you can extend by implementing your own encoder/decoder using `PolylineEncoding` class methods.
+
+**Q: How do I contribute documentation improvements?**
+A: Update XML doc comments in the codebase and submit a PR; all public APIs require XML documentation. In case, you would like to improve guides you have to updage relevant markdown file in `/api-reference/guide` folder.
+
+**Q: Does the library support streaming or incremental decoding of polylines?**
+A: Currently, only batch encode/decode is supported. For streaming scenarios, implement custom logic using `PolylineEncoding` utility functions.
+
+## Contributing
+
+- Follow code style and PR instructions in [AGENTS.md](./AGENTS.md).
+- Ensure all features are covered by tests and XML doc comments.
+- For questions or suggestions, open an issue and use the provided templates.
+
+## Support
+
+Have a question, bug, or feature request? [Open an issue!](https://github.com/petesramek/polyline-algorithm-csharp/issues)
+
+---
+
+## License
+
+MIT License © Pete Sramek
diff --git a/api-reference/1.0/PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.yml b/api-reference/1.0/PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.yml
deleted file mode 100644
index bffca6fe..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.yml
+++ /dev/null
@@ -1,190 +0,0 @@
-### YamlMime:ApiPage
-title: Class AbstractPolylineDecoder
-body:
-- api1: Class AbstractPolylineDecoder
- id: PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs#L23
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2
- commentId: T:PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm.Abstraction
- url: PolylineAlgorithm.Abstraction.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: >-
- Decodes encoded polyline strings into sequences of geographic coordinates.
-
- Implements the interface.
-- code: 'public abstract class AbstractPolylineDecoder : IPolylineDecoder'
-- h4: Type Parameters
-- parameters:
- - name: TPolyline
- - name: TCoordinate
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: AbstractPolylineDecoder
- url: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.html
-- h4: Implements
-- list:
- - text: IPolylineDecoder
- url: PolylineAlgorithm.Abstraction.IPolylineDecoder-2.html
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.MemberwiseClone()
- url: https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Remarks
-- markdown: This abstract class provides a base implementation for decoding polylines, allowing subclasses to define how to handle specific polyline formats.
-- h2: Constructors
-- api3: AbstractPolylineDecoder()
- id: PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2__ctor
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs#L27
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.#ctor
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.#ctor
-- markdown: Initializes a new instance of the class with default encoding options.
-- code: protected AbstractPolylineDecoder()
-- api3: AbstractPolylineDecoder(PolylineEncodingOptions)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2__ctor_PolylineAlgorithm_PolylineEncodingOptions_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs#L39
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
-- markdown: Initializes a new instance of the class with the specified encoding options.
-- code: protected AbstractPolylineDecoder(PolylineEncodingOptions options)
-- h4: Parameters
-- parameters:
- - name: options
- type:
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
- description: The to use for encoding operations.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when options is null
-- h2: Properties
-- api3: Options
- id: PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2_Options
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs#L46
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.Options
- commentId: P:PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.Options
-- markdown: Gets the encoding options used by this polyline encoder.
-- code: public PolylineEncodingOptions Options { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
-- h2: Methods
-- api3: CreateCoordinate(double, double)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2_CreateCoordinate_System_Double_System_Double_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs#L153
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.CreateCoordinate(System.Double,System.Double)
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.CreateCoordinate(System.Double,System.Double)
-- markdown: Creates a coordinate instance from the given latitude and longitude values.
-- code: protected abstract TCoordinate CreateCoordinate(double latitude, double longitude)
-- h4: Parameters
-- parameters:
- - name: latitude
- type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The latitude value.
- - name: longitude
- type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The longitude value.
-- h4: Returns
-- parameters:
- - type:
- - TCoordinate
- description: A coordinate instance of type TCoordinate.
-- api3: Decode(TPolyline)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2_Decode__0_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs#L66
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.Decode(`0)
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.Decode(`0)
-- markdown: Decodes an encoded TPolyline into a sequence of TCoordinate instances.
-- code: public IEnumerable Decode(TPolyline polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - TPolyline
- description: The TPolyline instance containing the encoded polyline string to decode.
-- h4: Returns
-- parameters:
- - type:
- - text: IEnumerable
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1
- - <
- - TCoordinate
- - '>'
- description: An of TCoordinate representing the decoded latitude and longitude pairs.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when polyline is null.
- - type:
- - text: ArgumentException
- url: https://learn.microsoft.com/dotnet/api/system.argumentexception
- description: Thrown when polyline is empty.
- - type:
- - text: InvalidPolylineException
- url: PolylineAlgorithm.InvalidPolylineException.html
- description: Thrown when the polyline format is invalid or malformed at a specific position.
-- api3: GetReadOnlyMemory(TPolyline)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2_GetReadOnlyMemory__0_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs#L139
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.GetReadOnlyMemory(`0)
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineDecoder`2.GetReadOnlyMemory(`0)
-- markdown: Converts the provided polyline instance into a for decoding.
-- code: protected abstract ReadOnlyMemory GetReadOnlyMemory(TPolyline polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - TPolyline
- description: The TPolyline instance containing the encoded polyline data to decode.
-- h4: Returns
-- parameters:
- - type:
- - text: ReadOnlyMemory
- url: https://learn.microsoft.com/dotnet/api/system.readonlymemory-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: A representing the encoded polyline data.
-languageId: csharp
-metadata:
- description: >-
- Decodes encoded polyline strings into sequences of geographic coordinates.
-
- Implements the interface.
diff --git a/api-reference/1.0/PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.yml b/api-reference/1.0/PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.yml
deleted file mode 100644
index 45ae4d3e..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.yml
+++ /dev/null
@@ -1,204 +0,0 @@
-### YamlMime:ApiPage
-title: Class AbstractPolylineEncoder
-body:
-- api1: Class AbstractPolylineEncoder
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L25
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2
- commentId: T:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm.Abstraction
- url: PolylineAlgorithm.Abstraction.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: >-
- Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
-
- Implements the interface.
-- code: 'public abstract class AbstractPolylineEncoder : IPolylineEncoder'
-- h4: Type Parameters
-- parameters:
- - name: TCoordinate
- - name: TPolyline
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: AbstractPolylineEncoder
- url: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.html
-- h4: Implements
-- list:
- - text: IPolylineEncoder
- url: PolylineAlgorithm.Abstraction.IPolylineEncoder-2.html
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.MemberwiseClone()
- url: https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Remarks
-- markdown: This abstract class serves as a base for specific polyline encoders, allowing customization of the encoding process.
-- h2: Constructors
-- api3: AbstractPolylineEncoder()
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2__ctor
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L29
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.#ctor
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.#ctor
-- markdown: Initializes a new instance of the class with default encoding options.
-- code: protected AbstractPolylineEncoder()
-- api3: AbstractPolylineEncoder(PolylineEncodingOptions)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2__ctor_PolylineAlgorithm_PolylineEncodingOptions_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L39
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
-- markdown: Initializes a new instance of the class with the specified encoding options.
-- code: protected AbstractPolylineEncoder(PolylineEncodingOptions options)
-- h4: Parameters
-- parameters:
- - name: options
- type:
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
- description: The to use for encoding operations.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when options is null
-- h2: Properties
-- api3: Options
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2_Options
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L46
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.Options
- commentId: P:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.Options
-- markdown: Gets the encoding options used by this polyline encoder.
-- code: public PolylineEncodingOptions Options { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
-- h2: Methods
-- api3: CreatePolyline(ReadOnlyMemory)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2_CreatePolyline_System_ReadOnlyMemory_System_Char__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L199
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.CreatePolyline(System.ReadOnlyMemory{System.Char})
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.CreatePolyline(System.ReadOnlyMemory{System.Char})
-- markdown: Creates a polyline instance from the provided read-only sequence of characters.
-- code: protected abstract TPolyline CreatePolyline(ReadOnlyMemory polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - text: ReadOnlyMemory
- url: https://learn.microsoft.com/dotnet/api/system.readonlymemory-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: A containing the encoded polyline characters.
-- h4: Returns
-- parameters:
- - type:
- - TPolyline
- description: An instance of TPolyline representing the encoded polyline.
-- api3: Encode(IEnumerable)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2_Encode_System_Collections_Generic_IEnumerable__0__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L64
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.Encode(System.Collections.Generic.IEnumerable{`0})
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.Encode(System.Collections.Generic.IEnumerable{`0})
-- markdown: Encodes a collection of TCoordinate instances into an encoded TPolyline string.
-- code: public TPolyline Encode(IEnumerable coordinates)
-- h4: Parameters
-- parameters:
- - name: coordinates
- type:
- - text: IEnumerable
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1
- - <
- - TCoordinate
- - '>'
- description: The collection of TCoordinate objects to encode.
-- h4: Returns
-- parameters:
- - type:
- - TPolyline
- description: >-
- An instance of TPolyline representing the encoded coordinates.
-
- Returns default if the input collection is empty or null.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when coordinates is null.
- - type:
- - text: ArgumentException
- url: https://learn.microsoft.com/dotnet/api/system.argumentexception
- description: Thrown when coordinates is an empty enumeration.
-- api3: GetLatitude(TCoordinate)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2_GetLatitude__0_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L219
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.GetLatitude(`0)
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.GetLatitude(`0)
-- markdown: Extracts the latitude value from the specified coordinate.
-- code: protected abstract double GetLatitude(TCoordinate current)
-- h4: Parameters
-- parameters:
- - name: current
- type:
- - TCoordinate
- description: The coordinate from which to extract the latitude.
-- h4: Returns
-- parameters:
- - type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The latitude value as a .
-- api3: GetLongitude(TCoordinate)
- id: PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2_GetLongitude__0_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs#L209
- metadata:
- uid: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.GetLongitude(`0)
- commentId: M:PolylineAlgorithm.Abstraction.AbstractPolylineEncoder`2.GetLongitude(`0)
-- markdown: Extracts the longitude value from the specified coordinate.
-- code: protected abstract double GetLongitude(TCoordinate current)
-- h4: Parameters
-- parameters:
- - name: current
- type:
- - TCoordinate
- description: The coordinate from which to extract the longitude.
-- h4: Returns
-- parameters:
- - type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The longitude value as a .
-languageId: csharp
-metadata:
- description: >-
- Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
-
- Implements the interface.
diff --git a/api-reference/1.0/PolylineAlgorithm.Abstraction.IPolylineDecoder-2.yml b/api-reference/1.0/PolylineAlgorithm.Abstraction.IPolylineDecoder-2.yml
deleted file mode 100644
index 01478f20..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Abstraction.IPolylineDecoder-2.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-### YamlMime:ApiPage
-title: Interface IPolylineDecoder
-body:
-- api1: Interface IPolylineDecoder
- id: PolylineAlgorithm_Abstraction_IPolylineDecoder_2
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs#L13
- metadata:
- uid: PolylineAlgorithm.Abstraction.IPolylineDecoder`2
- commentId: T:PolylineAlgorithm.Abstraction.IPolylineDecoder`2
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm.Abstraction
- url: PolylineAlgorithm.Abstraction.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Defines a contract for decoding an encoded polyline into a sequence of geographic coordinates.
-- code: public interface IPolylineDecoder
-- h4: Type Parameters
-- parameters:
- - name: TPolyline
- - name: TCoordinate
-- h2: Methods
-- api3: Decode(TPolyline)
- id: PolylineAlgorithm_Abstraction_IPolylineDecoder_2_Decode__0_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs#L23
- metadata:
- uid: PolylineAlgorithm.Abstraction.IPolylineDecoder`2.Decode(`0)
- commentId: M:PolylineAlgorithm.Abstraction.IPolylineDecoder`2.Decode(`0)
-- markdown: Decodes the specified encoded polyline into a sequence of geographic coordinates.
-- code: IEnumerable Decode(TPolyline polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - TPolyline
- description: The TPolyline instance containing the encoded polyline string to decode.
-- h4: Returns
-- parameters:
- - type:
- - text: IEnumerable
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1
- - <
- - TCoordinate
- - '>'
- description: An of TCoordinate representing the decoded latitude and longitude pairs.
-languageId: csharp
-metadata:
- description: Defines a contract for decoding an encoded polyline into a sequence of geographic coordinates.
diff --git a/api-reference/1.0/PolylineAlgorithm.Abstraction.IPolylineEncoder-2.yml b/api-reference/1.0/PolylineAlgorithm.Abstraction.IPolylineEncoder-2.yml
deleted file mode 100644
index 424f9516..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Abstraction.IPolylineEncoder-2.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-### YamlMime:ApiPage
-title: Interface IPolylineEncoder
-body:
-- api1: Interface IPolylineEncoder
- id: PolylineAlgorithm_Abstraction_IPolylineEncoder_2
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs#L13
- metadata:
- uid: PolylineAlgorithm.Abstraction.IPolylineEncoder`2
- commentId: T:PolylineAlgorithm.Abstraction.IPolylineEncoder`2
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm.Abstraction
- url: PolylineAlgorithm.Abstraction.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Defines a contract for encoding a sequence of geographic coordinates into an encoded polyline string.
-- code: public interface IPolylineEncoder
-- h4: Type Parameters
-- parameters:
- - name: TCoordinate
- - name: TPolyline
-- h2: Methods
-- api3: Encode(IEnumerable)
- id: PolylineAlgorithm_Abstraction_IPolylineEncoder_2_Encode_System_Collections_Generic_IEnumerable__0__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs#L23
- metadata:
- uid: PolylineAlgorithm.Abstraction.IPolylineEncoder`2.Encode(System.Collections.Generic.IEnumerable{`0})
- commentId: M:PolylineAlgorithm.Abstraction.IPolylineEncoder`2.Encode(System.Collections.Generic.IEnumerable{`0})
-- markdown: Encodes a sequence of geographic coordinates into an encoded polyline representation.
-- code: TPolyline Encode(IEnumerable coordinates)
-- h4: Parameters
-- parameters:
- - name: coordinates
- type:
- - text: IEnumerable
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1
- - <
- - TCoordinate
- - '>'
- description: The collection of TCoordinate instances to encode into a polyline.
-- h4: Returns
-- parameters:
- - type:
- - TPolyline
- description: A TPolyline containing the encoded polyline string that represents the input coordinates.
-languageId: csharp
-metadata:
- description: Defines a contract for encoding a sequence of geographic coordinates into an encoded polyline string.
diff --git a/api-reference/1.0/PolylineAlgorithm.Abstraction.yml b/api-reference/1.0/PolylineAlgorithm.Abstraction.yml
deleted file mode 100644
index ff580e3c..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Abstraction.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-### YamlMime:ApiPage
-title: Namespace PolylineAlgorithm.Abstraction
-body:
-- api1: Namespace PolylineAlgorithm.Abstraction
- id: PolylineAlgorithm_Abstraction
- metadata:
- uid: PolylineAlgorithm.Abstraction
- commentId: N:PolylineAlgorithm.Abstraction
-- h3: Classes
-- parameters:
- - type:
- text: AbstractPolylineDecoder
- url: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.html
- description: >-
- Decodes encoded polyline strings into sequences of geographic coordinates.
-
- Implements the interface.
- - type:
- text: AbstractPolylineEncoder
- url: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.html
- description: >-
- Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
-
- Implements the interface.
-- h3: Interfaces
-- parameters:
- - type:
- text: IPolylineDecoder
- url: PolylineAlgorithm.Abstraction.IPolylineDecoder-2.html
- description: Defines a contract for decoding an encoded polyline into a sequence of geographic coordinates.
- - type:
- text: IPolylineEncoder
- url: PolylineAlgorithm.Abstraction.IPolylineEncoder-2.html
- description: Defines a contract for encoding a sequence of geographic coordinates into an encoded polyline string.
-languageId: csharp
diff --git a/api-reference/1.0/PolylineAlgorithm.Coordinate.yml b/api-reference/1.0/PolylineAlgorithm.Coordinate.yml
deleted file mode 100644
index 7f5afdf3..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Coordinate.yml
+++ /dev/null
@@ -1,250 +0,0 @@
-### YamlMime:ApiPage
-title: Struct Coordinate
-body:
-- api1: Struct Coordinate
- id: PolylineAlgorithm_Coordinate
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L22
- metadata:
- uid: PolylineAlgorithm.Coordinate
- commentId: T:PolylineAlgorithm.Coordinate
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Represents a geographic coordinate as a pair of latitude and longitude values.
-- code: 'public readonly struct Coordinate : IEquatable'
-- h4: Implements
-- list:
- - text: IEquatable
- url: https://learn.microsoft.com/dotnet/api/system.iequatable-1
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Remarks
-- markdown: >-
- This struct is designed to be immutable and lightweight, providing a simple way to represent
-
- geographic coordinates in degrees. It includes validation for latitude and longitude ranges
-
- and provides methods for equality comparison and string representation.
-- h2: Constructors
-- api3: Coordinate()
- id: PolylineAlgorithm_Coordinate__ctor
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L28
- metadata:
- uid: PolylineAlgorithm.Coordinate.#ctor
- commentId: M:PolylineAlgorithm.Coordinate.#ctor
-- markdown: Initializes a new instance of the struct with default values (0) for and .
-- code: public Coordinate()
-- api3: Coordinate(double, double)
- id: PolylineAlgorithm_Coordinate__ctor_System_Double_System_Double_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L46
- metadata:
- uid: PolylineAlgorithm.Coordinate.#ctor(System.Double,System.Double)
- commentId: M:PolylineAlgorithm.Coordinate.#ctor(System.Double,System.Double)
-- markdown: Initializes a new instance of the struct with the specified latitude and longitude values.
-- code: public Coordinate(double latitude, double longitude)
-- h4: Parameters
-- parameters:
- - name: latitude
- type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The latitude component of the coordinate, in degrees. Must be between -90 and 90.
- - name: longitude
- type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The longitude component of the coordinate, in degrees. Must be between -180 and 180.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentOutOfRangeException
- url: https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception
- description: >-
- Thrown when latitude is less than -90 or greater than 90,
-
- or when longitude is less than -180 or greater than 180.
-- h2: Properties
-- api3: Latitude
- id: PolylineAlgorithm_Coordinate_Latitude
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L62
- metadata:
- uid: PolylineAlgorithm.Coordinate.Latitude
- commentId: P:PolylineAlgorithm.Coordinate.Latitude
-- markdown: Gets the latitude component of the coordinate, in degrees.
-- code: public double Latitude { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
-- api3: Longitude
- id: PolylineAlgorithm_Coordinate_Longitude
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L67
- metadata:
- uid: PolylineAlgorithm.Coordinate.Longitude
- commentId: P:PolylineAlgorithm.Coordinate.Longitude
-- markdown: Gets the longitude component of the coordinate, in degrees.
-- code: public double Longitude { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
-- h2: Methods
-- api3: Equals(object?)
- id: PolylineAlgorithm_Coordinate_Equals_System_Object_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L82
- metadata:
- uid: PolylineAlgorithm.Coordinate.Equals(System.Object)
- commentId: M:PolylineAlgorithm.Coordinate.Equals(System.Object)
-- markdown: Indicates whether this instance and a specified object are equal.
-- code: public override bool Equals(object? obj)
-- h4: Parameters
-- parameters:
- - name: obj
- type:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - '?'
- description: The object to compare with the current instance.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if obj and this instance are the same type and represent the same value; otherwise, false.
-- api3: Equals(Coordinate)
- id: PolylineAlgorithm_Coordinate_Equals_PolylineAlgorithm_Coordinate_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L102
- metadata:
- uid: PolylineAlgorithm.Coordinate.Equals(PolylineAlgorithm.Coordinate)
- commentId: M:PolylineAlgorithm.Coordinate.Equals(PolylineAlgorithm.Coordinate)
-- markdown: Indicates whether the current object is equal to another object of the same type.
-- code: public bool Equals(Coordinate other)
-- h4: Parameters
-- parameters:
- - name: other
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- description: An object to compare with this object.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if the current object is equal to the other parameter; otherwise, false.
-- api3: GetHashCode()
- id: PolylineAlgorithm_Coordinate_GetHashCode
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L85
- metadata:
- uid: PolylineAlgorithm.Coordinate.GetHashCode
- commentId: M:PolylineAlgorithm.Coordinate.GetHashCode
-- markdown: Returns the hash code for this instance.
-- code: public override int GetHashCode()
-- h4: Returns
-- parameters:
- - type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: A 32-bit signed integer that is the hash code for this instance.
-- api3: IsDefault()
- id: PolylineAlgorithm_Coordinate_IsDefault
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L75
- metadata:
- uid: PolylineAlgorithm.Coordinate.IsDefault
- commentId: M:PolylineAlgorithm.Coordinate.IsDefault
-- markdown: Determines whether this coordinate is the default value (both and are 0).
-- code: public bool IsDefault()
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if both latitude and longitude are 0; otherwise, false.
-- api3: ToString()
- id: PolylineAlgorithm_Coordinate_ToString
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L93
- metadata:
- uid: PolylineAlgorithm.Coordinate.ToString
- commentId: M:PolylineAlgorithm.Coordinate.ToString
-- markdown: 'Returns a string representation of this coordinate in the format: { Latitude: [double], Longitude: [double] }.'
-- code: public override string ToString()
-- h4: Returns
-- parameters:
- - type:
- - text: string
- url: https://learn.microsoft.com/dotnet/api/system.string
- description: A string representation of the coordinate.
-- h2: Operators
-- api3: operator ==(Coordinate, Coordinate)
- id: PolylineAlgorithm_Coordinate_op_Equality_PolylineAlgorithm_Coordinate_PolylineAlgorithm_Coordinate_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L119
- metadata:
- uid: PolylineAlgorithm.Coordinate.op_Equality(PolylineAlgorithm.Coordinate,PolylineAlgorithm.Coordinate)
- commentId: M:PolylineAlgorithm.Coordinate.op_Equality(PolylineAlgorithm.Coordinate,PolylineAlgorithm.Coordinate)
-- markdown: Determines whether two instances are equal.
-- code: public static bool operator ==(Coordinate left, Coordinate right)
-- h4: Parameters
-- parameters:
- - name: left
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- description: The first coordinate to compare.
- - name: right
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- description: The second coordinate to compare.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if both coordinates are equal; otherwise, false.
-- api3: operator !=(Coordinate, Coordinate)
- id: PolylineAlgorithm_Coordinate_op_Inequality_PolylineAlgorithm_Coordinate_PolylineAlgorithm_Coordinate_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Coordinate.cs#L129
- metadata:
- uid: PolylineAlgorithm.Coordinate.op_Inequality(PolylineAlgorithm.Coordinate,PolylineAlgorithm.Coordinate)
- commentId: M:PolylineAlgorithm.Coordinate.op_Inequality(PolylineAlgorithm.Coordinate,PolylineAlgorithm.Coordinate)
-- markdown: Determines whether two instances are not equal.
-- code: public static bool operator !=(Coordinate left, Coordinate right)
-- h4: Parameters
-- parameters:
- - name: left
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- description: The first coordinate to compare.
- - name: right
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- description: The second coordinate to compare.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if the coordinates are not equal; otherwise, false.
-languageId: csharp
-metadata:
- description: Represents a geographic coordinate as a pair of latitude and longitude values.
diff --git a/api-reference/1.0/PolylineAlgorithm.CoordinateValueType.yml b/api-reference/1.0/PolylineAlgorithm.CoordinateValueType.yml
deleted file mode 100644
index 775098b4..00000000
--- a/api-reference/1.0/PolylineAlgorithm.CoordinateValueType.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-### YamlMime:ApiPage
-title: Enum CoordinateValueType
-body:
-- api1: Enum CoordinateValueType
- id: PolylineAlgorithm_CoordinateValueType
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/CoordinateValueType.cs#L11
- metadata:
- uid: PolylineAlgorithm.CoordinateValueType
- commentId: T:PolylineAlgorithm.CoordinateValueType
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Represents the type of a geographic coordinate value.
-- code: public enum CoordinateValueType
-- h2: Fields
-- parameters:
- - name: Latitude
- default: "1"
- description: >+
- Represents a latitude value.
-
- - name: Longitude
- default: "2"
- description: >+
- Represents a longitude value.
-
- - name: None
- default: "0"
- description: >+
- Represents no specific type. This value is used when the type is not applicable or not specified.
-
-- h2: Remarks
-- markdown: >-
- This enumeration is used to specify whether a coordinate value represents latitude or
-
- longitude. Latitude values indicate the north-south position, while longitude values indicate the east-west
-
- position.
-languageId: csharp
-metadata:
- description: Represents the type of a geographic coordinate value.
diff --git a/api-reference/1.0/PolylineAlgorithm.Extensions.PolylineDecoderExtensions.yml b/api-reference/1.0/PolylineAlgorithm.Extensions.PolylineDecoderExtensions.yml
deleted file mode 100644
index 086af359..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Extensions.PolylineDecoderExtensions.yml
+++ /dev/null
@@ -1,182 +0,0 @@
-### YamlMime:ApiPage
-title: Class PolylineDecoderExtensions
-body:
-- api1: Class PolylineDecoderExtensions
- id: PolylineAlgorithm_Extensions_PolylineDecoderExtensions
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Extensions/PolylineDecoderExtensions.cs#L16
- metadata:
- uid: PolylineAlgorithm.Extensions.PolylineDecoderExtensions
- commentId: T:PolylineAlgorithm.Extensions.PolylineDecoderExtensions
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm.Extensions
- url: PolylineAlgorithm.Extensions.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Provides extension methods for the interface to facilitate decoding encoded polylines.
-- code: public static class PolylineDecoderExtensions
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: PolylineDecoderExtensions
- url: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.html
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.MemberwiseClone()
- url: https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Methods
-- api3: Decode(IPolylineDecoder, string)
- id: PolylineAlgorithm_Extensions_PolylineDecoderExtensions_Decode_PolylineAlgorithm_Abstraction_IPolylineDecoder_PolylineAlgorithm_Polyline_PolylineAlgorithm_Coordinate__System_String_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Extensions/PolylineDecoderExtensions.cs#L32
- metadata:
- uid: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode(PolylineAlgorithm.Abstraction.IPolylineDecoder{PolylineAlgorithm.Polyline,PolylineAlgorithm.Coordinate},System.String)
- commentId: M:PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode(PolylineAlgorithm.Abstraction.IPolylineDecoder{PolylineAlgorithm.Polyline,PolylineAlgorithm.Coordinate},System.String)
-- markdown: Decodes an encoded polyline string into a sequence of geographic coordinates.
-- code: public static IEnumerable Decode(this IPolylineDecoder decoder, string polyline)
-- h4: Parameters
-- parameters:
- - name: decoder
- type:
- - text: IPolylineDecoder
- url: PolylineAlgorithm.Abstraction.IPolylineDecoder-2.html
- - <
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- - ','
- - " "
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '>'
- description: The instance used to perform the decoding operation.
- - name: polyline
- type:
- - text: string
- url: https://learn.microsoft.com/dotnet/api/system.string
- description: The encoded polyline string to decode.
-- h4: Returns
-- parameters:
- - type:
- - text: IEnumerable
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1
- - <
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '>'
- description: An containing the decoded latitude and longitude pairs.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when decoder is null.
-- api3: Decode(IPolylineDecoder, char[])
- id: PolylineAlgorithm_Extensions_PolylineDecoderExtensions_Decode_PolylineAlgorithm_Abstraction_IPolylineDecoder_PolylineAlgorithm_Polyline_PolylineAlgorithm_Coordinate__System_Char___
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Extensions/PolylineDecoderExtensions.cs#L55
- metadata:
- uid: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode(PolylineAlgorithm.Abstraction.IPolylineDecoder{PolylineAlgorithm.Polyline,PolylineAlgorithm.Coordinate},System.Char[])
- commentId: M:PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode(PolylineAlgorithm.Abstraction.IPolylineDecoder{PolylineAlgorithm.Polyline,PolylineAlgorithm.Coordinate},System.Char[])
-- markdown: Decodes an encoded polyline represented as a character array into a sequence of geographic coordinates.
-- code: public static IEnumerable Decode(this IPolylineDecoder decoder, char[] polyline)
-- h4: Parameters
-- parameters:
- - name: decoder
- type:
- - text: IPolylineDecoder
- url: PolylineAlgorithm.Abstraction.IPolylineDecoder-2.html
- - <
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- - ','
- - " "
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '>'
- description: The instance used to perform the decoding operation.
- - name: polyline
- type:
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '['
- - ']'
- description: The encoded polyline as a character array to decode.
-- h4: Returns
-- parameters:
- - type:
- - text: IEnumerable
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1
- - <
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '>'
- description: An containing the decoded latitude and longitude pairs.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when decoder is null.
-- api3: Decode(IPolylineDecoder, ReadOnlyMemory)
- id: PolylineAlgorithm_Extensions_PolylineDecoderExtensions_Decode_PolylineAlgorithm_Abstraction_IPolylineDecoder_PolylineAlgorithm_Polyline_PolylineAlgorithm_Coordinate__System_ReadOnlyMemory_System_Char__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Extensions/PolylineDecoderExtensions.cs#L78
- metadata:
- uid: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode(PolylineAlgorithm.Abstraction.IPolylineDecoder{PolylineAlgorithm.Polyline,PolylineAlgorithm.Coordinate},System.ReadOnlyMemory{System.Char})
- commentId: M:PolylineAlgorithm.Extensions.PolylineDecoderExtensions.Decode(PolylineAlgorithm.Abstraction.IPolylineDecoder{PolylineAlgorithm.Polyline,PolylineAlgorithm.Coordinate},System.ReadOnlyMemory{System.Char})
-- markdown: Decodes an encoded polyline represented as a read-only memory of characters into a sequence of geographic coordinates.
-- code: public static IEnumerable Decode(this IPolylineDecoder decoder, ReadOnlyMemory polyline)
-- h4: Parameters
-- parameters:
- - name: decoder
- type:
- - text: IPolylineDecoder
- url: PolylineAlgorithm.Abstraction.IPolylineDecoder-2.html
- - <
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- - ','
- - " "
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '>'
- description: The instance used to perform the decoding operation.
- - name: polyline
- type:
- - text: ReadOnlyMemory
- url: https://learn.microsoft.com/dotnet/api/system.readonlymemory-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: The encoded polyline as a read-only memory of characters to decode.
-- h4: Returns
-- parameters:
- - type:
- - text: IEnumerable
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1
- - <
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '>'
- description: An containing the decoded latitude and longitude pairs.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when decoder is null.
-languageId: csharp
-metadata:
- description: Provides extension methods for the interface to facilitate decoding encoded polylines.
diff --git a/api-reference/1.0/PolylineAlgorithm.Extensions.PolylineEncoderExtensions.yml b/api-reference/1.0/PolylineAlgorithm.Extensions.PolylineEncoderExtensions.yml
deleted file mode 100644
index 767322e4..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Extensions.PolylineEncoderExtensions.yml
+++ /dev/null
@@ -1,130 +0,0 @@
-### YamlMime:ApiPage
-title: Class PolylineEncoderExtensions
-body:
-- api1: Class PolylineEncoderExtensions
- id: PolylineAlgorithm_Extensions_PolylineEncoderExtensions
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs#L16
- metadata:
- uid: PolylineAlgorithm.Extensions.PolylineEncoderExtensions
- commentId: T:PolylineAlgorithm.Extensions.PolylineEncoderExtensions
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm.Extensions
- url: PolylineAlgorithm.Extensions.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Provides extension methods for the interface to facilitate encoding geographic coordinates into polylines.
-- code: public static class PolylineEncoderExtensions
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: PolylineEncoderExtensions
- url: PolylineAlgorithm.Extensions.PolylineEncoderExtensions.html
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.MemberwiseClone()
- url: https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Methods
-- api3: Encode(IPolylineEncoder, ICollection)
- id: PolylineAlgorithm_Extensions_PolylineEncoderExtensions_Encode_PolylineAlgorithm_Abstraction_IPolylineEncoder_PolylineAlgorithm_Coordinate_PolylineAlgorithm_Polyline__System_Collections_Generic_ICollection_PolylineAlgorithm_Coordinate__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs#L32
- metadata:
- uid: PolylineAlgorithm.Extensions.PolylineEncoderExtensions.Encode(PolylineAlgorithm.Abstraction.IPolylineEncoder{PolylineAlgorithm.Coordinate,PolylineAlgorithm.Polyline},System.Collections.Generic.ICollection{PolylineAlgorithm.Coordinate})
- commentId: M:PolylineAlgorithm.Extensions.PolylineEncoderExtensions.Encode(PolylineAlgorithm.Abstraction.IPolylineEncoder{PolylineAlgorithm.Coordinate,PolylineAlgorithm.Polyline},System.Collections.Generic.ICollection{PolylineAlgorithm.Coordinate})
-- markdown: Encodes a collection of instances into an encoded polyline.
-- code: public static Polyline Encode(this IPolylineEncoder encoder, ICollection coordinates)
-- h4: Parameters
-- parameters:
- - name: encoder
- type:
- - text: IPolylineEncoder
- url: PolylineAlgorithm.Abstraction.IPolylineEncoder-2.html
- - <
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - ','
- - " "
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- - '>'
- description: The instance used to perform the encoding operation.
- - name: coordinates
- type:
- - text: ICollection
- url: https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1
- - <
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '>'
- description: The sequence of objects to encode.
-- h4: Returns
-- parameters:
- - type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: A representing the encoded polyline string for the provided coordinates.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when encoder is null.
-- api3: Encode(IPolylineEncoder, Coordinate[])
- id: PolylineAlgorithm_Extensions_PolylineEncoderExtensions_Encode_PolylineAlgorithm_Abstraction_IPolylineEncoder_PolylineAlgorithm_Coordinate_PolylineAlgorithm_Polyline__PolylineAlgorithm_Coordinate___
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs#L55
- metadata:
- uid: PolylineAlgorithm.Extensions.PolylineEncoderExtensions.Encode(PolylineAlgorithm.Abstraction.IPolylineEncoder{PolylineAlgorithm.Coordinate,PolylineAlgorithm.Polyline},PolylineAlgorithm.Coordinate[])
- commentId: M:PolylineAlgorithm.Extensions.PolylineEncoderExtensions.Encode(PolylineAlgorithm.Abstraction.IPolylineEncoder{PolylineAlgorithm.Coordinate,PolylineAlgorithm.Polyline},PolylineAlgorithm.Coordinate[])
-- markdown: Encodes an array of instances into an encoded polyline.
-- code: public static Polyline Encode(this IPolylineEncoder encoder, Coordinate[] coordinates)
-- h4: Parameters
-- parameters:
- - name: encoder
- type:
- - text: IPolylineEncoder
- url: PolylineAlgorithm.Abstraction.IPolylineEncoder-2.html
- - <
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - ','
- - " "
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- - '>'
- description: The instance used to perform the encoding operation.
- - name: coordinates
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- - '['
- - ']'
- description: The array of objects to encode.
-- h4: Returns
-- parameters:
- - type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: A representing the encoded polyline string for the provided coordinates.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when encoder is null.
-languageId: csharp
-metadata:
- description: Provides extension methods for the interface to facilitate encoding geographic coordinates into polylines.
diff --git a/api-reference/1.0/PolylineAlgorithm.Extensions.yml b/api-reference/1.0/PolylineAlgorithm.Extensions.yml
deleted file mode 100644
index c39da0ca..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Extensions.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-### YamlMime:ApiPage
-title: Namespace PolylineAlgorithm.Extensions
-body:
-- api1: Namespace PolylineAlgorithm.Extensions
- id: PolylineAlgorithm_Extensions
- metadata:
- uid: PolylineAlgorithm.Extensions
- commentId: N:PolylineAlgorithm.Extensions
-- h3: Classes
-- parameters:
- - type:
- text: PolylineDecoderExtensions
- url: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.html
- description: Provides extension methods for the interface to facilitate decoding encoded polylines.
- - type:
- text: PolylineEncoderExtensions
- url: PolylineAlgorithm.Extensions.PolylineEncoderExtensions.html
- description: Provides extension methods for the interface to facilitate encoding geographic coordinates into polylines.
-languageId: csharp
diff --git a/api-reference/1.0/PolylineAlgorithm.InvalidPolylineException.yml b/api-reference/1.0/PolylineAlgorithm.InvalidPolylineException.yml
deleted file mode 100644
index fd2c31fe..00000000
--- a/api-reference/1.0/PolylineAlgorithm.InvalidPolylineException.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-### YamlMime:ApiPage
-title: Class InvalidPolylineException
-body:
-- api1: Class InvalidPolylineException
- id: PolylineAlgorithm_InvalidPolylineException
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/InvalidPolylineException.cs#L19
- metadata:
- uid: PolylineAlgorithm.InvalidPolylineException
- commentId: T:PolylineAlgorithm.InvalidPolylineException
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Exception thrown when a polyline is determined to be malformed or invalid during processing.
-- code: >-
- [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "Internal use only.")]
-
- public sealed class InvalidPolylineException : Exception, ISerializable
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: Exception
- url: https://learn.microsoft.com/dotnet/api/system.exception
- - text: InvalidPolylineException
- url: PolylineAlgorithm.InvalidPolylineException.html
-- h4: Implements
-- list:
- - text: ISerializable
- url: https://learn.microsoft.com/dotnet/api/system.runtime.serialization.iserializable
-- h4: Inherited Members
-- list:
- - text: Exception.GetBaseException()
- url: https://learn.microsoft.com/dotnet/api/system.exception.getbaseexception
- - text: Exception.GetObjectData(SerializationInfo, StreamingContext)
- url: https://learn.microsoft.com/dotnet/api/system.exception.getobjectdata
- - text: Exception.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.exception.gettype
- - text: Exception.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.exception.tostring
- - text: Exception.Data
- url: https://learn.microsoft.com/dotnet/api/system.exception.data
- - text: Exception.HelpLink
- url: https://learn.microsoft.com/dotnet/api/system.exception.helplink
- - text: Exception.HResult
- url: https://learn.microsoft.com/dotnet/api/system.exception.hresult
- - text: Exception.InnerException
- url: https://learn.microsoft.com/dotnet/api/system.exception.innerexception
- - text: Exception.Message
- url: https://learn.microsoft.com/dotnet/api/system.exception.message
- - text: Exception.Source
- url: https://learn.microsoft.com/dotnet/api/system.exception.source
- - text: Exception.StackTrace
- url: https://learn.microsoft.com/dotnet/api/system.exception.stacktrace
- - text: Exception.TargetSite
- url: https://learn.microsoft.com/dotnet/api/system.exception.targetsite
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Remarks
-- markdown: This exception is used internally to indicate that a polyline string does not conform to the expected format or contains errors.
-languageId: csharp
-metadata:
- description: Exception thrown when a polyline is determined to be malformed or invalid during processing.
diff --git a/api-reference/1.0/PolylineAlgorithm.Polyline.yml b/api-reference/1.0/PolylineAlgorithm.Polyline.yml
deleted file mode 100644
index 5da10f97..00000000
--- a/api-reference/1.0/PolylineAlgorithm.Polyline.yml
+++ /dev/null
@@ -1,315 +0,0 @@
-### YamlMime:ApiPage
-title: Struct Polyline
-body:
-- api1: Struct Polyline
- id: PolylineAlgorithm_Polyline
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L20
- metadata:
- uid: PolylineAlgorithm.Polyline
- commentId: T:PolylineAlgorithm.Polyline
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: >-
- Represents an immutable, read-only encoded polyline string.
-
- Provides methods for creation, inspection, and conversion of polyline data from various character sources.
-- code: 'public readonly struct Polyline : IEquatable'
-- h4: Implements
-- list:
- - text: IEquatable
- url: https://learn.microsoft.com/dotnet/api/system.iequatable-1
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Remarks
-- markdown: This struct is designed to be lightweight and efficient, allowing for quick comparisons and memory-safe operations.
-- h2: Constructors
-- api3: Polyline()
- id: PolylineAlgorithm_Polyline__ctor
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L28
- metadata:
- uid: PolylineAlgorithm.Polyline.#ctor
- commentId: M:PolylineAlgorithm.Polyline.#ctor
-- markdown: Initializes a new, empty instance of the struct.
-- code: public Polyline()
-- h2: Properties
-- api3: IsEmpty
- id: PolylineAlgorithm_Polyline_IsEmpty
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L50
- metadata:
- uid: PolylineAlgorithm.Polyline.IsEmpty
- commentId: P:PolylineAlgorithm.Polyline.IsEmpty
-- markdown: Gets a value indicating whether this is empty.
-- code: public bool IsEmpty { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
-- api3: Length
- id: PolylineAlgorithm_Polyline_Length
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L55
- metadata:
- uid: PolylineAlgorithm.Polyline.Length
- commentId: P:PolylineAlgorithm.Polyline.Length
-- markdown: Gets the length of the polyline in characters.
-- code: public long Length { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: long
- url: https://learn.microsoft.com/dotnet/api/system.int64
-- h2: Methods
-- api3: CopyTo(char[])
- id: PolylineAlgorithm_Polyline_CopyTo_System_Char___
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L69
- metadata:
- uid: PolylineAlgorithm.Polyline.CopyTo(System.Char[])
- commentId: M:PolylineAlgorithm.Polyline.CopyTo(System.Char[])
-- markdown: Copies the characters of this polyline to the specified destination array.
-- code: public void CopyTo(char[] destination)
-- h4: Parameters
-- parameters:
- - name: destination
- type:
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '['
- - ']'
- description: The destination array to copy the characters to.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when destination is null.
- - type:
- - text: ArgumentException
- url: https://learn.microsoft.com/dotnet/api/system.argumentexception
- description: Thrown when the length of destination does not match the polyline's length.
-- api3: Equals(Polyline)
- id: PolylineAlgorithm_Polyline_Equals_PolylineAlgorithm_Polyline_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L110
- metadata:
- uid: PolylineAlgorithm.Polyline.Equals(PolylineAlgorithm.Polyline)
- commentId: M:PolylineAlgorithm.Polyline.Equals(PolylineAlgorithm.Polyline)
-- markdown: Indicates whether the current object is equal to another object of the same type.
-- code: public bool Equals(Polyline other)
-- h4: Parameters
-- parameters:
- - name: other
- type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: An object to compare with this object.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if the current object is equal to the other parameter; otherwise, false.
-- api3: Equals(object)
- id: PolylineAlgorithm_Polyline_Equals_System_Object_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L119
- metadata:
- uid: PolylineAlgorithm.Polyline.Equals(System.Object)
- commentId: M:PolylineAlgorithm.Polyline.Equals(System.Object)
-- markdown: Indicates whether this instance and a specified object are equal.
-- code: public override bool Equals(object obj)
-- h4: Parameters
-- parameters:
- - name: obj
- type:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- description: The object to compare with the current instance.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if obj and this instance are the same type and represent the same value; otherwise, false.
-- api3: FromCharArray(char[])
- id: PolylineAlgorithm_Polyline_FromCharArray_System_Char___
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L168
- metadata:
- uid: PolylineAlgorithm.Polyline.FromCharArray(System.Char[])
- commentId: M:PolylineAlgorithm.Polyline.FromCharArray(System.Char[])
-- markdown: Creates a from a Unicode character array.
-- code: public static Polyline FromCharArray(char[] polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '['
- - ']'
- description: A character array representing an encoded polyline.
-- h4: Returns
-- parameters:
- - type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The instance corresponding to the specified character array.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when polyline is null.
-- api3: FromMemory(ReadOnlyMemory)
- id: PolylineAlgorithm_Polyline_FromMemory_System_ReadOnlyMemory_System_Char__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L205
- metadata:
- uid: PolylineAlgorithm.Polyline.FromMemory(System.ReadOnlyMemory{System.Char})
- commentId: M:PolylineAlgorithm.Polyline.FromMemory(System.ReadOnlyMemory{System.Char})
-- markdown: Creates a from a read-only memory region of characters.
-- code: public static Polyline FromMemory(ReadOnlyMemory polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - text: ReadOnlyMemory
- url: https://learn.microsoft.com/dotnet/api/system.readonlymemory-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: A read-only memory region representing an encoded polyline.
-- h4: Returns
-- parameters:
- - type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The instance corresponding to the specified memory region.
-- api3: FromString(string)
- id: PolylineAlgorithm_Polyline_FromString_System_String_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L188
- metadata:
- uid: PolylineAlgorithm.Polyline.FromString(System.String)
- commentId: M:PolylineAlgorithm.Polyline.FromString(System.String)
-- markdown: Creates a from a string.
-- code: public static Polyline FromString(string polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - text: string
- url: https://learn.microsoft.com/dotnet/api/system.string
- description: A string representing an encoded polyline.
-- h4: Returns
-- parameters:
- - type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The instance corresponding to the specified string.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when polyline is null.
-- api3: GetHashCode()
- id: PolylineAlgorithm_Polyline_GetHashCode
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L124
- metadata:
- uid: PolylineAlgorithm.Polyline.GetHashCode
- commentId: M:PolylineAlgorithm.Polyline.GetHashCode
-- markdown: Returns the hash code for this instance.
-- code: public override int GetHashCode()
-- h4: Returns
-- parameters:
- - type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: A 32-bit signed integer that is the hash code for this instance.
-- api3: ToString()
- id: PolylineAlgorithm_Polyline_ToString
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L87
- metadata:
- uid: PolylineAlgorithm.Polyline.ToString
- commentId: M:PolylineAlgorithm.Polyline.ToString
-- markdown: Returns a string representation of the polyline.
-- code: public override string ToString()
-- h4: Returns
-- parameters:
- - type:
- - text: string
- url: https://learn.microsoft.com/dotnet/api/system.string
- description: A string containing the characters of the polyline, or an empty string if the polyline is empty.
-- h2: Operators
-- api3: operator ==(Polyline, Polyline)
- id: PolylineAlgorithm_Polyline_op_Equality_PolylineAlgorithm_Polyline_PolylineAlgorithm_Polyline_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L140
- metadata:
- uid: PolylineAlgorithm.Polyline.op_Equality(PolylineAlgorithm.Polyline,PolylineAlgorithm.Polyline)
- commentId: M:PolylineAlgorithm.Polyline.op_Equality(PolylineAlgorithm.Polyline,PolylineAlgorithm.Polyline)
-- markdown: Determines whether two instances are equal.
-- code: public static bool operator ==(Polyline left, Polyline right)
-- h4: Parameters
-- parameters:
- - name: left
- type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The first polyline to compare.
- - name: right
- type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The second polyline to compare.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if the polylines are equal; otherwise, false.
-- api3: operator !=(Polyline, Polyline)
- id: PolylineAlgorithm_Polyline_op_Inequality_PolylineAlgorithm_Polyline_PolylineAlgorithm_Polyline_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/Polyline.cs#L150
- metadata:
- uid: PolylineAlgorithm.Polyline.op_Inequality(PolylineAlgorithm.Polyline,PolylineAlgorithm.Polyline)
- commentId: M:PolylineAlgorithm.Polyline.op_Inequality(PolylineAlgorithm.Polyline,PolylineAlgorithm.Polyline)
-- markdown: Determines whether two instances are not equal.
-- code: public static bool operator !=(Polyline left, Polyline right)
-- h4: Parameters
-- parameters:
- - name: left
- type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The first polyline to compare.
- - name: right
- type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The second polyline to compare.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if the polylines are not equal; otherwise, false.
-languageId: csharp
-metadata:
- description: >-
- Represents an immutable, read-only encoded polyline string.
-
- Provides methods for creation, inspection, and conversion of polyline data from various character sources.
diff --git a/api-reference/1.0/PolylineAlgorithm.PolylineDecoder.yml b/api-reference/1.0/PolylineAlgorithm.PolylineDecoder.yml
deleted file mode 100644
index 446fdd9c..00000000
--- a/api-reference/1.0/PolylineAlgorithm.PolylineDecoder.yml
+++ /dev/null
@@ -1,149 +0,0 @@
-### YamlMime:ApiPage
-title: Class PolylineDecoder
-body:
-- api1: Class PolylineDecoder
- id: PolylineAlgorithm_PolylineDecoder
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineDecoder.cs#L11
- metadata:
- uid: PolylineAlgorithm.PolylineDecoder
- commentId: T:PolylineAlgorithm.PolylineDecoder
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: >-
- Decodes encoded polyline strings into sequences of geographic coordinates.
-
- Implements the interface.
-- code: 'public sealed class PolylineDecoder : AbstractPolylineDecoder, IPolylineDecoder'
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: AbstractPolylineDecoder
- url: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.html
- - text: PolylineDecoder
- url: PolylineAlgorithm.PolylineDecoder.html
-- h4: Implements
-- list:
- - text: IPolylineDecoder
- url: PolylineAlgorithm.Abstraction.IPolylineDecoder-2.html
-- h4: Inherited Members
-- list:
- - text: AbstractPolylineDecoder.Options
- url: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.html#PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2_Options
- - text: AbstractPolylineDecoder.Decode(Polyline)
- url: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.html#PolylineAlgorithm_Abstraction_AbstractPolylineDecoder_2_Decode__0_
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h4: Extension Methods
-- list:
- - text: PolylineDecoderExtensions.Decode(IPolylineDecoder, string)
- url: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.html#PolylineAlgorithm_Extensions_PolylineDecoderExtensions_Decode_PolylineAlgorithm_Abstraction_IPolylineDecoder_PolylineAlgorithm_Polyline_PolylineAlgorithm_Coordinate__System_String_
- - text: PolylineDecoderExtensions.Decode(IPolylineDecoder, char[])
- url: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.html#PolylineAlgorithm_Extensions_PolylineDecoderExtensions_Decode_PolylineAlgorithm_Abstraction_IPolylineDecoder_PolylineAlgorithm_Polyline_PolylineAlgorithm_Coordinate__System_Char___
- - text: PolylineDecoderExtensions.Decode(IPolylineDecoder, ReadOnlyMemory)
- url: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.html#PolylineAlgorithm_Extensions_PolylineDecoderExtensions_Decode_PolylineAlgorithm_Abstraction_IPolylineDecoder_PolylineAlgorithm_Polyline_PolylineAlgorithm_Coordinate__System_ReadOnlyMemory_System_Char__
-- h2: Remarks
-- markdown: This abstract class provides a base implementation for decoding polylines, allowing subclasses to define how to handle specific polyline formats.
-- h2: Constructors
-- api3: PolylineDecoder()
- id: PolylineAlgorithm_PolylineDecoder__ctor
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineDecoder.cs#L13
- metadata:
- uid: PolylineAlgorithm.PolylineDecoder.#ctor
- commentId: M:PolylineAlgorithm.PolylineDecoder.#ctor
-- markdown: Initializes a new instance of the class with default encoding options.
-- code: public PolylineDecoder()
-- api3: PolylineDecoder(PolylineEncodingOptions)
- id: PolylineAlgorithm_PolylineDecoder__ctor_PolylineAlgorithm_PolylineEncodingOptions_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineDecoder.cs#L17
- metadata:
- uid: PolylineAlgorithm.PolylineDecoder.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
- commentId: M:PolylineAlgorithm.PolylineDecoder.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
-- markdown: Initializes a new instance of the class with the specified encoding options.
-- code: public PolylineDecoder(PolylineEncodingOptions options)
-- h4: Parameters
-- parameters:
- - name: options
- type:
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
- description: The to use for encoding operations.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when options is null
-- h2: Methods
-- api3: CreateCoordinate(double, double)
- id: PolylineAlgorithm_PolylineDecoder_CreateCoordinate_System_Double_System_Double_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineDecoder.cs#L21
- metadata:
- uid: PolylineAlgorithm.PolylineDecoder.CreateCoordinate(System.Double,System.Double)
- commentId: M:PolylineAlgorithm.PolylineDecoder.CreateCoordinate(System.Double,System.Double)
-- markdown: Creates a coordinate instance from the given latitude and longitude values.
-- code: protected override Coordinate CreateCoordinate(double latitude, double longitude)
-- h4: Parameters
-- parameters:
- - name: latitude
- type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The latitude value.
- - name: longitude
- type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The longitude value.
-- h4: Returns
-- parameters:
- - type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- description: A coordinate instance of type .
-- api3: GetReadOnlyMemory(Polyline)
- id: PolylineAlgorithm_PolylineDecoder_GetReadOnlyMemory_PolylineAlgorithm_Polyline_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineDecoder.cs#L26
- metadata:
- uid: PolylineAlgorithm.PolylineDecoder.GetReadOnlyMemory(PolylineAlgorithm.Polyline)
- commentId: M:PolylineAlgorithm.PolylineDecoder.GetReadOnlyMemory(PolylineAlgorithm.Polyline)
-- markdown: Converts the provided polyline instance into a for decoding.
-- code: protected override ReadOnlyMemory GetReadOnlyMemory(Polyline polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: The instance containing the encoded polyline data to decode.
-- h4: Returns
-- parameters:
- - type:
- - text: ReadOnlyMemory
- url: https://learn.microsoft.com/dotnet/api/system.readonlymemory-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: A representing the encoded polyline data.
-languageId: csharp
-metadata:
- description: >-
- Decodes encoded polyline strings into sequences of geographic coordinates.
-
- Implements the interface.
diff --git a/api-reference/1.0/PolylineAlgorithm.PolylineEncoder.yml b/api-reference/1.0/PolylineAlgorithm.PolylineEncoder.yml
deleted file mode 100644
index 2cc3a5dd..00000000
--- a/api-reference/1.0/PolylineAlgorithm.PolylineEncoder.yml
+++ /dev/null
@@ -1,161 +0,0 @@
-### YamlMime:ApiPage
-title: Class PolylineEncoder
-body:
-- api1: Class PolylineEncoder
- id: PolylineAlgorithm_PolylineEncoder
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoder.cs#L11
- metadata:
- uid: PolylineAlgorithm.PolylineEncoder
- commentId: T:PolylineAlgorithm.PolylineEncoder
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: >-
- Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
-
- Implements the interface.
-- code: 'public sealed class PolylineEncoder : AbstractPolylineEncoder, IPolylineEncoder'
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: AbstractPolylineEncoder
- url: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.html
- - text: PolylineEncoder
- url: PolylineAlgorithm.PolylineEncoder.html
-- h4: Implements
-- list:
- - text: IPolylineEncoder
- url: PolylineAlgorithm.Abstraction.IPolylineEncoder-2.html
-- h4: Inherited Members
-- list:
- - text: AbstractPolylineEncoder.Options
- url: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.html#PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2_Options
- - text: AbstractPolylineEncoder.Encode(IEnumerable)
- url: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.html#PolylineAlgorithm_Abstraction_AbstractPolylineEncoder_2_Encode_System_Collections_Generic_IEnumerable__0__
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h4: Extension Methods
-- list:
- - text: PolylineEncoderExtensions.Encode(IPolylineEncoder, ICollection)
- url: PolylineAlgorithm.Extensions.PolylineEncoderExtensions.html#PolylineAlgorithm_Extensions_PolylineEncoderExtensions_Encode_PolylineAlgorithm_Abstraction_IPolylineEncoder_PolylineAlgorithm_Coordinate_PolylineAlgorithm_Polyline__System_Collections_Generic_ICollection_PolylineAlgorithm_Coordinate__
- - text: PolylineEncoderExtensions.Encode(IPolylineEncoder, Coordinate[])
- url: PolylineAlgorithm.Extensions.PolylineEncoderExtensions.html#PolylineAlgorithm_Extensions_PolylineEncoderExtensions_Encode_PolylineAlgorithm_Abstraction_IPolylineEncoder_PolylineAlgorithm_Coordinate_PolylineAlgorithm_Polyline__PolylineAlgorithm_Coordinate___
-- h2: Remarks
-- markdown: This abstract class serves as a base for specific polyline encoders, allowing customization of the encoding process.
-- h2: Constructors
-- api3: PolylineEncoder()
- id: PolylineAlgorithm_PolylineEncoder__ctor
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoder.cs#L13
- metadata:
- uid: PolylineAlgorithm.PolylineEncoder.#ctor
- commentId: M:PolylineAlgorithm.PolylineEncoder.#ctor
-- markdown: Initializes a new instance of the class with default encoding options.
-- code: public PolylineEncoder()
-- api3: PolylineEncoder(PolylineEncodingOptions)
- id: PolylineAlgorithm_PolylineEncoder__ctor_PolylineAlgorithm_PolylineEncodingOptions_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoder.cs#L17
- metadata:
- uid: PolylineAlgorithm.PolylineEncoder.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
- commentId: M:PolylineAlgorithm.PolylineEncoder.#ctor(PolylineAlgorithm.PolylineEncodingOptions)
-- markdown: Initializes a new instance of the class with the specified encoding options.
-- code: public PolylineEncoder(PolylineEncodingOptions options)
-- h4: Parameters
-- parameters:
- - name: options
- type:
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
- description: The to use for encoding operations.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when options is null
-- h2: Methods
-- api3: CreatePolyline(ReadOnlyMemory)
- id: PolylineAlgorithm_PolylineEncoder_CreatePolyline_System_ReadOnlyMemory_System_Char__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoder.cs#L31
- metadata:
- uid: PolylineAlgorithm.PolylineEncoder.CreatePolyline(System.ReadOnlyMemory{System.Char})
- commentId: M:PolylineAlgorithm.PolylineEncoder.CreatePolyline(System.ReadOnlyMemory{System.Char})
-- markdown: Creates a polyline instance from the provided read-only sequence of characters.
-- code: protected override Polyline CreatePolyline(ReadOnlyMemory polyline)
-- h4: Parameters
-- parameters:
- - name: polyline
- type:
- - text: ReadOnlyMemory
- url: https://learn.microsoft.com/dotnet/api/system.readonlymemory-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: A containing the encoded polyline characters.
-- h4: Returns
-- parameters:
- - type:
- - text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: An instance of representing the encoded polyline.
-- api3: GetLatitude(Coordinate)
- id: PolylineAlgorithm_PolylineEncoder_GetLatitude_PolylineAlgorithm_Coordinate_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoder.cs#L21
- metadata:
- uid: PolylineAlgorithm.PolylineEncoder.GetLatitude(PolylineAlgorithm.Coordinate)
- commentId: M:PolylineAlgorithm.PolylineEncoder.GetLatitude(PolylineAlgorithm.Coordinate)
-- markdown: Extracts the latitude value from the specified coordinate.
-- code: protected override double GetLatitude(Coordinate coordinate)
-- h4: Parameters
-- parameters:
- - name: coordinate
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
-- h4: Returns
-- parameters:
- - type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The latitude value as a .
-- api3: GetLongitude(Coordinate)
- id: PolylineAlgorithm_PolylineEncoder_GetLongitude_PolylineAlgorithm_Coordinate_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoder.cs#L26
- metadata:
- uid: PolylineAlgorithm.PolylineEncoder.GetLongitude(PolylineAlgorithm.Coordinate)
- commentId: M:PolylineAlgorithm.PolylineEncoder.GetLongitude(PolylineAlgorithm.Coordinate)
-- markdown: Extracts the longitude value from the specified coordinate.
-- code: protected override double GetLongitude(Coordinate coordinate)
-- h4: Parameters
-- parameters:
- - name: coordinate
- type:
- - text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
-- h4: Returns
-- parameters:
- - type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The longitude value as a .
-languageId: csharp
-metadata:
- description: >-
- Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
-
- Implements the interface.
diff --git a/api-reference/1.0/PolylineAlgorithm.PolylineEncoding.yml b/api-reference/1.0/PolylineAlgorithm.PolylineEncoding.yml
deleted file mode 100644
index 8b249376..00000000
--- a/api-reference/1.0/PolylineAlgorithm.PolylineEncoding.yml
+++ /dev/null
@@ -1,254 +0,0 @@
-### YamlMime:ApiPage
-title: Class PolylineEncoding
-body:
-- api1: Class PolylineEncoding
- id: PolylineAlgorithm_PolylineEncoding
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoding.cs#L19
- metadata:
- uid: PolylineAlgorithm.PolylineEncoding
- commentId: T:PolylineAlgorithm.PolylineEncoding
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: >-
- Provides methods for encoding and decoding polyline data, as well as utilities for normalizing and de-normalizing
-
- geographic coordinate values.
-- code: public static class PolylineEncoding
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: PolylineEncoding
- url: PolylineAlgorithm.PolylineEncoding.html
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.MemberwiseClone()
- url: https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Remarks
-- markdown: >-
- The class includes functionality for working with encoded polyline
- data, such as reading and writing encoded values, as well as methods for normalizing and de-normalizing geographic
- coordinates. It also provides validation utilities to ensure values conform to expected ranges for latitude and
- longitude.
-- h2: Methods
-- api3: Denormalize(int, CoordinateValueType)
- id: PolylineAlgorithm_PolylineEncoding_Denormalize_System_Int32_PolylineAlgorithm_CoordinateValueType_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoding.cs#L91
- metadata:
- uid: PolylineAlgorithm.PolylineEncoding.Denormalize(System.Int32,PolylineAlgorithm.CoordinateValueType)
- commentId: M:PolylineAlgorithm.PolylineEncoding.Denormalize(System.Int32,PolylineAlgorithm.CoordinateValueType)
-- markdown: Converts a normalized integer value to its denormalized double representation based on the specified type.
-- code: public static double Denormalize(int value, CoordinateValueType type)
-- h4: Parameters
-- parameters:
- - name: value
- type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: The normalized integer value to be denormalized. Must be within the valid range for the specified type.
- - name: type
- type:
- - text: CoordinateValueType
- url: PolylineAlgorithm.CoordinateValueType.html
- description: The type that defines the valid range for value.
-- h4: Returns
-- parameters:
- - type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The denormalized double representation of the input value. Returns 0.0 if value is 0.
-- h4: Remarks
-- markdown: >-
- The denormalization process divides the input value by a predefined precision factor to
- produce the resulting double. Ensure that value is validated against the specified type before calling this method.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentOutOfRangeException
- url: https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception
- description: Thrown when value is outside the valid range for the specified type.
-- api3: GetCharCount(int)
- id: PolylineAlgorithm_PolylineEncoding_GetCharCount_System_Int32_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoding.cs#L222
- metadata:
- uid: PolylineAlgorithm.PolylineEncoding.GetCharCount(System.Int32)
- commentId: M:PolylineAlgorithm.PolylineEncoding.GetCharCount(System.Int32)
-- markdown: >-
- Determines the number of characters required to represent the specified integer value within predefined
-
- variance ranges.
-- code: public static int GetCharCount(int variance)
-- h4: Parameters
-- parameters:
- - name: variance
- type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: >-
- The integer value for which the character count is calculated. Must be within the range of a 32-bit signed
-
- integer.
-- h4: Returns
-- parameters:
- - type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: >-
- The number of characters required to represent the variance value, based on its magnitude.
-
- Returns a value between 1 and 6 inclusive.
-- h4: Remarks
-- markdown: >-
- The method uses predefined ranges to efficiently determine the character count. Smaller
-
- values require fewer characters, while larger values require more. This method is optimized for performance
-
- using a switch expression.
-- api3: Normalize(double, CoordinateValueType)
- id: PolylineAlgorithm_PolylineEncoding_Normalize_System_Double_PolylineAlgorithm_CoordinateValueType_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoding.cs#L180
- metadata:
- uid: PolylineAlgorithm.PolylineEncoding.Normalize(System.Double,PolylineAlgorithm.CoordinateValueType)
- commentId: M:PolylineAlgorithm.PolylineEncoding.Normalize(System.Double,PolylineAlgorithm.CoordinateValueType)
-- markdown: Normalizes a given numeric value based on the specified type and precision settings.
-- code: public static int Normalize(double value, CoordinateValueType type)
-- h4: Parameters
-- parameters:
- - name: value
- type:
- - text: double
- url: https://learn.microsoft.com/dotnet/api/system.double
- description: The numeric value to normalize. Must be a finite number.
- - name: type
- type:
- - text: CoordinateValueType
- url: PolylineAlgorithm.CoordinateValueType.html
- description: The type against which the value is validated. Determines the acceptable range for the value.
-- h4: Returns
-- parameters:
- - type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: An integer representing the normalized value. Returns 0 if the input value is 0.0.
-- h4: Remarks
-- markdown: >-
- This method validates the input value to ensure it is finite and within the acceptable range
-
- for the specified type. If the value is valid, it applies a normalization algorithm using a predefined precision
-
- factor.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentOutOfRangeException
- url: https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception
- description: >-
- Thrown when value is not a finite number or is outside the valid range for the specified
-
- type.
-- api3: TryReadValue(ref int, ref ReadOnlyMemory, ref int)
- id: PolylineAlgorithm_PolylineEncoding_TryReadValue_System_Int32__System_ReadOnlyMemory_System_Char___System_Int32__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoding.cs#L40
- metadata:
- uid: PolylineAlgorithm.PolylineEncoding.TryReadValue(System.Int32@,System.ReadOnlyMemory{System.Char}@,System.Int32@)
- commentId: M:PolylineAlgorithm.PolylineEncoding.TryReadValue(System.Int32@,System.ReadOnlyMemory{System.Char}@,System.Int32@)
-- markdown: Attempts to read a value from the specified buffer and updates the variance.
-- code: public static bool TryReadValue(ref int variance, ref ReadOnlyMemory buffer, ref int position)
-- h4: Parameters
-- parameters:
- - name: variance
- type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: A reference to the integer that will be updated based on the value read from the buffer.
- - name: buffer
- type:
- - text: ReadOnlyMemory
- url: https://learn.microsoft.com/dotnet/api/system.readonlymemory-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: A reference to the read-only memory buffer containing the data to be processed.
- - name: position
- type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: A reference to the current position within the buffer. The position is incremented as the method reads data.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if a value was successfully read and the end of the buffer was not reached; otherwise, false.
-- h4: Remarks
-- markdown: >-
- This method processes the buffer starting at the specified position and attempts to decode a value.
- The decoded value is used to update the variance parameter. The method stops reading when a
- termination condition is met or the end of the buffer is reached.
-- api3: TryWriteValue(int, ref Span, ref int)
- id: PolylineAlgorithm_PolylineEncoding_TryWriteValue_System_Int32_System_Span_System_Char___System_Int32__
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncoding.cs#L133
- metadata:
- uid: PolylineAlgorithm.PolylineEncoding.TryWriteValue(System.Int32,System.Span{System.Char}@,System.Int32@)
- commentId: M:PolylineAlgorithm.PolylineEncoding.TryWriteValue(System.Int32,System.Span{System.Char}@,System.Int32@)
-- markdown: Attempts to write a value derived from the specified variance into the provided buffer at the given position.
-- code: public static bool TryWriteValue(int variance, ref Span buffer, ref int position)
-- h4: Parameters
-- parameters:
- - name: variance
- type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: The integer value used to calculate the output to be written into the buffer.
- - name: buffer
- type:
- - text: Span
- url: https://learn.microsoft.com/dotnet/api/system.span-1
- - <
- - text: char
- url: https://learn.microsoft.com/dotnet/api/system.char
- - '>'
- description: A reference to the span of characters where the value will be written.
- - name: position
- type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: >-
- A reference to the current position in the buffer where writing begins. This value is updated to reflect the new
-
- position after writing.
-- h4: Returns
-- parameters:
- - type:
- - text: bool
- url: https://learn.microsoft.com/dotnet/api/system.boolean
- description: true if the value was successfully written to the buffer; otherwise, false.
-- h4: Remarks
-- markdown: >-
- This method performs bounds checking to ensure that the buffer has sufficient space to
-
- accommodate the calculated value. If the buffer does not have enough space, the method returns false without modifying the buffer or position.
-languageId: csharp
-metadata:
- description: >-
- Provides methods for encoding and decoding polyline data, as well as utilities for normalizing and de-normalizing
-
- geographic coordinate values.
diff --git a/api-reference/1.0/PolylineAlgorithm.PolylineEncodingOptions.yml b/api-reference/1.0/PolylineAlgorithm.PolylineEncodingOptions.yml
deleted file mode 100644
index 49c71468..00000000
--- a/api-reference/1.0/PolylineAlgorithm.PolylineEncodingOptions.yml
+++ /dev/null
@@ -1,74 +0,0 @@
-### YamlMime:ApiPage
-title: Class PolylineEncodingOptions
-body:
-- api1: Class PolylineEncodingOptions
- id: PolylineAlgorithm_PolylineEncodingOptions
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptions.cs#L18
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptions
- commentId: T:PolylineAlgorithm.PolylineEncodingOptions
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Options for configuring polyline encoding.
-- code: public sealed class PolylineEncodingOptions
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Remarks
-- markdown: This class allows you to set options such as buffer size and logger factory for encoding operations.
-- h2: Properties
-- api3: LoggerFactory
- id: PolylineAlgorithm_PolylineEncodingOptions_LoggerFactory
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptions.cs#L34
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptions.LoggerFactory
- commentId: P:PolylineAlgorithm.PolylineEncodingOptions.LoggerFactory
-- markdown: Gets or sets the precision for encoding coordinates.
-- code: public ILoggerFactory LoggerFactory { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: ILoggerFactory
- url: https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggerfactory
-- h4: Remarks
-- markdown: The default logger factory is , which does not log any messages.
-- api3: MaxBufferSize
- id: PolylineAlgorithm_PolylineEncodingOptions_MaxBufferSize
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptions.cs#L26
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptions.MaxBufferSize
- commentId: P:PolylineAlgorithm.PolylineEncodingOptions.MaxBufferSize
-- markdown: Gets the maximum buffer size for encoding operations.
-- code: public int MaxBufferSize { get; }
-- h4: Property Value
-- parameters:
- - type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
-- h4: Remarks
-- markdown: The default maximum buffer size is 64,000 bytes (64 KB). This can be adjusted based on the expected size of the polyline data, but should be enough for common cases.
-languageId: csharp
-metadata:
- description: Options for configuring polyline encoding.
diff --git a/api-reference/1.0/PolylineAlgorithm.PolylineEncodingOptionsBuilder.yml b/api-reference/1.0/PolylineAlgorithm.PolylineEncodingOptionsBuilder.yml
deleted file mode 100644
index 91c4c2a6..00000000
--- a/api-reference/1.0/PolylineAlgorithm.PolylineEncodingOptionsBuilder.yml
+++ /dev/null
@@ -1,126 +0,0 @@
-### YamlMime:ApiPage
-title: Class PolylineEncodingOptionsBuilder
-body:
-- api1: Class PolylineEncodingOptionsBuilder
- id: PolylineAlgorithm_PolylineEncodingOptionsBuilder
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs#L15
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptionsBuilder
- commentId: T:PolylineAlgorithm.PolylineEncodingOptionsBuilder
-- facts:
- - name: Namespace
- value:
- text: PolylineAlgorithm
- url: PolylineAlgorithm.html
- - name: Assembly
- value: PolylineAlgorithm.dll
-- markdown: Provides a builder for configuring options for polyline encoding operations.
-- code: public class PolylineEncodingOptionsBuilder
-- h4: Inheritance
-- inheritance:
- - text: object
- url: https://learn.microsoft.com/dotnet/api/system.object
- - text: PolylineEncodingOptionsBuilder
- url: PolylineAlgorithm.PolylineEncodingOptionsBuilder.html
-- h4: Inherited Members
-- list:
- - text: object.Equals(object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)
- - text: object.Equals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)
- - text: object.GetHashCode()
- url: https://learn.microsoft.com/dotnet/api/system.object.gethashcode
- - text: object.GetType()
- url: https://learn.microsoft.com/dotnet/api/system.object.gettype
- - text: object.MemberwiseClone()
- url: https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone
- - text: object.ReferenceEquals(object, object)
- url: https://learn.microsoft.com/dotnet/api/system.object.referenceequals
- - text: object.ToString()
- url: https://learn.microsoft.com/dotnet/api/system.object.tostring
-- h2: Methods
-- api3: Build()
- id: PolylineAlgorithm_PolylineEncodingOptionsBuilder_Build
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs#L37
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptionsBuilder.Build
- commentId: M:PolylineAlgorithm.PolylineEncodingOptionsBuilder.Build
-- markdown: Builds a new instance using the configured options.
-- code: public PolylineEncodingOptions Build()
-- h4: Returns
-- parameters:
- - type:
- - text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
- description: A configured instance.
-- api3: Create()
- id: PolylineAlgorithm_PolylineEncodingOptionsBuilder_Create
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs#L27
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptionsBuilder.Create
- commentId: M:PolylineAlgorithm.PolylineEncodingOptionsBuilder.Create
-- markdown: Creates a new instance for the specified coordinate type.
-- code: public static PolylineEncodingOptionsBuilder Create()
-- h4: Returns
-- parameters:
- - type:
- - text: PolylineEncodingOptionsBuilder
- url: PolylineAlgorithm.PolylineEncodingOptionsBuilder.html
- description: An instance for configuring polyline encoding options.
-- api3: WithLoggerFactory(ILoggerFactory)
- id: PolylineAlgorithm_PolylineEncodingOptionsBuilder_WithLoggerFactory_Microsoft_Extensions_Logging_ILoggerFactory_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs#L72
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptionsBuilder.WithLoggerFactory(Microsoft.Extensions.Logging.ILoggerFactory)
- commentId: M:PolylineAlgorithm.PolylineEncodingOptionsBuilder.WithLoggerFactory(Microsoft.Extensions.Logging.ILoggerFactory)
-- markdown: Sets the logger factory for logging during encoding operations.
-- code: public PolylineEncodingOptionsBuilder WithLoggerFactory(ILoggerFactory loggerFactory)
-- h4: Parameters
-- parameters:
- - name: loggerFactory
- type:
- - text: ILoggerFactory
- url: https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.iloggerfactory
- description: The instance of a logger factory.
-- h4: Returns
-- parameters:
- - type:
- - text: PolylineEncodingOptionsBuilder
- url: PolylineAlgorithm.PolylineEncodingOptionsBuilder.html
- description: The current builder instance.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentNullException
- url: https://learn.microsoft.com/dotnet/api/system.argumentnullexception
- description: Thrown when loggerFactory is null.
-- api3: WithMaxBufferSize(int)
- id: PolylineAlgorithm_PolylineEncodingOptionsBuilder_WithMaxBufferSize_System_Int32_
- src: https://github.com/petesramek/polyline-algorithm-csharp/blob/preview/1.0/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs#L54
- metadata:
- uid: PolylineAlgorithm.PolylineEncodingOptionsBuilder.WithMaxBufferSize(System.Int32)
- commentId: M:PolylineAlgorithm.PolylineEncodingOptionsBuilder.WithMaxBufferSize(System.Int32)
-- markdown: Sets the buffer size for encoding operations.
-- code: public PolylineEncodingOptionsBuilder WithMaxBufferSize(int bufferSize)
-- h4: Parameters
-- parameters:
- - name: bufferSize
- type:
- - text: int
- url: https://learn.microsoft.com/dotnet/api/system.int32
- description: The maximum buffer size. Must be greater than 11.
-- h4: Returns
-- parameters:
- - type:
- - text: PolylineEncodingOptionsBuilder
- url: PolylineAlgorithm.PolylineEncodingOptionsBuilder.html
- description: The current builder instance.
-- h4: Exceptions
-- parameters:
- - type:
- - text: ArgumentOutOfRangeException
- url: https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception
- description: Thrown when bufferSize is less than or equal to 11.
-languageId: csharp
-metadata:
- description: Provides a builder for configuring options for polyline encoding operations.
diff --git a/api-reference/1.0/PolylineAlgorithm.yml b/api-reference/1.0/PolylineAlgorithm.yml
deleted file mode 100644
index ace2f946..00000000
--- a/api-reference/1.0/PolylineAlgorithm.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-### YamlMime:ApiPage
-title: Namespace PolylineAlgorithm
-body:
-- api1: Namespace PolylineAlgorithm
- id: PolylineAlgorithm
- metadata:
- uid: PolylineAlgorithm
- commentId: N:PolylineAlgorithm
-- h3: Namespaces
-- parameters:
- - type:
- text: PolylineAlgorithm.Abstraction
- url: PolylineAlgorithm.Abstraction.html
- - type:
- text: PolylineAlgorithm.Extensions
- url: PolylineAlgorithm.Extensions.html
-- h3: Classes
-- parameters:
- - type:
- text: InvalidPolylineException
- url: PolylineAlgorithm.InvalidPolylineException.html
- description: Exception thrown when a polyline is determined to be malformed or invalid during processing.
- - type:
- text: PolylineDecoder
- url: PolylineAlgorithm.PolylineDecoder.html
- description: >-
- Decodes encoded polyline strings into sequences of geographic coordinates.
-
- Implements the interface.
- - type:
- text: PolylineEncoder
- url: PolylineAlgorithm.PolylineEncoder.html
- description: >-
- Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
-
- Implements the interface.
- - type:
- text: PolylineEncoding
- url: PolylineAlgorithm.PolylineEncoding.html
- description: >-
- Provides methods for encoding and decoding polyline data, as well as utilities for normalizing and de-normalizing
-
- geographic coordinate values.
- - type:
- text: PolylineEncodingOptions
- url: PolylineAlgorithm.PolylineEncodingOptions.html
- description: Options for configuring polyline encoding.
- - type:
- text: PolylineEncodingOptionsBuilder
- url: PolylineAlgorithm.PolylineEncodingOptionsBuilder.html
- description: Provides a builder for configuring options for polyline encoding operations.
-- h3: Structs
-- parameters:
- - type:
- text: Coordinate
- url: PolylineAlgorithm.Coordinate.html
- description: Represents a geographic coordinate as a pair of latitude and longitude values.
- - type:
- text: Polyline
- url: PolylineAlgorithm.Polyline.html
- description: >-
- Represents an immutable, read-only encoded polyline string.
-
- Provides methods for creation, inspection, and conversion of polyline data from various character sources.
-- h3: Enums
-- parameters:
- - type:
- text: CoordinateValueType
- url: PolylineAlgorithm.CoordinateValueType.html
- description: Represents the type of a geographic coordinate value.
-languageId: csharp
diff --git a/api-reference/1.0/toc.yml b/api-reference/1.0/toc.yml
deleted file mode 100644
index b69f5d3f..00000000
--- a/api-reference/1.0/toc.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-### YamlMime:TableOfContent
-- name: PolylineAlgorithm
- href: PolylineAlgorithm.yml
- items:
- - name: Classes
- - name: InvalidPolylineException
- href: PolylineAlgorithm.InvalidPolylineException.yml
- - name: PolylineDecoder
- href: PolylineAlgorithm.PolylineDecoder.yml
- - name: PolylineEncoder
- href: PolylineAlgorithm.PolylineEncoder.yml
- - name: PolylineEncoding
- href: PolylineAlgorithm.PolylineEncoding.yml
- - name: PolylineEncodingOptions
- href: PolylineAlgorithm.PolylineEncodingOptions.yml
- - name: PolylineEncodingOptionsBuilder
- href: PolylineAlgorithm.PolylineEncodingOptionsBuilder.yml
- - name: Structs
- - name: Coordinate
- href: PolylineAlgorithm.Coordinate.yml
- - name: Polyline
- href: PolylineAlgorithm.Polyline.yml
- - name: Enums
- - name: CoordinateValueType
- href: PolylineAlgorithm.CoordinateValueType.yml
-- name: PolylineAlgorithm.Abstraction
- href: PolylineAlgorithm.Abstraction.yml
- items:
- - name: Classes
- - name: AbstractPolylineDecoder
- href: PolylineAlgorithm.Abstraction.AbstractPolylineDecoder-2.yml
- - name: AbstractPolylineEncoder
- href: PolylineAlgorithm.Abstraction.AbstractPolylineEncoder-2.yml
- - name: Interfaces
- - name: IPolylineDecoder
- href: PolylineAlgorithm.Abstraction.IPolylineDecoder-2.yml
- - name: IPolylineEncoder
- href: PolylineAlgorithm.Abstraction.IPolylineEncoder-2.yml
-- name: PolylineAlgorithm.Extensions
- href: PolylineAlgorithm.Extensions.yml
- items:
- - name: Classes
- - name: PolylineDecoderExtensions
- href: PolylineAlgorithm.Extensions.PolylineDecoderExtensions.yml
- - name: PolylineEncoderExtensions
- href: PolylineAlgorithm.Extensions.PolylineEncoderExtensions.yml
diff --git a/api-reference/guide/advanced-scenarios.md b/api-reference/guide/advanced-scenarios.md
new file mode 100644
index 00000000..e731319c
--- /dev/null
+++ b/api-reference/guide/advanced-scenarios.md
@@ -0,0 +1,168 @@
+# Advanced Usage
+
+PolylineAlgorithm is designed for extensibility and integration with advanced .NET scenarios.
+This guide covers custom types, integrations, and best practices for power users.
+
+---
+
+## Custom Coordinate and Polyline Types
+
+You can encode and decode custom coordinate or polyline representations by extending the abstract base classes:
+
+- `AbstractPolylineEncoder`
+- `AbstractPolylineDecoder`
+
+### Example: Custom Encoder
+
+```csharp
+public sealed class MyPolylineEncoder : AbstractPolylineEncoder<(double Latitude, double Longitude), string>
+{
+ public MyPolylineEncoder() : base() { }
+
+ public MyPolylineEncoder(PolylineEncodingOptions options)
+ : base(options) { }
+
+ protected override double GetLatitude((double Latitude, double Longitude) coordinate)
+ => coordinate.Latitude;
+
+ protected override double GetLongitude((double Latitude, double Longitude) coordinate)
+ => coordinate.Longitude;
+
+ protected override string CreatePolyline(ReadOnlyMemory polyline)
+ => polyline.ToString();
+}
+```
+
+---
+
+## Example: Custom Decoder
+
+```csharp
+public sealed class MyPolylineDecoder : AbstractPolylineDecoder
+{
+ public MyPolylineDecoder() : base() { }
+
+ public MyPolylineDecoder(PolylineEncodingOptions options)
+ : base(options) { }
+
+ protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude)
+ => (latitude, longitude);
+
+ protected override ReadOnlyMemory GetReadOnlyMemory(ref string polyline)
+ => polyline.AsMemory();
+}
+```
+
+---
+
+# Registering Custom Encoder and Decoder with `IServiceCollection`
+
+For ASP.NET Core or DI-enabled .NET applications, you can easily register your custom polyline encoder and decoder as services with `IServiceCollection` by defining an extension method. This enables constructor injection and central DI management.
+
+---
+
+## Example: Register Custom Polyline Encoder/Decoder
+
+Suppose you have the following custom encoder and decoder (see [Advanced Usage](./advanced.md)):
+
+```csharp
+public sealed class MyPolylineEncoder : AbstractPolylineEncoder<(double Latitude, double Longitude), string>
+{
+ public MyPolylineEncoder(PolylineEncodingOptions options = null)
+ : base(options) { }
+
+ // ... override required members ...
+}
+
+public sealed class MyPolylineDecoder : AbstractPolylineDecoder
+{
+ public MyPolylineDecoder(PolylineEncodingOptions options = null)
+ : base(options) { }
+
+ // ... override required members ...
+}
+```
+
+---
+
+## IServiceCollection Extension Method
+
+```csharp
+using Microsoft.Extensions.DependencyInjection;
+using PolylineAlgorithm;
+
+public static class PolylineServiceCollectionExtensions
+{
+ public static IServiceCollection AddMyPolylineEncoderDecoder(
+ this IServiceCollection services,
+ PolylineEncodingOptions options = null)
+ {
+ // Register encoder and decoder as singletons (adjust lifetime as needed)
+ services.AddSingleton>(
+ _ => new MyPolylineEncoder(options));
+ services.AddSingleton>(
+ _ => new MyPolylineDecoder(options));
+ return services;
+ }
+}
+```
+
+---
+
+## Usage
+
+In your application startup (e.g., `Program.cs` or `Startup.cs`):
+
+```csharp
+using PolylineAlgorithm;
+
+var builder = WebApplication.CreateBuilder(args);
+
+builder.Services.AddMyPolylineEncoderDecoder(
+ PolylineEncodingOptionsBuilder.Create()
+ .SetMaxBufferSize(10000)
+ .Build()
+);
+
+// Now you can inject IPolylineEncoder<(double, double), string> and IPolylineDecoder
+```
+
+---
+
+## Benefits
+
+- **Central DI management** for polyline components
+- Plug-and-play integration with ASP.NET Core and modern .NET project styles
+- Easily swap out or configure encoders/decoders for different environments
+
+---
+
+> **Tip:**
+> You can generalize the extension method for different encoder/decoder types or include multiple algorithms by adding extra parameters.
+
+---
+
+## Integration Guidance
+
+- **Batch or incremental processing:**
+ For large datasets, control buffer sizes via `PolylineEncodingOptions`.
+- **Thread safety:**
+ Default encoders/decoders are stateless and thread-safe. If extending for mutable types, ensure synchronization.
+- **Logging:**
+ Integrate with .NET's `ILoggerFactory` when diagnostics or audit trails are needed.
+
+---
+
+## Best Practices
+
+- Always validate input data—leverage built-in validation or extend for custom rules.
+- Document all public APIs using XML comments for seamless integration with the auto-generated docs.
+- For non-standard coordinate systems or precision, clearly specify semantics in your custom encoder/decoder.
+
+---
+
+## More Resources
+
+- [Configuration](./configuration.md)
+- [FAQ](./faq.md)
+- [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/)
diff --git a/api-reference/guide/configuration.md b/api-reference/guide/configuration.md
new file mode 100644
index 00000000..4a155cb2
--- /dev/null
+++ b/api-reference/guide/configuration.md
@@ -0,0 +1,75 @@
+# Configuration
+
+PolylineAlgorithm offers flexible configuration for encoding and decoding polylines, allowing you to fine-tune performance, control validation, and integrate diagnostics and logging.
+
+---
+
+## PolylineEncodingOptions
+
+Most configuration is handled via the `PolylineEncodingOptions` object, which you can build using the fluent `PolylineEncodingOptionsBuilder`.
+
+### Example: Customizing Buffer Size
+
+```csharp
+using PolylineAlgorithm;
+
+var options = PolylineEncodingOptionsBuilder.Create()
+ .SetMaxBufferSize(10000) // Set custom buffer size
+ .Build();
+
+var encoder = new PolylineEncoder(options);
+```
+
+---
+
+## Logging and Diagnostics
+
+PolylineAlgorithm supports internal logging for advanced scenarios and diagnostic purposes.
+
+- Use your preferred .NET logging framework (`ILoggerFactory`)
+- Attach loggers for encoding/decoding diagnostics, especially in automated or agent-based environments
+
+---
+
+## Validation
+
+Input validation is always enabled by default:
+
+- Latitude: must be between -90 and 90
+- Longitude: must be between -180 and 180
+- Invalid or malformed coordinates throw descriptive exceptions
+
+For custom validation (e.g., for custom coordinate types), extend the provided interfaces or abstract base classes.
+
+---
+
+## Advanced Configuration Options
+
+When using `PolylineEncodingOptionsBuilder`, you may set:
+
+- **Buffer sizes:** Configure allocation for large or streaming polylines
+- **Logging hooks:** Integrate your logger for troubleshooting/instrumentation
+- **(Future)** Custom precision, additional metadata (as needed)
+
+See the XML API documentation for all available builder methods.
+
+---
+
+## Example: Full Custom Encoder with Options
+
+```csharp
+var options = PolylineEncodingOptionsBuilder.Create()
+ .SetMaxBufferSize(5000)
+ // .EnableLogging(myLogger) // (if applicable)
+ .Build();
+
+var encoder = new PolylineEncoder(options);
+```
+
+---
+
+## Further Reading
+
+- [Getting Started Guide](./guide.md)
+- [Advanced Usage](./advanced.md)
+- [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/)
diff --git a/api-reference/guide/faq.md b/api-reference/guide/faq.md
new file mode 100644
index 00000000..186f97aa
--- /dev/null
+++ b/api-reference/guide/faq.md
@@ -0,0 +1,63 @@
+# FAQ
+
+Frequently Asked Questions for PolylineAlgorithm
+
+---
+
+## General
+
+**Q: What coordinate ranges are valid?**
+A: Latitude must be between -90 and 90; longitude must be between -180 and 180. Passing out-of-range values throws `ArgumentOutOfRangeException`.
+
+**Q: Which .NET versions are supported?**
+A: Any platform supporting `netstandard2.1`, including .NET Core, .NET 5+, Xamarin, Unity, and Blazor.
+
+**Q: Can the library be used in Unity, Xamarin, Blazor, or other .NET-compatible platforms?**
+A: Yes! Any environment that supports `netstandard2.1` can use this library.
+
+---
+
+## Usage & Extensibility
+
+**Q: How do I add a new polyline algorithm or coordinate type?**
+A: Implement your own encoder/decoder using `AbstractPolylineEncoder` and `AbstractPolylineDecoder`. Add unit tests and XML doc comments, then submit a PR.
+
+**Q: How do I customize encoding options (e.g., buffer size, logging)?**
+A: Use `PolylineEncodingOptionsBuilder` to set options, and pass the result to the encoder or decoder constructor.
+
+**Q: Is the library thread-safe?**
+A: Yes, main encoding/decoding APIs are stateless and thread-safe. If you extend using shared mutable resources, ensure proper synchronization.
+
+**Q: What happens if I pass invalid or malformed input to the decoder?**
+A: The decoder throws descriptive exceptions for malformed polyline strings. Ensure proper exception handling in your application.
+
+**Q: Does the library support streaming or incremental decoding of polylines?**
+A: Currently, only batch encode/decode is supported. For streaming scenarios, implement your own logic using `PolylineEncoding` utilities.
+
+---
+
+## Features & Support
+
+**Q: Is there support for elevation, timestamps, or third coordinate values?**
+A: Not currently, and not planned for the core library. You may implement your own encoder/decoder using `PolylineEncoding` methods for extended coordinate data.
+
+**Q: How do I contribute documentation improvements?**
+A: Update XML doc comments in the codebase and submit a pull request. To improve guides, update relevant markdown files in `/api-reference/guide`.
+
+**Q: Where can I report bugs or request features?**
+A: Open a GitHub issue using the provided templates and tag `@petesramek`.
+
+---
+
+## Documentation & Community
+
+**Q: Where can I find detailed API documentation?**
+A: [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/)
+
+**Q: How do I contribute?**
+A: Read [CONTRIBUTING.md](../CONTRIBUTING.md), follow coding style and testing guidelines, and use issue/PR templates.
+
+**Q: Need more help?**
+A: Open an issue in the [GitHub repository](https://github.com/petesramek/polyline-algorithm-csharp/issues).
+
+---
diff --git a/api-reference/guide/getting-started.md b/api-reference/guide/getting-started.md
index 8b3a7945..54d558c4 100644
--- a/api-reference/guide/getting-started.md
+++ b/api-reference/guide/getting-started.md
@@ -1 +1,76 @@
-# Getting Started
\ No newline at end of file
+# Getting Started
+
+PolylineAlgorithm is a lightweight, Google-compliant polyline encoding/decoding library for .NET Standard 2.1 and above.
+Follow these simple steps to get started, encode and decode polylines, and configure advanced features.
+
+---
+
+## Installation
+
+Install via the .NET CLI:
+
+```shell
+dotnet add package PolylineAlgorithm
+```
+
+Or via NuGet Package Manager:
+
+```powershell
+Install-Package PolylineAlgorithm
+```
+
+---
+
+## Basic Usage
+
+### Encoding Coordinates
+
+```csharp
+using PolylineAlgorithm;
+
+var coordinates = new List
+{
+ new Coordinate(48.858370, 2.294481), // Eiffel Tower
+ new Coordinate(51.500729, -0.124625) // Big Ben
+};
+
+var encoder = new PolylineEncoder();
+Polyline encoded = encoder.Encode(coordinates);
+
+Console.WriteLine(encoded.ToString()); // Prints the encoded polyline string
+```
+
+### Decoding a Polyline
+
+```csharp
+using PolylineAlgorithm;
+
+var decoder = new PolylineDecoder();
+Polyline polyline = Polyline.FromString("yseiHoc_MwacOjnwM"); // Sample encoded string
+
+IEnumerable decoded = decoder.Decode(polyline);
+
+// Show decoded coordinates
+foreach(var coord in decoded)
+{
+ Console.WriteLine($"{coord.Latitude}, {coord.Longitude}");
+}
+```
+
+---
+
+## Customizing and Advanced Features
+
+- Use `PolylineEncodingOptionsBuilder` to customize settings (buffer size, logging, etc.)
+- Implement custom encoder/decoder types for advanced coordinate representations
+- See [API reference](https://petesramek.github.io/polyline-algorithm-csharp/) for details
+
+---
+
+## Need More Help?
+
+- [FAQ](./faq.md)
+- [Examples](./examples.md)
+- [Report an Issue](https://github.com/petesramek/polyline-algorithm-csharp/issues)
+
+---
diff --git a/api-reference/guide/introduction.md b/api-reference/guide/introduction.md
index f6ecaa67..a0874834 100644
--- a/api-reference/guide/introduction.md
+++ b/api-reference/guide/introduction.md
@@ -1 +1,33 @@
-# Introduction
\ No newline at end of file
+# Introduction
+
+Welcome to **PolylineAlgorithm for .NET**, a modern library offering Google-compliant polyline encoding and decoding with strong input validation, extensible API design, and robust performance.
+
+## What is PolylineAlgorithm?
+
+PolylineAlgorithm provides tools for encoding a sequence of geographic coordinates into a compact string format used by Google Maps and other mapping platforms, and for decoding those strings back into coordinates. Its simple API and thorough documentation make it suitable for .NET Core, .NET 5+, Xamarin, Unity, Blazor, and any framework supporting `netstandard2.1`.
+
+## Key Benefits
+
+- **Standards compliance**: Implements Google’s Encoded Polyline Algorithm as specified
+- **Immutable, strongly-typed objects**: Guarantees reliability and thread safety
+- **Extensible**: Custom coordinate/polyline support via abstract base classes and interfaces
+- **Robust input validation**: Throws descriptive exceptions for out-of-range or malformed input
+- **Configuration and logging**: Advanced options and integration with `ILoggerFactory`
+- **Full API documentation**: [Auto-generated API Reference](https://petesramek.github.io/polyline-algorithm-csharp/)
+- **Benchmarked and tested**: Includes unit and performance tests
+
+## Who Should Use This Library?
+
+- .NET developers needing polyline encoding/decoding in mapping, GIS, logistics, or spatial applications
+- Teams requiring reliability, easy integration, and customizable algorithms
+- Anyone seeking a lightweight, modern, and maintainable polyline solution
+
+## How To Get Started
+
+- See the [Getting Started Guide](./guide.md) for installation and basic usage
+- Explore [Examples](./examples.md) and [FAQ](./faq.md) for real-world scenarios and solutions
+- Read about advanced [configuration](./configuration.md) and [customization](./advanced.md)
+
+---
+
+For technical details, see the [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/).
diff --git a/api-reference/guide/sample.md b/api-reference/guide/sample.md
new file mode 100644
index 00000000..336bc254
--- /dev/null
+++ b/api-reference/guide/sample.md
@@ -0,0 +1,115 @@
+# Sample Console Application: Using NetTopologySuite with PolylineAlgorithm
+
+This sample demonstrates how to encode and decode polylines using custom implementations (`NetTopologyPolylineEncoder` and `NetTopologyPolylineDecoder`) based on NetTopologySuite's `Point` type.
+
+---
+
+## Prerequisites
+
+- Install the following NuGet packages:
+ - `PolylineAlgorithm`
+ - `NetTopologySuite`
+
+```shell
+dotnet add package PolylineAlgorithm
+dotnet add package NetTopologySuite
+```
+
+---
+
+## Program.cs
+
+```csharp
+using System;
+using System.Collections.Generic;
+using NetTopologySuite.Geometries;
+using PolylineAlgorithm.Abstraction;
+
+class Program
+{
+ static void Main()
+ {
+ // Create some sample points (latitude, longitude)
+ var points = new List
+ {
+ new Point(48.858370, 2.294481), // Eiffel Tower
+ new Point(51.500729, -0.124625) // Big Ben
+ };
+
+ // Instantiate the custom encoder
+ var encoder = new NetTopologyPolylineEncoder();
+
+ // Encode the list of points to a polyline string
+ string encodedPolyline = encoder.Encode(points);
+
+ Console.WriteLine("Encoded polyline string:");
+ Console.WriteLine(encodedPolyline);
+
+ // Instantiate the custom decoder
+ var decoder = new NetTopologyPolylineDecoder();
+
+ // Decode back to NetTopologySuite Point objects
+ IEnumerable decodedPoints = decoder.Decode(encodedPolyline);
+
+ Console.WriteLine("\nDecoded coordinates:");
+ foreach (var point in decodedPoints)
+ {
+ Console.WriteLine($"Latitude: {point.X}, Longitude: {point.Y}");
+ }
+ }
+}
+
+public sealed class NetTopologyPolylineDecoder : AbstractPolylineDecoder {
+ protected override Point CreateCoordinate(double latitude, double longitude) {
+ return new Point(latitude, longitude);
+ }
+
+ protected override ReadOnlyMemory GetReadOnlyMemory(ref string polyline) {
+ return polyline.AsMemory();
+ }
+}
+
+public sealed class NetTopologyPolylineEncoder : AbstractPolylineEncoder {
+ protected override string CreatePolyline(ReadOnlyMemory polyline) {
+ if (polyline.IsEmpty) {
+ return string.Empty;
+ }
+
+ return polyline.ToString();
+ }
+
+ protected override double GetLatitude(Point current) {
+ // Validate parameter
+
+ return current.X;
+ }
+
+ protected override double GetLongitude(Point current) {
+ // Validate parameter
+
+ return current.Y;
+ }
+}
+```
+
+---
+
+## Expected Output
+
+```text
+Encoded polyline string:
+{sample output will be generated at runtime}
+
+Decoded coordinates:
+Latitude: 48.85837, Longitude: 2.294481
+Latitude: 51.500729, Longitude: -0.124625
+```
+
+---
+
+## Notes
+
+- You can further extend this pattern to use any coordinate or geometry type supported by NetTopologySuite.
+- The sample demonstrates real usage of a custom `PolylineEncoder`/`PolylineDecoder` in a typical .NET application.
+
+---
diff --git a/api-reference/guide/toc.yml b/api-reference/guide/toc.yml
index d7e9ea8c..64357007 100644
--- a/api-reference/guide/toc.yml
+++ b/api-reference/guide/toc.yml
@@ -1,4 +1,12 @@
-- name: Introduction
+- name: Introduction
href: introduction.md
- name: Getting Started
- href: getting-started.md
\ No newline at end of file
+ href: getting-started.md
+- name: Configuration
+ href: configuration.md
+- name: Advanced Scenarios
+ href: advanced-scenarions.md
+- name: Sample
+ href: sample.md
+- name: FAQ
+ href: faq.md
diff --git a/api-reference/index.md b/api-reference/index.md
index 5403debe..8c5b8d16 100644
--- a/api-reference/index.md
+++ b/api-reference/index.md
@@ -1,26 +1,18 @@
-# PolylineAlgorithm for .NET
+# PolylineAlgorithm API Reference
-[](https://github.com/sramekpete/polyline-algorithm-csharp/actions/workflows/build.yml)
-[](https://www.nuget.org/packages/PolylineAlgorithm/)
-[](https://opensource.org/licenses/MIT)
+Welcome! This documentation provides guides, configuration options, examples, and FAQs for the PolylineAlgorithm library.
+For detailed class and method docs, see the [auto-generated API documentation](https://petesramek.github.io/polyline-algorithm-csharp/).
-Lightweight .NET Standard 2.1 library implementing Google Encoded Polyline Algorithm.
-More info about the algorithm can be found at [Google Developers](https://developers.google.com/maps/documentation/utilities/polylinealgorithm).
+## Contents
-## Prerequisites
+- [Quick Start Guide](./guide.md)
+- [Configuration Options](./configuration.md)
+- [Advanced Usage](./advanced.md)
+- [Examples](./examples.md)
+- [FAQ](./faq.md)
-PolylineAlgorithm for .NET is available as a NuGet package targeting .NET Standard 2.1.
+## Links
-**.NET CLI**
-
-`dotnet add package PolylineAlgorithm`
-
-**Package Manager Console**
-
-`Install-Package PolylineAlgorithm`
-
-## How to use it
-
-In the majority of cases you would like to inherit `AbstractPolylineDecoder` and `AbstractPolylineEncoder` classes and implement abstract methods that are mainly responsible for extracting data from your coordinate and polyline types and creating new instances of them.
-
-In some cases you may want to implement your own decoder and encoder from scratch. In that case you can use `PolylineEncoding` static class that offers static methods for encoding and decoding polyline segments.
\ No newline at end of file
+- [API Reference Site](https://petesramek.github.io/polyline-algorithm-csharp/)
+- [Contributing Guidelines](../CONTRIBUTING.md)
+- [Changelog](./changelog.md) (if provided)
diff --git a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineAlgorithm.Benchmarks.csproj b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineAlgorithm.Benchmarks.csproj
index 2859331b..a7c3ce4e 100644
--- a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineAlgorithm.Benchmarks.csproj
+++ b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineAlgorithm.Benchmarks.csproj
@@ -2,12 +2,12 @@
Exe
- net8.0;net9.0;net10.0;
- 13.0
- enable
- enable
- true
- en
+ net8.0;net9.0;net10.0
+
+
+
+ pdbonly
+ true
@@ -15,7 +15,13 @@
-
+
+
+
+
+
+
+
diff --git a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineBenchmark.cs b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineBenchmark.cs
index 9d09883b..8275f93e 100644
--- a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineBenchmark.cs
+++ b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineBenchmark.cs
@@ -11,13 +11,16 @@ namespace PolylineAlgorithm.Benchmarks;
using PolylineAlgorithm.Utility;
///
-/// Benchmarks for the struct.
+/// Benchmarks for .
///
public class PolylineBenchmark {
- private static readonly Consumer consumer = new();
+ private static readonly Consumer _consumer = new();
+ ///
+ /// Number of coordinates for benchmarks. Set by BenchmarkDotNet.
+ ///
[Params(1, 100, 1_000)]
- public int Count;
+ public int CoordinatesCount { get; set; }
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
///
@@ -45,8 +48,12 @@ public class PolylineBenchmark {
///
public Polyline PolylineNotEqualValue { get; private set; }
+ ///
+ /// Gets the destination array used for benchmarking the method.
+ /// This array is initialized in to match the length of the encoded polyline,
+ /// and is used as the target buffer for copying polyline data during benchmark runs.
+ ///
public char[] CopyToDestination { get; private set; }
-
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
@@ -55,8 +62,8 @@ public class PolylineBenchmark {
///
[GlobalSetup]
public void SetupData() {
- PolylineValue = Polyline.FromString(RandomValueProvider.GetPolyline(Count));
- PolylineNotEqualValue = Polyline.FromString(RandomValueProvider.GetPolyline(Count + Random.Shared.Next(1, 101)));
+ PolylineValue = Polyline.FromString(RandomValueProvider.GetPolyline(CoordinatesCount));
+ PolylineNotEqualValue = Polyline.FromString(RandomValueProvider.GetPolyline(CoordinatesCount + Random.Shared.Next(1, 101)));
StringValue = PolylineValue.ToString();
CharArrayValue = [.. StringValue];
MemoryValue = CharArrayValue.AsMemory();
@@ -65,101 +72,101 @@ public void SetupData() {
}
///
- /// Benchmarks the encoding of a list of coordinates into a polyline.
+ /// Benchmark: create polyline from string.
///
/// The encoded polyline.
[Benchmark]
- public Polyline Polyline_FromString() {
+ public void Polyline_FromString() {
var polyline = Polyline
- .FromString(StringValue);
+ .FromString(StringValue);
- return polyline;
+ _consumer.Consume(polyline);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: create polyline from char array.
///
/// The encoded polyline.
[Benchmark]
- public Polyline Polyline_FromCharArray() {
+ public void Polyline_FromCharArray() {
var polyline = Polyline
- .FromCharArray(CharArrayValue);
+ .FromCharArray(CharArrayValue);
- return polyline;
+ _consumer.Consume(polyline);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: create polyline from memory.
///
/// The encoded polyline.
[Benchmark]
- public Polyline Polyline_FromMemory() {
+ public void Polyline_FromMemory() {
var polyline = Polyline
- .FromMemory(MemoryValue);
+ .FromMemory(MemoryValue);
- return polyline;
+ _consumer.Consume(polyline);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: convert polyline to string.
///
/// The encoded polyline.
[Benchmark]
- public string Polyline_ToString() {
+ public void Polyline_ToString() {
var stringValue = PolylineValue
- .ToString();
+ .ToString();
- return stringValue;
+ _consumer.Consume(stringValue);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: copy polyline to array.
///
/// The encoded polyline.
[Benchmark]
public void Polyline_CopyTo() {
PolylineValue
- .CopyTo(CopyToDestination);
+ .CopyTo(CopyToDestination);
CopyToDestination
- .Consume(consumer);
+ .Consume(_consumer);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: compare polyline with same value.
///
/// The encoded polyline.
[Benchmark]
- public bool Polyline_Equals_SameValue() {
+ public void Polyline_Equals_SameValue() {
var equals = PolylineValue
- .Equals(PolylineValue);
+ .Equals(PolylineValue);
- return equals;
+ _consumer.Consume(equals);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: compare polyline with different value.
///
/// The encoded polyline.
[Benchmark]
- public bool Polyline_Equals_DifferentValue() {
+ public void Polyline_Equals_DifferentValue() {
var equals = PolylineValue
- .Equals(PolylineNotEqualValue);
+ .Equals(PolylineNotEqualValue);
- return equals;
+ _consumer.Consume(equals);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: compare polyline with different type.
///
/// The encoded polyline.
[Benchmark]
- public bool Polyline_Equals_DifferentType() {
+ public void Polyline_Equals_DifferentType() {
var equals = PolylineValue
- .Equals(StringValue);
+ .Equals(StringValue);
- return equals;
+ _consumer.Consume(equals);
}
}
\ No newline at end of file
diff --git a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs
index 718cdd8b..fc8ba1e9 100644
--- a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs
+++ b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineDecoderBenchmark.cs
@@ -8,45 +8,94 @@ namespace PolylineAlgorithm.Benchmarks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using PolylineAlgorithm;
+using PolylineAlgorithm.Extensions;
using PolylineAlgorithm.Utility;
///
-/// Benchmarks for the class.
+/// Benchmarks for .
///
public class PolylineDecoderBenchmark {
private readonly Consumer _consumer = new();
[Params(1, 100, 1_000)]
- public int Count;
+ public int CoordinatesCount { get; set; }
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
///
- /// Gets the string value representing the encoded polyline.
+ /// Polyline instance for benchmarks.
///
public Polyline Polyline { get; private set; }
+ ///
+ /// Encoded polyline as string.
+ ///
+ public string String { get; private set; }
+
+ ///
+ /// Encoded polyline as char array.
+ ///
+ public char[] CharArray { get; private set; }
+
+ ///
+ /// Encoded polyline as read-only memory.
+ ///
+ public ReadOnlyMemory Memory { get; private set; }
+
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
///
- /// The polyline decoder instance.
+ /// Polyline decoder instance.
///
- public PolylineDecoder Decoder = new();
+ private readonly PolylineDecoder _decoder = new();
///
- /// Sets up the data for the benchmarks.
+ /// Sets up benchmark data.
///
[GlobalSetup]
public void SetupData() {
- Polyline = Polyline.FromString(RandomValueProvider.GetPolyline(Count));
+ Polyline = Polyline.FromString(RandomValueProvider.GetPolyline(CoordinatesCount));
+ String = RandomValueProvider.GetPolyline(CoordinatesCount);
+ CharArray = RandomValueProvider.GetPolyline(CoordinatesCount).ToCharArray();
+ Memory = RandomValueProvider.GetPolyline(CoordinatesCount).AsMemory();
}
///
- /// Benchmarks the decoding of a polyline from a string.
+ /// Benchmark: decode polyline instance.
///
[Benchmark]
- public void PolylineDecoder_Decode() {
- Decoder
+ public void PolylineDecoder_Decode_Polyline() {
+ _decoder
.Decode(Polyline)
.Consume(_consumer);
}
+
+ ///
+ /// Benchmark: decode from string.
+ ///
+ [Benchmark]
+ public void PolylineDecoder_Decode_String() {
+ _decoder
+ .Decode(String)
+ .Consume(_consumer);
+ }
+
+ ///
+ /// Benchmark: decode from char array.
+ ///
+ [Benchmark]
+ public void PolylineDecoder_Decode_CharArray() {
+ _decoder
+ .Decode(CharArray)
+ .Consume(_consumer);
+ }
+
+ ///
+ /// Benchmark: decode from memory.
+ ///
+ [Benchmark]
+ public void PolylineDecoder_Decode_Memory() {
+ _decoder
+ .Decode(Memory)
+ .Consume(_consumer);
+ }
}
\ No newline at end of file
diff --git a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncoderBenchmark.cs b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncoderBenchmark.cs
index 71743ca8..3993ecf8 100644
--- a/benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncoderBenchmark.cs
+++ b/benchmarks/PolylineAlgorithm.Benchmarks/PolylineEncoderBenchmark.cs
@@ -6,64 +6,90 @@
namespace PolylineAlgorithm.Benchmarks;
using BenchmarkDotNet.Attributes;
+using BenchmarkDotNet.Engines;
using PolylineAlgorithm;
+using PolylineAlgorithm.Extensions;
using PolylineAlgorithm.Utility;
using System.Collections.Generic;
///
-/// Benchmarks for the class.
+/// Benchmarks for .
///
public class PolylineEncoderBenchmark {
+ private readonly Consumer _consumer = new();
+
+ ///
+ /// Number of coordinates for benchmarks.
+ ///
[Params(1, 100, 1_000)]
- public int Count;
+ public int CoordinatesCount { get; set; }
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
///
- /// Gets the enumeration of coordinates to be encoded.
+ /// Coordinates as list.
///
- public IEnumerable Enumeration { get; private set; }
+ public List List { get; private set; }
///
- /// Gets the list of coordinates to be encoded.
+ /// Coordinates as array.
///
- public List List { get; private set; }
+ public Coordinate[] Array { get; private set; }
+
+ ///
+ /// Coordinates as read-only memory.
+ ///
+ public ReadOnlyMemory Memory { get; private set; }
+
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
///
- /// The polyline encoder instance.
+ /// Polyline encoder instance.
///
- public PolylineEncoder Encoder = new();
+ private readonly PolylineEncoder _encoder = new();
///
- /// Sets up the data for the benchmarks.
+ /// Sets up benchmark data.
///
[GlobalSetup]
public void SetupData() {
- Enumeration = RandomValueProvider.GetCoordinates(Count).Select(c => new Coordinate(c.Latitude, c.Longitude));
- List = [.. Enumeration];
+ List = [.. RandomValueProvider.GetCoordinates(CoordinatesCount).Select(c => new Coordinate(c.Latitude, c.Longitude))];
+ Array = [.. List];
+ Memory = Array.AsMemory();
}
///
- /// Benchmarks the encoding of a list of coordinates into a polyline.
+ /// Benchmark: encode coordinates from span.
///
- /// The encoded polyline.
+ /// Encoded polyline.
[Benchmark]
- public Polyline PolylineEncoder_Encode_List() {
- var polyline = Encoder
- .Encode(List!);
+ public void PolylineEncoder_Encode_Span() {
+ var polyline = _encoder
+ .Encode(Memory.Span!);
+
+ _consumer.Consume(polyline);
+ }
+
+ ///
+ /// Benchmark: encode coordinates from array.
+ ///
+ /// Encoded polyline.
+ [Benchmark]
+ public void PolylineEncoder_Encode_Array() {
+ var polyline = _encoder
+ .Encode(Array!);
- return polyline;
+ _consumer.Consume(polyline);
}
///
- /// Benchmarks the encoding of an enumeration of coordinates into a polyline.
+ /// Benchmark: encode coordinates from list.
///
- /// The encoded polyline.
+ /// Encoded polyline.
[Benchmark]
- public Polyline PolylineEncoder_Encode_Enumerator() {
- var polyline = Encoder
- .Encode(Enumeration!);
+ public void PolylineEncoder_Encode_List() {
+ var polyline = _encoder
+ .Encode(List!);
- return polyline;
+ _consumer.Consume(polyline);
}
}
\ No newline at end of file
diff --git a/benchmarks/PolylineAlgorithm.Benchmarks/Program.cs b/benchmarks/PolylineAlgorithm.Benchmarks/Program.cs
index e1dffccb..92c38c10 100644
--- a/benchmarks/PolylineAlgorithm.Benchmarks/Program.cs
+++ b/benchmarks/PolylineAlgorithm.Benchmarks/Program.cs
@@ -8,13 +8,13 @@ namespace PolylineAlgorithm.Benchmarks;
using BenchmarkDotNet.Running;
///
-/// The main entry point for the benchmark application.
+/// Main entry point for benchmarks.
///
-internal class Program {
+internal static class Program {
///
- /// The main method that runs the benchmarks.
+ /// Runs the benchmarks.
///
- /// The command-line arguments.
+ /// Command-line arguments.
static void Main(string[] args) {
BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
diff --git a/benchmarks/PolylineAlgorithm.Benchmarks/Properties/CodeCoverage.cs b/benchmarks/PolylineAlgorithm.Benchmarks/Properties/CodeCoverage.cs
new file mode 100644
index 00000000..04094932
--- /dev/null
+++ b/benchmarks/PolylineAlgorithm.Benchmarks/Properties/CodeCoverage.cs
@@ -0,0 +1,8 @@
+//
+// Copyright © Pete Sramek. All rights reserved.
+// Licensed under the MIT License. See LICENSE file in the project root for full license information.
+//
+
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: ExcludeFromCodeCoverage]
\ No newline at end of file
diff --git a/benchmarks/PolylineAlgorithm.Benchmarks/Properties/GlobalSuppressions.cs b/benchmarks/PolylineAlgorithm.Benchmarks/Properties/GlobalSuppressions.cs
index 39178369..98b7cc75 100644
--- a/benchmarks/PolylineAlgorithm.Benchmarks/Properties/GlobalSuppressions.cs
+++ b/benchmarks/PolylineAlgorithm.Benchmarks/Properties/GlobalSuppressions.cs
@@ -1,8 +1,15 @@
-//
-// Copyright © Pete Sramek. All rights reserved.
-// Licensed under the MIT License. See LICENSE file in the project root for full license information.
-//
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project.
+// Project-level suppressions either have no target or are given
+// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
-[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Benchmarks need instance methods.")]
\ No newline at end of file
+[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Benchmarks.")]
+[assembly: SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification = "Benchmarks.")]
+[assembly: SuppressMessage("Design", "MA0016:Prefer using collection abstraction instead of implementation", Justification = "Benchmarks.")]
+[assembly: SuppressMessage("Design", "CA1002:Do not expose generic lists", Justification = "Benchmarks.")]
+[assembly: SuppressMessage("Naming", "CA1720:Identifier contains type name", Justification = "Benchmarks.")]
+[assembly: SuppressMessage("Maintainability", "CA1515:Consider making public types internal", Justification = "Benchmarks.")]
+[assembly: SuppressMessage("Security", "CA5394:Do not use insecure randomness", Justification = "Benchmarks.")]
+[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Benchmarks need instance methods.")]
diff --git a/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineDecoder.cs b/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineDecoder.cs
index 10a034d0..e5d304c5 100644
--- a/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineDecoder.cs
+++ b/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineDecoder.cs
@@ -10,38 +10,26 @@ namespace PolylineAlgorithm.NetTopologySuite.Sample;
using System;
///
-/// Represents a polyline decoder that converts encoded polyline strings into a collection of geographic coordinates using NetTopologySuite.
+/// Polyline decoder using NetTopologySuite.
///
public sealed class NetTopologyPolylineDecoder : AbstractPolylineDecoder {
///
- /// Creates a coordinate instance from the given latitude and longitude values.
+ /// Creates a NetTopologySuite point from latitude and longitude.
///
- ///
- /// The latitude value.
- ///
- ///
- /// The longitude value.
- ///
- ///
- /// A coordinate instance of type .
- ///
+ /// Latitude value.
+ /// Longitude value.
+ /// Point instance.
protected override Point CreateCoordinate(double latitude, double longitude) {
return new Point(latitude, longitude);
}
///
- /// Converts the provided polyline string into a read-only memory of characters.
+ /// Converts polyline string to read-only memory.
///
- ///
- /// The encoded polyline string to be converted into a read-only memory of characters.
- ///
- ///
- /// A containing the characters of the polyline string.
- ///
- ///
- /// Thrown when the provided polyline string is null, empty, or consists only of whitespace characters.
- ///
- protected override ReadOnlyMemory GetReadOnlyMemory(string polyline) {
+ /// Encoded polyline string.
+ /// ReadOnlyMemory of characters.
+ /// Thrown if polyline is null or whitespace.
+ protected override ReadOnlyMemory GetReadOnlyMemory(ref string polyline) {
return polyline.AsMemory();
}
}
diff --git a/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineEncoder.cs b/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineEncoder.cs
index f9e71f50..d829d27c 100644
--- a/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineEncoder.cs
+++ b/samples/PolylineAlgorithm.NetTopologySuite.Sample/NetTopologyPolylineEncoder.cs
@@ -9,18 +9,14 @@ namespace PolylineAlgorithm.NetTopologySuite.Sample;
using PolylineAlgorithm.Abstraction;
///
-/// Encodes a collection of geographic coordinates into an encoded polyline string using NetTopologySuite's Point type.
+/// Polyline encoder using NetTopologySuite's Point type.
///
public sealed class NetTopologyPolylineEncoder : AbstractPolylineEncoder {
///
- /// Creates a string representation of the provided polyline.
+ /// Creates encoded polyline string from memory.
///
- ///
- /// The polyline to encode as a string.
- ///
- ///
- /// An encoded polyline string representation of the provided polyline.
- ///
+ /// Polyline memory.
+ /// Encoded polyline string.
protected override string CreatePolyline(ReadOnlyMemory polyline) {
if (polyline.IsEmpty) {
return string.Empty;
@@ -30,31 +26,27 @@ protected override string CreatePolyline(ReadOnlyMemory polyline) {
}
///
- /// Extracts the latitude value from the specified coordinate.
+ /// Gets latitude from point.
///
- ///
- /// The coordinate from which to extract the latitude value. This should be a not null instance.
- ///
- ///
- /// The latitude value as a .
- ///
+ /// Point instance.
+ /// Latitude value.
protected override double GetLatitude(Point current) {
- // Validate parameter
+ if (current is null) {
+ throw new ArgumentNullException(nameof(current));
+ }
return current.X;
}
///
- /// Extracts the longitude value from the specified coordinate.
+ /// Gets longitude from point.
///
- ///
- /// The coordinate from which to extract the longitude value. This should be a not null instance.
- ///
- ///
- /// The longitude value as a .
- ///
+ /// Point instance.
+ /// Longitude value.
protected override double GetLongitude(Point current) {
- // Validate parameter
+ if (current is null) {
+ throw new ArgumentNullException(nameof(current));
+ }
return current.Y;
}
diff --git a/samples/PolylineAlgorithm.NetTopologySuite.Sample/PolylineAlgorithm.NetTopologySuite.Sample.csproj b/samples/PolylineAlgorithm.NetTopologySuite.Sample/PolylineAlgorithm.NetTopologySuite.Sample.csproj
index 6aad5fb7..57d5f7c1 100644
--- a/samples/PolylineAlgorithm.NetTopologySuite.Sample/PolylineAlgorithm.NetTopologySuite.Sample.csproj
+++ b/samples/PolylineAlgorithm.NetTopologySuite.Sample/PolylineAlgorithm.NetTopologySuite.Sample.csproj
@@ -2,18 +2,6 @@
netstandard2.1
- 13.0
- enable
- enable
- true
- en
-
-
-
- All
- latest
- true
- true
@@ -21,11 +9,11 @@
-
+
-
\ No newline at end of file
+
diff --git a/samples/PolylineAlgorithm.NetTopologySuite.Sample/Properties/CodeCoverage.cs b/samples/PolylineAlgorithm.NetTopologySuite.Sample/Properties/CodeCoverage.cs
new file mode 100644
index 00000000..04094932
--- /dev/null
+++ b/samples/PolylineAlgorithm.NetTopologySuite.Sample/Properties/CodeCoverage.cs
@@ -0,0 +1,8 @@
+//
+// Copyright © Pete Sramek. All rights reserved.
+// Licensed under the MIT License. See LICENSE file in the project root for full license information.
+//
+
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: ExcludeFromCodeCoverage]
\ No newline at end of file
diff --git a/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs b/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs
index b15766b5..6e146ba6 100644
--- a/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs
+++ b/src/PolylineAlgorithm/Abstraction/AbstractPolylineDecoder.cs
@@ -11,7 +11,11 @@ namespace PolylineAlgorithm.Abstraction;
using PolylineAlgorithm.Internal.Logging;
using PolylineAlgorithm.Properties;
using System;
-using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+#if NET8_0_OR_GREATER
+using System.Text;
+#endif
///
/// Decodes encoded polyline strings into sequences of geographic coordinates.
@@ -21,6 +25,14 @@ namespace PolylineAlgorithm.Abstraction;
/// This abstract class provides a base implementation for decoding polylines, allowing subclasses to define how to handle specific polyline formats.
///
public abstract class AbstractPolylineDecoder : IPolylineDecoder {
+#if NET8_0_OR_GREATER
+ private static readonly CompositeFormat _polylineCannotBeShorterThanExceptionMessage = CompositeFormat.Parse(ExceptionMessageResource.PolylineCannotBeShorterThanExceptionMessage);
+#else
+ private static readonly string _polylineCannotBeShorterThanExceptionMessage = ExceptionMessageResource.PolylineCannotBeShorterThanExceptionMessage;
+#endif
+
+
+ private readonly ILogger> _logger;
///
/// Initializes a new instance of the class with default encoding options.
///
@@ -38,10 +50,13 @@ protected AbstractPolylineDecoder()
///
protected AbstractPolylineDecoder(PolylineEncodingOptions options) {
Options = options ?? throw new ArgumentNullException(nameof(options));
+ _logger = Options
+ .LoggerFactory
+ .CreateLogger>();
}
///
- /// Gets the encoding options used by this polyline encoder.
+ /// Gets the encoding options used by this polyline decoder.
///
public PolylineEncodingOptions Options { get; }
@@ -56,7 +71,7 @@ protected AbstractPolylineDecoder(PolylineEncodingOptions options) {
///
///
/// Thrown when is .
- /// "
+ ///
///
/// Thrown when is empty.
///
@@ -64,37 +79,30 @@ protected AbstractPolylineDecoder(PolylineEncodingOptions options) {
/// Thrown when the polyline format is invalid or malformed at a specific position.
///
public IEnumerable Decode(TPolyline polyline) {
- var logger = Options
- .LoggerFactory
- .CreateLogger>();
+ const string OperationName = nameof(Decode);
- logger.
- LogOperationStartedInfo(nameof(Decode));
+ _logger.
+ LogOperationStartedDebug(OperationName);
- ValidateNullPolyline(polyline, logger);
+ ValidateNullPolyline(polyline, _logger);
- ReadOnlyMemory sequence = GetReadOnlyMemory(polyline);
+ ReadOnlyMemory sequence = GetReadOnlyMemory(ref polyline);
- ValidateEmptySequence(logger, sequence);
+ ValidateEmptySequence(sequence, _logger);
int position = 0;
int latitude = 0;
int longitude = 0;
- while (true) {
- // Check if we have reached the end of the sequence
- if (sequence.Length == position) {
- break;
- }
-
+ while (position < sequence.Length) {
// Read the next value from the polyline encoding
- if (!PolylineEncoding.TryReadValue(ref latitude, ref sequence, ref position)
- || !PolylineEncoding.TryReadValue(ref longitude, ref sequence, ref position)
+ if (!PolylineEncoding.TryReadValue(ref latitude, sequence, ref position)
+ || !PolylineEncoding.TryReadValue(ref longitude, sequence, ref position)
) {
- logger
+ _logger.
+ LogOperationFailedDebug(OperationName);
+ _logger
.LogInvalidPolylineWarning(position);
- logger.
- LogOperationFailedInfo(nameof(Decode));
InvalidPolylineException.Throw(position);
}
@@ -102,11 +110,11 @@ public IEnumerable Decode(TPolyline polyline) {
yield return CreateCoordinate(PolylineEncoding.Denormalize(latitude, CoordinateValueType.Latitude), PolylineEncoding.Denormalize(longitude, CoordinateValueType.Longitude));
}
- logger
- .LogOperationFinishedInfo(nameof(Decode));
+ _logger
+ .LogOperationFinishedDebug(OperationName);
-
- static void ValidateNullPolyline(TPolyline polyline, ILogger> logger) {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static void ValidateNullPolyline(TPolyline polyline, ILogger logger) {
if (polyline is null) {
logger
.LogNullArgumentWarning(nameof(polyline));
@@ -115,14 +123,15 @@ static void ValidateNullPolyline(TPolyline polyline, ILogger> logger, ReadOnlyMemory sequence) {
- if (sequence.Length < Defaults.Polyline.Block.Length.Min) {
- logger
- .LogPolylineCannotBeShorterThanWarning(nameof(sequence), sequence.Length, Defaults.Polyline.Block.Length.Min);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static void ValidateEmptySequence(ReadOnlyMemory polyline, ILogger logger) {
+ if (polyline.Length < Defaults.Polyline.Block.Length.Min) {
logger.
- LogOperationFailedInfo(nameof(Decode));
+ LogOperationFailedDebug(OperationName);
+ logger
+ .LogPolylineCannotBeShorterThanWarning(nameof(polyline), polyline.Length, Defaults.Polyline.Block.Length.Min);
- throw new ArgumentException(string.Format(ExceptionMessageResource.PolylineCannotBeShorterThanExceptionMessage, sequence.Length), nameof(polyline));
+ throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, _polylineCannotBeShorterThanExceptionMessage, polyline.Length, Defaults.Polyline.Block.Length.Min), nameof(polyline));
}
}
}
@@ -136,7 +145,8 @@ static void ValidateEmptySequence(ILogger
/// A representing the encoded polyline data.
///
- protected abstract ReadOnlyMemory GetReadOnlyMemory(TPolyline polyline);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ protected abstract ReadOnlyMemory GetReadOnlyMemory(ref TPolyline polyline);
///
/// Creates a coordinate instance from the given latitude and longitude values.
@@ -150,5 +160,6 @@ static void ValidateEmptySequence(ILogger
/// A coordinate instance of type .
///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
protected abstract TCoordinate CreateCoordinate(double latitude, double longitude);
}
\ No newline at end of file
diff --git a/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs b/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs
index 6ea869bd..2d2e12c6 100644
--- a/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs
+++ b/src/PolylineAlgorithm/Abstraction/AbstractPolylineEncoder.cs
@@ -11,9 +11,10 @@ namespace PolylineAlgorithm.Abstraction;
using PolylineAlgorithm.Internal.Logging;
using PolylineAlgorithm.Properties;
using System;
-using System.Collections;
-using System.Collections.Generic;
+using System.Buffers;
using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.CompilerServices;
///
/// Provides functionality to encode a collection of geographic coordinates into an encoded polyline string.
@@ -23,6 +24,7 @@ namespace PolylineAlgorithm.Abstraction;
/// This abstract class serves as a base for specific polyline encoders, allowing customization of the encoding process.
///
public abstract class AbstractPolylineEncoder : IPolylineEncoder {
+ private readonly ILogger> _logger;
///
/// Initializes a new instance of the class with default encoding options.
///
@@ -38,6 +40,9 @@ protected AbstractPolylineEncoder()
/// Thrown when is
protected AbstractPolylineEncoder(PolylineEncodingOptions options) {
Options = options ?? throw new ArgumentNullException(nameof(options));
+ _logger = Options
+ .LoggerFactory
+ .CreateLogger>();
}
///
@@ -53,7 +58,6 @@ protected AbstractPolylineEncoder(PolylineEncodingOptions options) {
///
///
/// An instance of representing the encoded coordinates.
- /// Returns if the input collection is empty or null.
///
///
/// Thrown when is .
@@ -61,129 +65,114 @@ protected AbstractPolylineEncoder(PolylineEncodingOptions options) {
///
/// Thrown when is an empty enumeration.
///
- public TPolyline Encode(IEnumerable coordinates) {
- var logger = Options
- .LoggerFactory
- .CreateLogger>();
-
- logger
- .LogOperationStartedInfo(nameof(Encode));
-
- Debug.Assert(coordinates is not null, "Coordinates cannot be null.");
+ ///
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MA0051:Method is too long", Justification = "Method contains local methods. Actual method only 55 lines.")]
+ public TPolyline Encode(ReadOnlySpan coordinates) {
+ const string OperationName = nameof(Encode);
- ValidateNullCoordinates(coordinates, logger);
+ _logger
+ .LogOperationStartedDebug(OperationName);
- int count = GetCount(coordinates);
+ Debug.Assert(coordinates.Length >= 0, "Count must be non-negative.");
- Debug.Assert(count >= 0, "Count must be non-negative.");
-
- ValidateEmptyCoordinates(logger, count);
+ ValidateEmptyCoordinates(ref coordinates, _logger);
CoordinateVariance variance = new();
int position = 0;
int consumed = 0;
- int length = GetMaxBufferLength(count);
+ int length = GetMaxBufferLength(coordinates.Length);
- Span buffer = stackalloc char[length];
+ char[]? temp = length <= Options.StackAllocLimit
+ ? null
+ : ArrayPool.Shared.Rent(length);
- using var enumerator = coordinates.GetEnumerator();
+ Span buffer = temp is null ? stackalloc char[length] : temp.AsSpan(0, length);
- while (enumerator.MoveNext()) {
- variance
- .Next(
- PolylineEncoding.Normalize(GetLatitude(enumerator.Current), CoordinateValueType.Latitude),
- PolylineEncoding.Normalize(GetLongitude(enumerator.Current), CoordinateValueType.Longitude)
- );
+ try {
+ for (var i = 0; i < coordinates.Length; i++) {
+ variance
+ .Next(
+ PolylineEncoding.Normalize(GetLatitude(coordinates[i]), CoordinateValueType.Latitude),
+ PolylineEncoding.Normalize(GetLongitude(coordinates[i]), CoordinateValueType.Longitude)
+ );
- ValidateBuffer(logger, variance, position, buffer);
+ ValidateBuffer(variance, position, buffer, _logger);
- if (!PolylineEncoding.TryWriteValue(variance.Latitude, ref buffer, ref position)
- || !PolylineEncoding.TryWriteValue(variance.Longitude, ref buffer, ref position)
- ) {
- // This shouldn't happen, but if it does, log the error and throw an exception.
- logger
- .LogCannotWriteValueToBufferWarning(position, consumed);
- logger
- .LogOperationFailedInfo(nameof(Encode));
+ if (!PolylineEncoding.TryWriteValue(variance.Latitude, buffer, ref position)
+ || !PolylineEncoding.TryWriteValue(variance.Longitude, buffer, ref position)
+ ) {
+ // This shouldn't happen, but if it does, log the error and throw an exception.
+ _logger
+ .LogOperationFailedDebug(OperationName);
+ _logger
+ .LogCannotWriteValueToBufferWarning(position, consumed);
- throw new InvalidOperationException(ExceptionMessageResource.CouldNotWriteEncodedValueToTheBuffer);
- }
+ throw new InvalidOperationException(ExceptionMessageResource.CouldNotWriteEncodedValueToTheBuffer);
+ }
- consumed++;
+ consumed++;
+ }
+ } finally {
+ if (temp is not null) {
+ ArrayPool.Shared.Return(temp);
+ }
}
- logger
- .LogOperationFinishedInfo(nameof(Encode));
+ _logger
+ .LogOperationFinishedDebug(OperationName);
return CreatePolyline(buffer[..position].ToString().AsMemory());
- static int GetCount(IEnumerable coordinates) => coordinates switch {
- ICollection collection => collection.Count,
- _ => coordinates.Count(),
- };
-
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
static int GetRequiredLength(CoordinateVariance variance) =>
PolylineEncoding.GetCharCount(variance.Latitude) + PolylineEncoding.GetCharCount(variance.Longitude);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
static int GetRemainingBufferSize(int position, int length) {
Debug.Assert(length > 0, "Buffer length must be greater than zero.");
Debug.Assert(position >= 0, "Position must be non-negative.");
Debug.Assert(position < length, "Position must be less than buffer length.");
- Debug.Assert(length - position >= 0, "Remaining length must be non-negative.");
+ Debug.Assert(length >= position, "Remaining length must be non-negative.");
return length - position;
}
- int GetMaxBufferLength(int count) {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static int GetMaxBufferLength(int count) {
Debug.Assert(count > 0, "Count must be greater than zero.");
int requestedBufferLength = count * Defaults.Polyline.Block.Length.Max;
- Debug.Assert(Options.MaxBufferLength > 0, "Max buffer length must be greater than zero.");
Debug.Assert(requestedBufferLength > 0, "Requested buffer length must be greater than zero.");
- if (requestedBufferLength > Options.MaxBufferLength) {
- logger
- .LogRequestedBufferSizeExceedsMaxBufferLengthWarning(requestedBufferLength, Options.MaxBufferLength);
-
- return Options.MaxBufferLength;
- }
-
return requestedBufferLength;
}
- static void ValidateNullCoordinates(IEnumerable coordinates, ILogger> logger) {
- if (coordinates is null) {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static void ValidateEmptyCoordinates(ref ReadOnlySpan coordinates, ILogger logger) {
+ if (coordinates.Length < 1) {
logger
- .LogNullArgumentWarning(nameof(coordinates));
- logger
- .LogOperationFailedInfo(nameof(Encode));
-
- throw new ArgumentNullException(nameof(coordinates));
- }
- }
-
- static void ValidateEmptyCoordinates(ILogger> logger, int count) {
- if (count < 1) {
+ .LogOperationFailedDebug(OperationName);
logger
.LogEmptyArgumentWarning(nameof(coordinates));
- logger
- .LogOperationFailedInfo(nameof(Encode));
throw new ArgumentException(ExceptionMessageResource.ArgumentCannotBeEmptyEnumerationMessage, nameof(coordinates));
}
}
- static void ValidateBuffer(ILogger> logger, CoordinateVariance variance, int position, Span buffer) {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static void ValidateBuffer(CoordinateVariance variance, int position, Span buffer, ILogger logger) {
if (GetRemainingBufferSize(position, buffer.Length) < GetRequiredLength(variance)) {
+ var requiredLength = GetRequiredLength(variance);
+
logger
- .LogInternalBufferOverflowWarning(position, buffer.Length, GetRequiredLength(variance));
+ .LogOperationFailedDebug(OperationName);
logger
- .LogOperationFailedInfo(nameof(Encode));
-
+ .LogInternalBufferOverflowWarning(position, buffer.Length, requiredLength);
- throw new InternalBufferOverflowException();
+ throw new InternalBufferOverflowException($"Internal buffer has size of {buffer.Length}. At position {position.ToString(CultureInfo.InvariantCulture)} is required additional {requiredLength.ToString(CultureInfo.InvariantCulture)} space.");
}
}
}
@@ -195,7 +184,7 @@ static void ValidateBuffer(ILogger
/// An instance of representing the encoded polyline.
///
-
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
protected abstract TPolyline CreatePolyline(ReadOnlyMemory polyline);
///
@@ -205,7 +194,7 @@ static void ValidateBuffer(ILogger
/// The longitude value as a .
///
-
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
protected abstract double GetLongitude(TCoordinate current);
///
@@ -215,7 +204,7 @@ static void ValidateBuffer(ILogger
/// The latitude value as a .
///
-
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
protected abstract double GetLatitude(TCoordinate current);
}
diff --git a/src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs b/src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs
index 363601ee..3937353c 100644
--- a/src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs
+++ b/src/PolylineAlgorithm/Abstraction/IPolylineDecoder.cs
@@ -10,7 +10,7 @@ namespace PolylineAlgorithm.Abstraction;
///
/// Defines a contract for decoding an encoded polyline into a sequence of geographic coordinates.
///
-public interface IPolylineDecoder {
+public interface IPolylineDecoder {
///
/// Decodes the specified encoded polyline into a sequence of geographic coordinates.
///
diff --git a/src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs b/src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs
index 8febc1bf..7fc93905 100644
--- a/src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs
+++ b/src/PolylineAlgorithm/Abstraction/IPolylineEncoder.cs
@@ -4,9 +4,6 @@
//
namespace PolylineAlgorithm.Abstraction;
-
-using System.Collections.Generic;
-
///
/// Defines a contract for encoding a sequence of geographic coordinates into an encoded polyline string.
///
@@ -20,5 +17,5 @@ public interface IPolylineEncoder {
///
/// A containing the encoded polyline string that represents the input coordinates.
///
- TPolyline Encode(IEnumerable coordinates);
+ TPolyline Encode(ReadOnlySpan coordinates);
}
diff --git a/src/PolylineAlgorithm/Coordinate.cs b/src/PolylineAlgorithm/Coordinate.cs
index 43156f29..0d496f6e 100644
--- a/src/PolylineAlgorithm/Coordinate.cs
+++ b/src/PolylineAlgorithm/Coordinate.cs
@@ -10,6 +10,9 @@ namespace PolylineAlgorithm;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
+#if NET8_0_OR_GREATER
+using System.Text;
+#endif
///
/// Represents a geographic coordinate as a pair of latitude and longitude values.
@@ -20,8 +23,14 @@ namespace PolylineAlgorithm;
/// and provides methods for equality comparison and string representation.
///
[DebuggerDisplay("{ToString()}")]
-[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 16)]
+[StructLayout(LayoutKind.Auto)]
public readonly struct Coordinate : IEquatable {
+#if NET8_0_OR_GREATER
+ private static readonly CompositeFormat _coordinateValueMustBeBetweenValuesMessageFormat = CompositeFormat.Parse(ExceptionMessageResource.CoordinateValueMustBeBetweenValuesMessageFormat);
+#else
+ private static readonly string _coordinateValueMustBeBetweenValuesMessageFormat = ExceptionMessageResource.CoordinateValueMustBeBetweenValuesMessageFormat;
+#endif
+
///
/// Initializes a new instance of the struct with default values (0) for and .
///
@@ -44,12 +53,12 @@ public Coordinate() {
/// or when is less than -180 or greater than 180.
///
public Coordinate(double latitude, double longitude) {
- if (latitude < -90 || latitude > 90 || double.IsNaN(latitude) || double.IsInfinity(latitude)) {
- throw new ArgumentOutOfRangeException(nameof(latitude), string.Format(ExceptionMessageResource.CoordinateValueMustBeBetweenValuesMessageFormat, "Latitude", -90, 90));
+ if (latitude < -90 || latitude > 90 || !double.IsFinite(latitude)) {
+ throw new ArgumentOutOfRangeException(nameof(latitude), string.Format(CultureInfo.InvariantCulture, _coordinateValueMustBeBetweenValuesMessageFormat, "Latitude", -90, 90));
}
- if (longitude < -180 || longitude > 180 || double.IsNaN(longitude) || double.IsInfinity(longitude)) {
- throw new ArgumentOutOfRangeException(nameof(longitude), string.Format(ExceptionMessageResource.CoordinateValueMustBeBetweenValuesMessageFormat, "Longitude", -180, 180));
+ if (longitude < -180 || longitude > 180 || !double.IsFinite(longitude)) {
+ throw new ArgumentOutOfRangeException(nameof(longitude), string.Format(CultureInfo.InvariantCulture, _coordinateValueMustBeBetweenValuesMessageFormat, "Longitude", -180, 180));
}
Latitude = latitude;
@@ -73,14 +82,18 @@ public Coordinate(double latitude, double longitude) {
/// if both latitude and longitude are 0; otherwise, .
///
public bool IsDefault()
- => Latitude == default
- && Longitude == default;
-
- #region Overrides
+ => Latitude.Equals(default)
+ && Longitude.Equals(default);
///
public override bool Equals(object? obj) => obj is Coordinate coordinate && Equals(coordinate);
+ ///
+ public bool Equals(Coordinate other) {
+ return Latitude.Equals(other.Latitude) &&
+ Longitude.Equals(other.Longitude);
+ }
+
///
public override int GetHashCode() => HashCode.Combine(Latitude, Longitude);
@@ -94,20 +107,6 @@ public override string ToString() {
return $"{{ {nameof(Latitude)}: {Latitude.ToString("G", CultureInfo.InvariantCulture)}, {nameof(Longitude)}: {Longitude.ToString("G", CultureInfo.InvariantCulture)} }}";
}
- #endregion
-
- #region IEquatable implementation
-
- ///
- public bool Equals(Coordinate other) {
- return Latitude == other.Latitude &&
- Longitude == other.Longitude;
- }
-
- #endregion
-
- #region Equality operators
-
///
/// Determines whether two instances are equal.
///
@@ -127,6 +126,4 @@ public bool Equals(Coordinate other) {
/// if the coordinates are not equal; otherwise, .
///
public static bool operator !=(Coordinate left, Coordinate right) => !(left == right);
-
- #endregion
}
diff --git a/src/PolylineAlgorithm/CoordinateValueType.cs b/src/PolylineAlgorithm/CoordinateValueType.cs
index f576e8dd..aaf15efc 100644
--- a/src/PolylineAlgorithm/CoordinateValueType.cs
+++ b/src/PolylineAlgorithm/CoordinateValueType.cs
@@ -8,7 +8,7 @@
/// longitude. Latitude values indicate the north-south position, while longitude values indicate the east-west
/// position.
///
-public enum CoordinateValueType : int {
+public enum CoordinateValueType {
///
/// Represents no specific type. This value is used when the type is not applicable or not specified.
///
@@ -20,5 +20,5 @@ public enum CoordinateValueType : int {
///
/// Represents a longitude value.
///
- Longitude = 2
+ Longitude = 2,
}
\ No newline at end of file
diff --git a/src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs b/src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs
index 14cecfad..f9cee8cd 100644
--- a/src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs
+++ b/src/PolylineAlgorithm/Extensions/PolylineEncoderExtensions.cs
@@ -9,54 +9,71 @@ namespace PolylineAlgorithm.Extensions;
using PolylineAlgorithm.Abstraction;
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using static PolylineAlgorithm.Internal.Defaults;
///
/// Provides extension methods for the interface to facilitate encoding geographic coordinates into polylines.
///
public static class PolylineEncoderExtensions {
///
- /// Encodes a collection of instances into an encoded polyline.
+ /// Encodes a collection of instances into an encoded polyline.
///
///
/// The instance used to perform the encoding operation.
///
///
- /// The sequence of objects to encode.
+ /// The sequence of objects to encode.
///
///
- /// A representing the encoded polyline string for the provided coordinates.
+ /// A representing the encoded polyline string for the provided coordinates.
///
///
/// Thrown when is .
///
- public static Polyline Encode(this IPolylineEncoder encoder, ICollection coordinates) {
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1002:Do not expose generic lists", Justification = "We need a list as we do need to marshal it as span.")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MA0016:Prefer using collection abstraction instead of implementation", Justification = "We need a list as we do need to marshal it as span.")]
+ public static TPolyline Encode(this IPolylineEncoder encoder, List coordinates) {
if (encoder is null) {
throw new ArgumentNullException(nameof(encoder));
}
- return encoder.Encode(coordinates);
+ if (coordinates is null) {
+ throw new ArgumentNullException(nameof(coordinates));
+ }
+
+#if NET5_0_OR_GREATER
+ return encoder.Encode(CollectionsMarshal.AsSpan(coordinates));
+#else
+ return encoder.Encode([.. coordinates]);
+#endif
}
+
///
- /// Encodes an array of instances into an encoded polyline.
+ /// Encodes an array of instances into an encoded polyline.
///
///
/// The instance used to perform the encoding operation.
///
///
- /// The array of objects to encode.
+ /// The array of objects to encode.
///
///
- /// A representing the encoded polyline string for the provided coordinates.
+ /// A representing the encoded polyline string for the provided coordinates.
///
///
/// Thrown when is .
///
- public static Polyline Encode(this IPolylineEncoder encoder, Coordinate[] coordinates) {
+ public static TPolyline Encode(this IPolylineEncoder encoder, TCoordinate[] coordinates) {
if (encoder is null) {
throw new ArgumentNullException(nameof(encoder));
}
- return encoder.Encode(coordinates);
+ if (coordinates is null) {
+ throw new ArgumentNullException(nameof(coordinates));
+ }
+
+ return encoder.Encode(coordinates.AsSpan());
}
}
diff --git a/src/PolylineAlgorithm/Internal/CoordinateVariance.cs b/src/PolylineAlgorithm/Internal/CoordinateVariance.cs
index e33f02af..2177e9fb 100644
--- a/src/PolylineAlgorithm/Internal/CoordinateVariance.cs
+++ b/src/PolylineAlgorithm/Internal/CoordinateVariance.cs
@@ -5,7 +5,6 @@
namespace PolylineAlgorithm.Internal;
-using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@@ -13,8 +12,8 @@ namespace PolylineAlgorithm.Internal;
/// Represents the difference (variance) in latitude and longitude between consecutive geographic coordinates.
/// This struct is used to compute and store the change in coordinate values as integer deltas.
///
-[DebuggerDisplay($"{{{nameof(ToString)}(),nq}}")]
-[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 16)]
+[DebuggerDisplay("{ToString(),nq}")]
+[StructLayout(LayoutKind.Auto)]
internal struct CoordinateVariance {
private (int Latitude, int Longitude) _current;
@@ -22,7 +21,7 @@ internal struct CoordinateVariance {
/// Initializes a new instance of the struct with the default latitude and longitude deltas.
///
public CoordinateVariance() {
- _current =(default, default);
+ _current = (default, default);
}
///
@@ -59,15 +58,7 @@ public void Next(int latitude, int longitude) {
/// The next coordinate value.
/// The computed variance between and .
- private static int Variance(int initial, int next) => (initial, next) switch {
- (0, 0) => 0,
- (0, _) => next,
- (_, 0) => -initial,
- ( < 0, < 0) => -(Math.Abs(next) - Math.Abs(initial)),
- ( < 0, > 0) => next + Math.Abs(initial),
- ( > 0, < 0) => -(Math.Abs(next) + initial),
- ( > 0, > 0) => next - initial,
- };
+ private static int Variance(int initial, int next) => next - initial;
///
/// Returns a string representation of the current coordinate variance.
@@ -75,6 +66,8 @@ public void Next(int latitude, int longitude) {
///
/// A string in the format { Coordinate: { Latitude: [int], Longitude: [int] }, Variance: { Latitude: [int], Longitude: [int] } } representing the current coordinate and deltas to previous coordinate.
///
- public override readonly string ToString()
- => $"{{ Coordinate: {{ Latitude: {Latitude}, Longitude: {Longitude} }}, Variance: {{ Latitude: {Latitude}, Longitude: {Longitude} }} }}";
+ public override readonly string ToString() =>
+ $"{{ Coordinate: {{ Latitude: {_current.Latitude}, Longitude: {_current.Longitude} }}, " +
+ $"Variance: {{ Latitude: {Latitude}, Longitude: {Longitude} }} }}";
+
}
diff --git a/src/PolylineAlgorithm/Internal/Defaults.cs b/src/PolylineAlgorithm/Internal/Defaults.cs
index 3f62fac8..c94350f5 100644
--- a/src/PolylineAlgorithm/Internal/Defaults.cs
+++ b/src/PolylineAlgorithm/Internal/Defaults.cs
@@ -73,6 +73,7 @@ internal static class Latitude {
///
/// Contains constants related to normalized latitude values.
///
+ [SuppressMessage("Critical Code Smell", "S3218:Inner class members should not shadow outer class \"static\" or type members", Justification = "Internal use only.")]
internal static class Normalized {
///
/// The minimum normalized latitude value.
@@ -105,6 +106,7 @@ internal static class Longitude {
///
/// Contains constants related to normalized longitude values.
///
+ [SuppressMessage("Critical Code Smell", "S3218:Inner class members should not shadow outer class \"static\" or type members", Justification = "Internal use only.")]
internal static class Normalized {
///
/// The minimum normalized latitude value.
diff --git a/src/PolylineAlgorithm/Internal/Logging/LogInfoExtensions.cs b/src/PolylineAlgorithm/Internal/Logging/LogDebugExtensions.cs
similarity index 67%
rename from src/PolylineAlgorithm/Internal/Logging/LogInfoExtensions.cs
rename to src/PolylineAlgorithm/Internal/Logging/LogDebugExtensions.cs
index b3360a1b..86405d62 100644
--- a/src/PolylineAlgorithm/Internal/Logging/LogInfoExtensions.cs
+++ b/src/PolylineAlgorithm/Internal/Logging/LogDebugExtensions.cs
@@ -7,16 +7,16 @@ namespace PolylineAlgorithm.Internal.Logging;
using Microsoft.Extensions.Logging;
-internal static partial class LogInfoExtensions {
- private const LogLevel LOG_LEVEL = LogLevel.Information;
+internal static partial class LogDebugExtensions {
+ private const LogLevel LOG_LEVEL = LogLevel.Debug;
private const int EVENT_ID_BASE = (int)LOG_LEVEL * Defaults.Logging.LogLevelMultiplier;
[LoggerMessage(EVENT_ID_BASE + 1, LOG_LEVEL, "Operation {operationName} has started.")]
- internal static partial void LogOperationStartedInfo(this ILogger logger, string operationName);
+ internal static partial void LogOperationStartedDebug(this ILogger logger, string operationName);
[LoggerMessage(EVENT_ID_BASE + 2, LOG_LEVEL, "Operation {operationName} has failed.")]
- internal static partial void LogOperationFailedInfo(this ILogger logger, string operationName);
+ internal static partial void LogOperationFailedDebug(this ILogger logger, string operationName);
[LoggerMessage(EVENT_ID_BASE + 3, LOG_LEVEL, "Operation {operationName} has finished.")]
- internal static partial void LogOperationFinishedInfo(this ILogger logger, string operationName);
+ internal static partial void LogOperationFinishedDebug(this ILogger logger, string operationName);
}
diff --git a/src/PolylineAlgorithm/InvalidPolylineException.cs b/src/PolylineAlgorithm/InvalidPolylineException.cs
index 36250da6..86b8834c 100644
--- a/src/PolylineAlgorithm/InvalidPolylineException.cs
+++ b/src/PolylineAlgorithm/InvalidPolylineException.cs
@@ -9,6 +9,10 @@ namespace PolylineAlgorithm;
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+#if NET8_0_OR_GREATER
+using System.Text;
+#endif
///
/// Exception thrown when a polyline is determined to be malformed or invalid during processing.
@@ -16,9 +20,15 @@ namespace PolylineAlgorithm;
///
/// This exception is used internally to indicate that a polyline string does not conform to the expected format or contains errors.
///
-[SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "Internal use only.")]
[DebuggerDisplay($"{nameof(InvalidPolylineException)}: {{ToString()}}")]
+[SuppressMessage("Roslynator", "RCS1194:Implement exception constructors", Justification = "Internal use only.")]
+[SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "Internal use only.")]
public sealed class InvalidPolylineException : Exception {
+#if NET8_0_OR_GREATER
+ private static readonly CompositeFormat _polylineStringIsMalformedMessage = CompositeFormat.Parse(ExceptionMessageResource.PolylineStringIsMalformedMessage);
+#else
+ private static readonly string _polylineStringIsMalformedMessage = ExceptionMessageResource.PolylineStringIsMalformedMessage;
+#endif
///
/// Initializes a new instance of the class with a specified error message.
///
@@ -40,6 +50,6 @@ private InvalidPolylineException(string message)
internal static void Throw(long position) {
Debug.Assert(position >= 0, "Position must be a non-negative value.");
- throw new InvalidPolylineException(string.Format(ExceptionMessageResource.PolylineStringIsMalformedMessage, position.ToString()));
+ throw new InvalidPolylineException(string.Format(CultureInfo.InvariantCulture, _polylineStringIsMalformedMessage, position));
}
}
\ No newline at end of file
diff --git a/src/PolylineAlgorithm/Polyline.cs b/src/PolylineAlgorithm/Polyline.cs
index d5e51295..121a16cf 100644
--- a/src/PolylineAlgorithm/Polyline.cs
+++ b/src/PolylineAlgorithm/Polyline.cs
@@ -20,13 +20,11 @@ namespace PolylineAlgorithm;
[StructLayout(LayoutKind.Auto)]
[DebuggerDisplay("Value: {ToDebugString()}, IsEmpty: {IsEmpty}, Length: {Length}")]
public readonly struct Polyline : IEquatable {
- private readonly ReadOnlyMemory _value;
-
///
/// Initializes a new, empty instance of the struct.
///
public Polyline() {
- _value = ReadOnlyMemory.Empty;
+ Value = ReadOnlyMemory.Empty;
}
///
@@ -36,13 +34,13 @@ public Polyline() {
/// A read-only memory region of characters representing an encoded polyline.
///
private Polyline(ReadOnlyMemory value) {
- _value = value;
+ Value = value;
}
///
/// Gets the underlying read-only sequence of characters representing the polyline.
///
- internal readonly ReadOnlyMemory Value => _value;
+ internal readonly ReadOnlyMemory Value { get; }
///
/// Gets a value indicating whether this is empty.
@@ -75,7 +73,7 @@ public void CopyTo(char[] destination) {
throw new ArgumentException(ExceptionMessageResource.DestinationArrayLengthMustBeEqualOrGreaterThanPolylineLengthMessage, nameof(destination));
}
- _value.CopyTo(destination);
+ Value.CopyTo(destination);
}
///
@@ -116,7 +114,7 @@ public bool Equals(Polyline other) {
}
///
- public override bool Equals(object obj) {
+ public override bool Equals(object? obj) {
return obj is Polyline other && Equals(other);
}
diff --git a/src/PolylineAlgorithm/PolylineAlgorithm.csproj b/src/PolylineAlgorithm/PolylineAlgorithm.csproj
index 54b8cc74..9772a079 100644
--- a/src/PolylineAlgorithm/PolylineAlgorithm.csproj
+++ b/src/PolylineAlgorithm/PolylineAlgorithm.csproj
@@ -1,19 +1,7 @@
- netstandard2.1
- 13.0
- enable
- enable
- true
- en
-
-
-
- All
- latest
- true
- true
+ netstandard2.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0;
@@ -22,13 +10,13 @@
true
-
+
pdbonly
true
snupkg
-
+
True
@@ -44,7 +32,7 @@
-
+
True
\
@@ -55,7 +43,7 @@
all
runtime; build; native; contentfiles; analyzers
-
+
@@ -68,11 +56,11 @@
-
- ExceptionMessageResource.resx
- True
- True
-
+
+ True
+ True
+ ExceptionMessageResource.resx
+
diff --git a/src/PolylineAlgorithm/PolylineDecoder.cs b/src/PolylineAlgorithm/PolylineDecoder.cs
index 2e398d28..590851d0 100644
--- a/src/PolylineAlgorithm/PolylineDecoder.cs
+++ b/src/PolylineAlgorithm/PolylineDecoder.cs
@@ -23,7 +23,7 @@ protected override Coordinate CreateCoordinate(double latitude, double longitude
}
///
- protected override ReadOnlyMemory GetReadOnlyMemory(Polyline polyline) {
+ protected override ReadOnlyMemory GetReadOnlyMemory(ref Polyline polyline) {
return polyline.Value;
}
}
\ No newline at end of file
diff --git a/src/PolylineAlgorithm/PolylineEncoding.cs b/src/PolylineAlgorithm/PolylineEncoding.cs
index 75100f5e..0bc53240 100644
--- a/src/PolylineAlgorithm/PolylineEncoding.cs
+++ b/src/PolylineAlgorithm/PolylineEncoding.cs
@@ -4,9 +4,14 @@
//
namespace PolylineAlgorithm;
+
using PolylineAlgorithm.Internal;
using PolylineAlgorithm.Properties;
using System;
+using System.Globalization;
+#if NET8_0_OR_GREATER
+using System.Text;
+#endif
///
/// Provides methods for encoding and decoding polyline data, as well as utilities for normalizing and de-normalizing
@@ -17,6 +22,13 @@ namespace PolylineAlgorithm;
/// coordinates. It also provides validation utilities to ensure values conform to expected ranges for latitude and
/// longitude.
public static class PolylineEncoding {
+#if NET8_0_OR_GREATER
+ private static readonly CompositeFormat _argumentCannotBeCoordinateValueTypeMessageFormat = CompositeFormat.Parse(ExceptionMessageResource.ArgumentCannotBeCoordinateValueTypeMessageFormat);
+ private static readonly CompositeFormat _argumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat = CompositeFormat.Parse(ExceptionMessageResource.ArgumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat);
+#else
+ private static readonly string _argumentCannotBeCoordinateValueTypeMessageFormat = ExceptionMessageResource.ArgumentCannotBeCoordinateValueTypeMessageFormat;
+ private static readonly string _argumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat = ExceptionMessageResource.ArgumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat;
+#endif
///
/// Attempts to read a value from the specified buffer and updates the variance.
///
@@ -37,7 +49,7 @@ public static class PolylineEncoding {
/// langword="false"/>.
///
- public static bool TryReadValue(ref int variance, ref ReadOnlyMemory buffer, ref int position) {
+ public static bool TryReadValue(ref int variance, ReadOnlyMemory buffer, ref int position) {
// Validate that the position is within the bounds of the buffer.
if (position == buffer.Length) {
return false;
@@ -91,12 +103,12 @@ public static bool TryReadValue(ref int variance, ref ReadOnlyMemory buffe
public static double Denormalize(int value, CoordinateValueType type) {
// Validate that the type is not None, as it does not represent a valid coordinate value type.
if (type == CoordinateValueType.None) {
- throw new ArgumentOutOfRangeException(nameof(type), string.Format(ExceptionMessageResource.ArgumentCannotBeCoordinateValueTypeMessageFormat, type.ToString()));
+ throw new ArgumentOutOfRangeException(nameof(type), string.Format(CultureInfo.InvariantCulture, _argumentCannotBeCoordinateValueTypeMessageFormat, type.ToString()));
}
// Validate that the value is finite and within the acceptable range for the specified type.
if (!ValidateValue(value, type)) {
- throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(ExceptionMessageResource.ArgumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat, type.ToString().ToLowerInvariant()));
+ throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, _argumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat, type.ToString().ToLowerInvariant()));
}
// Return fast if the value is zero, return 0.0 as the denormalized value.
@@ -104,7 +116,7 @@ public static double Denormalize(int value, CoordinateValueType type) {
return 0.0;
}
- return Math.Truncate((double)value) / Defaults.Algorithm.Precision;
+ return value / (double)Defaults.Algorithm.Precision;
}
///
@@ -130,7 +142,7 @@ public static double Denormalize(int value, CoordinateValueType type) {
/// if the value was successfully written to the buffer; otherwise, .
///
- public static bool TryWriteValue(int variance, ref Span buffer, ref int position) {
+ public static bool TryWriteValue(int variance, Span buffer, ref int position) {
// Validate that the position and required space for write is within the bounds of the buffer.
if (buffer.Length < position + GetCharCount(variance)) {
return false;
@@ -145,7 +157,10 @@ public static bool TryWriteValue(int variance, ref Span buffer, ref int po
// Write the value to the buffer in a way that encodes it using the specified algorithm.
while (rem >= Defaults.Algorithm.Space) {
- buffer[position++] = (char)((Defaults.Algorithm.Space | rem & Defaults.Algorithm.UnitSeparator) + Defaults.Algorithm.QuestionMark);
+ buffer[position++] =
+ (char)((Defaults.Algorithm.Space
+ | (rem & Defaults.Algorithm.UnitSeparator))
+ + Defaults.Algorithm.QuestionMark);
rem >>= Defaults.Algorithm.ShiftLength;
}
@@ -180,7 +195,7 @@ public static bool TryWriteValue(int variance, ref Span buffer, ref int po
public static int Normalize(double value, CoordinateValueType type) {
// Validate that the type is not None, as it does not represent a valid coordinate value type.
if (type == CoordinateValueType.None) {
- throw new ArgumentOutOfRangeException(nameof(type), string.Format(ExceptionMessageResource.ArgumentCannotBeCoordinateValueTypeMessageFormat, type.ToString()));
+ throw new ArgumentOutOfRangeException(nameof(type), string.Format(CultureInfo.InvariantCulture, _argumentCannotBeCoordinateValueTypeMessageFormat, type.ToString()));
}
// Validate that the value is finite and not NaN or Infinity.
@@ -190,15 +205,17 @@ public static int Normalize(double value, CoordinateValueType type) {
// Validate that the value is within the acceptable range for the specified type.
if (!ValidateValue(value, type)) {
- throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(ExceptionMessageResource.ArgumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat, type.ToString().ToLowerInvariant()));
+ throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(CultureInfo.InvariantCulture, _argumentOutOfRangeForSpecifiedCoordinateValueTypeMessageFormat, type.ToString().ToLowerInvariant()));
}
// Fast return if the value is zero, return 0 as the normalized value.
- if (value == 0.0) {
+ if (value.Equals(default)) {
return 0;
}
- return (int)Math.Round(value * Defaults.Algorithm.Precision);
+ checked {
+ return (int)Math.Round(value * Defaults.Algorithm.Precision, MidpointRounding.AwayFromZero);
+ }
}
///
@@ -215,38 +232,65 @@ public static int Normalize(double value, CoordinateValueType type) {
/// integer.
///
///
- /// The number of characters required to represent the value, based on its magnitude.
- /// Returns a value between 1 and 6 inclusive.
+ /// The number of characters required to represent the value, based on its magnitude.
///
+ public static int GetCharCount(int variance) {
+ long rem = (long)variance << 1;
+
+ if (variance < 0) {
+ rem = ~rem;
+ }
+
+ int count = 1;
+
+ while (rem >= Defaults.Algorithm.Space) {
+ rem >>= Defaults.Algorithm.ShiftLength;
+ count++;
+ }
+
+ return count;
+ }
- public static int GetCharCount(int variance) => variance switch {
- // DO NOT CHANGE THE ORDER. We are skipping inside exclusive ranges as those are covered by previous statements.
- >= -16 and <= +15 => 1,
- >= -512 and <= +511 => 2,
- >= -16384 and <= +16383 => 3,
- >= -524288 and <= +524287 => 4,
- >= -16777216 and <= +16777215 => 5,
- _ => 6,
+ ///
+ /// Validates whether the specified normalized value falls within the acceptable range for the given value type.
+ ///
+ ///
+ /// The normalized value to validate.
+ ///
+ ///
+ /// The type of value to validate, such as latitude or longitude.
+ ///
+ ///
+ /// if the is within the valid range for the specified ; otherwise, .
+ ///
+ private static bool ValidateValue(int normalized, CoordinateValueType type) => type switch {
+ CoordinateValueType.Latitude => normalized >= Defaults.Coordinate.Latitude.Normalized.Min &&
+ normalized <= Defaults.Coordinate.Latitude.Normalized.Max,
+ CoordinateValueType.Longitude => normalized >= Defaults.Coordinate.Longitude.Normalized.Min &&
+ normalized <= Defaults.Coordinate.Longitude.Normalized.Max,
+ _ => false,
};
///
/// Validates whether the specified denormalized value falls within the acceptable range for the given value type.
///
- ///
+ ///
/// The denormalized value to validate.
///
///
/// The type of value to validate, such as latitude or longitude.
///
///
- /// if the is within the valid range for the specified if the is within the valid range for the specified ; otherwise, .
///
- private static bool ValidateValue(T value, CoordinateValueType type) => (type, value) switch {
- (CoordinateValueType.Latitude, int normalized) when normalized >= Defaults.Coordinate.Latitude.Normalized.Min && normalized <= Defaults.Coordinate.Latitude.Normalized.Max => true,
- (CoordinateValueType.Longitude, int normalized) when normalized >= Defaults.Coordinate.Longitude.Normalized.Min && normalized <= Defaults.Coordinate.Longitude.Normalized.Max => true,
- (CoordinateValueType.Latitude, double denormalized) when denormalized >= Defaults.Coordinate.Latitude.Min && denormalized <= Defaults.Coordinate.Latitude.Max => true,
- (CoordinateValueType.Longitude, double denormalized) when denormalized >= Defaults.Coordinate.Longitude.Min && denormalized <= Defaults.Coordinate.Longitude.Max => true,
+ private static bool ValidateValue(double denormalized, CoordinateValueType type) => type switch {
+ CoordinateValueType.Latitude => denormalized >= Defaults.Coordinate.Latitude.Min &&
+ denormalized <= Defaults.Coordinate.Latitude.Max,
+ CoordinateValueType.Longitude => denormalized >= Defaults.Coordinate.Longitude.Min &&
+ denormalized <= Defaults.Coordinate.Longitude.Max,
_ => false,
};
+
}
diff --git a/src/PolylineAlgorithm/PolylineEncodingOptions.cs b/src/PolylineAlgorithm/PolylineEncodingOptions.cs
index ae8d1a6f..bfbe614a 100644
--- a/src/PolylineAlgorithm/PolylineEncodingOptions.cs
+++ b/src/PolylineAlgorithm/PolylineEncodingOptions.cs
@@ -15,30 +15,23 @@ namespace PolylineAlgorithm;
///
/// This class allows you to set options such as buffer size and logger factory for encoding operations.
///
-[DebuggerDisplay("MaxBufferSize: {MaxBufferSize}, MaxBufferLength: {MaxBufferLength}, LoggerFactoryType: {LoggerFactory.GetType().Name}")]
+[DebuggerDisplay("StackAllocLimit: {StackAllocLimit}, LoggerFactoryType: {GetLoggerFactoryType()}")]
public sealed class PolylineEncodingOptions {
///
- /// Gets the maximum buffer size for encoding operations.
- ///
- ///
- /// The default maximum buffer size is 64,000 bytes (64 KB). This can be adjusted based on the expected size of the polyline data, but should be enough for common cases.
- ///
- public int MaxBufferSize { get; internal set; } = 64_000;
-
- ///
- /// Gets or sets the precision for encoding coordinates.
+ /// Gets logger factory.
///
///
/// The default logger factory is , which does not log any messages.
///
public ILoggerFactory LoggerFactory { get; internal set; } = NullLoggerFactory.Instance;
-
///
- /// Gets the maximum length of the encoded polyline string.
+ /// Gets stackalloc limit.
///
///
- /// The maximum length is calculated based on the buffer size divided by the size of a character.
+ /// The default stack alloc limit is 512.
///
- internal int MaxBufferLength => MaxBufferSize / sizeof(char);
+ public int StackAllocLimit { get; internal set; } = 512;
+
+ private string GetLoggerFactoryType() => LoggerFactory.GetType().Name;
}
\ No newline at end of file
diff --git a/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs b/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs
index a555b11f..663ef93a 100644
--- a/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs
+++ b/src/PolylineAlgorithm/PolylineEncodingOptionsBuilder.cs
@@ -8,12 +8,21 @@ namespace PolylineAlgorithm;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using PolylineAlgorithm.Properties;
+using System.Globalization;
+#if NET8_0_OR_GREATER
+using System.Text;
+#endif
///
/// Provides a builder for configuring options for polyline encoding operations.
///
-public class PolylineEncodingOptionsBuilder {
- private int _bufferSize = 64_000;
+public sealed class PolylineEncodingOptionsBuilder {
+#if NET8_0_OR_GREATER
+ private static readonly CompositeFormat _stackAllocLimitMustBeEqualOrGreaterThanMessageFormat = CompositeFormat.Parse(ExceptionMessageResource.StackAllocLimitMustBeEqualOrGreaterThanMessageFormat);
+#else
+ private static readonly string _stackAllocLimitMustBeEqualOrGreaterThanMessageFormat = ExceptionMessageResource.StackAllocLimitMustBeEqualOrGreaterThanMessageFormat;
+#endif
+ private int _stackAllocLimit = 512;
private ILoggerFactory _loggerFactory = NullLoggerFactory.Instance;
private PolylineEncodingOptionsBuilder() { }
@@ -36,23 +45,24 @@ public static PolylineEncodingOptionsBuilder Create() {
///
public PolylineEncodingOptions Build() {
return new PolylineEncodingOptions {
- MaxBufferSize = _bufferSize,
- LoggerFactory = _loggerFactory
+ StackAllocLimit = _stackAllocLimit,
+ LoggerFactory = _loggerFactory,
};
}
///
/// Sets the buffer size for encoding operations.
///
- ///
+ ///
/// The maximum buffer size. Must be greater than 11.
///
///
/// The current builder instance.
///
- /// Thrown when is less than or equal to 11.
- public PolylineEncodingOptionsBuilder WithMaxBufferSize(int bufferSize) {
- _bufferSize = bufferSize > 11 ? bufferSize : throw new ArgumentOutOfRangeException(nameof(bufferSize), string.Format(ExceptionMessageResource.BufferSizeMustBeGreaterThanMessageFormat, 11));
+ /// Thrown when is less than or equal to 11.
+ public PolylineEncodingOptionsBuilder WithStackAllocLimit(int stackAllocLimit) {
+ const int minStackAllocLimit = 1;
+ _stackAllocLimit = stackAllocLimit >= minStackAllocLimit ? stackAllocLimit : throw new ArgumentOutOfRangeException(nameof(stackAllocLimit), string.Format(CultureInfo.InvariantCulture, _stackAllocLimitMustBeEqualOrGreaterThanMessageFormat, minStackAllocLimit));
return this;
}
diff --git a/src/PolylineAlgorithm/Properties/ExceptionMessageResource.Designer.cs b/src/PolylineAlgorithm/Properties/ExceptionMessageResource.Designer.cs
index 04d5a153..2a2d306b 100644
--- a/src/PolylineAlgorithm/Properties/ExceptionMessageResource.Designer.cs
+++ b/src/PolylineAlgorithm/Properties/ExceptionMessageResource.Designer.cs
@@ -19,7 +19,7 @@ namespace PolylineAlgorithm.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class ExceptionMessageResource {
@@ -96,15 +96,6 @@ internal static string ArgumentValueMustBeFiniteNumber {
}
}
- ///
- /// Looks up a localized string similar to Buffer size must be greater than {0}..
- ///
- internal static string BufferSizeMustBeGreaterThanMessageFormat {
- get {
- return ResourceManager.GetString("BufferSizeMustBeGreaterThanMessageFormat", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to {0} must be between {1} and {2}..
///
@@ -133,7 +124,7 @@ internal static string DestinationArrayLengthMustBeEqualOrGreaterThanPolylineLen
}
///
- /// Looks up a localized string similar to Argument cannot be shorten than 2 characters. Actual length: {0}..
+ /// Looks up a localized string similar to Argument cannot be shorten than {1} characters. Actual length: {0}..
///
internal static string PolylineCannotBeShorterThanExceptionMessage {
get {
@@ -149,5 +140,14 @@ internal static string PolylineStringIsMalformedMessage {
return ResourceManager.GetString("PolylineStringIsMalformedMessage", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Stack alloc limit must be equal or greater than {0}..
+ ///
+ internal static string StackAllocLimitMustBeEqualOrGreaterThanMessageFormat {
+ get {
+ return ResourceManager.GetString("StackAllocLimitMustBeEqualOrGreaterThanMessageFormat", resourceCulture);
+ }
+ }
}
}
diff --git a/src/PolylineAlgorithm/Properties/ExceptionMessageResource.resx b/src/PolylineAlgorithm/Properties/ExceptionMessageResource.resx
index bf47eeee..defb5bc6 100644
--- a/src/PolylineAlgorithm/Properties/ExceptionMessageResource.resx
+++ b/src/PolylineAlgorithm/Properties/ExceptionMessageResource.resx
@@ -124,7 +124,7 @@
Polyline is malformed at position {0}.
- Argument cannot be shorten than 2 characters. Actual length: {0}.
+ Argument cannot be shorten than {1} characters. Actual length: {0}.
Value must be a finite number.
@@ -135,8 +135,8 @@
Argument cannot be CoordinateValueType.{0}.
-
- Buffer size must be greater than {0}.
+
+ Stack alloc limit must be equal or greater than {0}.
Destination array length must be greater than the polyline length.
diff --git a/src/PolylineAlgorithm/Properties/GlobalSuppressions.cs b/src/PolylineAlgorithm/Properties/GlobalSuppressions.cs
new file mode 100644
index 00000000..48f8c35a
--- /dev/null
+++ b/src/PolylineAlgorithm/Properties/GlobalSuppressions.cs
@@ -0,0 +1 @@
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Maintainability", "CA1510:Use ArgumentNullException throw helper", Justification = "We do target multiple frameworks. Not all have this method available.")]
diff --git a/src/PolylineAlgorithm/README.md b/src/PolylineAlgorithm/README.md
new file mode 100644
index 00000000..16794e2a
--- /dev/null
+++ b/src/PolylineAlgorithm/README.md
@@ -0,0 +1,79 @@
+# PolylineAlgorithm for .NET
+
+A modern, fully compliant Google Encoded Polyline Algorithm library for .NET Standard 2.1+, supporting strong input validation, extensibility for custom coordinate types, and robust performance.
+
+## Features
+
+- Google-compliant polyline encoding/decoding for geographic coordinates
+- Immutable, strongly-typed data structures: `Coordinate`, `Polyline`
+- Predefined encoder/decoder types for easy usage
+- Extensible APIs for custom coordinate and polyline types
+- Robust input validation and descriptive exceptions
+- Configurable with `PolylineEncodingOptions` (buffer, logging, etc.)
+- Thread-safe, stateless APIs
+- Benchmarks and unit tests for correctness and performance
+- Auto-generated API docs ([API Reference](https://petesramek.github.io/polyline-algorithm-csharp/))
+- Supports .NET Core, .NET 5+, Xamarin, Unity, Blazor via `netstandard2.1`
+
+## Installation
+
+```shell
+dotnet add package PolylineAlgorithm
+```
+
+or via NuGet PMC:
+
+```powershell
+Install-Package PolylineAlgorithm
+```
+
+## Quick Start
+
+### Encode coordinates
+
+```csharp
+using PolylineAlgorithm;
+
+var coordinates = new List
+{
+ new Coordinate(48.858370, 2.294481),
+ new Coordinate(51.500729, -0.124625)
+};
+
+var encoder = new PolylineEncoder();
+Polyline encoded = encoder.Encode(coordinates);
+
+Console.WriteLine(encoded.ToString()); // Print encoded polyline string
+```
+
+### Decode polyline
+
+```csharp
+using PolylineAlgorithm;
+
+var decoder = new PolylineDecoder();
+Polyline polyline = Polyline.FromString("yseiHoc_MwacOjnwM");
+IEnumerable decoded = decoder.Decode(polyline);
+```
+
+## Advanced Usage
+
+- Custom coordinate/polyline types are supported via `AbstractPolylineEncoder` and `AbstractPolylineDecoder`.
+- Additional configuration via `PolylineEncodingOptionsBuilder`.
+
+> See [API Reference](https://petesramek.github.io/polyline-algorithm-csharp/) for full documentation.
+
+## FAQ
+
+- **What coordinate ranges are valid?**
+ Latitude: -90..90, Longitude: -180..180 (throws `ArgumentOutOfRangeException` for invalid input)
+- **What .NET versions are supported?**
+ Any environment supporting `netstandard2.1`
+- **How do I customize encoder options?**
+ Use `PolylineEncodingOptionsBuilder` and pass to the encoder constructor.
+- **Where can I get help?**
+ [GitHub issues](https://github.com/petesramek/polyline-algorithm-csharp/issues)
+
+## License
+
+MIT License © Pete Sramek
diff --git a/tests/PolylineAlgorithm.Tests/AbstractPolylineDecoderTest.cs b/tests/PolylineAlgorithm.Tests/AbstractPolylineDecoderTest.cs
index 07c738d2..47765e20 100644
--- a/tests/PolylineAlgorithm.Tests/AbstractPolylineDecoderTest.cs
+++ b/tests/PolylineAlgorithm.Tests/AbstractPolylineDecoderTest.cs
@@ -13,7 +13,7 @@ namespace PolylineAlgorithm.Tests;
[TestClass]
public class AbstractPolylineDecoderTest {
- private static readonly PolylineDecoder _decoder = new();
+ private static readonly TestPolylineDecoder _decoder = new(new());
public static IEnumerable