Coder Social home page Coder Social logo

juliageo / geoformattypes.jl Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 0.0 508 KB

Wrapper types for spatial data formats like well known text, KML, Proj4 strings.

Home Page: https://juliageo.github.io/GeoFormatTypes.jl/stable

License: MIT License

Julia 100.00%
crs geometry geospatial gis io julia wkb wkt

geoformattypes.jl's Introduction

GeoFormatTypes

Stable Dev CI

GeoFormatTypes defines wrapper types to make it easy to pass and dispatch on geographic formats like Well Known Text or GeoJSON between packages. This way information about what format is contained is kept for later use, - instead of passing a String or Int that could mean anything.

Wrapper types also allow methods such as convert to work with data in multiple formats, instead of defining lists of format-specific handling methods. Currently ArchGDAL.jl is privileged to define convert methods for GeoFormatTypes.jl objects, using GDAL. When it is loaded, objects can be converted from one format to another:

julia> using GeoFormatTypes, ArchGDAL

julia> convert(WellKnownText, EPSG(4326))
WellKnownText{GeoFormatTypes.CRS, String}(GeoFormatTypes.CRS(), "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]")

ArchGDAL.jl is not a direct dependency of GeoFormatTypes.jl, so small packages that handle geospatial formats in some way can depend on GeoFormatTypes.jl without worry about large dependencies.

One complexity of GeoFormat objects is that some formats can hold either CRS (Coordinate Reference System) or geometric data, or even both at the same time.

This is handled using the CRS, Geom and Mixed traits. When the contents are explicitly known to be e.g. crs data, then CRS can be used, for example with all types of well known text:

crs = WellKnownText2(CRS(), crs_string)

If the contents are not known, the default Mixed() will mostly do the right thing anyway - it can be converted to either CRS or geometry formats using convert, given that it is actually possible to do with the contained data.

We thank Julia Computing for supporting contributions to this package.

geoformattypes.jl's People

Contributors

dependabot[bot] avatar evetion avatar juliatagbot avatar meggart avatar rafaqz avatar visr avatar yeesian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

geoformattypes.jl's Issues

Rename `MixedFormat`?

Mixed has always been a bit unclear to me. Maybe we could go for Extended (like Extended WKB/WKT, which hold a CRS on top of the normal WKT), or Combined? Or just GeomCRS to remove any ambiguity altogether?

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

PR #22 is breaking... should a major release be issued?

#22 is breaking.

using GeoFormatTypes v0.4.1

julia> epsg = GeoFormatTypes.EPSG(4326)
EPSG(4326)

julia> GeoFormatTypes.EPSG(epsg)
EPSG(4326)
julia> typeof(epsg) == GeoFormatTypes.EPSG
true

using GeoFormatTypes v0.4.2

julia> epsg = GeoFormatTypes.EPSG(4326)
EPSG{1}((4326,))

julia> GeoFormatTypes.EPSG(epsg)
ERROR: MethodError: no method matching EPSG(::EPSG{1})

Closest candidates are:
  EPSG(::AbstractString)
   @ GeoFormatTypes ~/.julia/packages/GeoFormatTypes/UFNTK/src/GeoFormatTypes.jl:319
  EPSG(::Tuple{Vararg{Int64, N}}) where N
   @ GeoFormatTypes ~/.julia/packages/GeoFormatTypes/UFNTK/src/GeoFormatTypes.jl:316
  EPSG(::Int64...)
   @ GeoFormatTypes ~/.julia/packages/GeoFormatTypes/UFNTK/src/GeoFormatTypes.jl:318
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[6]:1
julia> typeof(epsg) == GeoFormatTypes.EPSG
false

Add type parameters for compile-time dispatch on CRS

It would be useful to add at least coordinate order XY/YX and Spherical/Cartesian singletons to the CRS type.

This may let us wrap point with e.g. y/x order in the CRS, and dispatch to the correct distance/area methods. Having these in the type means we can use them for low level operations with no overheads.

These parameters could be nothing by default. At whatever point they to be used we could parse the CRS with Proj/ArchGDAL and fill in the parameters, or as the worse case / status quo - assume they are x/y, and just error for area/distance.

It may be that some other object could hold these parameters instead, but it seems like it should be attached to the CRS object to keep things simple.

It may also be useful for users to be able to specify the X/Y order manually because many other tools also do not follow the crs point order.

Add Ellipsoid type?

Should we add an Ellipsoid type to GeoFormatTypes?

This is what I'm using in my work:

"""
An ellipsoidal representation of the Earth surface 
"""
struct Ellipsoid
    a::Float64        # radius of the ellipsoid
    e::Float64        # eccentricity of the ellipsoid
    name::Symbol      
    epsg::EPSG
    # of the const instance in the package!
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.