line geom

Hello

Please help write PLSQL to create the geometry of the line of dots in the following table, based on posts composite (ACODE and ID) and in the order of the column SNO. I saw some questions and answers about this problem in this area, but I couldn't do it.

ACODE      ID           SNO                     X                                                             Y

---------------------------------------------------------------------------------------------

HMMS 11 1 - 118.3860785 33.9316596

HMMS 11 2 - 118.4008582 33.94779459

HMMS 11 3 - 118.4008435 33.94780758

HMMS 134 1 - 118.4112892 33.9452023

HMMS 134 2 - 118.4112631 33.9451993

HMMS 134 3 - 118.4112337 33.94519592

HMMS 134 4 - 118.4111911 33.94519104

150 1 - 118.4107496 33.94177833 PMM

150 2 - 118.4107045 33.941783 PMM

150 3 - 118.410683 33.94178523 PMM

150 4 - 118.410643 33.94178937 PMM

Thank you...

Hi people,

Well, Frédéric solution should work (I didn't test it) but I wonder if its work more than planned gift.  I could be wrong, but I bet that as a person SQL that Don would like to do something in the sense

SELECT FOO(x,y) FROM myTable GROUP BY acode, id;

and just to get a result.

It got me thinking about how many moons have passed since we all used to talk on the writing of our own space ODCI functions

Does anyone have an aggregation function APPEND

At the time seemed so possible, but over the years it seems a kind of consensus that do something with spatial data in this way the likely outcome an accident and/or terrible performance.  Anyone has revisited the things?  Is it not better to 12 c?  Did someone using their own space ODCI to aggregate successfully functions in the production?

I thought about how I would answer donation if I trust in fact the ODCI system. Here's what I put in place

DROP TABLE don123 PURGE;
CREATE TABLE don123(
    acode VARCHAR2(4 Char)
   ,donid INTEGER
   ,sno   INTEGER
   ,x     NUMBER
   ,y     NUMBER
   ,PRIMARY KEY(acode,donid,sno)
);

INSERT INTO don123 VALUES ('HMMS',11,1,-118.3860785,33.9316596);
INSERT INTO don123 VALUES ('HMMS',11,2,-118.4008582,33.94779459);
INSERT INTO don123 VALUES ('HMMS',11,3,-118.4008435,33.94780758);
INSERT INTO don123 VALUES ('HMMS',134,1,-118.4112892,33.9452023);
INSERT INTO don123 VALUES ('HMMS',134,2,-118.4112631,33.9451993);
INSERT INTO don123 VALUES ('HMMS',134,3,-118.4112337,33.94519592);
INSERT INTO don123 VALUES ('HMMS',134,4,-118.4111911,33.94519104);
INSERT INTO don123 VALUES ('PMMS',150,1,-118.4107496,33.94177833);
INSERT INTO don123 VALUES ('PMMS',150,2,-118.4107045,33.941783);
INSERT INTO don123 VALUES ('PMMS',150,3,-118.410683,33.94178523);
INSERT INTO don123 VALUES ('PMMS',150,4,-118.410643,33.94178937);
COMMIT;

DROP FUNCTION xy2line;
DROP TYPE xy2line_agg;
DROP TYPE xy2line_type_table;
DROP TYPE xy2line_type;

CREATE OR REPLACE TYPE xy2line_type FORCE
AS OBJECT(
    x         NUMBER
   ,y         NUMBER
   ,srid      NUMBER
   ,orderkey1 VARCHAR2(4000 Char)
   ,orderkey2 VARCHAR2(4000 Char)
   ,orderkey3 VARCHAR2(4000 Char)

   ,CONSTRUCTOR FUNCTION xy2line_type
    RETURN SELF AS RESULT

   ,CONSTRUCTOR FUNCTION xy2line_type(
       x         IN  NUMBER
      ,y         IN  NUMBER
      ,srid      IN  NUMBER
      ,orderkey1 IN  NUMBER
    ) RETURN SELF AS RESULT

   ,CONSTRUCTOR FUNCTION xy2line_type(
       x         IN  NUMBER
      ,y         IN  NUMBER
      ,srid      IN  NUMBER
      ,orderkey1 IN  NUMBER
      ,orderkey2 IN  NUMBER
    ) RETURN SELF AS RESULT
);
/

CREATE OR REPLACE TYPE BODY xy2line_type
AS
   CONSTRUCTOR FUNCTION xy2line_type
   RETURN SELF AS RESULT
   AS
   BEGIN
      RETURN;
   END;

   CONSTRUCTOR FUNCTION xy2line_type(
      x         IN  NUMBER
     ,y         IN  NUMBER
     ,srid      IN  NUMBER
     ,orderkey1 IN  NUMBER
   ) RETURN SELF AS RESULT
   AS
   BEGIN
      self.x         := x;
      self.y         := y;
      self.srid      := srid;
      self.orderkey1 := orderkey1;
      RETURN;
   END;

   CONSTRUCTOR FUNCTION xy2line_type(
      x         IN  NUMBER
     ,y         IN  NUMBER
     ,srid      IN  NUMBER
     ,orderkey1 IN  NUMBER
     ,orderkey2 IN  NUMBER
   ) RETURN SELF AS RESULT
   AS
   BEGIN
      self.x         := x;
      self.y         := y;
      self.srid      := srid;
      self.orderkey1 := orderkey1;
      RETURN;
   END;

END;
/

CREATE OR REPLACE TYPE xy2line_type_table FORCE
AS TABLE OF xy2line_type;
/

CREATE OR REPLACE TYPE xy2line_agg FORCE
AS OBJECT(
   ary_xy   xy2line_type_table

  ,STATIC FUNCTION ODCIAggregateInitialize(
      actx        IN OUT xy2line_agg
   ) RETURN NUMBER

  ,MEMBER FUNCTION ODCIAggregateIterate(
      self        IN OUT xy2line_agg
     ,val         IN xy2line_type
   ) RETURN NUMBER

  ,MEMBER FUNCTION ODCIAggregateTerminate(
      self        IN  xy2line_agg
     ,ReturnValue OUT MDSYS.SDO_GEOMETRY
     ,flags       IN  NUMBER
   ) RETURN NUMBER

  ,MEMBER FUNCTION ODCIAggregateMerge(
      self        IN OUT xy2line_agg
     ,ctx2        IN xy2line_agg
   ) RETURN NUMBER

);
/

CREATE OR REPLACE TYPE BODY xy2line_agg
AS
   -----------------------------------------------------------------------------
   -----------------------------------------------------------------------------
   STATIC FUNCTION ODCIAggregateInitialize(
      actx IN OUT xy2line_agg
   ) RETURN NUMBER
   AS
   BEGIN
      actx := xy2line_agg(xy2line_type_table());

      RETURN odciconst.success;

   END;

   -----------------------------------------------------------------------------
   -----------------------------------------------------------------------------
   MEMBER FUNCTION ODCIAggregateIterate(
      self  IN OUT xy2line_agg
     ,val   IN xy2line_type
   ) RETURN NUMBER
   AS
   BEGIN
      self.ary_xy.EXTEND();
      self.ary_xy(self.ary_xy.COUNT) := val; 

      RETURN odciconst.success;

   END;

   -----------------------------------------------------------------------------
   -----------------------------------------------------------------------------
   MEMBER FUNCTION ODCIAggregateTerminate(
       self        IN  xy2line_agg
      ,ReturnValue OUT MDSYS.SDO_GEOMETRY
      ,flags       IN  NUMBER
   ) RETURN NUMBER
   AS
      int_ords PLS_INTEGER;

   BEGIN
      IF self.ary_xy.COUNT = 1
      THEN
         ReturnValue := MDSYS.SDO_GEOMETRY(
             2001
            ,self.ary_xy(1).srid
            ,MDSYS.SDO_POINT_TYPE(
                self.ary_xy(1).x
               ,self.ary_xy(1).y
               ,NULL
             )
            ,NULL
            ,NULL
         );

      ELSE
         FOR i IN (
            SELECT
             x
            ,y
            ,srid
            FROM
            TABLE(self.ary_xy)
            ORDER BY
             orderkey1
            ,orderkey2
            ,orderkey3
         )
         LOOP
            IF ReturnValue IS NULL
            THEN
               ReturnValue := MDSYS.SDO_GEOMETRY(
                   2002
                  ,i.srid
                  ,NULL
                  ,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1)
                  ,MDSYS.SDO_ORDINATE_ARRAY(
                      i.x
                     ,i.y
                   )
               );

            ELSE
               int_ords := ReturnValue.SDO_ORDINATES.COUNT;
               ReturnValue.SDO_ORDINATES.EXTEND(2);
               ReturnValue.SDO_ORDINATES(int_ords + 1) := i.x;
               ReturnValue.SDO_ORDINATES(int_ords + 2) := i.y;

            END IF;

         END LOOP;

      END IF;

      RETURN odciconst.success;

   END;

   -----------------------------------------------------------------------------
   -----------------------------------------------------------------------------
   MEMBER FUNCTION ODCIAggregateMerge(
       self IN OUT xy2line_agg
      ,ctx2 IN xy2line_agg
   ) RETURN NUMBER
   AS
   BEGIN
      self.ary_xy := self.ary_xy MULTISET UNION (ctx2.ary_xy);

      RETURN odciconst.success;

   END;

