sql - MYSQL CSV Import - Cannot get geometry object from data you send to the GEOMETRY field -
i have csv file on server in data looks follows;
16777216,17039359,"apnic debogon project" 17367040,17432575,"tmnet, telekom malaysia bhd." 17435136,17435391,"apnic debogon project" 17498112,17563647,"cj-hellovision" 17563648,17825791,"beijing founder broadband network technology co.,l" 17825792,18087935,"allocated krnic member." 18153984,18154239,"double cast" 18157056,18163711,"family net japan incorporated"
i'm trying insert table structured follows;
ipoid integer 11 not null primary key beginip integer 14 not null unsigned endip integer 14 not null unsigned org varchar 255 ip_poly polygon
i have spatial index created on ip_poly field
i'm trying insert csv data following code
load data infile "/home/geoiporg.csv" table crm_geo_org fields terminated "," enclosed "\"" lines terminated "\n" (@beginip,@endip,@org) set ipoid := null, beginip := @beginip, endip := @endip, ip_poly := geomfromwkb(polygon(linestring( /* clockwise, 4 points , 0 */ point(@beginip, -1), /* 0, top left */ point(@endip, -1), /* 1, top right */ point(@endip, 1), /* 2, bottom right */ point(@beginip, 1), /* 3, bottom left */ point(@beginip, -1) /* 0, start */ ))), org:= @org;
however when try error
error 1416 (22003): cannot geometry object data send geometry field
any ideas?
in later versions of mysql
don't need wkb
/ wkt
transformations build geometry objects.
also, polygon
overkill here: mbr
can built single linestring
well.
change ip_poly
iprange linestring not null
, use this:
load data infile "/home/geoiporg.csv" table crm_geo_org fields terminated "," enclosed "\"" lines terminated "\n" (@beginip, @endip, @org) set ipoid := null, beginip := @beginip, endip := @endip, iprange := geomfromwkb( linestring( point(@beginip, -1), point(@endip, 1) ) ), org := @org;
Comments
Post a Comment