Opened 8 years ago

Closed 8 years ago

#6452 closed defect (fixed)

GeoJSON import with ogr2ogr treat relative URLs as dates

Reported by: ethervoid Owned by: warmerdam
Priority: normal Milestone: 2.0.3
Component: default Version: unspecified
Severity: normal Keywords: ogr2ogr geojson import
Cc:

Description

I have the next geojson file:

{"type": "FeatureCollection", "features": [{"type":"Feature","geometry":{"type":"Point","coordinates":[-4.72372,41.65518]},"properties":{"id":1,"url":"//images.contentful.com/xts27qnup0jr/47Yq6W7PgAKQKGQ4cSG6oa/7c8d8296ffa3481efd93b2bb2cefc86c/stamen.png","name":"url relativa","city":"valladolid"}}]}

When I try to import into postgresql using ogr2ogr, I receive the following error message:

ERROR 1: COPY statement failed.
ERROR:  date/time field value out of range: "2000/00/00"
HINT:  Perhaps you need a different "datestyle" setting.
CONTEXT:  COPY importer_29147a0400bb11e69244080027eb929e, line 1, column url: "2000/00/00"

Funny thing is that ogrinfo is detecting it as a string:

ERROR 4: GeoJSON Driver doesn't support update.
Had to open data source read-only.
INFO: Open of `lala.geojson'
      using driver `GeoJSON' successful.

Layer name: OGRGeoJSON
Geometry: Point
Feature Count: 1
Extent: (-4.723720, 41.655180) - (-4.723720, 41.655180)
Layer SRS WKT:
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"]],
    AUTHORITY["EPSG","4326"]]
id: Integer (0.0)
url: String (0.0)
name: String (0.0)
city: String (0.0)
OGRFeature(OGRGeoJSON):0
  id (Integer) = 1
  url (String) = http//images.contentful.com/xts27qnup0jr/47Yq6W7PgAKQKGQ4cSG6oa/7c8d8296ffa3481efd93b2bb2cefc86c/stamen.png
  name (String) = url relativa
  city (String) = valladolid
  POINT (-4.72372 41.65518)

Any idea? It looks like a bug in the GeoJSON driver, in other formats I don't any problems at all.

Change History (1)

comment:1 by Even Rouault, 8 years ago

Milestone: 2.0.3
Resolution: fixed
Status: newclosed

(You didn't use the same json in ogrinfo as in ogr2ogr. I get the issue also with ogrinfo when using the json you put inline)

trunk r33953 "OGRParseDate(): more strict validation to reject invalide dates (#6452)"

trunk r33954 "OGRParseDate(): more strict validation of handling of 2-digit years (#6452)"

trunk r33955 "OGRParseDate(): little tuning to go on supporting Y/MM/DD like 200Y/MM/DD (#6452)"

3 above commits backported in branches/2.1 r33956 and branches/2.0 r33957

Note: See TracTickets for help on using tickets.