Public/Tools/ConvertFrom-GisPoint.ps1

function ConvertFrom-GisPoint {
    <#
    .SYNOPSIS
        Converts Milestone's internal representation of a GPS coordinate to a [System.Device.Location.GeoCoordinate] object.
    .DESCRIPTION
        Milestone stores GPS coordinates as X,Y coordinates on a standard coordinate plane. For example, the coordinates
        47.25726, -122.51608 are represented in Milestone as "POINT (-122.51608 47.25726)" where the latitude and longitude
        are reversed. An unset coordinate for a camera is represented as "POINT EMPTY".
 
        This function converts Milestone's GisPoint property string into a [System.Device.Location.GeoCoordinate] object which
        has a ToString() method which will properly format the coordinates. If the coordinates are unset in Milestone, then you
        will receive the same object but the position will be defined as "Unknown".
    .EXAMPLE
        PS C:\> Select-Camera | ConvertFrom-GisPoint
        Opens a camera selection dialog and pipes the camera to ConvertFrom-GisPoint. The GisPoint parameter accepts the value
        from the pipeline by property name and the Camera object's coordinates are stored in a property with a matching name.
    #>

    [CmdletBinding()]
    [OutputType([system.device.location.geocoordinate])]
    param (
        # Specifies the GisPoint value to convert to a GeoCoordinate. Milestone stores GisPoint data in the format "POINT ([longitude] [latitude])" or "POINT EMPTY".
        [Parameter(Mandatory, ValueFromPipelineByPropertyName)]
        [string]
        $GisPoint
    )

    process {
        if ($GisPoint -eq 'POINT EMPTY') {
            Write-Output ([system.device.location.geocoordinate]::Unknown)
        }
        else {
            $temp = $GisPoint.Substring(7, $GisPoint.Length - 8)
            $long, $lat, $null = $temp -split ' '
            Write-Output ([system.device.location.geocoordinate]::new($lat, $long))
        }
    }
}