CREATE TABLE places
(
  bounding_box geometry(Polygon,26918),
  country character varying,
  full_name character varying,
  id character varying NOT NULL,
  name character varying,
  type character varying,
  url character varying,
  CONSTRAINT places_pkey PRIMARY KEY (id)
);

CREATE INDEX places_bounding_box_idx
  ON places
  USING gist
  (bounding_box);

CREATE INDEX places_type_idx
  ON places
  USING btree
  (type COLLATE pg_catalog."default");

CREATE FUNCTION st_transform_null(IN g GEOMETRY, IN srid integer) RETURNS geometry AS
  $BODY$BEGIN
  RETURN st_transform($1, $2);
  EXCEPTION WHEN internal_error THEN
    RETURN NULL;
  END;$BODY$
  LANGUAGE plpgsql IMMUTABLE NOT LEAKPROOF STRICT;

INSERT INTO places (bounding_box,country,full_name,id,name,type,url) VALUES (st_transform_null(ST_GeometryFromText('POLYGON((-94.043352 28.855127,-94.043352 33.019543,-88.758388 33.019543,-88.758388 28.855127,-94.043352 28.855127))',4326),26918),'United States','Louisiana, US','1c73ebb264e145ee','Louisiana','admin','http://api.twitter.com/1/geo/id/1c73ebb264e145ee.json'),(st_transform_null(ST_GeometryFromText('POLYGON((-96.53409 41.418782,-96.53409 41.463913,-96.45365 41.463913,-96.45365 41.418782,-96.53409 41.418782))',4326),26918),'United States','Fremont, NE','5ab200939c0b29b0','Fremont','city','http://api.twitter.com/1/geo/id/5ab200939c0b29b0.json'),(st_transform_null(ST_GeometryFromText('POLYGON((49.5789033 54.4972,49.5789033 55.0566984,50.2571973 55.0566984,50.2571973 54.4972,49.5789033 54.4972))',4326),26918),'Russia','','a48e840d12fa4c4f','','admin','http://api.twitter.com/1/geo/id/a48e840d12fa4c4f.json');