Finding the centroid of a polyline

Hi.
I am trying to write a function that will return the centroid of an input polyline. I have come up with two possible solutions, but both are problematic in different ways...
This first function returns an error:
ORA-00600: internal error code
Our DBA is looking in to this, but so far with no success
The second function seems to work ok, but is very slow. It takes over half an hour to process the first 10,000 records in my table (there are 270,000 in all)
Any suggestions as to what the problem might be with the first function, or how to speed up the second?
Thanks!
1
create or replace function get_line_centroid(geoloc MDSYS.SDO_GEOMETRY) return MDSYS.SDO_GEOMETRY
as
mbr MDSYS.SDO_GEOMETRY;
centroid MDSYS.SDO_GEOMETRY;
begin
mbr := MDSYS.SDO_GEOM.SDO_MBR(geoloc);
If SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(mbr, 0.05) = 'TRUE' Then
centroid := MDSYS.SDO_GEOM.SDO_CENTROID(mbr, 0.05);
End If;
return centroid;
end;
2
create or replace function get_line_centroid(geoloc MDSYS.SDO_GEOMETRY) return MDSYS.SDO_GEOMETRY
as
lrs_seg MDSYS.SDO_GEOMETRY;
centroid MDSYS.SDO_GEOMETRY;
begin
lrs_seg := SDO_LRS.CONVERT_TO_LRS_GEOM(geoloc);
centroid := SDO_LRS.LOCATE_PT(lrs_seg, SDO_LRS.PERCENTAGE_TO_MEASURE(lrs_seg, 50));
return SDO_LRS.CONVERT_TO_STD_GEOM(centroid);
end;

Hi All.
Well I have still not figured why my first function was failing, but I have discovered a much faster alternative to the second one...
This is to perform a manual computation of the centroid using the coordinates in the ordinate array of the line.
Quite straight forward :)

