Git Product home page Git Product logo

rust-postgis's People

Contributors

andelf avatar centril avatar edupleich avatar jblondin avatar kestred avatar lnicola avatar maxburke avatar michaelkirk avatar petrochenkov avatar pka avatar smellman avatar yannleretaille avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-postgis's Issues

[Help] Cannot build on nightly?

I was attempting to integrate this library with diesel while using the nightly compiler.

Do you know off the top of your head problem changes in nightly that would cause build failures? It is fine if you don't know. I can debug it myself but I wanted to check for any possible leads from the people who know the most about this library first. Please tell me if you don't know so I can begin working on the problem.

All of the errors look like the blanket trait implementations not being found by the compiler. If you know the name of the problem or the rust issue the this comes from that would be a huge help.

error[E0277]: the trait bound `usize: types::MultiPolygon<'a>` is not satisfied
   --> src/postgis.rs:138:13
    |
138 | /             fn to_sql(&self, _: &Type, out: &mut Vec<u8>) -> Result<IsNull, Box<Error + Sync + Send>> {                                                             
139 | |                 self.write_ewkb(out)?;
140 | |                 Ok(IsNull::No)
141 | |             }
    | |_____________^ the trait `types::MultiPolygon<'a>` is not implemented for `usize`                                                                                    
...
150 |   impl_sql_for_ewkb_type!(multipoly EwkbMultiPolygon contains Polygon);
    |   --------------------------------------------------------------------- in this macro invocation                                                                      

error[E0277]: the trait bound `usize: types::MultiPolygon<'a>` is not satisfied
   --> src/postgis.rs:150:1
    |
150 | impl_sql_for_ewkb_type!(multipoly EwkbMultiPolygon contains Polygon);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | |
    | the trait `types::MultiPolygon<'a>` is not implemented for `usize`
    | in this macro invocation
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)                           

error: aborting due to 128 previous errors

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `postgis`

Implement Default trait for Point types

It would be nice if Default was implemented for Point. Without it migration from geo_types is that much harder. Moreover, we can't use crates like derive-builder which require Default.

The obvious choice for postgis::ewkb::Point is (0,0) with an SRID of None

Implement From<tuple> for Point types

It would be nice if the From<(tuple)> trait was implemented for the Point types. the corresponding types in geo_types implement this trait and it makes it easier to create these types with iterators and the like.

Support for postgis curve types?

Hi. Just wanted to ask - is there a way to get the geometry if the postgis geometry is a curve (such as CURVEPOLYGON and CIRCULARSTRING, etc.)?

What's the oid and array-oid for `geography(point, 4326)`?

I'm using diesel and Postgres+PostGIS. In my table I'm using loc geography(point, 4326) not null, in my table!{} schema loc -> Point (postgis::ewkb::Point) and in my ORM struct loc: MyPoint.

Then I have:

use postgis::ewkb::Point;

#[derive(Debug, Clone, PartialEq, FromSqlRow, AsExpression)]
pub struct MyPoint(Point); // newtype

impl FromSql<Point, Pg> for MyPoint {
    fn from_sql(bytes: Option<&[u8]>) -> deserialize::Result<Self> {
        use std::io::Cursor;
        use postgis::ewkb::EwkbRead;
        let bytes = not_none!(bytes);
        let mut rdr = Cursor::new(bytes);
        Ok(MyPoint(Point::read_ewkb(&mut rdr)?))
    }
}

impl ToSql<Point, Pg> for MyPoint {
    fn to_sql<W: Write>(&self, out: &mut Output<W, Pg>) -> serialize::Result {
        use postgis::ewkb::{AsEwkbPoint, EwkbWrite};
        self.0.as_ewkb().write_ewkb(out)?;
        Ok(IsNull::No)
    }
}

But when I try to use it in a diesel query (such as users.load::<models::User>(conn)) I get:

error: src\main.rs:56: the trait bound diesel::pg::Pg: diesel::sql_types::HasSqlType<postgis::ewkb::Point> is not satisfied
note: src\main.rs:56: required because of the requirements on the impl of diesel::sql_types::HasSqlType<(diesel::sql_types::BigInt, postgis::ewkb::Point, diesel::sql_types::Float)> for diesel::pg::Pg
note: src\main.rs:56: required because of the requirements on the impl of diesel::query_dsl::LoadQuery<r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::PgConnection>>, models::User> for schema::users::table

