Distance between all points

Hi all, I am trying to find the distance between all points in an array. I was able to get the all possible combinations but i am not getting the expected ouput.
For eg, if i have four points, total number combinations are going to be 6 and i want to find distance in all six combinations.
Please help me where i did mistake. Please find the attached vi.
Thanks
uday,
Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
Certified LabVIEW Associate Developer (CLAD) Using LV13
Solved!
Go to Solution.
Attachments:
Find distance between all points.vi ‏17 KB

Try something like this.
Since I don't have the IMAQ function, I am using complex data for each point, but it would be trivial to adapt it to your data structures instead.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Find distance between all points.png ‏33 KB
Find distance between all pointsMODCA.vi ‏10 KB
Find distance between all pointsFP.png ‏21 KB

Similar Messages

  • How to measure distance between two points uisng uiaccelerometer

    Hello all,
    I am trying to measure distance between two points.So for that i am used uiaccelerometer but its give only rotation changes. I am moving my whole device from one point to another point so for that all x,y & z changes remain same. So how can get the device movement for that?
    Thank you..

    UIAccelerometer does not give rotation changes, it senses acceleration in each of the 3 axis in g-force units. Moving in a plane from one point to another and stopping will result in a net g-force in that axis of zero. To get distance one has to measure the initial acceleration and then the time before a deceleration is detected. It gets really complicated in real life since the start and stop are not instantaneous.

  • Customizing distance between data Points on x-Axis

    Hi,
    I want to draw a LineChart.
    I have these Timestamps [84, 1000, 34000, 34699, 439999] who
    are represanting the x-Value of DataPoints along the X-Axis.
    Unfortunately the distance between 2 datapoints along the
    x-Axis is always the same, that means that between the points with
    x-values 84 and 1000 is the same distance along the axis as between
    the points with x-values 34699 and 439999.
    But the distance between points with x-values of 34699 and
    439999 should be much greater than between 84 and 1000.
    How can I customize the distance between data Points on a
    LineChart to solve my Problem?
    I really dont know right now!
    Greeting,
    Z.

    "zidaninho" <[email protected]> wrote in
    message
    news:gls479$nkt$[email protected]..
    > Hi,
    >
    > I want to draw a LineChart.
    > I have these Timestamps [84, 1000, 34000, 34699, 439999]
    who are
    > represanting
    > the x-Value of DataPoints along the X-Axis.
    >
    > Unfortunately the distance between 2 datapoints along
    the x-Axis is always
    > the
    > same, that means that between the points with x-values
    84 and 1000 is the
    > same
    > distance along the axis as between the points with
    x-values 34699 and
    > 439999.
    > But the distance between points with x-values of 34699
    and 439999 should
    > be
    > much greater than between 84 and 1000.
    >
    > How can I customize the distance between data Points on
    a LineChart to
    > solve
    > my Problem?
    >
    > I really dont know right now!
    What happens if you convert the time stamps to Dates and use
    a DateAxis?

  • Find driving distance between two points without using API by use of Lat & Long?

    Using Google geocode API : http://maps.googleapis.com/maps/api/geocode/xml?address=thane&sensor=true
    We performed get distance between search criteria entered by user and all related clubs by lat & long  stored at db.
    2. Two different points such as  
    (origin: Lat1 & Long1) and (destination: Lat2 & Long2)
    We tried for to get distance between these two points,
     (Lat2 & Long2) to (Lat1 & Long1)
    But distance which we get by calculation is simple straight line distance 
    Origin Destination
    (Lat1 & Long1) (Lat2 & Long2)
    3. This is not driving distance as google shows in exact Km
    4. For that Google provide another API (distancematrix API)
    http://maps.googleapis.com/maps/api/distancematrix/xml?origins=Thane&sensor=true&destinations=khopat&mode=driving&language=en%20-%20EN
    5. But there is limit for DistanceMatrix-Service without ClientID and client key
    100 elements per query.
    100 elements per 10 seconds.
    2 500 elements per 24 hour period.
    But as element request exceeds it shows : OVER_QUERY_LIMIT error  
    6. In case of Client ID and Client key
    In Distance Matrix 100 000 elements per 24 hour period,a maximum of 625 elements per query and a maximum of 1 000 elements per 10 seconds.
    As per this one there is option to get purchase these API but basic question is remain same for us if we are requesting single origin and multiple destination then how element calculation done by google?
    But in document google says :
    Elements
    The information about each origin-destination pairing is returned in an element entry. An element contains the following fields:
    Status: See Status Codes for a list of possible status codes.
    Duration: The duration of this route, expressed in seconds (the value field) and as text. The textual representation is localized according to
    the query's language parameter.
    Distance: The total distance of this route, expressed in meters (value) and as text. The textual value uses the unit system specified with the
    unit parameter of the original request, or the origin's region.

    Any information that you see in a google map webpage can be retrieved using the API.  The best way of finding the tags on the webpage is to manually perform the query using an IE webpage.   Then capture the source and save to a file so you
    can use a text editor to look at results.  I often on a webpage use the menu : View -  Source and then copy the source to a text file.
    jdweng

  • Distance between two points with degrees and minutes

    I would like to store several points in the database given degrees and minutes as position. In this example I have point 1 that is E 150, 0/S 30, 0 and points 2 that is E 150, 0/S 30.1. For example if I enter 2 km as distance from position of point 1 I would like the search to return all points witin 2 km.(should return points 2 that is very near)
    If I run the query
    SELECT c.name
    FROM cola_markets_cs c
    WHERE
    SDO_WITHIN_DISTANCE(c.shape,
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(150.0, 30.1, NULL), NULL, NULL),
    'distance=10000 unit=KM')
    = 'TRUE';
    I get result both position 1 and 2, but if I decrease to distance=1000 no rows is returned.
    Can you see what I am doing wrong here?
    Can I also combine SDO_WITHIN_DISTANCE with SDO_NN_DISTANCE so I can ask for all points 10 km in distance from the reference point and I can also see the actual distance for each point?
    Thank you
    I have tested with the following code. Do I save the position wrong..?
    CREATE TABLE cola_markets_cs (
    mkt_id NUMBER PRIMARY KEY,
    name VARCHAR2(32),
    shape MDSYS.SDO_GEOMETRY);
    INSERT INTO cola_markets_cs VALUES (
    1,
    'Point 1',
    MDSYS.SDO_GEOMETRY(
    2001,
    8307,
    MDSYS.SDO_POINT_TYPE(150.0, 30.0, NULL),
    NULL,
    NULL
    INSERT INTO cola_markets_cs VALUES (
    2,
    'Point 2',
    MDSYS.SDO_GEOMETRY(
    2001,
    8307,
    MDSYS.SDO_POINT_TYPE(150.0, 30.1, NULL),
    NULL,
    NULL
    -- UPDATE METADATA VIEW --
    -- Update the USER_SDO_GEOM_METADATA view. This is required
    -- before the Spatial index can be created. Do this only once for each
    -- layer (i.e., table-column combination; here: cola_markets_cs and shape).
    INSERT INTO USER_SDO_GEOM_METADATA
    VALUES (
    'cola_markets_cs',
    'shape',
    MDSYS.SDO_DIM_ARRAY(
    MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, 10), -- 10 meters tolerance
    MDSYS.SDO_DIM_ELEMENT('Latitude', -90, 90, 10) -- 10 meters tolerance
    8307 -- SRID for 'Longitude / Latitude (WGS 84)' coordinate system
    -- CREATE THE SPATIAL INDEX --
    -- Must be R-tree; quadtree not supported for geodetic data.
    CREATE INDEX cola_spatial_idx_cs
    ON cola_markets_cs(shape)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX;
    --This search only return if distance is 10 000 km...
    SELECT c.name
    FROM cola_markets_cs c
    WHERE
    SDO_WITHIN_DISTANCE(c.shape,
    SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(150.0, 30.1, NULL), NULL, NULL),
    'distance=10000 unit=KM')
    = 'TRUE';
    --According to this search the distance to point 1 is 3331198,72256398,
    --this  should be zero..
    SELECT
    c.mkt_id, c.name, SDO_NN_DISTANCE(1) dist
    FROM cola_markets_cs c
    WHERE SDO_NN(c.shape,
    sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL),
    'sdo_num_res=2', 1) = 'TRUE' ORDER BY dist

    Hi,
    What version of Oracle are you using? I got this using your example:
    SELECT
    c.mkt_id, c.name, SDO_NN_DISTANCE(1) dist
    FROM cola_markets_cs c
    WHERE SDO_NN(c.shape,
    sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL), 'sdo_num_res=2', 1) = 'TRUE'
    ORDER BY dist ;
    MKT_ID NAME DIST
    2 Point 2 0
    1 Point 1 11085.3285
    This is 10.1.0.4
    Also:
    Can I also combine SDO_WITHIN_DISTANCE with SDO_NN_DISTANCE so I can ask for all points 10 km in distance from the reference point and I can also see the actual distance for each point?
    No, but you can add a distance calculation:
    SELECT
    c.mkt_id, c.name, SDO_GEOM.SDO_DISTANCE(c.shape,sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL),1) dist
    FROM cola_markets_cs c
    WHERE SDO_WITHIN_DISTANCE(c.shape,
    sdo_geometry(2001, 8307,sdo_point_type(150.0, 30.1, NULL), NULL, NULL), 'distance=10 unit=km') = 'TRUE'
    ORDER BY dist ;

  • Excel formula to calculate the distance between multiple points using lat/lon coordinates

    I'm currently drawing up a mock database schema with two tables: Booking and Waypoint.
    Booking stores the taxi booking information.
    Waypoint stores the pickup and drop off points during the journey, along with the lat lon position. Each sequence is a stop in the journey.
    How would I calculate the distance between the different stops in each journey (using the lat/lon data) in Excel?
    Is there a way to programmatically define this in Excel, i.e. so that a formula can be placed into the mileagecolumn
    (Booking table),
    lookup the matching sequence (via bookingId)
    for that journey in the Waypointtable
    and return a result?
    Example 1:
    A journey with 2 stops:
    1 1 1 MK4 4FL, 2, Levens Hall Drive, Westcroft, Milton Keynes 52.002529 -0.797623
    2 1 2 MK2 2RD, 55, Westfield Road, Bletchley, Milton Keynes 51.992571 -0.72753
    4.1 miles according to Google, entry made in mileage column
    in Booking table
    where id
    = 1
    Example 2:
    A journey with 3 stops:
    6 3 1 MK7 7DT, 2, Spearmint Close, Walnut Tree, Milton Keynes 52.017486 -0.690113
    7 3 2 MK18 1JL, H S B C, Market Hill, Buckingham 52.000674 -0.987062
    8 3 1 MK17 0FE, 1, Maids Close, Mursley, Milton Keynes 52.040622 -0.759417
    27.7 miles according to Google, entry made in mileage column
    in Booking table
    where id
    = 3
    I understand that 100% accuracy is not possible, so it will not be an issue.

    http://www.cpearson.com/excel/LatLong.aspx
    and
    http://www.contextures.com/excellatitudelongitude.html

  • Calculating a distance between random points.

    Hi everyone,
    so my situation is like this :
    1) I have created a graph containing random points (3 different series). And the graph have three buttons .The first button will plot 30 random points on the chart. the second and third button will plot random point with different colour.
    What I am trying to do now is I need to choose one random point from the 30 points, and calculate the distance from the chosen point to the qrand or qinit..
    How can I do that? I really have no idea. Help!
    public void ForBtn1()
    Random qrand = new Random();
    int[,] points = new int[100, 2];
    int qinitx, qinity;
    for (int i = 0; i < 30; i++)
    int pointx = qrand.Next(0, 100);
    int pointy = qrand.Next(0, 100);
    points[i, 0] = pointx;
    points[i, 1] = pointy;
    qinitx = points[0,0];
    qinity = points[0, 1];
    chart1.Series["Initial Point"].Points.AddXY(pointx, pointy);
    chart1.Series["Initial Location"].Points.AddXY(qinitx,qinity);
    //To initialize random points and initial point
    private void button1_Click(object sender, EventArgs e)
    ForBtn1();
    private void chart1_Click(object sender, EventArgs e)
    //To initialize rand_config
    private void button2_Click(object sender, EventArgs e)
    Random qrand = new Random();
    int[,] points = new int[100, 2];
    int qrandx, qrandy;
    qrandx = qrand.Next(0,100);
    qrandy = qrand.Next(0,100);
    chart1.Series["Random Configuration"].Points.AddXY(qrandx, qrandy);
    private void button3_Click(object sender, EventArgs e)

    i cannot attach the photo here .. i dont know why. but here's the photo . check this link.. i uploaded it to fb.. 
    https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-xpa1/v/t1.0-9/11054299_811876005567689_3794441462666954824_n.jpg?oh=7c9576e4f1f9b2a7e2ac9cf744383051&oe=55AC5BD5&__gda__=1438193773_becbb041c6c51cfc4db4b38c2d18e7a2

  • Distance between GPS points

    I have an application where I am collecting GPS data and all is well, had no problem writing the drivers for gps communication but now I need to calculate displacement between my long and lat readings.  Is there a labview function developed to do this or do I need to figure out the calculations and code it myself.  I am trying to not reinvent the wheel.
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

    There is a vi for the Garmin GPS, here. 
    Here is an application in the Developper's Zone
    You may want to check out this thread
    Message Edited by JoeLabView on 06-13-2007 08:48 AM

  • Minimum distance between access points

    Is it possible to locate 2 ap's (1200s) so close that they desense each other? I'm having some performance issues in an area where the 1200s are pretty close to each other.
    Thanks for any help on this.
    Mark

    Hi Mark,
    It is possible to locate AP's so close that they cause each other problems. Here is a link to a good document for the 1200 AP.
    http://www.cisco.com/en/US/products/hw/wireless/ps430/products_tech_note09186a00805190f1.shtml#topic4
    Here is an excerpt from the actual doc:
    Position the APs Optimally
    "The placement of the APs at the correct places is an important factor that accounts in the extension of the coverage area of the AP. Too many APs in the same vicinity can create radio congestion and interference, and reduce the throughput.
    A careful site survey can determine the best placement of APs for maximum radio coverage and throughput."
    Hope this helps!
    Rob
    Please remember to rate helpful posts...........

  • Getting the length between two points

    Hi All,
    I am trying to get the distance between two points and came across the SDO_LENGTH function in the manual - however there is no example on how to use it.
    I was expecting the following statement to return me the value 9 but instead I am getting errors along the lines of SDO_GEOM.SDO_LENGTH must be declared etc.
    =============================================
    SDO_GEOM.SD0_LENGTH(
    MDSYS.SDO_GEOMETRY(2
    ,NULL
    ,NULL
    ,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
    ,MDSYS.SDO_ORDINATE_ARRAY(1,1,10,10))
    ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.0001)
    ,MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.0001))
    ============================================
    what am I missing
    any help appreciated
    Brent Glover

    I think I have found my answer
    ============================================
    DECLARE
    v_length NUMBER;
    BEGIN
    v_length := SDO_GEOM.SDO_LENGTH(
    MDSYS.SDO_GEOMETRY(2
    ,NULL
    ,NULL
    ,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
    ,MDSYS.SDO_ORDINATE_ARRAY(1,1,10,10))
    ,MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.0001)
    ,MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.0001))
    DBMS_OUTPUT.put_line(v_length);
    END;
    =============================================

  • Calculating co-ordinate distances between specific atoms

    Hi,
    Below is some code to calculate distances between all pairs of atoms. However, i need to make it slightly more specific by only calculating the distance between certain pairs of atoms
    input
    ATOM 5 CA PHE 1 113.142 75.993 130.862
    ATOM 119 CA LEU 7 113.101 72.808 140.110
    ATOM 138 CA ASP 8 109.508 74.207 140.047
    ATOM 150 CA LYS 9 108.132 70.857 141.312
    ATOM 172 CA LEU 10 110.758 70.962 144.119
    e.g distance between all pairs for atoms 5, 119, 150 and 172 (say), last three columns are x,y and z co-ordinates
    code it self
    import java.util.*;
    import java.io.*;
    public class Distance {
    public static void main(String[] args) {
    System.out.println("***Campbells PDB Distance Calculator***" + "\n");
    new Distance();
    System.out.println("\nResults printed to file DistanceCalculations" + "\n");
    System.out.println("\nDue to nature of code, if rerun results will be appended to the end of previous run.");
    public Distance() {
    Vector atomArray = new Vector();
    String line;
    try{
    System.out.println("Enter PDB file:" + "\n");
    BufferedReader inputReader =new BufferedReader (new InputStreamReader(System.in));
    String fileName = inputReader.readLine();
    if ( fileName !=null) {
    BufferedReader inputDistance = new BufferedReader (new FileReader (fileName));
    while (( line = inputDistance.readLine()) !=null && !line.equals(""))
    Atom atom = new Atom(line);
    atomArray.addElement(atom);
    for (int j=0; j<atomArray.size(); j++) {
    for (int k=j+1; k<atomArray.size(); k++) {
    Atom a = (Atom) atomArray.elementAt(j);
    Atom b = (Atom) atomArray.elementAt(k);
    Atom.printDistance (a,b);
    } //if
    } //try
    catch (IOException e) {
    System.out.println("Input file problem");
    } catch (Exception ex) {
    System.out.println (ex);
    class Atom {
    public double x, y, z;
    public String name;
    public Atom(String s) throws IllegalArgumentException {
    try {
    StringTokenizer t = new StringTokenizer (s, " ");
    t.nextToken();
    this.name = t.nextToken();
    for (int j=0; j<3; j++) t.nextToken();
    this.x = new Double(t.nextToken()).doubleValue();
    this.y = new Double(t.nextToken()).doubleValue();
    this.z = new Double(t.nextToken()).doubleValue();
    catch (Exception ex) {
    throw new IllegalArgumentException ("Problem!!!! :-(");
    public String toString() {
    return "atom : " + name + "(x=" + x + " y=" + y + " z=" + z + ")";
    public double distanceFrom (Atom other) {
    return calculateDistance (x, y, z, other.x, other.y, other.z);
    public static double calculateDistance (double x1, double y1, double z1, double x2, double y2, double z2) {
    return Math.sqrt(Math.sqrt(Math.pow(Math.abs(x1-x2),2)+Math.pow(Math.abs(y1-y2),2))+Math.pow(Math.abs(z1-z2),2));
    public static void printDistance (Atom a, Atom b) {
    try{
    FileWriter fw = new FileWriter("DistanceCalculations", true);
    PrintWriter pw = new PrintWriter (fw, true);
    if
    (a.distanceFrom(b) <9){
    pw.println("Distance between " + a.toString() + " and " + b.toString() + " is " + a.distanceFrom(b));
    pw.flush();
    pw.close();
    } // if??
    } //try loop
    catch(IOException e) {
    System.out.println("System error");
    }

    ok, essentially
    want to calculate distance between to ranges. Say
    range 1 is the first three, range 2 the rest. THen
    calculate distance between all possible pairs between
    these two rangesYes - and no doubt that any number of people here could write it for you. But that's not what the forum is about. So what, exactly, is preventing you from doing it?
    Sylvia.

  • MInimun Distance between points

    Hi all, can you help me understand this program so that I can started:
    public static int[] minDistance(int[] x,
    int[] y)
    Given N points in the plane with integer coordinates, determine the minimum distance between two distinct points in the input. The points will be given by two arrays of the same length, one containing the x-coordinates and the other containing the y-coordinates. Return the indices in the array of a pair of points at minimum (positive) distance from each other, least index first. If more than one pair of points have the minimum distance from each other, return the lexicographically first pair (i,j) of indices of closest points.
    Constraints The two arrays will have the same length N, which will be at least two. The numbers in the input arrays will be between -10000 and 10000. Note that you are not guaranteed that there will be no duplicates in the list, but the requirements state that only positive distances are compared.
    Examples
    (1) { 0,1}, {0,1}. This input represents the two points (0,0) and (1,1). Return {0,1}.
    (2) { 0,1,0}, {0,1,0}. Return {0,1} as before, not {0,2}. The point (0,0) occurs twice in the input list, but this does not cause the minimum distance to be zero.
    (3) {0,1,2,3,4,5,6,7,8,9,10}, {0,12,34,-48,15,347,8,5,3,2,1}. Return {8,9}; the points with those indices are (8,3) and (9,2).
    (3a) {0,1,2,3,4,5,6,9,8,7,10}, {0,12,34,-48,15,347,8,2,3,5,1}. Return {7,8}
    Thanks..........

    BTW, what's Sedgewick?He's an author.
    http://www.cs.princeton.edu/~rs/
    A little googling on my part reminds me that it was "divide and conquer" that he was talking about (too many) years ago.
    http://www.facweb.iitkgp.ernet.in/~arijit/courses/autumn2006/cs60001/lec-compugeo-2.pdf

  • Calculating distance between Lat Long points

    I'm wondering if anyone out there has done this before in LabVIEW.  Does anyone have a model of the "Great Circle" calculation?  I have a file of lat/long points that I need to calculate the distance between.  Any help??
    V/r,
    Chris

    I haven't done it in LV, but if you go to Wikipedia and search for Great Circle Distance you'll find the formual and an example.

  • Accurate distance between points, lat/long to miles?

    Hi,
    I have a bunch of points as lat/long data in SRID 8307 format. From reading this forum, I understand than in Oracle 8.1.7 to get accurate distances I need to transform these points into a cartesian coordinate system.
    My data is US-based, so I am using SRID 32775 in a command like the following:
    EXECUTE SDO_CS.TRANSFORM_LAYER('restaurant_locations', 'location', 'restaurant_locations_32775', 32775);
    This creates a new table with new point geometries and a rowid that I assume points back to the original 8307 table.
    I've tried creating an index on the new table with cartesian coordinates, but I get this error:
    CREATE INDEX restaurant_csp_idx
    ON restaurant_locations_32775(geometry)
    INDEXTYPE IS MDSYS.SPATIAL_INDEX
    PARAMETERS('SDO_LEVEL=9 sdo_commit_interval=1000 layer_gtype=POINT' );
    2 3 4 CREATE INDEX restaurant_csp_idx
    ERROR at line 1:
    ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
    ORA-13200: internal error [POINT] in spatial indexing.
    ORA-29400: data cartridge error
    ORA-13003: the specified range for a dimension is invalid
    ORA-06512: at "MDSYS.MD", line 1673
    ORA-06512: at line 1
    ORA-13003: the specified range for a dimension is invalid
    ORA-06512: at "MDSYS.MD", line 1673
    ORA-06512: at line 1
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD", line 8
    ORA-06512: at line 1
    Here's the entry for the 32775-transformed points in the metadata table:
    INSERT INTO USER_SDO_GEOM_METADATA
    VALUES (
    'restaurant_locations_32775',
    'geometry',
    MDSYS.SDO_DIM_ARRAY( -- 20X20 grid, virtually zero tolerance
    MDSYS.SDO_DIM_ELEMENT('X', 1951908.05, 16230214.8, 0.005),
    MDSYS.SDO_DIM_ELEMENT('Y', -6858801, 13168375.5, 0.005)
    32775 -- SRID (reserved for future Spatial releases)
    My questions are;
    Do I need to build a new spatial index? It seems like once I transform the lat/long data to cartesian I need to build a new index as well ( on the 32775-transformed table ).
    Is this the best way to approach distance queries with lat/long data? It seems like a lot of work, plus the second index and table really add to the overhead if a location changes.
    Any ideas on why I can't build an index on the output table from my SDO_CS.TRANSFORM_LAYER() call? I used SDO_TUNE.ESTIMATE_TILING_LEVEL() and SDO_GEOM.VALIDATE_GEOMETRY() and got no complaints. I'm at a loss.
    I also can't seem to get set autotrace to work. It works fine for any non-spatial query, but if I try to trace a spatial query, I get this error:
    SQL> SELECT /*+ INDEX(restaurant_locations restaurant_sp_idx) */ r_a.restaurant_id
    FROM restaurant_locations r_a, restaurant_locations r_b, user_sdo_geom_metadata m
    WHERE r_b.restaurant_id != r_a.restaurant_id
    AND SDO_GEOM.WITHIN_DISTANCE(r_a.location, m.diminfo, 1, r_b.location, m.diminfo) = 'TRUE'
    AND r_b.restaurant_id = '5999';
    2 3 4 5
    RESTAURANT_ID
    456999
    456999
    Execution Plan
    ERROR:
    ORA-01031: insufficient privileges
    SP2-0612: Error generating AUTOTRACE EXPLAIN report
    Statistics
    49 recursive calls
    28 db block gets
    83 consistent gets
    0 physical reads
    0 redo size
    415 bytes sent via SQL*Net to client
    425 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    11 sorts (memory)
    0 sorts (disk)
    2 rows processed
    I've looked at the arraysize, and I've made sure to run the trace-enabling sql and granted plustrace to my DB user.
    Thanks for any help,
    _jason                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi Jason,
    The error on the index create is likely due to data being outside the bounds of the coordinate system as specified in user_sdo_geom_metadata.
    If the data is stored in the point field then you can check the bounds by doing queries like the following, altering them for your table/column name (my table is cities_test, the geometry column name is location):
    SQL> select min(a.location.sdo_point.x) from cities_test a;
    MIN(A.LOCATION.SDO_POINT.X)
    -157.80423
    SQL> select max(a.location.sdo_point.x) from cities_test a;
    MAX(A.LOCATION.SDO_POINT.X)
    -71.017892
    SQL> select max(a.location.sdo_point.y) from cities_test a;
    MAX(A.LOCATION.SDO_POINT.Y)
    61.178368
    SQL> select min(a.location.sdo_point.y) from cities_test a;
    MIN(A.LOCATION.SDO_POINT.Y)
    21.31725
    Do you need to build a spatial index?
    Only if you are going to use spatial operators such as sdo_filter, sdo_relate, sdo_within_distance, and sdo_nn. If you have no requirements for these operators, then there is no reason to build a spatial index. From the trace query at the end of the posting, I suspect that you will need to have a spatial index.
    Is this the best approach? Maybe, it depends on what your requirements are. If the data is static and performance is your highest priority, then maybe it is. If you have a requirement for a spatial index, then certainly it is. If you are only getting the distance between a few few known geometries, and you don't care about the time it takes to convert data on the fly, then you can use the sdo_cs.transform function within the sdo_geom.sdo_distance function to convert both geometries to the equal area projection.
    The validation routines should have caught this - I checked and they do not for 8.1.7, and they do for 9i.
    Regarding the set autotrace command, I'm not sure why it isn't working for you. It works for my generic scott/tiger account from a typical install.
    hope some of this is useful.
    dan
    null

  • Distance between two GPS points

    Is there an inbuilt function in PL/SQL for calulating the distance between two GPS (lat/long) points?
    I'm using Oracle 9i. There's a thing called SDO_GEOM available, but I'm not sure if this is what its used for or if it's the best option.

    If the earth is a complete globe and its circumference is 40000km,
    I make the function as follows.
    create ore replace
    function distance
    (a_lat number,a_lon number,b_lat number, b_lon number)
    return number is
    circum number := 40000; -- kilometers
    pai number := acos(-1);
    a_nx number;
    a_ny number;
    a_nz number;
    b_nx number;
    b_ny number;
    b_nz number;
    inner_product number;
    begin
    if (a_lat=b_lat) and (a_lon=b_lon) then
    return 0;
    else
    a_nx := cos(a_lat*pai/180) * cos(a_lon*pai/180);
    a_ny := cos(a_lat*pai/180) * sin(a_lon*pai/180);
    a_nz := sin(a_lat*pai/180);
    b_nx := cos(b_lat*pai/180) * co s(b_lon*pai/180);
    b_ny := cos(b_lat*pai/180) * sin(b_lon*pai/180);
    b_nz := sin(b_lat*pai/180);
    inner_product := a_nx*b_nx + a_ny*b_ny + a_nz*b_nz;
    if inner_product > 1 then
    return 0;
    else
    return (circum*acos(inner_product))/(2*pai);
    end if;
    end if;
    end;
    I rewrite it by using the factorization and the triangle function's sum and difference formulas:
    cos(x-y) = cos(x)cos(y)+sin(x)sin(y)
    As result, this function is same to the 1st method of Billy Verreynne.
    create or replace
    function distance
    (a_lat number,a_lon number,b_lat number, b_lon number)
    return number is
    circum number := 40000; -- kilometers
    pai number := acos(-1);
    dz number;
    dx2y2 number;
    inner_product number;
    begin
    if (a_lat=b_lat) and (a_lon=b_lon) then
    return 0;
    else
    dz := sin(a_lat*pai/180)*sin(b_lat*pai/180);
    dx2y2 := cos(a_lat*pai/180)*cos(b_lat*pai/180)*cos((a_lon-b_lon)*pai/180);
    inner_product := dz*dz + dx2y2;
    if inner_product > 1 then
    return 0;
    else
    return (circum*acos(inner_product))/(2*pai);
    end if;
    end if;
    end;
    Message was edited by:
    ushitaki

Maybe you are looking for

  • Error while provisioning resource object to any user

    I get below error while trying to provision or reconcile any user to AD resource object. This was working fine till yesterday and suddenly started behaving otherwise. This error occurs while provisioning to the user i.e., as we de-selected auto save

  • How to call a servlet in new window without toolbar from OA page

    How to call a servlet in new window without toolbar from a OA page?Please provide sample code

  • Can't screen share in messages osx mountain lion

    Since upgrading to Mountain Lion, I have been unable to connect to someone else's computer via Messages and share their screen.  I use this to help my parents with computer problems.  I have checked, and their "capabilities" do not show screen sharin

  • Change all page templates in one go

    Hi, Is it possible to change all page templates in all applications in 1 go, we have 100s of applications and want to change the titile tag from <title>#TITLE#</title> to <title>#TITLE# - #APP_VERSION#</title> Thanks in advance. Graham

  • Iis7 and cf8

    Hi, I configured iis7 and cf8. The question is that, do i put my application under inetpub or under coldfusion 8 directory? Weird things happening when i put it on both locations. Sometimes changes dont effect etc. Thank you, Syed