Trying to use Oracle Locator for latitude and longitude proximity searches

I am prototyping using Oracle Locator to do proximity searches and other spatial operations within the database in our software products. I’ve got it working fine in SQL Server, where geodetic is built in as well as geometric features, but with Oracle we’re trying to restrict ourselves to the Locator features so our customers are forced to buy the add-on. I am getting perplexing results, as you can see if you run the little test program I wrote.
I am using lat and long as the point coordinates. I am inserting the data using
SDO_GEOMETRY(2001, 4326, SDO_POINT_TYPE(?, ?, null), null, null
Then I am doing the search with
SELECT pointname, SDO_NN_DISTANCE (1) distance_in_miles
FROM geotest g
WHERE SDO_NN(g.geopoint, sdo_geometry(2001, 4326, SDO_POINT_TYPE(38.683, 123.083, NULL), NULL, NULL), 'distance=1000 unit=mile', 1) = 'TRUE'
ORDER BY distance_in_miles
I am getting distances from 56 to 86 units, whatever the units are.
Am I attempting the impossible with Locator, to use lat and long and then expect the sdo_nn function to work in miles?
Select results:
POINTNAME DISTANCE_IN_MILES
Point number 19 56.8497254738894
Point number 17 57.0758802885512
Point number 5 62.096857977487
Point number 3 67.3555572959989
Point number 16 70.8005407529483
Point number 1 73.0370426667902
Point number 9 73.1047740624495
Point number 14 73.1451566004902
Point number 11 74.9344307572887
Point number 10 75.3710529989389
Point number 2 75.423714095366
Point number 8 77.2121183101138
Point number 4 77.6458963754559
Point number 18 80.4569749046142
Point number 6 81.0025026191188
Point number 20 81.8444977200089
Point number 13 83.4095236051998
Point number 15 86.9333533902019
Point number 7 88.9312783958262
Point number 12 98.72957787982
Point number 0 98.9999489634554
21 rows selected

Couple of things that we found out using sdo_nn here...
It works...but the knobs need to be turned in the right order...
You may have done this already...but here is what we have...
a. we create our table containing the location sdo_geometry column ..( in our case the column is called location )
b.We loaded the data..If you elected to use a partitioned table for your spatial data and created the corresponding spatial index as local...your sql will need to account for that.if your index is global ..don't worry about it
c. We inserted the metadata...this needs to be done once per table...by either the dba or the schema owner...
INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID)
VALUES ('<YOUR TABLE NAME>', '<SPATIAL COLUMN NAME>',
MDSYS.SDO_DIM_ARRAY
(MDSYS.SDO_DIM_ELEMENT('LONGITUDE', -180.0, 180.0, 0.5),
MDSYS.SDO_DIM_ELEMENT('LATITUDE', -90.0, 90.0, 0.5)
8307);
COMMIT;
If this is not done before the spatial index is created...stuff won't work...
d. create your spatial index
e. our query looked something like this...( I changed the table names )
This returns the top 30 results sorted by distance in feet...
SELECT LOCATION_KEY,
result_center_distance
FROM
SELECT LOCATION_KEY,
SDO_NN_DISTANCE(1) result_center_distance
FROM LOCATION_OWNER.D_LOCATION dlocation
WHERE SDO_NN(dlocation.LOCATION,
MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(-97.07845,33.138006,null),null,null), 'SDO_NUM_RES=31 unit=FOOT distance=5800.0 SDO_MAX_MEMORY=50000000', 1) = 'TRUE'
ORDER BY 2
WHERE ROWNUM <= 31
We had to use this structure because our index is local...and sdo_nn will return the sdo_num_res results for each partition...so you need to get the results first..then treat it as a top-n query...
If you index is global...this should work
SELECT LOCATION_KEY,
SDO_NN_DISTANCE(1) result_center_distance
FROM LOCATION_OWNER.D_LOCATION dlocation
WHERE SDO_NN(dlocation.LOCATION,
MDSYS.SDO_GEOMETRY(2001,8307,MDSYS.SDO_POINT_TYPE(-97.07845,33.138006,null),null,null), 'SDO_NUM_RES=31 unit=FOOT distance=5800.0 SDO_MAX_MEMORY=50000000', 1) = 'TRUE'
ORDER BY 2
If you want the distance in MILE...replace FOOT by MILE...
good luck...
Edited by: user5431290 on Oct 23, 2011 9:36 AM