END;
/

CREATE OR REPLACE FUNCTION xy2line(
   input xy2line_type
) RETURN MDSYS.SDO_GEOMETRY
PARALLEL_ENABLE
AGGREGATE USING xy2line_agg;
/

SELECT
a.acode
,a.donid
,xy2line(xy2line_type(a.x,a.y,8265,a.sno)) AS new_line
FROM
don123 a
GROUP BY
a.acode
,a.donid
ORDER BY
a.acode
,a.donid;

Select it then final (which btw blows the stack into a FROG) would be the easiest way to do this aggregation from a SQL perspective.

Now I recommend this as a good idea?  Probably not, I don't know.  If the workload of the Don's just tens of points, I think that it working great - until it hits the gigantic of a line with 25,000 points, then it will break.  Or are things better now with ODCI?

It occurs to me that I've not seen a single question on this forum in the eight years since the issue of Jean Luc where the answer has been a custom ODCI function.  One might think that there are good practices here to avoid them when you work with spatial data.  Them would all you?

See you soon,.

Paul

Tags: Database

Similar Questions

  • Create two point line

    Hello.

    I started using Oracle Spatial and must create a view get points of two associates and show a line connecting.

    I found many articles showing how to create lines of an array of points, but none explaining how to get a geometry of one table and one from table b and create a line between them.

    The tables change with some frequency, so it is out of the question to create lines in a GIS and download.

    Thank you

    E. Barbara

    E,

    It's quite simple, especially if you have simple points. The sql below should help you get started:

    create table t1 (pk number, geom sdo_geometry);
    create table t2 (pk number, geom sdo_geometry);
    
    insert into t1 values(1, sdo_geometry(2001,4326,SDO_POINT_TYPE(11,11,NULL),NULL,NULL));
    insert into t1 values(2, sdo_geometry(2001,4326,SDO_POINT_TYPE(12,12,NULL),NULL,NULL));
    insert into t2 values(1, sdo_geometry(2001,4326,SDO_POINT_TYPE(21,21,NULL),NULL,NULL));
    insert into t2 values(2, sdo_geometry(2001,4326,SDO_POINT_TYPE(22,22,NULL),NULL,NULL));
    
    commit;
    
    SELECT sdo_geometry (2002,
                         4326,
                         NULL,
                         sdo_elem_info_array (1,
                                              2,
                                              1),
                         sdo_ordinate_array (a.geom.sdo_point.x,
                                             a.geom.sdo_point.y,
                                             b.geom.sdo_point.x,
                                             b.geom.sdo_point.y))
      FROM t1 a,
           t2 b
    where a.pk = b.pk;
    

    Kind regards

    Bryan

  • How to find the connection line

    Hello

    I have a spatial table with geom type in 2002.

    I have a set of line (for example say it's 5 rows) attach image.

    I need to find the line that is internal linking to these 5 rows. I mean, it's a dividing line has the inside line.

    I am unable to get the inner lines of a border.

    If I have a spatial query table I get limit but I want inner lines.

    Fix is instant for ref.example.jpg

    Thanks in advance

    Saaz

    This is because CONCAT_LINES does not create a polygon, it only concatenates lines in a new line. But always a line (even if the endpoint and the starting point of this line may be the same).

    It might be a good idea to start reading the Documentation space: content, since it seems that there are some concepts in Oracle Spatial, which are not clear to you. Basically: there is no simple easy feature to create a polygon of a bunch of lines delivered with Oracle, you will need to create one yourself.

    Concat_lines might be a start, however, that allows to create a line, then check the endpoint and the starting point: if they are identical, you can create your polygon. Is they are not the same, you can copy the starting at the end point. You can then change the GTYPE and the Ansdo_elem_info so that the entire element becomes a polygon. With a polygon you can use inside effectively to get the results you want. I don't have access to my environment of development here, so can't help you build something right now. But maybe someone else has something already?

    Oh, and after the fact: do not store your polygons in a temporary table, but change your datamodel and begin to use them properly. Temporary tables will be only complicate things more.

  • Join Segments of line (road segments) SDO_AGGR_UNION/SDO_AGGR_CONCAT_LINES

    Hello

    I have road segments I need join/merge in order to get the axe of full road. Unfortunately, I have some segments that are not attached and the axe of road resulting has a gap.

    When I look at the road segments and the result of the join it seems to me that the aggregation does not work for roads that either have segments that are disjoint (we have a few roads where simple segments do not touch) or if a road has two or more "branches" (just take the letter 'Y' as example for this).

    (1) SDO_AGGR_CONCAT_LINES

    Did not work at all - I couldn't create a view using SDO_AGGR_CONCAT_LINES. As mentioned in documentation - is not suitable if you have bows (we have).

    (2) SDO_AGGR_UNION

    I tried SDO_AGGR_UNION also that the documentation mentions: "do not use SDO_AGGR_UNION to merge the string line or chain multiline; Instead, use the function of spatial aggregation SDO_AGGR_CONCAT_LINES . »

    (3) SDO_AGGR_SET_UNION

    I tried as well SDO_AGGR_SET_UNION. This seemed promising that the documentation mentions not everything related to arcs but says: «Can aggregate sets of lines...» »

    2 and 3 provide the same result. Please take a look at the screenshot (HD, it looks like I can't upload a photo...)

    I want to aggregate the segments - is there another function in Oracle, I could use?

    Any idea, be it SDO_AGGR_UNION / SDO_AGGR_SET_UNION are / are not suitable for my dataset?

    Thank you, Rob

    My display definitions:

    CREATE OR REPLACE FORCE VIEW AV_V_STRASSEN_2
    AS
      SELECT l.fid,
        ln.location_name,
        SDO_AGGR_UNION(sdo.SDOAGGRTYPE(rs.geom, 0.005)) geom
      FROM lm_lo_location l,
        lm_lo_location_name ln,
        lm_lo_road_section rs
      WHERE l.fid = ln.fid_lo_location
      AND l.fid   = rs.fid_lo_location
      GROUP BY l.fid,
        ln.location_name;
    
        CREATE OR REPLACE FORCE VIEW AV_V_STRASSEN_3
    AS
        SELECT l.fid,
        ln.location_name,
        sdo_aggr_set_union (get_geom_set ('lm_lo_road_section', 'geom','fid_lo_location = ', l.fid), .0005 ) geom
      FROM lm_lo_location l,
        lm_lo_location_name ln,
        lm_lo_road_section rs
      WHERE l.fid = ln.fid_lo_location
      AND l.fid   = rs.fid_lo_location
      GROUP BY l.fid,
        ln.location_name;
    
    

    Hello

    After some further tests, I discovered that the cause of the problem seems to be the application I used to display my road network.

    I have displayed the view in SQLDeveloper and with FME and two look fine - result is expected (see for 2 and 3). But initially, I used another package to check the view visually.

    Stefan - Thanks for the answer to yopur:

    -J' I need the roads step road segments displaying the data in our system GIS, most users want a road not simple segments

    -performance: will see, if not good, I'll create a carpet. view, the road network is fairly static and does not change often

    -gaps: there are no gaps in our data set (but 'gaps' appeared when I displayed the view in a specific package).

    -sdo_aggr_union / sdo_aggr_set_union seem to do what I want and seem to work with our data as well

    Rob

  • Line that auto cross

    I was looking at the previous posts regarding how to determine if a LINE intersects itself...

    and the orientation was use sdo_intersection to do a free intersection on the line (i.e. pass in the same line with two args)

    then use sdo_getvertices and County

    I tried to do however get (what I think) is the strange results.

    Two examples:

    In an example here, I have a line that starts and ends at the same point, and the point that has a count > 1 is not the starting point / end.

    Select t.x, t.y, count (*) total

    Of

    TABLE)

    () sdo_util.getVertices

    sdo_geom. () SDO_INTERSECTION

    (select SDO_GEOMETRY (2002, 8265, NULL, SDO_ELEM_INFO_ARRAY (1,2,1), SDO_ORDINATE_ARRAY ()))

    -122.3117777778, 47.4498888889,

    -122.3, 47.45,

    -122.5375277777,48.7926944444,

    -122.3117777778, 47.4498888889

    () as double geom)

    ,

    (select SDO_GEOMETRY (2002, 8265, NULL, SDO_ELEM_INFO_ARRAY (1,2,1), SDO_ORDINATE_ARRAY ()))

    -122.3117777778, 47.4498888889,

    -122.3, 47.45,

    -122.5375277777,48.7926944444,

    -122.3117777778, 47.4498888889

    () as double geom)

    0.005))

    ) t

    Group of t.x, t.y;

    The above returns this point as the point of intersection free?

    -122.5375277777,48.7926944444

    I also have a more complex example that contains a line with many points, I'm expecting TWO x, y of the points as a free intersection points...

    There are THREE of them.  The I wasn't expecting to have a number of 2 is - 122.5903, 48.8563

    Based on below why would '-122.5903, 48.8563' be considered a free intersection point?

    Select t.x, t.y, count (*) total

    Of

    TABLE)

    () sdo_util.getVertices

    sdo_geom. () SDO_INTERSECTION

    (select SDO_GEOMETRY (2002, 8265, NULL, SDO_ELEM_INFO_ARRAY (1,2,1), SDO_ORDINATE_ARRAY ()))

    -122.3117777778, 47.4498888889,-122.2955, 47.7347,-122.293, 47.8181,-122.2904, 47.9015,-122.2879, 47.9849,-122.3108, 48.0519,-122.3332, 48.1356,-122.3808, 48.2197,-122.3788, 48.2864,-122.4015, 48.3701,-122.4247, 48.4371,-122.4732, 48.5045,-122.5222, 48.5551,-122.5209, 48.6052,-122.5448, 48.6555,-122.5435, 48.7055,-122.5431, 48.7222,-122.5418, 48.7723,-122.5903, 48.8563,-122.6422, 48.8068,-122.6434, 48.7567,-122.6198, 48.6897,-122.544, 48.6889,-122.5431, 48.7222,-122.5667, 48.7892,-122.6426, 48.7901,-122.6695, 48.7236,-122.6711, 48.6569,-122.6731, 48.5735,-122.7002, 48.4903,-122.3117777778 47.4498888889

    () as double geom)

    ,

    (select SDO_GEOMETRY (2002, 8265, NULL, SDO_ELEM_INFO_ARRAY (1,2,1), SDO_ORDINATE_ARRAY ()))

    -122.3117777778, 47.4498888889,-122.2955, 47.7347,-122.293, 47.8181,-122.2904, 47.9015,-122.2879, 47.9849,-122.3108, 48.0519,-122.3332, 48.1356,-122.3808, 48.2197,-122.3788, 48.2864,-122.4015, 48.3701,-122.4247, 48.4371,-122.4732, 48.5045,-122.5222, 48.5551,-122.5209, 48.6052,-122.5448, 48.6555,-122.5435, 48.7055,-122.5431, 48.7222,-122.5418, 48.7723,-122.5903, 48.8563,-122.6422, 48.8068,-122.6434, 48.7567,-122.6198, 48.6897,-122.544, 48.6889,-122.5431, 48.7222,-122.5667, 48.7892,-122.6426, 48.7901,-122.6695, 48.7236,-122.6711, 48.6569,-122.6731, 48.5735,-122.7002, 48.4903,-122.3117777778 47.4498888889

    () as double geom)

    0.005))

    ) t

    Group of t.x, t.y;

    I could do something wrong but I wanted to see if the experts knew why these two example of free intersection tests do not seem to return the results, I expect.

    Thanks in advance

    See you soon

    Look at the geometry out of just sdo_geom. SDO_INTERSECTION (no count and not sdo_util.getVertices). Both your examples are closed loops, and the SDO_INTERSECT is producing a reorganization but closed loop, it starts at a different point. By definition, a closed loop has the Summit even at the beginning and at the end, so the starting point will be a number two. The Geometry produced by sdo_geom. SDO_INTERSECTION is a legitimate topological representation of the intersection of the two loops: this is another representation of the object of the geometic.

    I conclude that the SDO_INTERSECTION trick for line self intersections requires more work where the line is a closed loop. If you know that the input is a closed circuit, so I think excluding the last Summit of the intersection works:

    Select t.x, t.y, count (*) total

    de)

    Select sdo_geom. () SDO_INTERSECTION

    SDO_GEOMETRY (2002, 8265, NULL, SDO_ELEM_INFO_ARRAY (1,2,1), SDO_ORDINATE_ARRAY ())

    -122.3117777778, 47.4498888889,

    -122.3, 47.45,

    -122.5375277777,48.7926944444,

    -122.3117777778, 47.4498888889

    ))

    ,

    SDO_GEOMETRY (2002, 8265, NULL, SDO_ELEM_INFO_ARRAY (1,2,1), SDO_ORDINATE_ARRAY ())

    -122.3117777778, 47.4498888889,

    -122.3, 47.45,

    -122.5375277777,48.7926944444,

    -122.3117777778, 47.4498888889

    ))

    0.0001) I

    the double) ii

    , ARRAY)

    t sdo_util.getVertices (II.i))

    where rownum<>

    Group of t.x, t.y

    Incidentally, you should use a smaller tolerance, tolerance 0.005 tell 0.0001 - there are other free intersections that were not given by the SDO_INTERSECTION Tower. The line between - 122.5667, 48.7892 and - 122.6426, 48.7901 is less than 0, 05 - 122.5903, 48.8563

  • Line with the polygon intersection points

    I have a (multi point) line that crosses a polygon and I can find the points of intersection

    See this site for example: find the Points of Intersection between the line and & amp; #160; Polygon

    However, I would get the multi point original line WITH the points of intersection...

    How could do?

    Essentially for a line that crosses a polygon, I have returned...

    a new line which consists of points of origin AND the intersection of points

    Thanks in advance

    Where did you get the geometry intersecting from?

    Table of Ansdo_elem_info does not match your definition of 2005 multipoint, I think.

    This should be SDO_ELEM_INFO_ARRAY (3,1,1, 1,1,1, 7,1,1, 5,1,1) instead of (1,2,1).

    Then the union result geom is a line of 2002 has opposed to your example that returns a collection of 2006.

    And you will see that these points are where you expect them to be. (11R2 test)

    Luke

  • Divide a line into several points

    I see that I can use SDO_LRS. SPLIT_GEOM_SEGMENT to divide a line into one only point (and get 2 lines resulting).

    However, someone at - it an idea how can I split a line, at several points, in several segments? I need to do for the number of lines, so a function or procedure would be nice as appropriate.

    Thank you

    Published by: ronnie-m on April 22, 2013 04:43

    Sorry for pasting quick and dirty, was a minimum on time and problems with my dev env.

    Perhaps still not the best outline but hoping there more explanaition should be ok.

    Concerning

    Luke

    select l.line_id,                                                                                                                                         -- line line_id
            ROW_NUMBER() OVER (PARTITION BY l.line_id order by l.rowid )                                                                              -- optional sub id, to make submains unique in combination with line_id (guess this will be ordered
            sdo_lrs.CLIP_GEOM_SEGMENT(SDO_LRS.CONVERT_TO_LRS_GEOM(l.geometry ), branch_measure, branch_next_measure, 0.05)              -- actual clipping, needs convert to LRS apparently, start end end branch measure
            from
                   line l,                                                                                                                                            -- rejoin mainly to get the geometry again
                             (
                             select line_id,                                                                                             -- line_id
                                     branch_measure,                                                                                                              -- measure of the branches (from CASE WHEN
                                     LEAD(branch_measure, 1, 0) OVER (PARTITION BY line_id order by branch_measure) branch_next_measure   -- Analytical function LEAD will get the next branch measure form the following ordered records per line_id
                             from
                                  (
                                  select a.line_id,                                                                                                              -- line_id
                                          CASE when                                                                                                              -- CASE (assuming branch will touch only at one point) it will be either the start or the endpoint
                                                      sdo_lrs.find_offset(                                                                    -- of the branch that will TOUCH, we are checking this based on the offset which one is closest
                                                                               SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),                                   -- requires convert to LRS geom
                                                                               sdo_lrs.geom_segment_start_pt(b.geometry),                                   -- if it is neccessary to deal with multiple possibilities we might better use a temp table to evalute better
                                                                               0.05                                                                                -- TOLERANCE (all tolereance should be seen with respect to resolution of the data
                                                                               )                                                                   -- IF feasible, let spatial take care of the snapping
                                                      <
                                                      sdo_lrs.find_offset(
                                                                               SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),
                                                                               sdo_lrs.geom_segment_end_pt(b.geometry),
                                                                               0.05
                                                                               )
                                            THEN
                                                 sdo_lrs.find_measure(
                                                                           SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),
                                                                           sdo_lrs.geom_segment_start_pt(b.geometry),
                                                                           0.05
                                                                           )
                                            ELSE sdo_lrs.find_measure(
                                                                            SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),
                                                                            sdo_lrs.geom_segment_end_pt(b.geometry),
                                                                            0.05)
                                              END branch_measure
                                  from line a, line b                                                                                                      -- self join using main and branch that touches
                                       WHERE sdo_relate(b.geometry, a.geometry, 'mask=TOUCH') = 'TRUE'                                     -- Should be replaceable with sdo_join + self join optimsation
                                       AND a.line_type = 'main'
                                       AND b.line_type = 'branch'
                                  union all                                                                                                                        -- union all to get the 0 measure (startpoint) in the subquery as the beginning of the first clipping segment
                                       select line_id, 0 as branch_measure
                                       from line
                                  union all                                                                                                                         -- union all to get the last measure (endpoint) in the subquery as the beginning of the first clipping segment
                                       select line_id,
                                                 sdo_geom.sdo_length(geometry, 0.05) as branch_measure                                                  -- maybe better to use actual get measure form lrs endpoint but is the same if no spaecial measure are used
                                       from line
                                  )
                             ) b
                             where
                             branch_measure < branch_next_measure                                                                                          -- avoid duplicates (2 branches at same location on main (but also the last + 1 segment with last measure and default value 0 from LEAD
                             and
                             l.line_id = b.line_id                                                                                                              -- join on line-id to reuse the geom (or potential other attributes from original lines
                             ;
    
  • Convert multiline single line?

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0

    We deal with spatial data from another source to display in our GIS environment.

    The data is a set of multiline. The gtype is 2006. A typical geometry looks like:
    SDO_GTYPE     2006
    SDO_SRID      31370
    SDO_POINT.X   NULL     
    SDO_POINT.Y   NULL
    SDO_POINT.Z   NULL
    SDO_ELEM_INFO (1,2,1, 7,2,1)
    SDO_ORDINATES (105094.84, 195084.96,
                   105094.54, 195080.22,
                   105094.84, 195084.96,
                   105094.84, 195084.96,
                   105094.68, 195082.47 )
    Now, this isn't a real multiline... it's just encoded as a multiline, but if you look at the details, you will see that the endpoint of the first line is the same as the beginning of the second line (105094.84, 195084.96).

    A better way to code this geometry would be:
    SDO_GTYPE     2002 <---
    SDO_SRID      31370
    SDO_POINT.X   NULL     
    SDO_POINT.Y   NULL
    SDO_POINT.Z   NULL
    SDO_ELEM_INFO (1,2,1)
    SDO_ORDINATES (105094.84, 195084.96,
                   105094.54, 195080.22,
                   105094.84, 195084.96, <---
                   105094.68, 195082.47 )
    Is there a standard function in Oracle that performs this conversion for me? Or do I have to write my own :)

    Thank you very much!
    Rob

    Rob,

    Many ways for this cat with the standard tools of the skin.

    with mLine as (
    select SDO_GEOMETRY(2006,31370,NULL,
    SDO_ELEM_INFO_Array (1,2,1, 7,2,1),
    SDO_ORDINATE_ARRAY (105094.84, 195084.96,
                   105094.54, 195080.22,
                   105094.84, 195084.96,
                   105094.84, 195084.96,
                   105094.68, 195082.47 )) as geom
     from dual
    )
    select sdo_util.concat_lines(l1.geom,l2.geom) as line
      from (select sdo_util.extract(geom,1) as geom from mline) l1,
           (select sdo_util.extract(geom,2) as geom from mline) l2
    union all
    select sdo_geom.sdo_union(geom,geom,0.005) as line
      from mline l
    union all
    select sdo_util.remove_duplicate_vertices(sdo_geometry(2002,l.geom.sdo_srid,l.geom.sdo_point,SDO_ELEM_INFO_ARRAY(1,2,1),l.geom.sdo_ordinates),0.005) as line
      from mline l;
    -- Results
    --
    LINE
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------
    SDO_GEOMETRY(2002,31370,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(105094.84,195084.96, 105094.54,195080.22, 105094.84,195084.96, 105094.68,195082.47))
    SDO_GEOMETRY(2002,31370,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(105094.54,195080.22, 105094.68,195082.47, 105094.84,195084.96))
    SDO_GEOMETRY(2002,31370,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO_ORDINATE_ARRAY(105094.84,195084.96, 105094.54,195080.22, 105094.84,195084.96, 105094.68,195082.47))
    

    Note how SDO_UNION reorganizes and cleans the linestring which you can't.

    concerning
    Simon

  • sdo_inside - results vary according to the number of input lines

    Hello

    ... Using the Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production on Linux 64-bit...

    When I use SDO_INSIDE to find the 8 million points inside 30 000 polygons of postal code, I get the expected results, with the exception of 10 items that are duplicated in the results of each point being assigned to two different zip codes.

    When I change the where clause to use only 10 points in question, then SDO_INSIDE will return the correct results.

    Tables of point and polygon validates without errors. Does anyone have an explanation for this behavior?

    Thanks for your help,
    David
    SQL> explain plan for
      2  create table custom.out_table nologging
      3  as
      4  select
      5    a.blc_gcode blc_gcode, b.postcode postcode, '1' maskflag
      6  from
      7    custom.bnd_zip_2012_03 b,
      8    xref2012.aux_01_blc a
      9  where
     10    sdo_inside(a.geom, b.geom) = 'TRUE';
    
    Explained.
    
    SQL>
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 2405185576
    
    -----------------------------------------------------------------------------------------------------
    | Id  | Operation                     | Name                | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------------------------------
    |   0 | CREATE TABLE STATEMENT        |                     |  2424M|   212G|  3853K  (1)| 19:15:56 |
    |   1 |  LOAD AS SELECT               | OUT_TABLE           |       |       |         |          |
    |   2 |   NESTED LOOPS                |                     |  2424M|   212G|213   (1)| 00:00:04 |
    |   3 |    TABLE ACCESS FULL          | BND_ZIP_2012_03     | 30241 |   502K|213   (1)| 00:00:04 |
    |   4 |    TABLE ACCESS BY INDEX ROWID| AUX_01_BLC          | 80177 |  6028K|213   (1)| 00:00:04 |
    |*  5 |     DOMAIN INDEX              | AUX_01_BLC_GEOM_IDX |       |       |  0   (0)| 00:00:01 |
    -----------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       5 - access("MDSYS"."SDO_INSIDE"("A"."GEOM","B"."GEOM")='TRUE')
    
    17 rows selected.
    
    SQL>
    find duplicates:
    SQL> select a.blc_gcode, a.postcode, a.maskflag
      2  from
      3    out_table a,
      4    (select
      5    blc_gcode, count (blc_gcode) cnt
      6    from out_table
      7    group by blc_gcode) b
      8  where a.blc_gcode = b.blc_gcode and b.cnt > 1
      9  order by a.blc_gcode;
    
    BLC_GCODE       POSTCODE                  MASKFLAG
    --------------- ---------------------------------------- ---------------
    131150017011025 30125                     1
    131150017011025 30104                     1
    131150017011029 30125                     1
    131150017011029 30104                     1
    131150017011030 30104                     1
    131150017011030 30125                     1
    131150017011031 30104                     1
    131150017011031 30125                     1
    132339901003004 30125                     1
    132339901003004 30173                     1
    132339901003006 30125                     1
    132339901003006 30104                     1
    132339901003007 30125                     1
    132339901003007 30104                     1
    132339901003017 30104                     1
    132339901003017 30125                     1
    132339901003019 30104                     1
    132339901003019 30125                     1
    482299501002426 79837                     1
    482299501002426 79839                     1
    
    20 rows selected.
    
    SQL>
    Re-test the duplicates only:
    SQL> select
      2    a.blc_gcode, b.postcode, '1' maskflag
      3  from
      4    custom.bnd_zip_2012_03 b,
      5    xref2012.aux_01_blc a
      6  where
      7    a.blc_gcode IN
      8    ('131150017011025','131150017011029',
      9    '131150017011030','131150017011031',
     10    '132339901003004','132339901003006',
     11    '132339901003007','132339901003017',
     12    '132339901003019','482299501002426')
     13    AND
     14    sdo_inside(a.geom, b.geom) = 'TRUE';
    
    BLC_GCODE       POSTCODE                  MASKFLAG
    --------------- ---------------------------------------- --------------
    131150017011025 30104                     1
    131150017011029 30104                     1
    131150017011030 30104                     1
    131150017011031 30104                     1
    132339901003004 30173                     1
    132339901003006 30104                     1
    132339901003007 30104                     1
    132339901003017 30104                     1
    132339901003019 30104                     1
    482299501002426 79839                     1
    
    10 rows selected.
    
    SQL>

    Hi David,

    I tested the ZIP code = (30104, 30125) with 10 points.
    I ran the same query (as below) both 11.2.0.2 and 11.2.0.3:

    SQL> select a.blc_gcode blc_gcode, b.postcode postcode from bnd_zip_2012_03 b, aux_01_blc a where sdo_inside(a.geom, b.geom) = 'TRUE';
    

    11.2.0.2, I learned

             BLC_GCODE             POSTCODE
    -------------------------- --------------------------
           131150017011031            30104
           131150017011029            30104
           131150017011025            30104
           131150017011030            30104
           132339901003019            30104
           132339901003006            30104
           132339901003007            30104
           132339901003017            30104
           131150017011031            30125
           131150017011029            30125
           131150017011025            30125
           131150017011030            30125
           132339901003004            30125
           132339901003019            30125
           132339901003006            30125
           132339901003007            30125
           132339901003017            30125
    17 rows selected.
    

    On 11.2.0.3, I got

             BLC_GCODE             POSTCODE
    -------------------------- --------------------------
           131150017011031            30104
           131150017011029            30104
           131150017011025            30104
           131150017011030            30104
           132339901003019            30104
           132339901003006            30104
           132339901003007            30104
           132339901003017            30104
    8 rows selected.
    

    This is so the bug 12724515. Please either get 11.2.0.3 or
    ask the oracle support to obtain the fix for bug 12724515.

    Why your 10-point query shows the correct results?

    select
      2    a.blc_gcode, b.postcode, '1' maskflag
      3  from
      4    custom.bnd_zip_2012_03 b,
      5    xref2012.aux_01_blc a
      6  where
      7    a.blc_gcode IN
      8    ('131150017011025','131150017011029',
      9    '131150017011030','131150017011031',
     10    '132339901003004','132339901003006',
     11    '132339901003007','132339901003017',
     12    '132339901003019','482299501002426')
     13    AND
     14    sdo_inside(a.geom, b.geom) = 'TRUE';
    

    This is because the two motions are different. For example, the
    top query most likely chooses an index on blc_gcode and sdo_inside
    is run by function (i.e. a line a line). In your query
    with erroneous results, sdo_inside is run by a spatial index, i.e.
    you see the following execution plan:

    |   0 | SELECT STATEMENT             |                  |
    |   1 |  NESTED LOOPS                |                  |
    |   2 |   TABLE ACCESS FULL          | BND_ZIP_2012_03  |
    |   3 |   TABLE ACCESS BY INDEX ROWID| AUX_01_BLC       |
    |*  4 |    DOMAIN INDEX              | SPATIAL_IDX      |
    

    Thank you
    Ying

  • Line constructor

    Hello

    I point geometries with id and I want to build the geometry of the line of that. If there are only two points of a line, I can go start X, start to Y, end X, end Y to sdo_ordinate_array.

    But if I intermediate highs for a ID given, how to do this as County intermediate vertices is uncertain.

    ID x y
    ---------------------------------------
    1 x 1 y1
    1 x 2 y2
    1 x 3 y3
    1 x 4 y4
    1 x 5 y5
    2 x 1 y1
    2 x 2 y2
    2 x 3 y3

    Thanks for your help...

    Syed,

    OK, here's an example that fits your situation, I hope.

    First, I create a table called linepoints I think that contains data such as your:

    create table linepoints as
    SELECT case when trunc(level / 7) = 0 then 398639 else 2215595 end as feature_id,
           row_number() over (partition by 1 order by rownum) as point_id,
           sdo_geometry(2001,null,
                        sdo_point_type(round(dbms_random.value(1,10000),3),
                                       round(dbms_random.value(1,10000),3),
                                       NULL),NULL,NULL) as pointGeom
      FROM dual
    CONNECT BY LEVEL < 13;
    -- Result
    table LINEPOINTS created.
    

    That's what linepoints contains:

    select * from linepoints;
    -- Results
    FEATURE_ID POINT_ID POINTGEOM
    ---------- -------- ------------------------------------------------------------------------------------
    398639     1        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(512.505,9909.19,NULL),NULL,NULL)
    398639     2        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(701.488,8150.579,NULL),NULL,NULL)
    398639     3        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(753.581,2449.058,NULL),NULL,NULL)
    398639     4        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(7160.47,6238.475,NULL),NULL,NULL)
    398639     5        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(4550.681,1422.242,NULL),NULL,NULL)
    398639     6        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(1972.044,6790.043,NULL),NULL,NULL)
    2215595    7        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(1204.709,1973.255,NULL),NULL,NULL)
    2215595    8        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(7485.635,2439.01,NULL),NULL,NULL)
    2215595    9        MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(5005.396,5022.274,NULL),NULL,NULL)
    2215595    10       MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(1180.856,6256.96,NULL),NULL,NULL)
    2215595    11       MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(6425.442,7360.927,NULL),NULL,NULL)
    2215595    12       MDSYS.SDO_GEOMETRY(2001,NULL,MDSYS.SDO_POINT_TYPE(4200.348,5369.366,NULL),NULL,NULL)
    
     12 rows selected
    

    Secondly, given this table linepoints here, this is how I would create linear sdo_geometry objects (2002):

    SELECT c.feature_id,
           mdsys.sdo_geometry(2002,NULL,NULL,
                              mdsys.sdo_elem_info_array(1,2,1),
                              CAST(MULTISET(SELECT b.COLUMN_VALUE FROM linepoints a,table(mdsys.sdo_ordinate_array(a.pointGeom.sdo_point.x,a.pointGeom.sdo_point.y)) b where a.feature_id = c.feature_id order by a.point_id) as mdsys.sdo_ordinate_array))
           as geom
      FROM linepoints c
     GROUP BY c.feature_id;
    -- Results
    FEATURE_ID GEOM
    ---------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    2215595    MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(1204.709,1973.255,7485.635,2439.01,5005.396,5022.274,1180.856,6256.96,6425.442,7360.927,4200.348,5369.366))
    398639     MDSYS.SDO_GEOMETRY(2002,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(512.505,9909.19,701.488,8150.579,753.581,2449.058,7160.47,6238.475,4550.681,1422.242,1972.044,6790.043))
    

    If this is correct and give you the desired result, please mark my answer as being correct.

    respect of
    Simon

  • The line between two labels

    Hello world

    I wrote this little program where iam creating two label and I can drag this label and this works perfectly.
    I also try to include a line between this label. I am not getting the correct result because I see my tag, but not the line. (I know that my program is incomplete to separating it from the label, since I can't see the line with label iam not able to proceed)

    I am a newbie so my code is perhaps not too professional. Hoping to find a few tips.
    import java.awt.*;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.geom.Line2D;
    
    import javax.swing.*;
    
    @SuppressWarnings("serial")
    public class test extends JFrame implements MouseListener, MouseMotionListener  {
    
    private JPanel panel = new JPanel(null);   
    private JLabel label1 = new JLabel();
    private JLabel label2 = new JLabel();
    private int mouseX = 200;
    private int mouseY = 100;
    private boolean drag = false;
    
    
    public test() {
        this.add(panel);
        panel.setBackground(Color.WHITE);
    
        panel.add(label1);
        label1.setOpaque(true);
        label1.setBackground(Color.BLUE);
        label1.setBounds(mouseX, mouseY, 100, 50);
        label1.addMouseMotionListener(this);
        label1.addMouseListener(this);
    
        panel.add(label2);
        label2.setOpaque(true);
        label2.setBackground(Color.RED);
        label2.setBounds(mouseX + 200, mouseY, 100, 50);
        label2.addMouseMotionListener(this);
        label2.addMouseListener(this);
          
    }
    
    @Override
    public void mousePressed(MouseEvent e) {
        if (e.getSource() == label1) {
            drag = true;
        }
        if (e.getSource() == label2) {
            drag = true;
        }
    }
    
    
    
    @Override
    public void mouseReleased(MouseEvent e) {
        drag = false;
    }
    
    @Override
    public void mouseDragged(MouseEvent e) {
          if (drag == true)
        {
            JComponent jc = (JComponent)e.getSource();
            jc.setLocation(jc.getX()+e.getX(), jc.getY()+e.getY());
        }
    }
    
    public void mouseMoved(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mouseClicked(MouseEvent e) {}
    
    public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        Line2D lin = new Line2D.Float(100, 100, 250, 260);
        g2.draw(lin);
        super.paint(g2);
    }
    
    public static void main(String[] args) {
        test frame = new test();
        frame.setVisible(true);
        frame.setSize(600, 400);
        frame.setResizable(false);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
       
    }
    }
    Thanks for all your time and help.

    Outside of the Netbeans IDE is also there another tool that can help in creating faster GUI swing application.
    public void paint(Graphics g) {
        super.paint(g);
        Graphics2D g2 = (Graphics2D) g;
        Line2D lin = new Line2D.Float(100, 100, 250, 260);
        g2.draw(lin);
    }
    

    Also I suggest

    public void mousePressed(MouseEvent e) {
        if (e.getSource() == label1 || e.getSource() == label2) {
            drag = true;
        }
    }
    
  • Draw a line from any Point to any Point B dynamically using AS3

    I'm doing an animation where there are several places (for example A, B, C, D,...) on a map. If a person clicks a location A and then B elsewhere, I wanted to draw a dotted line from point A (from the destination of the aircraft) to point B (to destination of the flat) using AS3. Please help me...

    Here's a quick timeline and dirty code it does (class is below):

    var line:Shape;
    var lineGraphics:Graphics;
    var clickSwitch:int = 0;
    var mousePositions:Array = [];
    var conversion:Number = 180 / Math.PI;
    
    init();
    function init():void {
         drawBackground();
         line = new Shape();
         addChild(line);
         lineGraphics = line.graphics;
         stage.addEventListener(MouseEvent.CLICK, onClick);
    }
    
    function onClick(e:MouseEvent):void
    {
         clickSwitch = 1 - clickSwitch;
         mousePositions[clickSwitch] = new Point(mouseX, mouseY);
         if (clickSwitch == 0) {
              drawLine();
         }
         else {
              removeLine();
         }
    }
    
    function removeLine():void
    {
         lineGraphics.clear();
         line.rotation = 0;
    }
    
    function drawLine():void
    {
         lineGraphics.lineStyle(1, 0xff0000);
         lineGraphics.moveTo(0, 0);
         var dotDistance:Number = 2;
         var nextX:Number = dotDistance;
         while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
              lineGraphics.lineTo(nextX, 0);
              nextX += dotDistance;
              lineGraphics.moveTo(nextX, 0);
              nextX += dotDistance;
         }
         line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
         line.x = mousePositions[1].x;
         line.y = mousePositions[1].y;
    }
    
    function drawBackground():void
    {
         var s:Shape = new Shape();
         var g:Graphics = s.graphics;
         g.beginFill(0xC0C0C0);
         g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
         g.endFill();
         addChild(s);
    }
    

    Class:

    package
    {
         import flash.display.Graphics;
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.events.MouseEvent;
         import flash.geom.Point;
    
         public class DottedLine extends Sprite
         {
              private var line:Shape;
              private var lineGraphics:Graphics;
              private var clickSwitch:int = 0;
              private var mousePositions:Array = [];
              private var conversion:Number = 180 / Math.PI;
    
              public function DottedLine()
              {
                   init();
              }
    
              private function init():void {
                   drawBackground();
                   line = new Shape();
                   addChild(line);
                   lineGraphics = line.graphics;
                   stage.addEventListener(MouseEvent.CLICK, onClick);
              }
    
              private function onClick(e:MouseEvent):void
              {
                   clickSwitch = 1 - clickSwitch;
                   mousePositions[clickSwitch] = new Point(mouseX, mouseY);
                   if (clickSwitch == 0) drawLine();
                   else removeLine();
              }
    
              private function removeLine():void
              {
                   lineGraphics.clear();
                   line.rotation = 0;
              }
    
              private function drawLine():void
              {
                   lineGraphics.lineStyle(1, 0xff0000);
                   lineGraphics.moveTo(0, 0);
                   var dotDistance:Number = 2;
                   var nextX:Number = dotDistance;
                   while (line.width < Point.distance(mousePositions[0], mousePositions[1])) {
                        lineGraphics.lineTo(nextX, 0);
                        nextX += dotDistance;
                        lineGraphics.moveTo(nextX, 0);
                        nextX += dotDistance;
                   }
                   line.rotation =  conversion * Math.atan2(mousePositions[0].y - mousePositions[1].y, mousePositions[0].x - mousePositions[1].x);
                   line.x = mousePositions[1].x;
                   line.y = mousePositions[1].y;
              }
    
              private function drawBackground():void
              {
                   var s:Shape = new Shape();
                   var g:Graphics = s.graphics;
                   g.beginFill(0xC0C0C0);
                   g.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                   g.endFill();
                   addChild(s);
              }
    
         }
    
    }
    
  • Truncate the text after the first line in TextFlow

    I have a TextFlow object that is rendered in a Sprite with several lines.

    For a compact display, I now want to show only the first line, followed by 3 dots (...).

    I've not found a good approach up to now.

    There is a support for truncation.  It is limited to cases of use of label and requires the use of the TextLine factories.  There is no support for text editable with truncation.   Example below.

    Hope that helps,

    Richard

    /**
    ADOBE SYSTEMS INCORPORATED
    Copyright 2011 Adobe Systems Incorporated
    All Rights Reserved.

    NOTICE:  Adobe permits you to use, modify, and distribute this file
    in accordance with the terms of the Adobe license agreement
    accompanying it.  If you have received this file from a source
    other than Adobe, then your use, modification, or distribution
    of it requires the prior written permission of Adobe.
    */
    package
    {
        import flash.display.DisplayObject;
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.geom.Rectangle;
        import flash.text.StyleSheet;
        import flash.utils.ByteArray;
       
        import flashx.textLayout.container.ContainerController;
        import flashx.textLayout.conversion.TextConverter;
        import flashx.textLayout.elements.TextFlow;
        import flashx.textLayout.formats.TextLayoutFormat;
        import flashx.textLayout.factory.StringTextLineFactory;
        import flashx.textLayout.factory.TextFlowTextLineFactory;
        import flashx.textLayout.factory.TruncationOptions;
       
        [SWF(width="500", height="500")]
        public class Truncation extends Sprite
        {
           
            public function Truncation()
            {
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
               
                // sample of truncation with the StringFactory
                var stringFactory:StringTextLineFactory = new StringTextLineFactory();
                var stringSprite:Sprite = new Sprite();
                stringSprite.x = 25; stringSprite.y = 25; addChild(stringSprite);
                // this bounds has no maximum height
                stringFactory.compositionBounds = new Rectangle(0,0,200,NaN);
                stringFactory.text = "This is an extremely long and overly verbose string of text that I would like to see trunctated.";
                // truncate after two lines
                stringFactory.truncationOptions = new TruncationOptions(TruncationOptions.HORIZONTAL_ELLIPSIS,2);
                stringFactory.createTextLines(function (obj:DisplayObject):void { stringSprite.addChild(obj); });
               
                // sample of truncation with the TextFlowTextLineFactory
                var flowFactory:TextFlowTextLineFactory = new TextFlowTextLineFactory();
                var flowSprite:Sprite = new Sprite();
                flowSprite.x = 25; flowSprite.y = 75; addChild(flowSprite);
                // this bounds has no maximum height
                flowFactory.compositionBounds = new Rectangle(0,0,200,NaN);
                // truncate after three lines with a big red ellipsis
                flowFactory.truncationOptions = new TruncationOptions(TruncationOptions.HORIZONTAL_ELLIPSIS,3,TextLayoutFormat.createTextLayoutFormat({ fontSize:24, lineHeight:0, color:0xff0000 }));
                flowFactory.createTextLines(function (obj:DisplayObject):void { flowSprite.addChild(obj); },TextConverter.importToFlow(Data.markup, TextConverter.TEXT_LAYOUT_FORMAT));
            }
        }
    }
    class Data
    {
        public static const markup:String = "" +
            "

    The following excerpt is from Ethan Brand by Nathaniel Hawthorne.

    " +
            "

    There are many such lime-kilns in that tract of country, for the purpose of burning the white marble which composes" +
            " a large part of the substance of the hills. Some of them, built years ago, and long deserted, with weeds growing in the vacant round of the interior, which is open to the sky," +
            " and grass and wild-flowers rooting themselves into the chinks of the stones, look already like relics of antiquity, and may yet be overspread with the lichens of centuries to come." +
            " Others, where the lime-burner still feeds his daily and nightlong fire, afford points of interest to the wanderer among the hills, who seats himself on a log of wood or a fragment " +
            "of marble, to hold a chat with the solitary man. It is a lonesome, and, when the character is inclined to thought, may be an intensely thoughtful occupation; as it proved in the case " +
            "of Ethan Brand, who had mused to such strange purpose, in days gone by, while the fire in this very kiln was burning.

    The man who now watched the fire was of a " +
            "different order, and troubled himself with no thoughts save the very few that were requisite to his business. At frequent intervals, he flung back the clashing weight of the iron door, " +
            "and, turning his face from the insufferable glare, thrust in huge logs of oak, or stirred the immense brands with a long pole. Within the furnace were seen the curling and riotous flames, " +
            "and the burning marble, almost molten with the intensity of heat; while without, the reflection of the fire quivered on the dark intricacy of the surrounding forest, and showed in the " +
            "foreground a bright and ruddy little picture of the hut, the spring beside its door, the athletic and coal-begrimed figure of the lime-burner, and the half-frightened child, shrinking " +
            "into the protection of his father's shadow. And when again the iron door was closed, then reappeared the tender light of the half-full moon, which vainly strove to trace out the " +
            "indistinct shapes of the neighboring mountains; and, in the upper sky, there was a flitting congregation of clouds, still faintly tinged with the rosy sunset, though thus far down " +
            "into the valley the sunshine had vanished long and long ago.

    ";
    }

  • Functions to return data from polygon and line

    Hello

    I'm looking for different Oracle functions that return data from polygon and line (return sdo_geometry.ordinates cordinates collection). My sdo_geometry data like that.

    Select geometry.sdo_ordinate from myTable
    ------------------------------------------------------------

    61,42,0, 62,43,0 and so on

    I am unable to find functions by using google search, your help is greatly appreciated.

    Thank you
    Nancy

    Hi Nancy,.

    If you do not extract the coordinates of the geometry, you can use the suite of applications.

    SELECT t.X, t.Y, t.id
    OF state_boundary c,.
    TABLE (SDO_UTIL. GETVERTICES (c.geom)) t where id = 20022
    ORDER BY t.id;

    Another method:

    SELECT * FROM TABLE (SELECT C.GEOM. State_boundary SDO_ORDINATES c where id = 20022)

    Sujnan

  • Sierra: The missing in Email subject line

    I upgraded to Sierra and for some reason any in Mac Mail, the subject line has completely disappeared. I can see part of it in the preview to the left, as well as the sender and first line or more. How to make the subject line in the view on the far right in Mac Mail?

    Thank you!

    Vanders

    OMG I can't believe that everything they did was move and remove the label: "subject"! It appears right under the sender and before "to: I was so use to see above the gray line separating the headers from the body of the email, I was totally missing it! Thanks to all of you who have read my question!

