Flattening an array

I know how to flatten the sdo_ordinates array...
select *
from table (
select a.geo.sdo_ordinates
from states a
where a.state = 'California');
But we now have a need to be able to flatten the
sdo_ordinate array so that we can access the ordinates
in a more natural form as the X and Y elements of a 2D
geometry.
I know this is wrong but something like...
select X, Y
from table (
select a.geo.sdo_ordinates
from states a
where a.state = 'California');
The preferred method for doing this is via a view.
I am on 8.1.7.4 so any approach needs to keep this in mind.
Any suggestions?
S.

Dan,
8.1.7.4 was more picky and needed a CAST() to make it work.
The version I implemented (+ the view) is as follows:
==========================================
DEFINE defaultSchema = 'GIS'
CREATE OR REPLACE TYPE &defaultSchema..Coord2DType AS OBJECT (
x number,
y number );
show errors
grant execute on &defaultSchema..Coord2DType to public with grant option;
create or replace type Coord2DSetType
as table of &defaultSchema..Coord2DType
grant execute on &defaultSchema..Coord2DSetType to public with grant option;
drop function GetCoord2D;
create or replace function GetCoord2D (p_shape in mdsys.sdo_geometry)
return &defaultSchema..Coord2DSetType deterministic
is
v_shape mdsys.sdo_geometry := p_shape;
i number := 1;
coords &defaultSchema..Coord2DSetType := Coord2DSetType();
coordOffset number;
begin
while i < v_shape.sdo_ordinates.count
loop
coordOffset := (i+1)/2;
coords.extend;
coords(coordOffset) := &defaultSchema..Coord2DType(null,null);
coords(coordOffset).x := v_shape.sdo_ordinates(i);
coords(coordOffset).y := v_shape.sdo_ordinates(i+1);
i := i + 2;
end loop;
return coords;
end;
grant execute on &defaultSchema..GetCoord2D to public with grant option;
select shape from propright.pr_a where rownum = 1;
show errors
DECLARE
coords &defaultSchema..Coord2DSetType := Coord2DSetType();
v_shape mdsys.sdo_geometry;
BEGIN
select shape into v_shape from propright.pr_a where rownum = 1;
coords := GetCoord2D(v_shape);
END;
select rownum,coords.*
from propright.pr_a a, table(CAST(GetCoord2D(shape) AS Coord2DSetType)) coords
where a.pr_id = 14353;
The view is:
create or replace view pr_p
as
select property_right_id as pr_id, mdsys.sdo_geometry(2001,NULL,MDSYS.SDO_POINT_TYPE(coords.x,coords.y,NULL),NULL,NULL) as shape
from propright.property_right a, table(CAST(gis.GetCoord2D(a.shape) AS gis.Coord2DSetType)) coords;
==========================================
I now use the view to export data to a shapefile. So
now we can export the polygon as a polygon or as
a point shapefile! (Believe it or not this is a legal
requirement that we have to meet.)
Thanks mate,
S.