Similar Messages

  • How to configure Oracle SSO for forms and apex

    Hi All,
    I am trying to configure oracle SSO for forms and apex using third party external authentication. Please help me how to configure. I a have tried all possible things
    from web but I am not able to do it. Is there any doc or links are much appreciated.
    Info: Some reason my oiddas web link is not working it used to work fine before and also the from /pls/orasso/ link I am not able to login may be because of my oiddas issue
    Thanks

    Hi Andreas,
    Thanks you for your help. I am trying to implement third party external LDAP authentication for APEX and Forms.
    So I started with OID and SSO setup to create external Partner Applications. Some reason my oid and sso web login links are not working. I didn't find any errors. I need some help in finding the problem and direction, I already read docs on web but no proper direction. I appreciate your help.
    Thanks

  • Using Oracle Paser for schema validation

    Hi,
    I am trying to use oracle parser for schema validation. I get hold of oracle parser using jaxp api. Below is the code snippet. When i set the attribute to turn the schema validation on, orale parser does not recognize this jaxp attribute . How can i do schema validation using oracle's xml parser implementaion that i get using jaxp?
    String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
    javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
    factory.setValidating(validate);
    factory.setNamespaceAware(true);
    factory.setAttribute (JAXP_SCHEMA_LANGUAGE,W3C_XML_SCHEMA);
    javax.xml.parsers.DocumentBuilder builder = factory.newDocumentBuilder();
    Thanks

    DOMParser domParser=new DOMParser();
    domParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    domParser.setXMLSchema(SchemaUrl);
    DefaultHandler handler=new DefaultHandler();
    DOMParser.setErrorHandler(handler);
    Parse the XML document to validate with the XML schema.
    domParser.parse(XmlDocumentUrl);

  • Plotting Latitude and  Longitude  in Screen

    Hi ,
    Iam trying to implement applet application reads Latitude and Longitude from database and plots in the screen.
    For this i converted Latitude and Longitude To Screen X and Y.
    Some how when draw its always out of window.
    Is there a way by which we can do it only using java.
    Please guide
    Thanks,
    arvin

    aravind123 wrote:
    Thanks for the suggestion,
    The objective is i want to plot a route (set of lat lon ) using applet.
    Below is the code used for that,
    double newLon= (180 + Lon );
    double screenX = newLon* (screenHeight / 360);
    double newLat= (90 + Lat );
    double screenY = newLat* (screenWidth / 180);Lat and Lon in degrees.
    Iam i doing correctly?
    Please help,It's going to be upside down for a start, since Y position is measured downward from the top of the screen.
    It can be complex issue, though, plotting coordinates which refer to positions on a round planet on a flat screen. The transformations are called geographical projections and there about a half dozen kinds in common usage with names like "Transverse Mercator" and "Albers Equal Area". Different projections suit different maps. For example maps of North America typically use Albers Equal Area (because it works best with areas with more East to West than North to South, but maps of Britain, a North to South country, almost always use Transverse Mercator.
    However maps of the whole world typically use on of the the Mercator projection, which is essentially plotting latitude and longitude directly (or you can use the sin of the latitude, which gives a slightly more realistic impression of areas). However you would still need to think about the relationship between horizontal and vertical scale, if makes quite a difference to the appearance of the map. The Mercator is mathematically simple, but often very misleading.

  • I am trying to use the locate my macbook that was stolen. How do I know if it is set up on the service. It shows on the list but just says it is offline and doesn't say when or where it last was. I am trying to either locate it or erase it. HELP

    I am trying to use the locate my macbook that was stolen. How do I know if it is set up on the service. It shows on the list but just says it is offline and doesn't say when or where it last was. I am trying to either locate it or erase it. HELP

    Since you can see it in your device list it must have Find My Mac activated, but you're going to have to wait for them to take it online in order to either locate, lock or wipe it. Until it goes online you can't do anything. http://www.apple.com/support/icloud/find-my-device/
    iCloud: Locate your device

  • How to Find the Location in Google Maps using Latitude and Longitude

    Hai,
    I need to find the Location from Google Maps, which is match with the Latitude and Longitude values we are sending.
    This will be done by using pure java class i need, can anyone having the sample code for this.
    It's Urgent, please help me
    Expecting replies...

    Yes we were having the performance issues when it is getting locked? in this what i want to know
    why it happens suddenly?
    or what package this piece of code is calling?
    or is there any possiblity of system will degrade the performance like sys user etc...?
    where exactly i found the root cause for further analysis?
    so that next time onwards if particular objects is locking we come to know why it happens is there any logical false or how do we eliminate this issue last time?
    coz in our environment sometimes most of lockings are from the same table?
    pls let me know where i have to concentrate for debug and how to troubloshoot and reslove this
    sorry for the inconvience.. i m expecting the answer from here. if anybody wants some more info i ll let him know.
    as of till now i got some docs i start to read this.
    Regards
    M.Murali..
    Note: will system/sys degrade the performance ?if so how ?

  • Trying to use laf project for the first time

    hi all , i need help , please
    i am trying to use laf project for the first time as i said , and i want help on
    the installation process
    step by step please , i am soo junior here
    i've just downloaded the zip file as the site said (http://fdtool.free.fr/LAF/doc/implementation.htm)
    please go to this url and declare the steps to me
    thanks in advance

    The Forms Look and Feel Project is not an Oracle product. This product was developed by Francois Degrelle. Francois has posted numerous times in this forum that if you need help with the LAF you have to go to the Oracle Forms Look & Feel Project web site or his PJCs and Java Beans Forum for support.
    Craig...

  • Custom Map using latitude and longitude data points

    Hi,
    I am new to Apex and I want to lost custom data points using latitude and longitude data points. I
    have seen posts referring to the chart example (http://apex.oracle.com/pls/apex/f?p=36648:65:2214483882702::NO:::) ; could someone help me with the following:
    1) How to add On Demand Application Process to a map page (step 4 in the demo)
    2) What is a hidden item and how to add it to a page (step 6)
    Any help would be greatly appreciated.
    Kind regards,
    Lisa

    I am trying to do the same thing. I have got the get_data function working to create the desired output. However when I replace the xml <data> block with &P65_DATA, it does not work. If I display P65_DATA on the page, it has correct output. If I cut and paste the output into custom XML, it works fine. Anyone have come across this issue..any ideas how to fix it?

  • Can i  use Oracle Database Audit Vault and Oracle Database Firewall on Solaris?

    Can i  use Oracle Database Audit Vault and Oracle Database Firewall on Solaris?

    4195bee8-4db0-4799-a674-18f89aa500cb wrote:
    i dont have access to My Oracle Support can u send text or html of document please?
    Moderator Action:
    No they cannot send you a document that is available only to those with access to MOS.
    That would violate the conditions of having such service contract credentials.
    Asking someone to violate such privileges is a serious offense and could get that other person's organization banned from all support and all their support contracts cancelled.
    Your post is locked.
    Your duplicate post that you placed into the Audit Vault forum space has been removed (it had no responses).
    This thread which you had placed in the Solaris 10 forum space is moved to the Audit Vault forum space.
    That's the proper location for Audit Vault questions.

  • IPhoto 9.5 using latitude and longitude

    I am extremely frustrated with iPhoto's location function. I'm trying to geotag photos using latitude and longitude. iPhoto insists on trying to convert lat/long to an address that is inaccurate. When I try to reposition the pin point in the map it flies all over the place faster than I can control. When I try to delete the location that iPhoto has added, it refuses. When I turned off Automatic place lookup, the program won't allow me to enter address information at all.
    (After trying to use iPhoto's location function, I can't help but wonder if anyone at Apple has actually tried using it.)
    Is there a secret to getting iPhoto to accept lat/long inputs unaltered? Or should I just use Graphic Converter to geotag photos (which has a beautiful function - center Google Earth on the precise location and Graphic Convert imports the exact lat/long)?

    using Lat/long is easy as described in this article - http://support.apple.com/kb/PH2381
    You also can use the paste location command if you have another photo in the place you want - copy that photo, select the remaining photos at tha location and paste location
    Graphic converter is an option
    HouDahGeo is another option that can safely deal directly with the iPhtoo library - http://houdah.com/houdahGeo/
    LN

  • Predict Trip time duration from Pick up and Drop off Latitude and Longitude using Azure ML Studio

    I'm using Microsoft
    Azure Machine Learning Studio to create an experiment for predicting
    time duration of a trip by using
    a data set containing previous records of the trip time along with latitude and longitude of the pick up and drop off location.
    Can anyone help me out with whatregression model (or
    R-Script optional) should I use to train my model?

    Hi,
    Are you training with raw latitude/longitude? If so, you should try clustering the start/end points into groups. An easy way to do this is to take a decimal or two off the values. Otherwise, the algorithm is seeing
    many, many, unique pairs which may degrade the model performance.
    You will probably also want to use the
    Learning with Counts modules to summarize that lat/lon data because even with clustering, the features will still have high dimensionality. Here's some info on learning with counts:
    http://blogs.technet.com/b/machinelearning/archive/2015/02/17/big-learning-made-easy-with-counts.aspx
    Also, we did some experiments on similar data so if you want to read more about that see:
    http://blogs.technet.com/b/machinelearning/archive/2015/04/02/building-azure-ml-models-on-the-nyc-taxi-dataset.aspx
    Hope this helps!
    Margaret

  • Office 365 hosted Exchange Outlook 2013 "The resource you are trying to use is located on an unsupported version of Microsoft Exchange"

    I have Outlook 2013 downloaded from my Office 365 account and am getting the error "The resource you are trying to use is located on an unsupported version of Microsoft Exchange".  I have added all the steps I have followed so far below.
    We changed over to the Office 365 hosted Exchange from 2003 Small Business Server yesterday.  I have backed up my Outlook 2010 then uninstalled all Office applications and rebooted.  Then downloaded the Office 2013 suite from my account
    and installed it.  Ran the desktop setup to "Set up your desktop applications to work with Office 365."  Went to the control panel and launched the mail tool, made the
    profile and named it Outlook and it auto filled with the correct info.  Clicked Next and it all checked as good, but when I launch Outlook I get the error "The resource you are trying to use is located on an unsupported version of Microsoft
    Exchange".  I have rebooted the laptop and recreated the account three times with the same results.
    Any suggestions?

    OK.  So we solved the problem.  At least in my case.
    We deleted the profile again then jumped on a neighbors wifi and then ran the desktop setup from Office 365 again.  Then we launched the mail setup tool, created a new profile and entered the information for the account.  After this took we launched
    Outlook and everything is working fine.
    One thing to point out is that prior to the time that it worked, when I would create the profile and open it to set it up, it would auto fill the two available fields Name and Email Address.  On the last run it didn't auto fill and I had four fields
    to fill out.  Name, Email Address and Password (x2).
    Hope this helps someone.

  • STEPS TO CONVERT LATITUDES AND LONGITUDES INFORMATION INTO LOCATIONS URGENT

    Hi
    can anyone give me the sequence of steps about converting GPS information that is latitudes , longitudes into locations..
    The problem is i will give input as latitudes and longitudes ,,i should get location ..
    i need help regarding
    1)which api to be used
    2) any maps are required or not

    If you are talking about converting lat and long to x and y, there's plenty of information available around the web. If you are talking about mapping this data to addresses you pretty much need to do some service for that like deepspace suggested.

  • I am trying to use livetype with persian alphabet and it doesn't work. what should I do?

    I am trying to use livetype with persian alphabet and it doesn't work. what should I do?

    There is no more LiveType with Motion 5.  You may want to go to the Final Cut Express forum, as that's the only place it's existed for the last few years.

  • TS1506 I just updated my IOS to 7.1 and now I can't open Microsoft attachments - I used to always do it. Help - I use my iPad for work and now can't see any attachments.

    I just updated my IOS to 7.1 and now I can't open Microsoft attachments - I used to always do it. Help - I use my iPad for work and now can't see any attachments. I've tried opening straight into other apps and just get error messages, and I the mail preview there is just a grey screen telling me the file name and size. It worked fine until I did the IOS upgrade

    Troubleshooting apps purchased from the App Store
    http://support.apple.com/kb/TS1702
    Delete the app and redownload.
    Downloading Past Purchases from the iTunes Store, App Store and iBooks Store
    http://support.apple.com/kb/ht2519
     Cheers, Tom 

