Converting Spatial Objects to strings

Hi,
Many tools (SQL*Plus, DBVisualizer, various Python modules) seem to be able to retrieve spatial objects as strings. Is this conversion being done by each tool, or does the database know how to convert objects (at least Oracle Spatial objects) to strings?
Is there any way to get string as the result of a query of an Oracle Spatial object with Pro*C or the other precompilers?
Thanks for any information,
-- Andrew Bell
[email protected]

Andrew
Is your question about decoding the struct returned in an OCI, Pro*C, or SQLJ program to get at the fields of an sdo_geometry type?
There are oci examples (readgeom.c, writegeom.c) on OTN.
Jayant

Similar Messages

  • How do i convert an object into a string?

    has said above, im trying to convert a object to a string.
    here is what i ahve so far:
    Object nodeInfo = node.getUserObject()

    RTFM
    Object o =...
    String str = o.toString();

  • How to convert server specific date string into client specific date object

    Hi developers,
    I have a very complex issue to convert the server date string format "EEE MMM dd HH:mm:ss z yyyy" into java.util.Date object and find the difference of the client machine date to represent the elapsed time
    The problem is the server time zone and client time zone are not unique and when I try to covert the server date which is in string format to date format using SimpleDateFormat class , I got the server time as 3:30 hours appended to it. The server time zone is in IST and Client time zone format is GMT+5:30 , the appended time of 3:30 hours created the confusion in calculating the elapsed time between the server started time and client requested time
    I went through all the sites but none of them were useful
    If any help to solve the above issue is appriciated
    please send the response with the same subject line
    Advance Thanks

    Why don't you just subtract from the server time the 3:30 hours (consult api of java.util.date) before comparing with the client date? Hard to see where's the problem...

  • Converting objects into Strings

    How would someone convert an object of say (String, int, double, String) into a readable string. I tried the toString() method but all I get is something like this
    Student@1f12c4e

    ..I'm not sure I understand "how" to override. The whole point of this project is to use quicksort on a list of students, unfortunately all I get is the address whenever I use the .toStrings() method.
    Here's what I have, any help would be greatly appreciated-so very close
    import cs1.Keyboard;
    import java.io.*;
    import java.util.*;
    public class StudentTraverse
    public static void main(String[] args)
    String newName;
    int newSocial;
    double newGPAs;
    String newMajors;
    System.out.println("How many Students would you like to add");
    Student newStudent;
    StudentList12 WORK = new StudentList12();
    int total = Keyboard.readInt();
    for(int number = total; number > 0; number--)
    System.out.println("Name?");
    newName = Keyboard.readString();
    System.out.println("Social?");
    newSocial = Keyboard.readInt();
    System.out.println("GPA?");
    newGPAs = Keyboard.readDouble();
    System.out.println("Major?");
    newMajors = Keyboard.readString();
    newStudent = new Student(newName, newSocial, newGPAs, newMajors);
    System.out.println("Inserting: "+newStudent.toString());
    WORK.add(newStudent);
    for(total = 0; total < WORK.size(); total++)
    System.out.println("top" total": "+WORK.top(total).toString());
    try
    BufferedReader in = new BufferedReader(new FileReader("LIST.out"));
    while (in.ready())
    // Print file line to scree
    System.out.println (in.readLine());
    in.close();
    catch (Exception e)
    System.err.println("File input error");
    public class StudentNode
    public Student student;
    public StudentNode next;
    public StudentNode()
    next = null;
    student = null;
    public StudentNode(Student d, StudentNode n)
    student = d;
    next = n;
    public void setNext(StudentNode n)
    next = n;
    public void setData(Student d)
    data = d;
    public StudentNode getNext()
    return next;
    public Student getData()
    return data;
    public String toString()
    return ""+data;
    public StudentNode(Student newStudent)
    METHOD NAME: StudentNode
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Acts as a node for the Student list
    ALGORITHM:Acts as node for the list
    INSTANCE VARIABLES: none
    student = newStudent;
    next = null;
    public class Student
    private String name;
    private int social;
    private double GPA;
    private String Major;
    public Student(String newName, int newSocial, double newGPAs, String newMajors)
    METHOD NAME: Student
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: The actual Student class, determines what is allowed in the array
    ALGORITHM:Declare what variables will be needed for the program
    INSTANCE VARIABLES: String name, int social, double GPA, String Major
    name = newName;
    social = newSocial;
    GPA = newGPAs;
    Major = newMajors;
    import java.io.*;
    import cs1.Keyboard;
    import java.io.BufferedWriter;
    import java.util.*;
    public class StudentList12
    private StudentNode list;
    static int i = 0;
    public StudentList12()
    METHOD NAME: StudentList12
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Declares the Node
    ALGORITHM:Declare the Node
    INSTANCE VARIABLES: none
    list = null;
    public boolean isEmpty()
    return list == null;
    public int size()
    return i;
    public void add(Student newStudent)
    METHOD NAME: add
    AUTHOR:
    DATE OF CREATION: Nov 20, 2004
    DATE OF UPDATES: Nov 28, 2004
    PURPOSE: Let's users add objects to the array of objects
    ALGORITHM:Traverses the current list and adds object to the end
    INSTANCE VARIABLES: none
    list = new StudentNode(newStudent, list);
    i++;
    current = current.next;
    current.next = node;
    public Student remove()
    if(isEmpty())
    return null;
    StudentNode tmp = list;
    list = tmp.getNext();
    i--;
    return tmp.getData();
    public void insertEnd(Student newStudent)
    if(isEmpty())
    add(newStudent);
    else
    StudentNode t = list;
    while(t.getNext() != null)
    t=t.getNext();
    StudentNode tmp = new StudentNode(newStudent, t.getNext());
    t.setNext(tmp);
    i++;
    public Student removeEnd()
    if(isEmpty())
    return null;
    if(list.getNext() == null)
    return remove();
    StudentNode t = list;
    while(t.getNext().getNext() != null)
    t = t.getNext();
    Student newStudent = t.getNext().getData();
    t.setNext(t.getNext().getNext());
    i--;
    return newStudent;
    public Student top(int n)
    StudentNode t = list;
    for(int i = 0; i <n && t != null; i++)
    t = t.getNext();
    return t.getData();
    public void writeToFile(int n)
    int z = n;
    try
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("LIST.out")));
    for(int counter = z; counter >= 0; counter--)
    System.out.println(counter);
    out.close();
    catch(Exception e)
    System.err.println("Couldn't Write File");
    try
    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("LIST.out")));
    out.write(list.toString());
    out.close();
    catch(Exception e)
    System.err.println("Couldn't Write File");
    }

  • Converting large amounts of points - 76 million lat/lon's to spatial object...

    Hello, I need help.
    Platform - Oracle 11g 64bit on Windows Enterprise server 2008 64bit.  64 GB of ram with 2 CPUs totalling 24 cores
    Does any one know of a fast way to convert large amounts of points to a spatial object?  I need to convert 76 million lat/lon's to ESRI st_geometry or Oracle sdo_geometry.
    Currently, I have setup code using pipelined parallel functions and multiple jobs that run concurrently.  It still takes over 2.5 hours to process all of the points.
    Any pointers would be GREATLY appreciated!
    Thanks
    John

    Hi,
    Where is the lat/lon data at the moment?  In an external text file or in an existing database table as number attributes?
    If they're in an external text file, then I'd probably use an external table to load them in as quickly as possible.
    If they're in an existing database table, then you can just update the sdo_geometry column using:
    update <table> set <geometry column> = sdo_geometry(2001, <your srid>, sdo_point_type(<lon column>, <lat column>, null), null, null)
    where <lon column> is not null
    and <lat column> is not null;
    That should run very quick for you.  If you want to avoid the overhead of creating redo, you could use "create table .... as select...".  This example of creating 1,000,000 points runs in 9 seconds for me.
    create table sample_points (geometry) nologging as
      (select sdo_geometry(2001, null,
      sdo_point_type(
      trunc(100000 * dbms_random.value()),
      trunc(100000 * dbms_random.value()),
      null), null, null)
      from dual connect by level <= 1000000);
    I have setup code using pipelined parallel functions and multiple jobs that run concurrently
    You shouldn't need to use pl/sql for this task.  If you find you do, then provide some sample code and we'll take a look.
    Regards,
    John O'Toole

  • Accessing Oracle spatial objects (SDO_GEOMETRY) through ODBC/OLEDB

    Hello.
    I tried googling and reading through these forums and Oracle documentation, but I'm still uncertain on this question:
    Are Oracle spatial objects (of type SDO_GEOMETRY) accessible through ODBC and/or OLE DB drivers? Can I retrieve them with SELECT clause? Can I write them to database?
    I'm limited to these options because I'm developing Delphi application based on ADO and it must work with different DB servers. However I certainly don't want to implement different ways of accessing database for each server.
    If geometry objects aren't suported by ODBC/OLEDB, is there any way to convert SDO_GEOMETRY to (and from) BLOB or string or whatever, so I can read and write them like a normal data field?
    Thanks in advance.
    Edited by: user13816863 on 25.01.2011 20:35
    Edited by: user13816863 on 25.01.2011 21:57

    The SDO_UTIL package has lots of options to help output spatial data to other formats, and you may be able to use some of them to help.
    Some that come to mind are:
    SDO_UTIL.TO_WKTGEOMETRY
    SDO_UTIL.TO_GMLGEOMETRY
    SDO_UTIL.TO_KMLGEOMETRY
    This is covered in chapter 32 of the Oracle® Spatial Developer's Guide 11g Release 2 (11.2).

  • Convert a date in String format to a Date

    Hi,
    How can I convert a date in String format to a Date object?
    I have tried:
    import java.text.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Locale;
    import java.sql.*;
    public class casa {
    public static Connection con = null;
    public static Statement s = null;
    public static String sql = null;
    public static String mydate = "01.01.2001";
    /** Creates a new instance of casa */
    public casa() {
    public static void main(String[] args) throws SQLException{
    try {
    DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    Date date = shortFormat.parse(mydate);
    //Open Database
    con = getConnection();
    s = con.createStatement();
    sql = "select date1 from table1 where date1 <= '"+date+"'";
    ResultSet rs = s.executeQuery(sql);
    while(rs.next()){
    String aba = rs.getString("datum");
    System.out.println("New Datum = "+aba);
    } catch (Exception ex ) {
    ex.printStackTrace();
    closeConnection(s, con);
    //Connection
    private static Connection getConnection() {
    Connection con = null;
    String user ="aouzi";
    String passe ="aouzi";
    String url = "jdbc:db2:EjbTest";
    try {
    //Datenbanktreiber laden
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    //Verbindung herstellen
    con = DriverManager.getConnection(url,user,passe);
    }catch(ClassNotFoundException e){
    } catch(SQLException e){}
    return con;
    //close Connection
    private static void closeConnection(Statement s, Connection con) {
    try {
    s.close();
    } catch (SQLException e) {}
    try {
    con.close();
    } catch (SQLException e) {}
    I'm getting the following errors:
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0180N
    The syntax of the representation of a date/time of day value as character sequence is false. .SQLSTATE=22007

    I'm pretty sure it won't understand what date.toString() returns. If you know what format the database understands, you do it like this:
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy"); // e.g. 18-Apr-02
    String datestring = sdf.parse(date);
    and use that instead of date in your sql string. Some databases understands it if you do
    "to_date('18-Apr-02')"
    so you could include that in your sql string as well..
    You could also try to make it a java.sql.Date and hope your jdbc driver knows how to convert it to a string that the database understands if you don't know the format:
    con = getConnection();
    PreparedStatement ps = con.prepareStatement("select date1 from table1 where date1 <= ?");
    ps.setDate(new java.sql.Date(date.getTime()));
    ResultSet rs = s.executeQuery(sql);

  • Convert the date of string to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.

    I need convert the date of string format 'MM/dd/yyyy' to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.Since
    I need to search values based on date where my database datetime  is 'MM/dd/yyyy' format.

    In my opinion you should re-consider the assumption that the date picker returns a string. Maybe it is able to return a
    DateTime object directly instead of string. Then you will pass this value as a parameter of SQL query. This should work regardless of computer configuration.
    Otherwise, follow the previous string-based approaches.

  • Help with converting an object to something else

    How do I go about converting an Object from a Vector back into what it originally was?

    Vector v = new Vector();
    v.add(new String("Hello"));
    Object x = v.get(0);
    String s = (String) x; // this line; cast the object back to its type

  • How to convert an Object to byte[]

    How do I convert an object to a byte array without using the ObjectOutputStream?
    I need to send an object over UDP socket which only works with byte[].

    instead of serialisation for complex object i usexm and sax to transfer information over the network,
    it works great
    works nothing when transfering over the ORBWhen programming with a socket, sendTo is a standard function used in the connectionless protocol. I rewrote this function so as to be able to transmit objects. The following code example shows how to implement the send method in a Sender class:
    import java.io.*;
    import java.net.*;
    public class Sender
    {  public void sendTo(Object o, String hostName, int desPort) 
    {    try   
    {      InetAddress address = InetAddress.getByName(hostName);
    ByteArrayOutputStream byteStream = new
    ByteArrayOutputStream(5000);
    ObjectOutputStream os = new ObjectOutputStream(new
    BufferedOutputStream(byteStream));
    os.flush();
    os.writeObject(o);
    os.flush();
    //retrieves byte array
    byte[] sendBuf = byteStream.toByteArray();
    DatagramPacket packet = new DatagramPacket(
    sendBuf, sendBuf.length, address, desPort);
    int byteCount = packet.getLength();
    dSock.send(packet);
    os.close();
    catch (UnknownHostException e)
    System.err.println("Exception: " + e);
    e.printStackTrace(); }
    catch (IOException e) { e.printStackTrace();
    The code listing below demonstrates how to implement a receive method in a Receiver class. Method recvObjFrom is for the receiver to receive the object. You can include this method in your code to receive runtime objects.
    import java.io.*;
    import java.net.*;
    public class Receiver
    {  public Object recvObjFrom() 
    {    try
    byte[] recvBuf = new byte[5000];
    DatagramPacket packet = new DatagramPacket(recvBuf,
    recvBuf.length);
    dSock.receive(packet);
    int byteCount = packet.getLength();
    ByteArrayInputStream byteStream = new
    ByteArrayInputStream(recvBuf);
    ObjectInputStream is = new
    ObjectInputStream(new BufferedInputStream(byteStream));
    Object o = is.readObject();
    is.close();
    return(o);
    catch (IOException e)
    System.err.println("Exception: " + e);
    e.printStackTrace();
    catch (ClassNotFoundException e)
    { e.printStackTrace(); }
    return(null); }
    One may worry about the size of the byte array -- because when you construct ByteArrayOutputStream or ByteArrayInputStream, you have to specify the size of the array. Since you don't know the size of a runtime object, you will have trouble specifying that size. The size of a runtime object is often unpredictable. Fortunately, Java's ByteArrayInputStream and ByteArrayOutputStream classes can extend their sizes automatically whenever needed.
    By
    Sree Visveswaran

  • How can i convert an object to stream of chars or bytes?

    how can i convert an object to stream of chars or bytes?

    One way is the serialization mechanism. There are examples and explanations of it in the Java tutorial: http://java.sun.com/docs/books/tutorial/essential/io/serialization.html

  • How can I convert table object into table record format?

    I need to write a store procedure to convert table object into table record. The stored procedure will have a table object IN and then pass the data into another stored procedure with a table record IN. Data passed in may contain more than one record in the table object. Is there any example I can take a look? Thanks.

    I'm afraid it's a bit labourious but here's an example.
    I think it's a good idea to work with SQL objects rather than PL/SQL nested tables.
    SQL> CREATE OR REPLACE TYPE emp_t AS OBJECT
      2      (eno NUMBER(4)
      3      , ename  VARCHAR2(10)
      4      , job VARCHAR2(9)
      5      , mgr  NUMBER(4)
      6      , hiredate  DATE
      7      , sal  NUMBER(7,2)
      8      , comm  NUMBER(7,2)
      9      , deptno  NUMBER(2));
    10  /
    Type created.
    SQL> CREATE OR REPLACE TYPE staff_nt AS TABLE OF emp_t
      2  /
    Type created.
    SQL> Now we've got some Types let's use them. I've only implemented this as one public procedure but you can see the principles in action.
    SQL> CREATE OR REPLACE PACKAGE emp_utils AS
      2      TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
      3      PROCEDURE pop_emp (p_emps in staff_nt);
      4  END  emp_utils;
      5  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY emp_utils AS
      2      FUNCTION emp_obj_to_rows (p_emps IN staff_nt) RETURN EmpCurTyp IS
      3          rc EmpCurTyp;
      4      BEGIN
      5          OPEN rc FOR SELECT * FROM TABLE( CAST ( p_emps AS staff_nt ));
      6          RETURN rc;
      7      END  emp_obj_to_rows;
      8      PROCEDURE pop_emp (p_emps in staff_nt) is
      9          e_rec emp%ROWTYPE;
    10          l_emps EmpCurTyp;
    11      BEGIN
    12          l_emps := emp_obj_to_rows(p_emps);
    13          FETCH l_emps INTO e_rec;
    14          LOOP
    15              EXIT WHEN l_emps%NOTFOUND;
    16              INSERT INTO emp VALUES e_rec;
    17              FETCH l_emps INTO e_rec;
    18          END LOOP;
    19          CLOSE l_emps;
    20      END pop_emp;   
    21  END;
    22  /
    Package body created.
    SQL>Looks good. Let's see it in action...
    SQL> DECLARE
      2      newbies staff_nt :=  staff_nt();
      3  BEGIN
      4      newbies.extend(2);
      5      newbies(1) := emp_t(7777, 'APC', 'CODER', 7902, sysdate, 1700, null, 40);
      6      newbies(2) := emp_t(7778, 'J RANDOM', 'HACKER', 7902, sysdate, 1800, null, 40);
      7      emp_utils.pop_emp(newbies);
      8  END;
      9  /
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM emp WHERE deptno = 40
      2  /
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM
        DEPTNO
          7777 APC        CODER           7902 17-NOV-05       1700
            40
          7778 J RANDOM   HACKER          7902 17-NOV-05       1800
            40
    SQL>     Cheers, APC

  • Hello, 2 questionss here is it possible or is there a way to convert all object s outlines in all frames to fills at once and not frame by frame? and why sometimes erases the outline instead of converting it to fill?

    Hello, 2 questionss here>is it possible or is there a way to convert all object s outlines in all frames to fills at once and not frame by frame? and why sometimes erases the outline instead of converting it to fill?

    Hello, 2 questionss here>is it possible or is there a way to convert all object s outlines in all frames to fills at once and not frame by frame? and why sometimes erases the outline instead of converting it to fill?

  • How to convert BLOB into a String

    Hi,
    I got a blob column from the database.
    It contains one XML File.
    How to convert it into String.
    I need the code for how to convert the blob into String
    Thanks in Advance.

    A blob would be a byte-array, which you can use in the String(byte[]) constructor

  • ORA-13050:unable to construct spatial object in using SDO_INTERSECTION

    Hi Specialists,
    I am using Oracle Spatial and getting the ORA-13050 error when using the SDO_Intersection procedure. Below are the details of this.
    Objective: To find the addresses whose boundary lie within a user defined polygon.
    Input: List of coordinates for the user defined poygon.
    Query I am using: SELECT SDO_GEOM.SDO_INTERSECTION (add.boundary, SDO_GEOMETRY(2003,8311,NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),
    SDO_ORDINATE_ARRAY( 149.986507,-36.727242,149.985898,-36.726819,149.986756,-36.726512,149.987288,-36.726803,149.986507,-36.727242)), 0.000001)
    FROM address add
    WHERE add.id = '254378298'
    Error Received:
    ORA-13050: unable to construct spatial object
    ORA-06512: at "MDSYS.SDO_3GL", line 715
    ORA-06512: at "MDSYS.SDO_3GL", line 745
    ORA-06512: at "MDSYS.SDO_GEOM", line 3016
    ORA-06512: at "MDSYS.SDO_GEOM", line 3065
    Please can any one help me in this issue very urgent.
    Thanks,
    Ashish

    Hi All,
    The problem has been resolved by transforming the user defined polygon coordinates into the database specific coordinate system.
    Thanks

Maybe you are looking for

  • HDMI and Epson PowerLite X12 Projector

    I use a an Epson PowerLite X12 Projector with my computer and Smart Board. (I want the projector to project my computer screen on the board). My new HP Envy doesn't have serial ports so I was told that I could use HDMI. Unfortunately I can't get one

  • ALV grid Editable based on a Field value

    Hi, I need to make a ALV Grid Row editable based on a particular field of that row. For example if fields are   A   B   C  D and if there are three rows of data I must make the Field B editable in all the rows which have D value as X else it must be

  • How can i migrate oracle database  data to DB2 database

    Hi how can i migrate oracle database data to db2 database. can anyone provide me solution.

  • LR/PS Smart Object workflow question

    I have a RAW image (let call it image A) that I have sent to Photoshop as a smart object. I applied some smart filters and saved it (call image B). I see two images in LR. Now I've changed my mind and apply a bunch of adjustments to image A. Is there

  • Illustrator cc not opening

    Illustrator CC on maverick not opening up or crashing right after I turn on the app. I tried the cleaner and tried pasting a new IMSLib.dylib but nothing is working. I reinstalled illustrator over four times with restarting the computer but to no ava