-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ReverseGeocoder, PointInPolygon, and example notebooks (#1339)
Co-authored-by: Sudhindra Kovalam <[email protected]>
- Loading branch information
1 parent
4c67b9b
commit 2ae312e
Showing
10 changed files
with
1,042 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...itive/src/main/scala/com/microsoft/azure/synapse/ml/geospatial/AzMapsSpatialSchemas.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (C) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in project root for information. | ||
|
||
package com.microsoft.azure.synapse.ml.geospatial | ||
|
||
import com.microsoft.azure.synapse.ml.core.schema.SparkBindings | ||
|
||
case class PointInPolygonSummary ( | ||
sourcePoint: Option[LatLongPairAbbreviated], | ||
// A unique data id (udid) for the uploaded content. | ||
// Udid is not applicable for POST spatial operations(set to null) | ||
udid: Option[String], | ||
// Processing information | ||
information: Option[String] | ||
) | ||
|
||
case class PointInPolygonResult( | ||
pointInPolygons: Option[Boolean], | ||
intersectingGeometries: Option[Seq[String]] | ||
) | ||
|
||
object PointInPolygonProcessResult extends SparkBindings[PointInPolygonProcessResult] | ||
case class PointInPolygonProcessResult ( | ||
summary: Option[PointInPolygonSummary], | ||
// Point In Polygon Result Object | ||
result: Option[PointInPolygonResult] | ||
) | ||
|
||
case class MapDataMetadataResult( | ||
udid: Option[String], | ||
location: Option[String], | ||
created: Option[String], | ||
updated: Option[String], | ||
sizeInBytes: Option[String], | ||
uploadStatus: Option[String] | ||
) |
44 changes: 0 additions & 44 deletions
44
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/geospatial/AzureMapsSearch.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
cognitive/src/main/scala/com/microsoft/azure/synapse/ml/geospatial/CheckPointInPolygon.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in project root for information. | ||
|
||
package com.microsoft.azure.synapse.ml.geospatial | ||
|
||
import com.microsoft.azure.synapse.ml.build.BuildInfo | ||
import com.microsoft.azure.synapse.ml.cognitive._ | ||
import com.microsoft.azure.synapse.ml.io.http.{CustomInputParser, HTTPInputParser, HeaderValues} | ||
import com.microsoft.azure.synapse.ml.logging.BasicLogging | ||
import org.apache.http.client.methods.{HttpGet, HttpRequestBase} | ||
import org.apache.spark.ml.ComplexParamsReadable | ||
import org.apache.spark.ml.util.Identifiable | ||
import org.apache.spark.sql.Row | ||
import org.apache.spark.sql.types.{DataType, StructType} | ||
|
||
import java.net.URI | ||
|
||
object CheckPointInPolygon extends ComplexParamsReadable[CheckPointInPolygon] | ||
|
||
class CheckPointInPolygon(override val uid: String) | ||
extends CognitiveServicesBase(uid) | ||
with HasInternalJsonOutputParser with BasicLogging with HasServiceParams | ||
with HasSubscriptionKey with HasSetGeography with HasLatLonPairInput with HasUserDataIdInput { | ||
|
||
protected def inputFunc: Row => Option[HttpRequestBase] = { | ||
{ row: Row => | ||
if (shouldSkip(row)) { | ||
None | ||
} else { | ||
val udid = getValue(row, userDataIdentifier).mkString | ||
val lat = String.valueOf(getValue(row, latitude)) | ||
val lon = String.valueOf(getValue(row, longitude)) | ||
|
||
val queryParams = "?" + URLEncodingUtils.format(Map("api-version" -> "1.0", | ||
"subscription-key" -> getSubscriptionKey, | ||
"udid" -> udid, | ||
"lat" -> lat, | ||
"lon" -> lon)) | ||
val get = new HttpGet() | ||
get.setURI(new URI(getUrl + queryParams)) | ||
get.setHeader("User-Agent", s"synapseml/${BuildInfo.version}${HeaderValues.PlatformInfo}") | ||
Some(get) | ||
} | ||
} | ||
} | ||
|
||
protected def getInternalInputParser(schema: StructType): HTTPInputParser = { | ||
new CustomInputParser().setNullableUDF(inputFunc) | ||
} | ||
|
||
def this() = this(Identifiable.randomUID("CheckPointInPolygon")) | ||
|
||
setDefault( | ||
url -> "https://atlas.microsoft.com/") | ||
|
||
override protected def responseDataType: DataType = PointInPolygonProcessResult.schema | ||
|
||
override def urlPath: String = "spatial/pointInPolygon/json" | ||
} |
Oops, something went wrong.