-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-53760][Geo][SQL] Introduce GeometryType and GeographyType #52491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3985d5a
Initial commit
uros-db 1124ff5
Fix scalastyle
uros-db 3fa63c8
Regenerate golden files
uros-db 4be6774
Address comments
uros-db fcae2a1
Run scalafmt
uros-db fa62491
Merge branch 'apache:master' into geo-logical-types
uros-db e2dfe8e
Refactor classes
uros-db e6ceef9
Fix SQL keywords
uros-db 3085dc0
Fix failing tests
uros-db a25550d
Cleanup comment
uros-db 27fb2d2
Fix Java lint
uros-db b777086
Address comments
uros-db ee1a3eb
Move toSrid
uros-db 91755bb
Move toSrid
uros-db 64f2dd3
Move SpatialReferenceSystemMapper
uros-db 9c0828d
Merge branch 'apache:master' into geo-logical-types
uros-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
75 changes: 75 additions & 0 deletions
75
sql/api/src/main/scala/org/apache/spark/sql/internal/types/SpatialReferenceSystemMapper.java
This file contains hidden or 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,75 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.internal.types; | ||
|
||
import java.util.HashMap; | ||
|
||
/* | ||
* Class for maintaining mappings between supported SRID values and the string ID of the | ||
* corresponding CRS. | ||
*/ | ||
public class SpatialReferenceSystemMapper { | ||
uros-db marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// We implement this class as a singleton (we disallow construction). | ||
private SpatialReferenceSystemMapper() {} | ||
|
||
private static final SpatialReferenceSystemMapper Instance = new SpatialReferenceSystemMapper(); | ||
|
||
// Returns the unique instance of this class. | ||
public static SpatialReferenceSystemMapper get() { | ||
return Instance; | ||
} | ||
|
||
// Hash maps defining the mappings to/from SRID and string ID for a CRS. | ||
private static final HashMap<Integer, String> sridToStringId = buildSridToStringIdMap(); | ||
private static final HashMap<String, Integer> stringIdToSrid = buildStringIdToSridMap(); | ||
|
||
// Returns the string ID corresponding to the input SRID. If the input SRID is not supported, | ||
// `null` is returned. | ||
public String getStringId(int srid) { | ||
return sridToStringId.get(srid); | ||
} | ||
|
||
// Returns the SRID corresponding to the input string ID. If the input string ID is not | ||
// supported, `null` is returned. | ||
public Integer getSrid(String stringId) { | ||
return stringIdToSrid.get(stringId); | ||
} | ||
|
||
// Currently, we only support a limited set of SRID / CRS mappings. However, we will soon extend | ||
// this to support all the SRIDs supported by relevant authorities and libraries. The methods | ||
// below will be updated accordingly, in order to populate the mappings with more complete data. | ||
|
||
// Helper method for building the SRID-to-string-ID mapping. | ||
private static HashMap<Integer, String> buildSridToStringIdMap() { | ||
HashMap<Integer, String> map = new HashMap<>(); | ||
map.put(0, "SRID:0"); // Unspecified | ||
map.put(3857, "EPSG:3857"); // Web Mercator | ||
map.put(4326, "OGC:CRS84"); // WGS84 | ||
return map; | ||
} | ||
|
||
// Helper method for building the string-ID-to-SRID mapping. | ||
private static HashMap<String, Integer> buildStringIdToSridMap() { | ||
HashMap<String, Integer> map = new HashMap<>(); | ||
map.put("SRID:0", 0); // Unspecified | ||
map.put("EPSG:3857", 3857); // Web Mercator | ||
map.put("OGC:CRS84", 4326); // WGS84 | ||
return map; | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.