PHP and spatial data

Is there way to access spatial (MDSYS.GEOMETRY type) columns from PHP?
With older OCI8 interface I get ADT-error, with never PDO_OCI I don't get anything, neither error or data.
Or is there way to convert geometry columns to/from WKT in pure PL/SQL (I know that in 10g there is Java-based WKT functions but they don't work with XE or older releases of full Oracle)

You can return results from Oracle Spatial as long as they are not geometries. Here are two examples.
1. You can send a spatial query in PHP and return a non-spatial result, for example:
$query ="Select mkt_id
FROM cola_markets
WHERE SDO_RELATE(shape, mdsys.sdo_geometry(2003,NULL,NULL,
mdsys.sdo_elem_info_array(1,1003,3),
mdsys.sdo_ordinate_array(2,1,7,6)),
'mask=INSIDE querytype=WINDOW') = 'TRUE'";
This code returns mkt_id 2, which is INSIDE of the second shape.
2. You can also return coordinates from a SELECTed geometry by using the SDO_UTIL.GETVERTICES built-in function, for example:
<pre>
$query = " SELECT t.X, t.Y
FROM cola_markets c,
TABLE(SDO_UTIL.GETVERTICES(c.shape)) t
where mkt_id = 2";
$statement = Query($query); // Query() is my own function to test and send the query
while(list($x,$y) = oci_fetch_row($statement))
print "x: $x, y: $y<br />";
</pre>
Output is the set of coordinates for the shape geometry of mkt_id 2:
x: 5, y: 1
x: 8, y: 1
x: 8, y: 6
x: 5, y: 7
x: 5, y: 1
Hope this helps.

Similar Messages

  • Http service component working php and sql data

    hello i'm using that componet. i have trouble. now i want in my home page
    i have 2 title from my localhost/phpmyadin. and i want when click title 1 it will link to a detail.mxml  and display content of title 1
    and when click title 2 it will display content of title 2 in detail.xml
    i don't know transmission parameters . Can u help me please. I'm need it

    These links are good for showing how to use Flex + PHP + HTTPService + MySQL:
    http://www.switchonthecode.com/tutorials/using-flex-php-and-json-to-modify-a-mysql-databas e
    If this post answers your question or helps, please mark it as such.
    http://www.switchonthecode.com/tutorials/flex-php-tutorial-transmitting-data-using-json
    http://www.switchonthecode.com/tutorials/flex-php-json-mysql-advanced-updating
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex Training and Support Services

  • Server site php and As3 data

    Hi,
    I am new in php coding. I want to get image data from php and also display in flash.
    I want to know... how to read and display imagejpeg( $imgData ); from php.
    I am able to get php data in flash through below method...
    /* AS3 */------------------
    var src:String = "pic.jpg";
    var width:String = "250";
    var height:String = "250";
    var urlReq:URLRequest = new URLRequest(src);
    var urlLoader:URLLoader = new URLLoader();
    var urlVar:URLVariable = new URLVariable();
    urlVar.src= src;
    urlReq.mehtod = URLRequestMethod.POST;
    urlReq.data = urlVar;
    urlLoader.load ( urlReq );
    urlLoader.addEventListener(Event.Complete, doneProcFnc)
    function doneProcFnc(ev:Event):void{
          trace ( "data access from php done" );
    /* PHP */
    $src = $_POST [ 'src' ];
    $wd = $_POST [ ' width' ];
    $ht = $_POST [ ' height' ];
    /*  this function will create one black color area for croping refence */
    $cropImg = imagecreatetruecolor ( cropImageWd, cropImageHt );
    /* this function will reproduce particular image required width and height without reducing the image quality */
    imagecopyresampled ( cropImage , sourceImage, destX , destY, sourX, sourY, ect... );
    imagejpeg( $imgData ) ;
    Now, here the problem comes. I don't know how to display that imagejpeg data into flash.
    I need help.
    Thanks.

    Thanks.
    No.No.No. I am not loading image from folder.
    step1 : I m sending some image information to php (src , width , height)
    step2 : PHP code will take that information
    step3 : PHP code will crop that particular image (some calcution for quality)
    step4 : PHP code will generate some image data that is /* imagejpeg( $imgData ) */ and return back to flash
    step5 : Now the problem occur, how can i take that image data in flash or what form
    Possibilities :
    ? should i get image data as text format and it needs to be encoded (like jpeg encoder)
    ? i don't know i already try jpegencoder but i did not get anything
    var src:String = "pic.jpg";
    var width:String = "250";
    var height:String = "250";
    var urlReq:URLRequest = new URLRequest(src);
    var urlLoader:URLLoader = new URLLoader();
    var urlVar:URLVariable = new URLVariable();
    urlVar.src= src;
    urlReq.mehtod = URLRequestMethod.POST;
    urlReq.data = urlVar;
    urlLoader.load ( urlReq );
    urlLoader.addEventListener(Event.Complete, doneProcFnc)
    function doneProcFnc(ev:Event):void{
              trace ( "data access from php done" + ev.target );
            // imagejpeg( $imgData )
    /* PHP */
    $src = $_POST [ 'src' ];
    $wd = $_POST [ ' width' ];
    $ht = $_POST [ ' height' ];
    /*  this function will create one black color area for croping refence */
    $cropImg = imagecreatetruecolor ( cropImageWd, cropImageHt );
    /* this function will reproduce particular image required width and height without reducing the image quality */
    imagecopyresampled ( cropImage , sourceImage, destX , destY, sourX, sourY, ect... );
    imagejpeg( $imgData ) ;

  • Help in establishing connection to php and mysql data base.

    Hi,
    i have been trying to execute a simple flash program that communicates with a php page which is linked to a mysql database.
    somehow the php is not returning any data to flash , and even falsh is not sending any data to php.. I am using wamp server on win7.
    Heres my actionscript code:
    stop();
    var variables:URLVariables = new URLVariables();
    var varSend:URLRequest = new URLRequest("php.php");
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    var varLoader:URLLoader = new URLLoader;
    //varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader.dataFormat = URLLoaderDataFormat.TEXT;
    varLoader.addEventListener(Event.COMPLETE, completeHandler);
    variables.requestCode = "homepage";
    //variables.myRequest="homepage";
    trace(variables);
    varLoader.load(varSend);
    function completeHandler(event:Event):void
        trace(event.target.data.t_passed);
        var t_recieved = event.target.data.t_passed;
        //t_txt.text = "t_passed";
        t_txt.text=t_recieved;
    try
        varLoader.load(varSend);
    catch (error:Error)
        trace("error");
    And this is my php code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <?php
    //error_reporting(E_ALL  & ~E_NOTICE);
    $connection=mysql_connect("localhost" , "root" , "");
    if(!$connection)
        die("failed".mysql_error());
    $db_select = mysql_select_db("questions",$connection);
    if (!$db_select)
        die("failed".mysql_error());
        if ($_POST['requestCode'] == "homepage") {
        $pageName = $_POST['requestCode'];
        echo ($_POST['requestCode']);
    $result=mysql_query("select q from quest where qno=111",$connection);
    while($row=mysql_fetch_array($result))
    $t=$row[0];
    //print "t_passed = $s";
    echo "t_passed=".$t;
    mysql_close($connection);
    ?>
    </head>
    <body>
    </body>
    </html>
    The php gives me Undifined notice for the 'requestCode' variable...
    please help..
    Thanks in advance

    Sample Flash Code:
    package
        import flash.display.*;
        import flash.events.*;
        import flash.net.*;
        import flash.text.*;
        public class sendtophp extends Sprite
            var phpFile:String = "http://localhost/Raja/sendDataToServer.php";
            public function sendtophp():void
                callBtn.addEventListener(MouseEvent.CLICK, callServer);
            function callServer(e:MouseEvent):void
                var urlRequest:URLRequest = new URLRequest(phpFile);
                var urlParams:URLVariables = new URLVariables();
                urlParams.country = "India";
                urlParams.animal="Tiger";
                urlRequest.method = URLRequestMethod.POST;
                urlRequest.data = urlParams;
                var loader:URLLoader = new URLLoader();
                loader.addEventListener(Event.COMPLETE, serverResponse);
                loader.load(urlRequest);
            function serverResponse(e:Event):void
                trace("loaded");
                var loader:URLLoader = URLLoader(e.target);
                var variables:URLVariables = new URLVariables(loader.data); 
                responseTxt.text = variables.returnValue; 
        }//end of class sendtophp 
    }//end of package
    Sample PHP code:
    <?php
    print "returnValue= Hi ".$_POST['country'].", it's working";
        $host = "localhost";
        $user = "root";
        $pass = "";
        $db = "test";
        $country = $_POST['country'];
        $animal = $_POST['animal'];
         $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
         mysql_select_db($db) or die ("Unable to select database!");
          $query = "INSERT INTO symbols (country, animal) VALUES ('$country', '$animal')";
          $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
        echo "New record inserted with ID ".mysql_insert_id();
           mysql_close($connection);
    ?>
    I had tested and it works fine. Please have this as an sample. If you have any clarification then reply to the thread

  • Re:LOB, Spatial data

    Hi all,
    can any one tell me that does goldengate support LOB and spatial data? if so do we have to add any parameters to the parameter file in the goldengate?
    thanks in advance..

    Hi
    I hoppe this help you:
    ----- Supported data types Classic Capture
    **Basicfile LOB columns
    LOB modifications done via
    DML
    (INSERT/UPDATE/DELETE)
    are captured from redo.
    ◆ LOB modifications done via
    DBMS_LOB package are
    captured by fetching values
    from the base table.
    *** Securefile LOB
    ◆ Securefile LOBs are only
    captured from redo if LOBs are
    not transformed (such as not
    compressed or encrypted) and
    stored out of row, and if the
    modification is done via DML
    statements.
    ◆ LOBs are fetched from the
    base table for the following
    cases:
    ◆ LOB is encrypted
    ◆ LOB is compressed
    ◆ LOB is stored in-line
    ◆ LOB is modified via
    DBMS_LOB package
    ◆ LOB is deduplicated
    ◆ LOB is modified via
    fragment operations
    ◆ NOLOGGING LOBs
    Check the Oracle Installation and Setup Guide for obtain more detail
    Edited by: user11237143 on 23/05/2012 10:57 AM

  • Need urgent on installation of Spatial and R12 data in the same server

    Hi
    This is Hanumantha. I am getting problem with Geo Spatial data type objects manuplating from Apps.
    Geo spatial data is installed in Navteq database in one server. R12 application is installed in another server. Through data base link in APPS, I am able to access Navteq tables data, procedures etc. But I can't manuplate the objects data like Varrays and object types from apps throgh db link from navteq.
    Instead created the procedure which will decompose the object type to "primitive types" (number, date, varchar2,.) which is accessing from apps. But hz_locations , Geometry column will have data type SDO_GEOMETRY and I cant update with primitive data type (number, date, varchar2..).
    Kindly please help us reconstucting to the SDO_GEOMETRY object using primitive data types.
    OR
    Is there any possiblity of installing Navteq database(GeoSpatial data) and R12 applications data together in the one server.
    Could please any help on the above as soon as possible?
    Thanks in Advance.
    Thanks,
    Hanumantha

    Could you give me an example of this update rutine?

  • Retrieving spatial and non spatial data in one query

    Hello. I am having slight difficulties using JDBC to retrieve both spatial and non spatial data in the same query. The following is code from a sample program of mine that retrives spatial data from spatial tables.
    (In spatialquery geom is a geometry column and city is simply the name of the city):
    try
    Geometry geom = null;
    String database = "jdbc:oracle:thin:@" + m_host + ":" + m_port + ":" + m_sid;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = (OracleConnection)DriverManager.getConnection(database, sUsername, sPassword);
    GeometryAdapter sdoAdapter =
    OraSpatialManager.getGeometryAdapter("SDO", "8.1.7", STRUCT.class, null, null, con);
    String spatialquery = "SELECT a1.geom, a1.city \n" +
    "FROM cities a1";
    Statement stmt = con.createStatement();
    OracleResultSet rs = (OracleResultSet) stmt.executeQuery(spatialquery);
    int i = 0;
    int noOfFeatures = 2;
    while (rs.next())
    for(i = 1; i <= noOfFeatures; i++)
    STRUCT dbObject = (STRUCT)rs.getObject(i);
    try
    geom = sdoAdapter.importGeometry(dbObject);
    catch(GeometryInputTypeNotSupportedException e)
    System.out.println("Input Type not supported");
    catch(InvalidGeometryException e)
    System.out.println("Invalid geometry");
    System.out.println(geom);
    }//end while loop
    This retrieves the sptial data fine, however when I attempt to retreive the non-spatial data I keep getting a "ClassCastException" error. I understand it is something to do with "STRUCT dbObject = (STRUCT)rs.getObject(i);" line. Can anyone tell me how to retrieve both spatial and non-spatial data in the one query using JDBC. I have tried nearly everything at this stage. Cheers joe

    Theresa A Radke
    Posts: 20
    OTN Member Since: Jul, 2001
    retrieving spatial and non spatial in same query. May 23, 2003 12:02 AM
    retrieving spatial and non spatial in same query.

  • TimesTen and Geo-spatial data

    Can TimesTen support geo-spatial data (and datatypes) as supported in Oracle? For example, if one created a set of Oracle tables that held geo-spatial data, could TimesTen be used in its "caching" form to speed geo-spatial queries?
    Thanks!
    --rick grehan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    No, sorry. TimesTen does not support Geo-spatialo datatypes or functions.
    Chris

  • Spatial Data and XML metadata

    My project involves storing various types of spatial data in Oracle 8i. There is also going to be metadata collected for each project. The purpose of the metadata will be for discovery and retrieval of the spatial data. I would like to store the metadata entries (using WebDB to create entry form) as XML documents. What is the best way to create XML metadata from a HTML form? It appears that the new Xforms from W3C may accomplish this, although it's not really a standard yet. Also, it there a way to send the spatial data from a form created by WebDB? Would the XML metadata be stored in the spatial DB with the data or in a separate "metadata repository"? How would the metadata be attached to the data for query and discovery/retrieval? I appreciate any feedback. Thanks.

    Jonrka1,
    Spatial already uses a metadata table called user_sdo_geom_metadata where you need to store metadata for all of your spatial tables. Oracle spatial currently does not support metadata in XML format although it is being actively investigated in conjunction with Oracle 8i Spatial XML server. With the XML server you will be able to retrive spatial (and attribute) data as well as update the spatial table using XML.
    Check OTN often for announcemnets on the XML server and related products.
    For your customized XML spatial metadata you can store it anywhere (with a spatial db or in a separate repository), and you will have to maintain the link between the metadat and the real data yourself.
    LJ
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by jonrka1 ():
    My project involves storing various types of spatial data in Oracle 8i. There is also going to be metadata collected for each project. The purpose of the metadata will be for discovery and retrieval of the spatial data. I would like to store the metadata entries (using WebDB to create entry form) as XML documents. What is the best way to create XML metadata from a HTML form? It appears that the new Xforms from W3C may accomplish this, although it's not really a standard yet. Also, it there a way to send the spatial data from a form created by WebDB? Would the XML metadata be stored in the spatial DB with the data or in a separate "metadata repository"? How would the metadata be attached to the data for query and discovery/retrieval? I appreciate any feedback. Thanks.<HR></BLOCKQUOTE>
    null

  • Incorporating Spatial Data and maps

    I am trying to figure out how to create a map from spatial data w/in forms9i, but I can't find any documentation. Has anyone been succesful at this?
    Thanks,
    Jeremy.

    to use read_image_file() to show map on form is to show the map as static image, user cannot click ROOM IN button, then click a point on the image to show the details.
    so to get it inside form and want the map to respond like on browser is interested feature to know, and also the download time and performance if finally done inside form is a big question mark too.
    simply running the mapviewer on browser is properly the better way compared to invoke it inside form.

  • Spatial Data and Calc Views

    Hi there,
    I've been wondering if there is currently any way to use Spatial Data in Calculation or Analityc Views, to summarize or join data by Spatial Columns, and using Spatial methods in Hana SPS07? If so, could you provide some example?
    Thanks in advance.

    Jonrka1,
    Spatial already uses a metadata table called user_sdo_geom_metadata where you need to store metadata for all of your spatial tables. Oracle spatial currently does not support metadata in XML format although it is being actively investigated in conjunction with Oracle 8i Spatial XML server. With the XML server you will be able to retrive spatial (and attribute) data as well as update the spatial table using XML.
    Check OTN often for announcemnets on the XML server and related products.
    For your customized XML spatial metadata you can store it anywhere (with a spatial db or in a separate repository), and you will have to maintain the link between the metadat and the real data yourself.
    LJ
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by jonrka1 ():
    My project involves storing various types of spatial data in Oracle 8i. There is also going to be metadata collected for each project. The purpose of the metadata will be for discovery and retrieval of the spatial data. I would like to store the metadata entries (using WebDB to create entry form) as XML documents. What is the best way to create XML metadata from a HTML form? It appears that the new Xforms from W3C may accomplish this, although it's not really a standard yet. Also, it there a way to send the spatial data from a form created by WebDB? Would the XML metadata be stored in the spatial DB with the data or in a separate "metadata repository"? How would the metadata be attached to the data for query and discovery/retrieval? I appreciate any feedback. Thanks.<HR></BLOCKQUOTE>
    null

  • Spatial data and 8i versions?

    Is the Spatial Data option only available with the 8i Enterprise edition or is it also available with the 8i Standard edition?

    Spatial is only available
    with Enterprise edition.
    null

  • PHP and MySQL Connection problem

    I am trying to make a PHP MySQL on a remote server connection in Dreamwesaver CS3.
    When I enter the information (host, user, password, etc.) and hit TEST, I get the following error message.
    "Access Denied. The file may not exist, or there could be a permission problem. Make sure you have proper authorization on the server and the server is properly configured."
    I know the user, password, etc. work, as I can access the MySQL database with other software.
    I checked with my host and they say there are no permission problems on their end.
    I have checked the settings on the Test Server page in Site Setup and everything looks correct and works there.
    I have not seen this particular problem described in other forum postings (although there are a LOT of postings on this topic!).
    Any help would be appreciated.

    I thought my testing server was the remote server and is always on as far as I know. I don't know how to turn it on or off.
    Is there some other testing server that I should be aware of?
    Frank
    Date: Wed, 3 Jun 2009 15:43:02 -0600
    From: [email protected]
    To: [email protected]
    Subject: PHP and MySQL Connection problem
    I know you are using remote, but is your testing server on? if not turn that on and see if that does it. it just happened to me working on remote server and could not get mysql conn to work, until I turn on my testing (developer server), then I was able to connect to mysql and the tables that I created in phpmyadmin remotly was downloaded.
    >

  • Any way to use OBDC in SAP to access MySQL DB and retrieve data

    I'd like to logon to an external MySQL DB (can de done easily enough with PHP)   but I'd like to do it with ABAP if possible.
    Connecting via OBDC I should be able to retreive the data from the DB  and then use it in my SAP application.
    Some databases will allow connection via
    EXEC SQL.
    connect to :dbsid
      ENDEXEC.
    EXEC SQL.
        set connection :dbsid
      ENDEXEC.
    EXEC SQL.
      open xxxxxxx for
      select
    ...... data from external DB
    from tablespace in external db
    ENDEXEC.
    do.
      EXEC SQL.
        fetch next XXXXXX into
               :db_table_field, .... etc
                 ENDEXEC.
      if sy-subrc ne 0.
        exit.
      endif.
      insert table int_sap_table.
    enddo.
    EXEC SQL.
      close XXXXXX
    ENDEXEC.
    If you can make this type of stuff work for a MySQL DB i'd appreciate the answer.
    Using PHP has a drawback as you need to have it installed on the front end PC and run in Foreground.
    The EXEC SQL commands run in batch which is what you need if you are talking about 100,000's of records from an external DB.
    Cheers
    jimbo

    Hi Graham
    Currently it doesn't seem to support MySQL.
    Now that SAP has taken over again the development of MAXDB I can't see it providing  direct MySQL to SAP functionality.
    MAXDB is available but that would mean changing the entire architecture and we don't want to do that.
    I think probably the best route to go would be to create a BAPI which is capable of performing a logon to the remote  MySQL DB server, get the data and either send it back as  IDOCS, an external flat file, or as an internal table depending on the volume of data to be retrieved.
    The good thing about MySQL is that the command line interface makes logging on and retrieving data quite simple.
    This data is actually wanted in a BI  / BW system to provide for a number of business proces analyses.
    I did think abut using "Web Services"  but the data retrieval will essentially be done offline.
    There is no requirement currently for transferring data FROM SAP back to the MySQL database ( although if you've ever dealt with top level management you know how quickly developments can change).
    PHP for all it's drawbacks is the really easy way - but we'll have a problem doing this in background from the SAP servers. For foreground tasks it's a real doddle if you have php on your front end.
    for example
    <?php
    $username = "pee_wee";
    $password = "let_me_in";
    $hostname = "localhost";        */* IP address of remote DB server */*
    $dbh = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");
    print "Connected to MySQL<br>";
    // you're going to do lots more here soon
    mysql_close($dbh);
    ?>
    Batch mode also seems OK  also from the documentation
    http://dev.mysql.com/doc/refman/5.1/en/batch-mode.html
    so running an ABAP which can issue system commands (readily available) should work in theory provided the SAP server can connect to the remote MySQL server machine.
    Thanks for your suggestions however
    Cheers
    jimbo

  • How to load spatial data from .shp file

    Could anyone suggest an easy to use, free tool to upload spatial data from .shp file (or/and other open source spatial file sources) into an Oracle Locator database?
    We have licensing for ArcGIS10, but nobody (including ArcGIS) have been able to successfully create a direct connection from their software to our Oracle 10.2 database.
    Client desktops here are Windows 7 64bit, which further complicates matters (tend to find neither ArcGIS nor Oracle support 64bit OS in a cogent fashion)

    790951,
    . . . .You can also try Oracle's ShapeFile Converter (shp2sdo). It's a command line utility so there's automation potential.
    . . . .Note that ESRI's tools may (depending on how they're used) store spatial content in Oracle Spatial as BLOBs containing their ST_GEOMETRY data-type (rather than Oracle's SDO_GEOMETRY type).
    Regards,
    Noel

Maybe you are looking for

  • How to Restrict Creation of Infotype Record for Certain Org Units?

    Dear All, Requirement: Org Unit 1 does not have overtime. Even the employee works overtime, they will not get overtime compensation. One of the option is to disallow the creation of IT2005's record for all the employees in Org Unit 1. Is it possible

  • Hiding row and column labels

    You can format a table so that it looks just like a form - e.g. give it a background color, shadow, etc. Looks very nice. However, whenever you click on a cell, the row and column the row and column labels suddenly appear, and the visual illusion of

  • Saving files in Microsoft Sharepoint Server MOSS

    Our organisation is implementing a hosted Microsoft Office Sharepoint Server (MOSS) environment for file storage and sharing replacing file servers in 3 different locations. We are trialing the MOSS server with a subset of users and have found it wor

  • Skype 6.21 Preview: Looks terrible on Surface

    Hi, I just got a Surface Pro 3 and the latest version of Skype still does not seem to support DPI scaling properly. This makes it look very ugly on a premium Microsoft product. Secondly, the interface is currently not very usable with touch. The mode

  • Cannot make phone calls after update to iOS version  8.1.3

    hi i do own an iPhone 6, it was a beautiful phone until i updated to iOS 8.1.3. Now i cannot make phone calls at times, the phone shows no network. I updated the OS  from wifi, my mom owns an iPhone 5c it also has the same problem. please help