According to the docs I should #[derive(SqlType)] on Point (or MyPoint) but what are the oid and array_oid for geography(point, 4326)?

Serde support for point types

Please add optional support for serde's Serialize/Deserialize traits.
Like this:

serde = { version = "1.0", features = ["derive"], optional = true }
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Point { // postgis::ewkb::Point

Thanks!

Consider using new TZM geo/geo-types

Would it make sense to migrate all internal postgis types to the proposed geo-types that support T, Z, and M generic types? Are there any changes that should be made to that proposal? How should SRID be added to it? One option might be to double the number of types - e.g. LineString, LineStringM, LineStringZ, LineStringZM, LineStringS, LineStringMS, LineStringZS, LineStringZMS, where all of them are aliases to pub struct LineStringTZM<T: CoordNum, Z: ZCoord, M: Measure, S: SRID>(...) -- where SRID could be defined as either i32 or NoValue.

If SRID is not accepted to geo/geo-types as an i32 (which seems to be a postgis convention only), one option would be to have some sort of a wrapper enum as described in georust/wkt#91 with an additional i32 srid.

FromSql is not implemented anymore on 0.4.0, but on 0.3.0

The example doesn't work anymore (it worked a few weeks ago). It seems that the 0.4.0 version is missing the FromSQL trait for basically any type.

I just get errors a la:

the trait "graphics::renderer::postgres::types::FromSql" is not implemented for "types::osm_tuple::postgis::ewkb::Point"

I noticed that the 0.3.0 version had postgres::FromSql implemented: https://docs.rs/postgis/0.3.0/postgis/ewkb/struct.Point.html

The 0.4.0 has it too, but there seems to be something wrong - the trait isn't marked violet, as usual: https://docs.rs/postgis/0.4.0/postgis/ewkb/struct.Point.html

Plus, well, the examples as well as any code that worked with 0.3.0, doesn't compile anymore. It is impossible to get any geometry types out of a postgres database without this trait being implemented.

Better documentation

It would be very helpful to see a more complete example of how to use this. Especially on how to use this when writing geo data. I would happily do a PR, but unfortunately I don't understand enough about this library to contribute that at this point.

SRID has to be known at compile time

I can't find a way to select geometries without specifying the SRID at compile time. Is there a way to read the SRID from geometry_columns at runtime and select geometries using this SRID?

Integration with rust-geo/geo

Greetings,

What are your thoughts on a possible feature-flag (or just straight use) that supports the crate https://github.com/georust/rust-geo for the rust-postgis extension?

In general, I like the design of the https://github.com/georust projects, because they use a single crate which defines the base geometric types and then have other projects to convert between specific formats (eg. https://github.com/georust/rust-geojson, https://github.com/georust/rust-wkt).

Support for boxes

I'm currently making a rest API that needs to take the cords to construct a bounding box for a query. It would be great if rust-postgis had types for Box2d and Box3d. This would allow me to do things like..

SELECT *
FROM table
WHERE $1 && table.geog;
SELECT *
FROM table
WHERE ST_Intersects($1, table.geog);

"error while reading: UnexpectedEOF" reading MultiLineString

I get this exception for MultiLineString (and also MultiPolygon) when reading any data in EPSG:3857.

println!(">>>>>> {:#?}", row.get::<_, postgis::MultiLineString<postgis::Point<EPSG_3857>>>("wkb_geometry"));

->
thread 'datasource::postgis::test_from_geom_fields' panicked at 'called "Result::unwrap()" on an "Err" value: Read("error while reading: UnexpectedEOF")', ../src/libcore/result.rs:688

Here's a failing MultiLineString:
'0105000020110F000001000000010200000004000000A149950DA3BB564189DF62973DC35C4165CD9E8413C6564189DF62973DC35C410C6A639A84C856413CC52F806BC25C4159E55A3637CD5641D6FD917DC6BE5C41'::geometry
SRID=3857;MULTILINESTRING((5959308.21223679 7539958.36540974,5969998.07219252 7539958.36540974,5972498.41231776 7539118.00291568,5977308.84929784 7535385.96203562))

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.