Similar Messages

  • Centroid of a Polyline

    Hi,
    I am trying to find centroid of a polyline. The geometry function SDO_GEOM.SDO_CENTROID does not take polyline object. Is there any method to find the centroid of polyline?
    Thanks in advance.
    Jagan

    Hello Jagan
    I guess you need the centroid on the polyline?
    This is something that's provided in the LRS functions if i'm not mistaken. In case you do not want to use the LRS I've got here a part of a function which could help.
    It is not the nicest code, still I should do the trick or at least maybe get you in the right direction.
    The imput parameters are a the sdo_geometry 2D polyline and an interpolated factor. this should be 0.5 for the centroid, or midpoint of the polyline. (1.0 is end point, 0.0 is startpoint).
    Hope this can help you.
    Luc
    (my_geometry IN MDSYS.SDO_GEOMETRY, vInterpolFactor IN REAL)
                   RETURN MDSYS.SDO_GEOMETRY AS
    -- my_geometry IN is a 2D polyline --
    -- vInterpolFactor IN is a factor indicating at which --
    -- distancefactor a point needs be returned --
    -- 0.0 is startpoint, 1.0 is endpoint --
    -- 0.5 is midpoint (or centroid on the polyline itself --
    -- returns an sdo_geometry POINT --
    my_outPOI MDSYS.SDO_GEOMETRY;
    my_length REAL;
    my_IntDist REAL;
    my_TempDist REAL := 0;
    my_XCoord2 REAL;
    my_YCoord2 REAL;
    my_XCoord1 REAL;
    my_YCoord1 REAL;
    my_XCoordInt REAL;
    my_YCoordInt REAL;
    my_XCoordOffset REAL;
    my_YCoordOffset REAL;
    my_Count INTEGER;
    i INTEGER := 1;
    pi CONSTANT REAL := 4 * ATAN(1);
    my_DeltaX REAL;
    my_DeltaY REAL;
    my_LastLeg Real;
    my_LLIntDist REAL;
    my_Argument REAL;
    my_TGOmega REAL;
    my_Rotation REAL;
    my_dim CONSTANT INTEGER := 2;
    my_Offsfactor CONSTANT INTEGER := 10;
    l_tekst varchar2(250);
    BEGIN
    my_length := SDO_GEOM.SDO_LENGTH(my_geometry, my_dim);
    my_IntDist := my_length * vInterpolFactor;
    my_XCoord2 := my_geometry.SDO_ORDINATES(i);
    my_yCoord2 := my_geometry.SDO_ORDINATES(i+1);
    my_Count := my_geometry.SDO_ORDINATES.COUNT ;
    i := i + my_dim;
    WHILE NOT(FLOOR(my_IntDist) < my_TempDist) AND (NOT (i-my_dim = (my_Count - 1))) LOOP
    -- i := i + my_dim;
    my_XCoord1 := my_XCoord2;
    my_YCoord1 := my_YCoord2;
    my_XCoord2 := my_geometry.SDO_ORDINATES(i);
    my_yCoord2 := my_geometry.SDO_ORDINATES(i+1);
    my_DeltaX := my_XCoord2 - my_XCoord1;
    my_DeltaY := my_YCoord2 - my_YCoord1;
    my_LastLeg := SQRT((my_DeltaX**2) + (my_DeltaY**2));
    my_TempDist := my_TempDist + my_LastLeg;
    i := i + my_dim;
    END LOOP;
    my_LLIntDist := my_LastLeg - (my_TempDist - my_IntDist);
    IF (my_DeltaY = 0) THEN
    IF (my_DeltaX > 0) THEN
    my_Argument := pi / 2;
    ELSE
    my_Argument := 3 * (pi / 2);
    END IF;
    ELSE
    my_TGOmega := ABS(my_DELTAX) / ABS(my_DeltaY);
    IF (my_DeltaX > 0) THEN
    IF (my_DeltaY > 0) THEN
    my_Argument := ATAN(my_TGOmega);
    ELSE
    my_Argument := pi - ATAN(my_TGOmega);
    END IF;
    ELSE
    IF (my_DeltaY > 0) THEN
    my_Argument := 2 * pi - ATAN(my_TGOmega);
    ELSE
    my_Argument := pi + ATAN(my_TGOmega);
    END IF;
    END IF;
    END IF;
    my_XcoordInt := my_Xcoord1 + my_LLIntDist * Sin(my_Argument);
    my_YcoordInt := my_Ycoord1 + my_LLIntDist * Cos(my_Argument);
    my_outPOI := MDSYS.SDO_GEOMETRY
    2001,
    NULL,
    mdsys.sdo_point_type(my_XcoordInt , my_YcoordInt , NULL),
    NULL,
    NULL
    RETURN my_outPOI;
    END;

  • How to find image centroid & seperation between two images

    How to find image centroid and seperation between the images,
    i have 2 images pixel values as shown in the picture i should calculate the centroid of the image & find the distance of seperation of the image.
    help me how to do this
    I am using LabView 7.1
    thanks
    sk 
    Attachments:
    New Folder.zip ‏736 KB

    I have a center of energy program similar to the one used by IMAQ. I have attached an example using your data. I first found the center of the entire image. Then I split the array in two and found the centers of each half. That gives you the position of the two spots. This program won't work if the spots are too close to each other or are separeted in the other axis.
    Attachments:
    distance between two spots one direction.vi ‏1096 KB
    Center of energy calc.vi ‏40 KB

  • How to obtain an image subset and the centroid of the subset

    How can we obtain a subset of an image and find its centroid.I used picture function to find subset but finding centroid is possible only thru IMAQ toolbar.so how to combine both operations?

    Hai,
    This is not the correct thread to post ur technical queries. Post in the LabVIEW forum.

  • Programatically Creating a SDO GEOMETRY Object and Finding its Centroid

    Dear Gurus,
    I have the following requirement.
    List of Lat Long pairs will be loaded from a text file. Ex: List<String> list = new ArrayList<String>(); //Here String is lat value,long value_
    Each list contains lat lon pairs of a polygon.
    Similarly we have n number of lists.From each list, using the lat long pairs i need to find out the centroid. Can you please suggest me the best way of doing it.
    ** Note : we don't have any DB operations. Everything needs to be done using Java API.
    Thanks & Regards,
    Kiran Konjeti

    This is more a mathematical question
    This should be the solution http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/
    Timo

  • I have bought a film from itunes and the credit has come out of my account, but i can't find the film anywhere, it said it was downloading, then i left the laptop and on return i couldn't find the film. how do i find the film?

    i have bought a film from itunes and the credit has come out of my account, but i can't find the film anywhere, it said it was downloading, then i left the laptop and on return i couldn't find the film. how do i find the film?

    Maybe it is in the Purchased category of iTunes,
    Try going there

  • HT1349 How do you get help from apple if you don't know where to find the serial number of my "product."  I don't know if they mean my itunes program, my iphone, my computer, which one, the number on the computer (is there one), or something in Windows or

    How are you supposed to get help from Apple if you don't know what your serial number is?  They say to input the serial number of the "product" that you are asking about.  Since my problem is how to deauthorize/authorize computers, and they are saying I have more than 5 (which I have never owned more than 5 computers in my life), I can't imagine what serial number they mean.  Does it mean your desktop computer?  If so, which one?  Do they mean your device?  LIke your iPhone, iPod or whatever?  Do they mean the software ON one of your computers and/or devices?  If so, which program, and on which computer/device?
    We have three operational computers, one does not have iTunes on it.  Since Apple is saying I have more than 5 authorized computers, and I can't imagine what they are, I am afraid to deauthorize all my computers.  See what I mean?  I just wanted to ask the question about how I can find out WHICH computers Apple thinks I have authorized, so I can decide if it's safe to deauthorize them all or not.  I only know of 2 computers that have iTunes on them, so how can there be 5?  We also have 2 iPhones and 2 iPods in this family, but one of the iPhones has his own apple id.  He may have been using mine, since his computer died.  I read that those don't count as "computers" to the 5.  Do they, then?
    Help!  I can't contact apple because I have no idea what they mean about serial number.  I doubt they would help me anyway.  In order to get the serial number off my desktop computer (that has iTunes on it already), I will have to move furniture, so I don't want to if that's not it.  Is there some way to find the serial number in the software, either on my desktop or my iPhone?

    sunshinecowgill wrote:
    We have three operational computers, one does not have iTunes on it.  Since Apple is saying I have more than 5 authorized computers, and I can't imagine what they are, I am afraid to deauthorize all my computers.  See what I mean?  I just wanted to ask the question about how I can find out WHICH computers Apple thinks I have authorized, so I can decide if it's safe to deauthorize them all or not. 
    You could have more 5 computers authorized if you ever, for example, reformatted a hard drive or replaced a hard drive without deauthorizing the computer first. Apple's system would see that as a different computer, even though you don't. There's nothing to be afraid of in deauthorizing everything and the reauthorizing what you actually have. You won't lose any data. Mistimp is correct, they can't tell you which computers are authorized.

  • How do I find the total size of all my Music in iTunes 11?

    I'm looking to get a new iPod, either a nano or Touch, so I'm trying to find the total size of all of my Music. Since iTunes 11's interface is so different from previous versions, I don't see a way to view that.

    Ctrl B to show top menu
    View Show Status Bar to show the grey bar at the bottom with the info you want.
    While your there View> Show Sidebar and see if you prefer that.

  • How do I find the cookies I want to keep

    Recently I asked for some help but I think my request has got lost.
    I had beenadvised to save the cookies I want to keep but this is beyond me.
    My question is how do I find the cookie I want to keep? It is a cookie for an ebook and I have no idea what it is.
    Will deleting all other cookies mean that it will also delete my passwords and log ins on several sites? I don't want this to happen.
    Which brings me to the last point - You say that if I list exceptions to cookies I want to keep (at least I think that is what you mean), how do I find all those cookies?
    Again, sorry for troubling you but until I can find out more about the cookies, I don't want to delete these in case I delete the wrong ones, such as the ebook.
    Thank you cor-el. I do appreciate your advice...enormously.
    Anthony

    Dear Sir,
    Thank you so much for the above. It will be of great help in telling me where to go. But my problem is that if I can find cookies, I don't know which ones I want to keep. Are they labelled with the sites they refer to? If so that will help me. Apart from one which is the cookie I need to get to my online ebook, I guess there are cookies for the various passwords I have saved?
    Forgive me but I am an old man and not real great with computers.
    Thanks,
    Anthony

  • In Mountain Lion, how do I find the location of an open Preview File?  The file "properties" tab is no longer available.

    I typically have several open Preview files at any one time and often forget where, sometimes if, I saved them.  In Mountain Lion, how do I find the location of an open Preview File?  Tried holding option + command in spotlight but I don't see a path name appear anywhere. 

    Yes, cmd-option on a file you choose in Spotlight and the path will appear at the bottom of the Preview window.
    EDIT: Also, if it is bookmarked the path is in Bookmarks.

  • How do I find the position of a single character on a page?

    Hi guys,
    I am developing a PDFEditor, but am having trouble implementing the code which finds the location of glyph characters on a page (in device space). I have read the pdf reference on Text, but do not quite understand it.
    I have worked out the individual character spacings, but I cannot accurately find the location of the first character .
    Here is my current attempt:
    float y = CGPDFPageGetBoxRect([current_page pageReference], kCGPDFCropBox).size.height-current_matrix_position.y;
    float x = current_matrix_position.x;
    float xa = a * x + c * y + e;
    float ya = b * x + d * y + f;
    text_position = [NSValue valueWithCGRect: CGRectMake(xa, ya, 15, d)];
    (where text_position is the location of the start character in device space. a,b,c etc come from the Tm operator.
    current_matrix_position is set as a point (e,f) from the cm operator.)
    This code seems to work with some PDF files:
    But does not work with others:
    (Note there is text in the box above the blue which cannot be disclosed for reasons...)
    Is there something I am missing (like another operator?) or is my formula completely wrong.
    Your help would be greatly appreciated

    Hi Irosenth,
    I have been reading the spec and trying to understand it for several weeks. Unfortunately, I am still confused with how to find the coordinates of the text.
    >> You need to parse the content stream(s) that are associated with the page and
    I have done this. My program finds both the cm operator, the tm operator and the font widths etc. Unfortunately, now that I have all of this information, I am unsure what to do with it.
    How do I properly add these two matricies together? I have looked in the spec which describes it as:
    x' = a * x + c * y + e
    y' = b * x + d * y + f
    I tried this and the results worked on some pages, but not on others (several thousand x coordinates out...). I am finding the ISO 32000-1:2008 very confusing in this section.
    >> manage what you find there
    This is the part I am having major trouble with. Using the coordinate transformation matricies, how can I determine the starting coordinate for the first glyph in a text (BT, ET) on a non-scaled page (so 1 unit = 1 pixel) using the matricies?
    Thanks

  • How do i find the length of a string??

    trying to use the substring, I know the beginIndex (in my case 10), but the string will vary in size and so i need to find the last character and set it as the endIndex, how do i do this?
    public String substring(int beginIndex,
    int endIndex)Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
    Examples:
    "hamburger".substring(4, 8) returns "urge"
    "smiles".substring(1, 5) returns "mile"
    Parameters:
    beginIndex - the beginning index, inclusive.
    endIndex - the ending index, exclusive.
    Returns:
    the specified substring.

    Hi
    To substring the string where u know the begin index and want to extract till the end use the following function from the String class of the java.lang package
    String substring(int beginindex);
    String test = "Hello";
    String xx = test.substring(1);
    The Value stored in xx will be ello
    This is in case u need till the end of the String
    If wanna skip the last character u can
    use
    String substring(int beginindex,int endindex);
    String test = "Hello";
    String xx = test.substring(1,test.length()-1);
    The Value stored in xx will be ell

  • How do I find the original photo that is used in one of my contact photo in "Contacts"?

    Hi everyone,
    I am in a bit of a dilemma. I desperately need to find and/or access the original photo used as a contacts photo in the OSX built in app "Contacts". I can resize the photo and I can see it in full but I can't find the original anywhere and in any way.
    I'd really appreciate some help here, as the photo is dear to my heart but seems to have gone missing. It was originally scanned in but isn't showing up where all my scanned photos are saved. Eek!
    If anyone has any pointers on where I could find this photo in its original size, please do share them!
    Ta,
    posies

    Hi DonTimo,
    I've tried doing that, but in the said folder there are only default pictures. I can't find the images of any contacts in the app "Contacts" anywhere. The thread you refered me to and many others that are smilar to it, date back to about 2009-2010.
    Really need this photo.  Any other pointers?

  • Error while installing exchange2007 : Unable to initialize the Microsoft Exchange Information Store service. Failed to find the

    Hi,
    I am trying fresh install of exchange2007, everything gone well but, finally it thrown a error saying :
    Unable to initialize the Microsoft Exchange Information Store service. Failed to find the working directory parameter from the registry - Error 0x80004005.
    the installation log says
    6/5/2007 3:14:05 PM] [1] Processing component 'Mailbox Service Control (Last)' (Starting mailbox services).
    [6/5/2007 3:14:05 PM] [1] Executing 'start-SetupService -ServiceName MSExchangeIS -MaximumWaitTime "unlimited"', handleError = False
    [6/5/2007 3:14:05 PM] [2] Launching sub-task '$error.Clear(); start-SetupService -ServiceName MSExchangeIS -MaximumWaitTime "unlimited"'.
    [6/5/2007 3:14:05 PM] [2] Beginning processing.
    [6/5/2007 3:14:05 PM] [2] The maximum wait for the operation is set to 'unlimited'.
    [6/5/2007 3:14:05 PM] [2] Service checkpoint has progressed. Previous checkpoint='0' - Current checkpoint='1'.
    [6/5/2007 3:14:05 PM] [2] Will wait '10000' milliseconds for the service 'MSExchangeIS' to reach status 'Running'.
    [6/5/2007 3:14:15 PM] [2] Service 'MSExchangeIS' failed to reach status 'Running' on this server after waiting for '10000' milliseconds.
    [6/5/2007 3:14:15 PM] [2] Service 'MSExchangeIS' failed to start. Check the event log for possible reasons for the service start failure.
    [6/5/2007 3:14:15 PM] [2] [ERROR] Unexpected Error
    [6/5/2007 3:14:15 PM] [2] [ERROR] Service 'MSExchangeIS' failed to start. Check the event log for possible reasons for the service start failure.
    [6/5/2007 3:14:15 PM] [2] Ending processing.
    [6/5/2007 3:14:15 PM] [1] The following 1 error(s) occurred during task execution:
    [6/5/2007 3:14:15 PM] [1] 0.  ErrorRecord: Service 'MSExchangeIS' failed to start. Check the event log for possible reasons for the service start failure.
    [6/5/2007 3:14:15 PM] [1] 0.  ErrorRecord: Microsoft.Exchange.Configuration.Tasks.ServiceFailedToStartException: Service 'MSExchangeIS' failed to start. Check the event log for possible reasons for the service start failure.
    [6/5/2007 3:14:15 PM] [1] [ERROR] Service 'MSExchangeIS' failed to start. Check the event log for possible reasons for the service start failure.
    [6/5/2007 3:14:15 PM] [1] Setup is halting task execution because of one or more errors in a critical task.
    [6/5/2007 3:14:15 PM] [1] Finished executing component tasks.
    [6/5/2007 3:14:15 PM] [1] Ending processing.
    [6/5/2007 3:14:18 PM] [0] End of Setup
    [6/5/2007 3:14:18 PM] [0] **********************************************
    this I am trying on my test system please help me out in resolving the issue
    thanks in advance,

    Gary,
    Open Registry Editor.
    In Registry Editor, navigate to the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchangeIS\ParametersSystem
    Create the following value (REG_SZ): Working Directory and give it a value that points to the new database folder.
    Make sure you back up the registry before you do any changes on it.
    Raj

  • Airport TimeCapsule wireless works fine, but iMac can no longer find the time capsule disk for backups.

    Hi,
    I have a new Airport TimeCapsule that I set up about two weeks ago in combination with a new iMac running OS 10.9.4.  It ran fine until 2 days ago, when the TC disk image disappeared from the iMac and Time Machine was not able to back up.  I tried to find the TC in Airport Utility and it states the "Airport Time Capsule was previously part of your network. Check that it is still in range of your network and is plugged into a power outlet..."  I've tried restarting the time capsule. I've tried restarting everything in order (modem>TC>iMac) and the iMac still cannot see the TC disk.
    I've had two other issues that I will list in case they are all related somehow:
    1) The time capsule took several attempts to set up when I first bought it.  I had to reset the TC several times before I got all the way through the set up process successfully.
    2) I tried hooking up my printer to the USB port on the airport time capsule and although my MacBook could see it and print to it just fine, my iMac was never able to see it.
    The TC is hooked up to the iMac via ethernet cable.  Does any of this sound familiar to anyone?  I'm about ready to send the time capsule back and just resurrect my old airport that worked flawlessly for years.  This airport TC has been a huge disappointment so far.
    Thanks

    There are some real issues between Mavericks and TC .. (or just network bugginess!!)
    There is a heap of things you can do but it is easier to just run through the whole lot in order. None is necessarily the cure and that is why doing all is important.
    The list is in this thread.
    Airport Utility shows "unexpected error - please try again" when connecting to Time Capsule
    In your case using ethernet can be a problem.. let me say please make sure you have ipv6 set to link-local only in your ethernet setup. I usually only show it in wireless but for you it must be ethernet. The wireless connection seems to be utterly required now for connection.. and hidden away into the airport utility is a switch over from wireless to ethernet. When I made the manual setup instructions above this particular ability (or stupidity) of the Airport Utility was not apparent to me.
    So here is typical Airport Utility (AU) v6.. but it is actually working over wireless only. (The v5 utility was wireless + ethernet).
    I have an ethernet client on the network that is completely invisible.
    Click on the Other WiFi Devices (wrongly named.. it should say other devices).
    And you will see the option to choose ethernet.
    Then the AU sees the ethernet client and none of the wireless clients.. brilliant stuff eh??
    PS this is just a test setup.. never would I have any TC with such an illegal name.. But I hope it shows you what to do.
    Fix the names.. most important.. keep them short.. less than 10 characters all the better.
    No spaces and pure alphanumeric.

Maybe you are looking for

  • Error Validation In PO Creation

    Hi Gurus, I'm trying to create a PO in transaction ME21N. There are no validation on vendor and company code mapping, error message should occur. This error should come up upon PO creation since the vendor is not created for company code. How can I d

  • How to make the stage transparent for SWF file being used in Dreamweaver

    I have a SWF file in my Dreamweaver site, that plays correctly. The problem is that the stage is white and we would like it to be transparent. Searching the archives the following advice was given: in your html embedding code you need to set the wmod

  • How to change page size from A5 to A4 in CS3

    How do I change the pagesize of my booklet from A5 to A4 - basically I just want to blow the whole thing up a notch... I've tried to activate automatic layout adjust and then changing document settings but the result is scattered objects that are sti

  • This SQL statement always in Top Activity, with PX Deq Credit: send blkd

    Hi gurus, The following SQL statement is always among the Top Activity. I can see the details in Enerprise manager that it suffers from PX Deq Credit: send blkd This is the statement: SELECT S.Product, S.WH_CODE, S.RACK, S.BATCH, S.EXP_DATE, FLOOR(Qt

  • Abap query - print

    i have a abap query i would like to control the print . When personal number change i would like to create a new page for the print . how can i do this in abap query ? ?