Maybe you are looking for

  • How can I make the smaller print on the website "Play by Play"?

    I can't see the toolbar where I have used options to allow a smaller print on the site "game - by - play.com. The impression of this site is much too big. I don't know how to reduce its size without the toolbar. Could you tell me how to adjust the pr

  • Server HP ML310e gen8 v2: need system drivers

    My HP proliant ML310e gen8 v8 has is come as a freeDos system, I then installed windows xp professional 32-bit because editing software vedio, I intend to use only support window xp. the time to get its pilots became a nightmare for me. I checked the

  • Data execution prevention farm iTunes - Windows Vista Home Premium

    I installed the last iTunes/Quicktime (running on Vista SP1).  When I try to load either, I get the error message it is closing.  So, that "Data execution Protection" has closed. I have read the FAQ of the DEP and tried to change its parameters to au

  • Product key sticker is not readable, what can I do?

    Hi, I reinstalled windows vista on my laptop, but it has stopped working. I bought windows vista with laptop a few years ago. The sticker key on my laptop is in bad shape and I can read only 3 sets. Is there a way I can get this key? I'm not sure but

  • m9555sc freezes everything in the game.

    A week ago my computer started to freeze everything in play, forcing me to turn off the hardway. I am able to restart this right by then, but these days he came more and more frequently. The last two were a little different. Color suddenly changed fo