A
- AccessControlEntry.ConditionToIdentities
- Access.Database
- ActiveDirectory.Domains
- AdobeAnalytics.Cubes
- AdoDotNet.DataSource
- AdoDotNet.Query
- AnalysisServices.Database
- AnalysisServices.Databases
- AzureStorage.BlobContents
- AzureStorage.Blobs
- AzureStorage.DataLake
- AzureStorage.DataLakeContents
- AzureStorage.Tables
B
- BinaryFormat.Binary
- BinaryFormat.Byte
- BinaryFormat.ByteOrder
- BinaryFormat.Choice
- BinaryFormat.Decimal
- BinaryFormat.Double
- BinaryFormat.Group
- BinaryFormat.Length
- BinaryFormat.List
- BinaryFormat.Null
- BinaryFormat.Record
- BinaryFormat.SignedInteger16
- BinaryFormat.SignedInteger32
- BinaryFormat.SignedInteger64
- BinaryFormat.Single
- BinaryFormat.Text
- BinaryFormat.Transform
- BinaryFormat.UnsignedInteger16
- BinaryFormat.UnsignedInteger32
- BinaryFormat.UnsignedInteger64
- BinaryFormat.7BitEncodedSignedInteger
- BinaryFormat.7BitEncodedUnsignedInteger
- Binary data
- Binary.ApproximateLength
- Binary.Buffer
- Binary.Combine
- Binary.Compress
- Binary.Decompress
- Binary.From
- Binary.FromList
- Binary.FromText
- Binary.InferContentType
- Binary.Length
- Binary.Range
- Binary.Split
- Binary.ToList
- Binary.ToText
- Binary.View
- Binary.ViewError
- Binary.ViewFunction
- Byte.From
C
- Cdm.Contents
- Character.FromNumber
- Character.ToNumber
- Combiner.CombineTextByDelimiter
- Combiner.CombineTextByEachDelimiter
- Combiner.CombineTextByLengths
- Combiner.CombineTextByPositions
- Combiner.CombineTextByRanges
- Comparer.FromCulture
- Comparer.Ordinal
- Comparer.OrdinalIgnoreCase
- Controlling byte order
- Csv.Document
- Cube.AddAndExpandDimensionColumn
- Cube.AddMeasureColumn
- Cube.ApplyParameter
- Cube.AttributeMemberId
- Cube.AttributeMemberProperty
- Cube.CollapseAndRemoveColumns
- Cube.Dimensions
- Cube.DisplayFolders
- Cube.MeasureProperties
- Cube.MeasureProperty
- Cube.Measures
- Cube.Parameters
- Cube.Properties
- Cube.PropertyKey
- Cube.ReplaceDimensions
- Cube.Transform
- Currency.From
D
- DateTime.AddZone
- DateTime.Date
- DateTime.FixedLocalNow
- DateTime.From
- DateTime.FromFileTime
- DateTime.FromText
- DateTime.IsInCurrentHour
- DateTime.IsInCurrentMinute
- DateTime.IsInCurrentSecond
- DateTime.IsInNextHour
- DateTime.IsInNextMinute
- DateTime.IsInNextNHours
- DateTime.IsInNextNMinutes
- DateTime.IsInNextNSeconds
- DateTime.IsInNextSecond
- DateTime.IsInPreviousHour
- DateTime.IsInPreviousMinute
- DateTime.IsInPreviousNHours
- DateTime.IsInPreviousNMinutes
- DateTime.IsInPreviousNSeconds
- DateTime.IsInPreviousSecond
- DateTime.LocalNow
- DateTime.Time
- DateTime.ToRecord
- DateTime.ToText
- Date.AddDays
- Date.AddMonths
- Date.AddQuarters
- Date.AddWeeks
- Date.AddYears
- Date.Day
- Date.DayOfWeek
- Date.DayOfWeekName
- Date.DayOfYear
- Date.DaysInMonth
- Date.EndOfDay
- Date.EndOfMonth
- Date.EndOfQuarter
- Date.EndOfWeek
- Date.EndOfYear
- Date.From
- Date.FromText
- Date.IsInCurrentDay
- Date.IsInCurrentMonth
- Date.IsInCurrentQuarter
- Date.IsInCurrentWeek
- Date.IsInCurrentYear
- Date.IsInNextDay
- Date.IsInNextMonth
- Date.IsInNextNDays
- Date.IsInNextNMonths
- Date.IsInNextNQuarters
- Date.IsInNextNWeeks
- Date.IsInNextNYears
- Date.IsInNextQuarter
- Date.IsInNextWeek
- Date.IsInNextYear
- Date.IsInPreviousDay
- Date.IsInPreviousMonth
- Date.IsInPreviousNDays
- Date.IsInPreviousNMonths
- Date.IsInPreviousNQuarters
- Date.IsInPreviousNWeeks
- Date.IsInPreviousNYears
- Date.IsInPreviousQuarter
- Date.IsInPreviousWeek
- Date.IsInPreviousYear
- Date.IsInYearToDate
- Date.IsLeapYear
- Date.Month
- Date.MonthName
- Date.QuarterOfYear
- Date.StartOfDay
- Date.StartOfMonth
- Date.StartOfQuarter
- Date.StartOfWeek
- Date.StartOfYear
- Date.ToRecord
- Date.ToText
- Date.WeekOfMonth
- Date.WeekOfYear
- Date.Year
- DB2.Database
- Decimal.From
- Diagnostics.ActivityId
- Diagnostics.Trace
- DirectQueryCapabilities.From
- Double.From
- Duration.Days
- Duration.From
- Duration.FromText
- Duration.Hours
- Duration.Minutes
- Duration.Seconds
- Duration.ToRecord
- Duration.TotalDays
- Duration.TotalHours
- Duration.TotalMinutes
- Duration.TotalSeconds
- Duration.ToText
E
F
G
H
I
L
- Lines.FromBinary
- Lines.FromText
- Lines.ToBinary
- Lines.ToText
- List.Accumulate
- List.AllTrue
- List.Alternate
- List.AnyTrue
- List.Average
- List.Buffer
- List.Combine
- List.ConformToPageReader
- List.Contains
- List.ContainsAll
- List.ContainsAny
- List.Count
- List.Covariance
- List.Dates
- List.DateTimes
- List.DateTimeZones
- List.Difference
- List.Distinct
- List.Durations
- List.FindText
- List.First
- List.FirstN
- List.Generate
- List.InsertRange
- List.Intersect
- List.IsDistinct
- List.IsEmpty
- List.Last
- List.LastN
- List.MatchesAll
- List.MatchesAny
- List.Max
- List.MaxN
- List.Median
- List.Min
- List.MinN
- List.Mode
- List.Modes
- List.NonNullCount
- List.Numbers
- List.Percentile
- List.PositionOf
- List.PositionOfAny
- List.Positions
- List.Product
- List.Random
- List.Range
- List.RemoveFirstN
- List.RemoveItems
- List.RemoveLastN
- List.RemoveMatchingItems
- List.RemoveNulls
- List.RemoveRange
- List.Repeat
- List.ReplaceMatchingItems
- List.ReplaceRange
- List.ReplaceValue
- List.Reverse
- List.Select
- List.Single
- List.SingleOrDefault
- List.Skip
- List.Sort
- List.Split
- List.StandardDeviation
- List.Sum
- List.Times
- List.Transform
- List.TransformMany
- List.Union
- List.Zip
- Logical.From
- Logical.FromText
The M code behind the Geometry.FromWellKnownText function is responsible for parsing the WKT string and creating a spatial value that can be used in Power Query. In order to fully understand the M code behind this function, we need to first understand what WKT is and how it represents geometric objects.
What is Well-Known Text?
Well-known text (WKT) is a text markup language that is used to represent geometric objects. WKT is a part of the Open Geospatial Consortium (OGC) Simple Features Specification, which defines a standard for representing spatial data. WKT is used to represent points, lines, polygons, and other geometric objects in a human-readable format.
Here is an example of a WKT string that represents a polygon:
POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))
In this example, the polygon is defined by a series of points that form a closed shape. Each point is represented by its x and y coordinates, separated by a space. The entire string is enclosed in parentheses and preceded by the keyword "POLYGON".
How Does Geometry.FromWellKnownText Work?
The Geometry.FromWellKnownText function takes a WKT string as its input and returns a spatial value that represents the geometric object. The M code behind this function is responsible for parsing the WKT string and creating a spatial value that can be used in Power Query.
Here is an example of how to use the Geometry.FromWellKnownText function in Power Query:
let
wktString = “POINT (30 10)”,
spatialValue = Geometry.FromWellKnownText(wktString)
in
spatialValue
In this example, we are passing a WKT string that represents a point to the Geometry.FromWellKnownText function. The function returns a spatial value that can be used in Power Query.
The M Code Behind Geometry.FromWellKnownText
The M code behind the Geometry.FromWellKnownText function is responsible for parsing the WKT string and creating a spatial value that can be used in Power Query. The code is written in the M language, which is a functional programming language used by Power Query.
Here is an example of the M code that powers the Geometry.FromWellKnownText function:
let
ParseWKT = (wktString as text) as any =>
let
wktTokens = Text.Split(wktString, ” “),
geometryType = wktTokens{0},
coordinates = List.Skip(wktTokens),
spatialValue = CreateSpatialValue(geometryType, coordinates)
in
spatialValue,
CreateSpatialValue = (geometryType as text, coordinates as list) as any =>
let
spatialValue = type [#”Spatial” = Geometry.Type],
geometry = if geometryType = “POINT” then CreatePoint(coordinates)
else if geometryType = “LINESTRING” then CreateLineString(coordinates)
else if geometryType = “POLYGON” then CreatePolygon(coordinates)
else if geometryType = “MULTIPOINT” then CreateMultiPoint(coordinates)
else if geometryType = “MULTILINESTRING” then CreateMultiLineString(coordinates)
else if geometryType = “MULTIPOLYGON” then CreateMultiPolygon(coordinates)
else if geometryType = “GEOMETRYCOLLECTION” then CreateGeometryCollection(coordinates)
else null
in
spatialValue{#”Spatial”} = geometry,
spatialValue,
CreatePoint = (coordinates as list) as any =>
let
x = Number.FromText(coordinates{0}),
y = Number.FromText(coordinates{1}),
point = type [#”x” = number, #”y” = number][x = x, y = y]
in
point,
CreateLineString = (coordinates as list) as any =>
let
points = List.Transform(coordinates, (point) => CreatePoint(Text.Split(point, ” “))),
lineString = type [#”Points” = List.Type(point)][Points = points]
in
lineString,
CreatePolygon = (coordinates as list) as any =>
let
ring = List.First(coordinates),
points = List.Transform(ring, (point) => CreatePoint(Text.Split(point, ” “))),
polygon = type [#”Ring” = List.Type(point)][Ring = points]
in
polygon,
CreateMultiPoint = (coordinates as list) as any =>
let
points = List.Transform(coordinates, (point) => CreatePoint(Text.Split(point, ” “))),
multiPoint = type [#”Points” = List.Type(point)][Points = points]
in
multiPoint,
CreateMultiLineString = (coordinates as list) as any =>
let
lineStrings = List.Transform(coordinates, (lineString) => CreateLineString(Text.Split(lineString, “, “))),
multiLineString = type [#”LineStrings” = List.Type(lineString)][LineStrings = lineStrings]
in
multiLineString,
CreateMultiPolygon = (coordinates as list) as any =>
let
polygons = List.Transform(coordinates, (polygon) => CreatePolygon(Text.Split(polygon, “, “))),
multiPolygon = type [#”Polygons” = List.Type(polygon)][Polygons = polygons]
in
multiPolygon,
CreateGeometryCollection = (coordinates as list) as any =>
let
geometries = List.Transform(coordinates, (geometry) => ParseWKT(geometry)),
geometryCollection = type [#”Geometries” = List.Type(geometry)][Geometries = geometries]
in
geometryCollection
in
ParseWKT
In this code, we define several functions that are used to parse the WKT string and create a spatial value. The main function is ParseWKT, which takes a WKT string as its input and returns a spatial value. The function first splits the WKT string into tokens, then extracts the geometry type and coordinates. It then calls the CreateSpatialValue function to create the spatial value.
The CreateSpatialValue function takes the geometry type and coordinates as its input and creates a spatial value based on the type of geometry. For example, if the geometry type is "POINT", the function calls the CreatePoint function to create a point object.
The CreatePoint, CreateLineString, CreatePolygon, CreateMultiPoint, CreateMultiLineString, CreateMultiPolygon, and CreateGeometryCollection functions are responsible for creating the actual geometric objects based on the coordinates.
The Geometry.FromWellKnownText function is a powerful tool in Power Query that allows you to convert WKT strings into spatial values that can be used in your data transformations. The M code behind this function is responsible for parsing the WKT string and creating the spatial value. By understanding the M code behind this function, you can gain a deeper understanding of how Power Query works and how it can be used to transform and analyze data.