Maybe you are looking for

  • L2L VPN Issue - one subnet not reachable

    Hi Folks, I have a strange issue with a new VPN connection and would appreciate any help. I have a pair of Cisco asa 5540s configured as a failover pair (code version 8.2(5)).    I have recently added 2 new L2L VPNs - both these VPNs are sourced from

  • Recovery of documents deleted from sharepoint online

    Hi, Is there a way to recover a document that is deleted and purged from the secondary/administrator recycle bin? If not, are there options (third party services, maybe?) or solutions to create some kind of recovery plan beyond that stage? What are y

  • Have field map to existing record in table by secondary key

    Let's say I have a person table and a code table. person.datastoreId person.name person.foreignKeyToCodeValue code.datastoreId code.codeValue code is a static lookup table. I want to persist a new Person object: personObject.name = whatever personObj

  • CAN A PS3 READ A WD MY PASSPORT FOR MAC?

    I have moved all of my movies onto a mac hard drive and tried to watch them on a ps3 with no luck, is there a solution to this?

  • CS6 Configuration Error 16 - urgent

    I've been on chat help for over three hours. I've reassigned permisssions, used cleaner and reinstalled my programs. The only programs available are Acrobat and Air. I spent 4 hours yesterday trying to find a resolution without adobe's help. I have a