Similar Messages

  • How to flatten an array splice?

    var foo:Array = [1, 2, 3 ];
    var bar:Array = [9,10 ];
    foo.splice(2, 0, bar) == [1,2,[9,10],3]
    How can i splice in bar so i get a single flat result
    [1,2,9,10,3]?
    I know i could loop over bar and splice in each individual
    member into foo, but is there a more efficient option?
    Thank you.

    I'm not sure if this is more execution-time efficient, but
    code-wise it's more succinct.
    foo.splice.apply(foo, [2, 0].concat(bar));

  • How does flatten to string work with arrays?

    Hi all,
    I'm currently trying to get my head around how flatten to string works in terms of using it to write a configuration file which is loaded on startup in my VI. Writing and loading the configuration file is no problem and it is working beautifully. However... this is for a data acquisition system and the configuration file stores all the calibration data in the system which is entered through arrays. Anyway, the data recorded by my VI is to be post processed using MATLAB and needs to apply the calibration data stored in the configuration file.
    So I've been trying to work out how to get MATLAB to decypher the configuration file, but... I can't make heads or tails as to how the data is written into the file. I made a mock up of the saving file routine as you can see below, and run it a number of times by changing the input array dimensions and the values.
    Then opened the saved file to see if I can find a pattern... but I can't! Simply changing the element values changes the number of "\   \'s" Here is what I produced from my trials:
    [1x1 0]
    Config=\00\00\00\01\00\00\00\00\00\00\00\00      (1x1 array of 0's)
    [1x1 1]
    Config=\00\00\00\01?ð\00\00\00\00\00\00            (1x1 array of 1's)
    [1x1 2]
    Config=\00\00\00\01@\00\00\00\00\00\00\00       (1x1 array of 2's)
    [1x2 0]
    Config=\00\00\00\02\00\00\00\00\00\00\00\00\00\00\​00\00\00\00\00\00      (1x2 array of 0's)
    [1x2 1]
    Config=\00\00\00\02?ð\00\00\00\00\00\00?ð\00\00\00​\00\00\00                  (1x2 array of 1's)
    [1x2 2]
    Config=\00\00\00\02?ð\00\00\00\00\00\00?ð\00\00\00​\00\00\00                  (1x2 array of 2's) etc. etc. etc
    [2x2 0]
    Config=\00\00\00\02\00\00\00\02\00\00\00\00\00\00\​00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00​\00\00\00\00\00\00\00\00\00     
    [2x2 1]
    Config=\00\00\00\02\00\00\00\02?ð\00\00\00\00\00\0​0?ð\00\00\00\00\00\00?ð\00\00\00\00\00\00?ð\00\00\​00\00\00\00
    [2x2 2]
    Config=\00\00\00\02\00\00\00\02@\00\00\00\00\00\00​\00@\00\00\00\00\00\00\00@\00\00\00\00\00\00\00@\0​0\00\00\00\00\00\00
    Could someone explain to me how flatten to string flattens the array information? Particularly when the array elements are double precision? I look forward to any help that anyone can offer!
    Thanks,
    Stirling
    Message Edited by stirlsilver on 09-08-2007 08:47 AM
    Attachments:
    saveconfig.png ‏7 KB

    There are optional inputs to "flatten to string" That you can use to modify the outcome as needed. For example you can do little endian.
    You can also omit the array size from the flattened data (definitely not recommended for 2D arrays).
    LabVIEW Champion . Do more with less code and in less time .

  • Read array tags with OPC (not DS) -- LV6.1

    Hello DSC experts:
    The Siemens OPC server to which I am connected publishes array tags and I cannot change that fact. I can read those array tags using the "Datasocket Read Double Vector.vi" but as the number of tags grows this slow method becomes unreliable. Instead I would like to use DSC but I do not see any Vi that allows me to read vector tags? Like I said I have to live with the OPC configuration as it is today hence I do not think that going through the flatten/unflatten to string method is an alternative.
    Any clue?
    Thanks a lot,
    Chris

    Can you do any kind of array indexing when addressing the tag inside the opc server?? Something like tagname.xx or tagname[xx] where you would select a portion of the tagname array data. Could you talk directly with the VISA drivers and use a read multiple registers command instead of a DSC driver?? To my knowledge, the tag engine does not support array addressing for a tag datatype. I do use the method of flattening an array of data into a binary string and writing it to a memory tag, but the array data is created inside labview. I submitted DSC tag array datatype to a request list quite some time ago but never heard anything about it again. I wonder if a DDE connection could be established to read string data. Then do a string to number conversion. What version
    of Siemens hardware/software are you using?? I think the tag engine really is lacking with respect to the capabilites of the latest OPC software. I would love to see NI directly integrate an OPC program like KEPWARE so you did not have to use the tag engine. Are you using serial or ethernet communication??

  • Null Characters in Flatten to String

    Hi all,
    I am using the Flatten to String Function to convert a numerical array to a flattened data string in hexadecimal. When I do this, it adds 6 null characters (zeros) before every array element. How can I flatten my array without the addition of these null characters?
    Thanks,
    Jasmine
    Solved!
    Go to Solution.

    Now that I'm looking at your code, that can be simplified A LOT.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Flatten to String.png ‏25 KB

  • Anyone know how to add a string to a 1d array with file info, then be able to read back, display string, and sort data array.

    I need to store a data array and include text that describes what the data is. (using for various configuration files.) Anyway, I would like to be able to save the string as part of the txt file, and somehow read it back, remove the (various length string), and display it in an indicator. All the while, not causing too much problem with the initial data array.
    Thanks in advance!!

    There are several ways to do what you require. A simple method would be to use an ASCII text file. When writing one of those, you just need to basically build a gaint string starting with the description text you want. We like to call that a header. Once you've got the header, make some sort of delimiter like a bunch of "-" or two sets of ( EOL = End of Line = CRLF = \r\n ). After your delimiter, concatenate your array in string form or flatten your array from its native form into a string and tack it on the file (append).
    See the (very quick) example attached.
    Dan Press
    www.primetest.com
    Attachments:
    fileheader.vi ‏41 KB

  • Pass javascript array to java

    hii
    I have to pass a javascript array to my java MyAction.do . So how can i do it???
    Thnking You

    Being a Java newbie, I can't give you a definitive on how to pass the array to a client-side applet, although it should be possible.
    As for passing it to something server-side there are only a couple ways: in a GET request on the query string or in a POST. No matter what, you will have to flatten the array with some method or other, to convert it into a text string that can be parsed on the other end.
    I personally favor using hidden form elements and posting the data, because otherwise you have to worry about urlencoding your query string. You could just use javascript itself to write a series of hidden text inputs and then submit the form, so all your form handler has to do is pick up the variables.
    Let's say the array is named "myarray":
    Code:
    +<script language="Javascript">+
    document.writeln("<form name=\"myform\" method=\"POST\" action=\"myserver/myhandler.jsp\">")
    for(i = 0; i < myarray.length; i+){+
    document.writeln("<input type=\"hidden\" name=\"myarray[" i + "]\" value=\"" + myarray[i] + "\">")+
    +}+
    +document.writeln("</form>")+
    +document.myform.submit()+
    +</script>+
    I know this is clunky and "low-tech" but it will work, and has the benefit of working for any server-side platform that can handle forms

  • Txt Array to XML

    I have a 2D array string which I want to put in xml with the first row (the headers) as the tags when its in xml. At the moment when I flatten the array it treats them as just any other row and uses labviews own tags. How can I seperate the first row and make it the tags
    Solved!
    Go to Solution.

    "first matched node" and "child" refer to XML elements. You may wish to go through a basic XML tutorial, such as the one at w3schools.com.
    And, if you haven't gone through the LabVIEW tutorial, you should also go through those. You can also look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

  • How to get all the values of the SDO_ORDINATE_ARRAY of a Oriented Point

    Hi,
    I'm trying to get the values of a Geometry wich is an Oriented Point. To that, i'm using SDO_UTIL.GETVERTICES, but this utility only obtains the point X,Y, it doesn't obtain the values of the orientation vector.
    The Geometry is this:
    MDSYS.SDO_GEOMETRY(
         2001,8307,NULL,
         MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1,3,1,0),
         MDSYS.SDO_ORDINATE_ARRAY(-75.586088632813272,6.1794352615514194,0.57278169530235967,-0.81970795380217887,0)
    The query is this:
    SELECT c.ipid, c.nombre, t.X, t.Y, t.Z, t.W
    FROM Hidrantes c,
    TABLE(SDO_UTIL.GETVERTICES(c.geometria)) t
    where c.ipid = 4691117
    ORDER BY c.ipid, t.id;
    Result:
    4691117          -75,5860886328133     6,17943526155142          (null) (null)
    As you can see, it only obtains the X,Y values but not the values of the orientation vector, how can I get the values?.
    Thanks in advance

    Tobonale,
    Sql-Only approaches:
    *[1] Return Oridinate Array*
    Append .SDO_ORDINATES to your geometry object or column name:
    SELECT MDSYS.SDO_GEOMETRY(
         2001,8307,NULL,
         MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1,3,1,0),
         MDSYS.SDO_ORDINATE_ARRAY(-75.586088632813272,6.1794352615514194,0.57278169530235967,-0.81970795380217887,0)
    ).SDO_ORDINATES
    FROM dualResult:
    SDO_ORDINATE_ARRAY(-75.586089, 6.17943526, .572781695, -.81970795, 0)*[2] Return Flattened Oradinate Array*
    SELECT * FROM
    TABLE (
         MDSYS.SDO_GEOMETRY(
         2001,8307,NULL,
         MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1,3,1,0),
         MDSYS.SDO_ORDINATE_ARRAY(-75.586088632813272,6.1794352615514194,0.57278169530235967,-0.81970795380217887,0)).SDO_ORDINATES
    )Result:
      -75.586089
      6.17943526
      .572781695
      -.81970795
               0Regards,
    Noel

  • How does "Unflatten From String" take a type and return a value of that type?

    http://zone.ni.com/reference/en-XX/help/371361E-01/glang/unflatten_from_string/
    How exactly does the "type" argument for "Unflatten From String" work? I need to create a VI that takes a type, passes it as an argument to several calls of the "Unflatten From String" function, and returns an array containing elements of the type originally passed. The "Unflatten From String" function seems to do some magic though, because the type of the "value" that it outputs changes depending on the type it is passed as input. How do I do the same magic in my VI?
    Ultimately, what I need to accomplish is an unflatten-list operation. Given a type T and a byte string of length L (which contains a concatenation of T elements that are flattened to their bytes), create a VI that unflattens all the types in the string and return an array of length (L / sizeof(T)) that contains each type.
    Note: performing the unflatten-list operation is trivial, but I cannot for the life of me figure out how to do it in a VI that takes a type and returns an array of the appropriate type. By the way, my data is being given to me from another source, so please don't bother suggesting that I should be flattening an array using LabVIEW's "Flatten To String" function in the first place. My data is not given in LabVIEW's array format: http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/flattened_data/
    Thanks a ton!
    -Wakka

    Take a look at this example:  You can see that the flattened string contains several bytes.  The first four bytes contain the length of array (number of elements).  Since the data type is U32, the next 32 bits (4 bytes) contains the value of the first element, and so on.  Could you possibly use this scheme to do what you want to do?  Other data types present different outputs.  You would have to experiment with them.
    - tbob
    Inventor of the WORM Global

  • Trying to customize a multiple item lookup field using JSLink

    I'm trying to Customize a multiple item lookup field using JSLink, in SP 2013. This illustrates what I want to do:
    I can replace the ";" with <br /> in the Text column, but not the Lookup column. Here is the JSLink code I'm using for the Text column. 
    (function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Fields = {
    'Text': { 'View' : '<#=ctx.CurrentItem.Text.toString().replace(";","<br />")#>' }
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
    How can I display each item on separate lines in the Lookup column?

    You can retrieve the values of the lookup column and reformat their display by replacing the following:
    overrideCtx.Templates.Fields = {
    'Text': { 'View' : '<#=ctx.CurrentItem.Text.toString().replace(";","<br />")#>' }
    with something like this:
    overrideCtx.Templates.Fields = {
    'Lookup': { 'View' : function(ctx) {
    var arr=[];
    var fld=ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    for (i=0; i<fld.length; i++) {
    arr.push(fld[i].lookupValue);
    return arr.join("<br/>");
    Here we are looping through each lookup value contained in the multi value lookup field and adding it to an array. Once complete, we use join to flatten the array and separate each entry with the <br/>. Note...this will show each value on a new line,
    but it will be the string value without the hyperlink.  If you want the actual hyperlink to the item, you can rebuild the hyperlink and add that to the array instead. You can get the item's display form from ctx.CurrentFieldSchema.DispFormUrl and the
    item's id from fld[i].lookupId for rebuilding the hyperlink.

  • Hirarchical JSON Queries on Twitter Data Stream

    Hi,
    The ability to query hierarchical JSON data, and the Azure Table Storage output option are great additions to Stream Analytics.
    I'm currently experimenting with querying into data streams from Twitter.
    Stuff like this works fine:
    -- Get statistics for location
    select
    min (id) as Id,
    [user].location as Location,
    count([user].location) as Total,
    avg([user].followers_count) as AvgFollowers,
    avg([user].favourites_count) as AvgFavourites,
    avg([user].friends_count) as AvgFriends,
    avg([user].listed_count) as AvgListed
    from tweetstream
    where [user].location is not null and [user].location != ''
    group by [user].location, TumblingWindow (minute, 1)
    having Total > 10
    -- Get number of tweets by name
    select [user].screen_name, count (id) as Tweets
    from tweetstream
    group by [user].screen_name, TumblingWindow (minute, 1)
    having Tweets > 1
    -- Select based on text in tweet
    select text
    from tweetstream
    where text like '%food%'
    What I am having issues with is repeating data, such as selecting the hashtags from a tweet.
    There can be zero or more hashtags in a tweet, the JSON looks like this:
    "created_at":"Fri Nov 28 21:42:41 +0000 2014",
    "id":538447914268639232,
    // Deleted
    "entities":
    "hashtags":[
    "text":"fall",
    "indices":[33,38]
    "text":"confessionsofaprchic",
    "indices":[39,60]
    "trends":[],
    "urls":[],
    "user_mentions":[],
    "symbols":[]
    // Deleted
    Is there a way to select the hashtags for a tweet?
    If not, is it something that will be possible in the future?
    Regards,
    Alan
    Free e-book: Windows Azure Service Bus Developer Guide.

    Today you can't access contents of the array in the query. We will be extending query language to allow flattening of arrays for further processing.
    For example, in your scenario, you will be able to transform rows with tweets containing array of hashtags into multiple rows with individual hashtags.
    This should be available soon.

  • Does live streaming video disable event of a button on the stage?

    When a video is streamed from flash Media Server then the
    event assigned to any button on the stage doesn't work at runtime,
    Code example:
    var myNC:NetConnection = new NetConnection();
    myNC.connect("rtmp://server.domain.com/application");
    var myNS:NetStream = new NetStream(myNC);
    myNS.play("myNStream");
    But when the video is streamed without connecting rtmp URL
    and just requesting normal URL, the event of button works.
    Code example:
    var myNC:NetConnection = new NetConnection();
    myNC.connect(null);
    var myNS:NetStream = new NetStream(myNC);
    myNS.play("stream.flv");
    The video streaming is done using NetConnection and NetStream
    class in ActionScript 3.0.
    Does anyone know What's the matter?

    There is no straightforward way in LabVIEW to do on-the-fly H.264 compression.  If you want to send images over TCP, you can do so by converting the image to an array, flattening the array to a string, sending it over a TCP or UDP connection, then on the receiving end you unflatten from string to array and convert the array back to an image.  You can reduce the resolution of the image using the IMAQ Resample VI before you convert the image to an array.  Look up the UDP and TCP examples in the NI Example Finder to see how to create the sender and receiever VIs.
    www.movimed.com - Custom Imaging Solutions

  • How to obtain TextEdit paragraph justification info w/AppleScript

    Hi,
    I'm trying to develop an AppleScript that should get a file (chosen by the user), iterate through all its paragraphs obtaining paragraph justification info (whether it is centered, left, right or full) and process paragraph text according to that property.
    I manage to obtain font, size or color, even converting them to text but other style properties seem to resist. Furthermore, are the same in TextEdit and in other apps. I mean, once the user chooses the file, I get the default app, I use that app to open the file and I try to use the text suite to iterate thfough the paragraphs. Will I be able to do this with TextEdit, Pages, Preview or whatever the app is?
    Thanks in advance for any help you can  give me,
    iVax

    Tobonale,
    Sql-Only approaches:
    *[1] Return Oridinate Array*
    Append .SDO_ORDINATES to your geometry object or column name:
    SELECT MDSYS.SDO_GEOMETRY(
         2001,8307,NULL,
         MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1,3,1,0),
         MDSYS.SDO_ORDINATE_ARRAY(-75.586088632813272,6.1794352615514194,0.57278169530235967,-0.81970795380217887,0)
    ).SDO_ORDINATES
    FROM dualResult:
    SDO_ORDINATE_ARRAY(-75.586089, 6.17943526, .572781695, -.81970795, 0)*[2] Return Flattened Oradinate Array*
    SELECT * FROM
    TABLE (
         MDSYS.SDO_GEOMETRY(
         2001,8307,NULL,
         MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1,3,1,0),
         MDSYS.SDO_ORDINATE_ARRAY(-75.586088632813272,6.1794352615514194,0.57278169530235967,-0.81970795380217887,0)).SDO_ORDINATES
    )Result:
      -75.586089
      6.17943526
      .572781695
      -.81970795
               0Regards,
    Noel

  • Data type of preprend array size in Flatten To String block

    Hi 
    The data type of the preprend array size in Flatten To String block is given as I32. Is it somehow possible to reduce the data type to I8, since the width and height of my array won't exceed 255 ?. I also need to do the same in Unflatten To String as well. 
    Best regards
    Oesen

    Oesen wrote:
    Hi 
    The data type of the preprend array size in Flatten To String block is given as I32. Is it somehow possible to reduce the data type to I8, since the width and height of my array won't exceed 255 ?. I also need to do the same in Unflatten To String as well. 
    The short answer is no.  This is because the index is an I32.  NI likes to keep integers as an I32 whenever possible for reasons like this.
    Since you are dealing with a 2D array (width and height), it will actually use 2 I32s before the actual data.
    As Ravens stated, you could put in your own array sizes before the array in the string.  But it is worth saving 6 bytes?  Not likely.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for

  • How to validate a manual standby

    Hi all, I am setting up a manual physical standby and I want to periodically check the standby database for physical and logical corruption. I am not sure what is the best way to do it: 1) should I only use dbv? 2) should I open the database read onl

  • Windows Media Player keeping Automatic Maintenance window/Windows Updates from doing auto-restart

    I have a system that is connected to a domain, and it runs a video playlist in Windows Media Player for digital signage upon bootup (and auto-login).  WMP is set to loop the videos over and over again, but it also is preventing automatic updates from

  • Problem with Adobe Help Online

    Dear sir, Hi, My name is Palm. I have a problem with Adobe Help. Every time I use the function "Leyer Style" >> "Gradient Overlay". Adobe Help Online is often displayed without my pressing or click anything. It was a problem with my work. I have to r

  • Shortest Path Algorithm with Djikstra

    Hi all, im developing a shortest path searching techniques by using Djikstra's algorithm. My search space is very huge and it is about 100,000 nodes or we can call it Vertex. I store all the nodes and weight of edges in MySql as follows: From | To |

  • BI roles-queries

    Hello, I have some BI roles and queries have been assigned in to those roles. I need the list of Roles versus Queries , is there any table in BI where i can down load this in Excel ? ( like we have agr_tcodes table in R/3.. )  Thanks, SR