Re: MySQL Spatial Data types

From: Tore Halset (halse..vv.ntnu.no)
Date: Mon Aug 18 2008 - 16:12:38 EDT

  • Next message: Dave Dombrosky: "Should commitChangesToParent() call pre-persist method?"

    Hello.

    (cc to use..ayenne so this show up in the archive)

    The DB-side of your mapping should have geometry, varchar or clob as
    datatype. The java-side should have
    "com.vividsolutions.jts.geom.Geometry" or any of the subclasses like
    "com.vividsolutions.jts.geom.Point". Is that how you did it?

    If you use a cayenne-2 or cayenne-1, then you need to register the
    type, not only to Geometry, but all subclasses you want to use.
    ExtendedTypeMap extendedTypes = node.getAdapter().getExtendedTypes();
    extendedTypes.registerType(new WKTGeometryType(Point.class));

    I hope it helps.

    Regards,
      - Tore.

    On Aug 16, 2008, at 00:26, Rick Blair wrote:

    > Hi Tor,
    >
    > I must be missing something. I cannot get the WKT type handler to be
    > called. I followed the example from the URL, but the handler is never
    > called.
    >
    > I tried setting the type of the property to geometry, binary, blob and
    > varchar in the map.xml file.
    >
    > Suggestions?
    >
    > Thanks in advance.
    >
    > --
    > Tìoraidh!
    >
    > Rick Blair
    > Associate Technical Fellow
    > Boeing Phantom Works
    > Network Systems Technology
    > Information Management Program
    > M/S: 42-50
    > Voice: (206) 544-1610
    >
    >
    >
    >> From: Tore Halset <halse..vv.ntnu.no>
    >> Reply-To: <use..ayenne.apache.org>
    >> Date: Mon, 11 Aug 2008 07:02:57 +0200
    >> To: <use..ayenne.apache.org>
    >> Subject: Re: MySQL Spatial Data types
    >>
    >>
    >> On 11. aug.. 2008, at 04.54, Aristedes Maniatis wrote:
    >>
    >>>
    >>> On 11/08/2008, at 12:23 PM, Rick Blair wrote:
    >>>
    >>>> I have an existing mysql (5.1) database that has a column named
    >>>> location
    >>>> that is a POINT datatype. I used the DataModeler and attached to
    >>>> my
    >>>> database. I was able to use my existing schema, however the data
    >>>> type in
    >>>> the Modeler for that column show as OTHER. The class that was
    >>>> generated was
    >>>> had the following methods:
    >>>
    >>> I haven't used them myself, but you may need to use something like
    >>> JTS (http://www.vividsolutions.com/JTS) to get these data types
    >>> across JDBC into Cayenne. And then some customisation of the mysql
    >>> database adapter [1] might be needed.
    >>
    >> Here is an example how to convert between WKT in a database and JTS
    >> geomertries on the java side. You may have to modify it to let MySQL
    >> convert the POINT datatype from/to WKT.
    >>
    >> http://cwiki.apache.org/CAY/mapping-jts-geometries.html
    >>
    >> I am using this in production, but not with MySQL.
    >>
    >> Regards,
    >> - Tore.
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Aug 18 2008 - 16:14:10 EDT