Unclosed polygons
Hi - I'm running 8i at the moment and have a problem with unclosed polygons. As far as I'm concerned, they are closed, but the first and last coordinates are different after the tenth decimal place (much like this previous poster Why ORA-13348: SDO_TOLERANCE wrong? ) so they are flagged as invalid geometries by our GIS client. My SDO_TOLERANCE is 0.0005 so it shouldnt be flagged as open polygons, but they are. Upgrading Oracle is not an option unfortunately, but does anybody know of an easy way to close off my polygons? SQL or open source solution?
MTIA
Rob
Rob,
It sounds like your GIS client is not using the Tolerance to determine
that the first and last are the same and is just using the raw numbers to
make the comparison.
I have some 8i compliant PL/SQL that I can email to you that will actually
apply the Sdo_Tolerance to the vertices of the shape and round their xy
values off to the actual tolerance level. THis will then make the first and last
vertex the same. I will send it to your email address tonight.
S
Similar Messages
-
Hello :)
Question about Polygon method contains!
I have following polygon:
int[] x = { 10, 100, 100, 10 };
int[] y = { 10, 10, 100, 100 };
Polygon polygon = new Polygon(x, y, 4);and following points:
Point p1 = new Point(10, 45);
Point p2 = new Point(45, 10);
Point p3 = new Point(100, 45);
Point p4 = new Point(45, 100);executing method contains points p1, p2 are inside polygon! But points p3, p4 are not! Why? IMHO p3 and p4 also have to be inside polygon?Roberts_V wrote:
... Why? IMHO p3 and p4 also have to be inside polygon?From the Polygon.contains(...) docs:
Determines if the specified coordinates are inside this Polygon. For the definition of insideness, see the class comments of Shape.
From the Shape docs:
Definition of insideness: A point is considered to lie inside a Shape if and only if:
- it lies completely inside the Shape boundary or
- it lies exactly on the Shape boundary and the space immediately adjacent to the point in the increasing X direction is entirely inside the boundary or
- it lies exactly on a horizontal boundary segment and the space immediately adjacent to the point in the increasing Y direction is inside the boundary.
The contains and intersects methods consider the interior of a Shape to be the area it encloses as if it were filled. This means that these methods
consider unclosed shapes to be implicitly closed for the purpose of determining if a shape contains or intersects a rectangle or if a shape contains
a point. -
Polygonal lasso tool not working with stylus on Surface Pro 2
Hi guys,
I'm new here so please bare with me if I'm posting in the wrong place or don't make immediate sense.
Hardeware / software used: surface pro 2 and I'm running photoshop CS5.
Problem is a fairly basic one: I am trying to make basic selections using the polygonal lasso tool (using the stylus that comes with the tablet) but it simply will not work. All I get when I touch the stylus to the screen is the circle that appears then fades. If I attach the keypad and try using that then it works no problem at all.
Does anyone have any ideas as to whether there is a particular setting that I need to switch on or off e.g. something relating to pressure sensitivity (although not sure why this would affect this particular selection tool)?
I've searched the web and come up with nothing so far so any help is greatly appreciated!
Thanks for your time
Scottsame problem on surface pro 3 !!!!
and i think quite significant, for lot of artists using polygonal lasso a lot (including me). How come that the stupid surface cannot work properly -
How to find a polygon that contains a point
I have a table that has the boundaries (polygones) for all the zip codes in my state and I want to find the zip code that contains the given LON/LAT
The following query is aparently not valid:
SELECT *
FROM ZIP_BOUNDARY b
WHERE sdo_relate(b.geom, SDO_POINT_TYPE(-122.079155, 37.392892, NULL),'mask=touch') = 'TRUE'
WHERE sdo_relate(b.geom, SDO_POINT_TYPE(-122.079155, 37.392892, NULL),'mask=touch') = 'TRUE'
ERROR at line 5:
ORA-29900: operator binding does not exist
ORA-06553: PLS-306: wrong number or types of arguments in call to 'SDO_RELATE'
What is the correct way to write such a query?try the following:
SELECT *
FROM ZIP_BOUNDARY b
WHERE sdo_relate(b.geom, sdo_geometry(2001, YOUR_SRID, SDO_POINT_TYPE(-122.079155, 37.392892, NULL), NULL, NULL), 'mask=CONTAINS') = 'TRUE'; -
Calculating the length of the longest side of a polygon
If you want to calculate the length of the longest side of a polygon -- for example a rectangle -- how can that be done using the standard geometrical functions of spatial in an oracle 10g2 database?
SDO_LENGHT delivers the outline of the polygon. If have looked at the LRS functions, but could not come up with a combination that delivers me what I am looking for. Any suggestion is appreciated.What do you see as the longest side?
Is that the longest stretch between 2 consecutive vertices?
If this is the case, this sql could be of help, which could need maybe some optimisation and extension (calculates straigth distance between 2 consecutive vertices).
select id, p_side_nr, p_side, p_side_length
from
select id, p_side_nr, p_side, sdo_geom.sdo_length(p_side, 0.005) p_side_length, max(sdo_geom.sdo_length(p_side, 0.005)) over (partition by id) max_p_side_length
from
select id, p_side_nr,
sdo_geometry(2002, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(startx, starty, endx, endy)
) p_side
from
select
startp.id, startp.x startx, startp.y starty, startp.v_id p_side_nr, endp.x endx, endp.y endy, endp.v_id
from
select s.id, t.id v_id, t.x, t.y
from your_table_name s, table(sdo_util.getvertices(geometry)) t
) startp
select s.id, t.id v_id, t.x, t.y
from your_table_name s, table(sdo_util.getvertices(geometry)) t
) endp
where startp.id = endp.id
and startp.v_id = endp.v_id - 1
) where p_side_length = max_p_side_lengthif you do not need the geometry of that longest side, you could follow Ivan's suggestion as a shortcut by using Pythagoras.
Edited by: lucvanlinden on Sep 2, 2008 7:48 PM -
Polygon Line (Stroke Size)
Hello,
A friend in this forum once helped me to sort out a problem in the code below. The problem then was that I wanted to increase the stroke size of polygon lines. The polygon points represent cities. The example then was based on 2 cities and the code worked. Now I increased it to 3 cities but the result is wrong.
package graphic;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.geom.*;
import java.awt.BasicStroke;
import java.awt.RenderingHints;
public class DrawCliqueTest {
public static void main(String[] args) {
try {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BufferedImage image = new BufferedImage(400, 300,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.WHITE);
g.fillRect(0, 0, image.getWidth(), image.getHeight());
g.setColor(Color.BLACK);
List<String[]> StringElements = new ArrayList<String[]>();
String[] Elem1 = {"Wahington","Chicago","London"};
String[] Elem2 = {"Washington","Tokyo","London","Chicago"};
StringElements.add(Elem1);
StringElements.add(Elem2);
List<int[]> Xlist = new ArrayList<int[]>();
int[] xPoint1 = {150,278,250};
int[] xPoint2 = {150,50,250,278};
Xlist.add(xPoint1);
Xlist.add(xPoint2);
List<int[]>Ylist = new ArrayList<int[]>();
int[] yPoint1 = {50,80,203};
int[] yPoint2 = {50,200,203,80};
Ylist.add(yPoint1);
Ylist.add(yPoint2);
ArrayList<Polygon> list = new ArrayList<Polygon>();
list.add(new Polygon(new int[] {150, 278,250}, new int[] {50, 80,203}, 3));
list.add(new Polygon(new int[] {150, 50, 250, 278},
new int[] {50, 200, 203, 80}, 4));
//Draw the Strings
for(int i = 0; i < StringElements.size(); i++) {
for(int j = 0; j < StringElements.get(i).length; j++) {
g.setColor(Color.RED);
g.drawString(StringElements.get(i)[j], Xlist.get(i)[j],
Ylist.get(i)[j]);
// Draw a line between every pair of points
for (Polygon poly : list) {
for (int i = 0; i < poly.npoints-1; i++) {
for (int j = i+1; j < poly.npoints; j++) {
g.setColor(Color.BLACK);
//if((i == 0 && j == 3) || (i == 1 && j == 0))
if(((i==0 && j==3) ||(i==0 && j==2))||((i==1 && j==0)||(i==1 && j==2))||((i==2 && j==0 ||(i==2 && j==3))))
g.setStroke(new BasicStroke(2f));
else
g.setStroke(new BasicStroke(1f));
g.drawLine(poly.xpoints, poly.ypoints[i],poly.xpoints[j], poly.ypoints[j]);
g.dispose();
frame.add(new JLabel(new ImageIcon(image)));
frame.pack();
frame.setVisible(true);
} catch(Exception e) { e.printStackTrace(); }
The program is meant to check the elements in each array of the ArrayList "StringElements" and get the strongly connected cities (the same cities that are in both arrays; Elem1 and Elem2. .
If you run the code, it draws the connections between London->Washington, London->Chicago and London->Tokyo with a stroke size 2 and the rest with stroke size 1. But, London->Tokyo is not suppose to be drawn with stroke size 2 because Tokyo is not in Elem1.
My plans is to implement this line of the code which is my problem point: if(((i==0 && j==3) ||(i==0 && j==2))||((i==1 && j==0)||(i==1 && j==2))||((i==2 && j==0 ||(i==2 && j==3)))) dynamically but the static version is not even working.
Any solution or idea on how to overcome this problem?
Thanks,
Jona_Timport java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.geom.*;
import java.awt.BasicStroke;
import java.awt.RenderingHints;
public class DCT {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BufferedImage image = new BufferedImage(400, 300,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.WHITE);
g.fillRect(0, 0, image.getWidth(), image.getHeight());
g.setColor(Color.BLACK);
List<String[]> StringElements = new ArrayList<String[]>();
String[] Elem1 = {"Washington","Chicago","London"};
String[] Elem2 = {"Washington","Tokyo","London","Chicago"};
StringElements.add(Elem1);
StringElements.add(Elem2);
List<int[]> Xlist = new ArrayList<int[]>();
int[] xPoint1 = {150,278,250};
int[] xPoint2 = {150,50,250,278};
Xlist.add(xPoint1);
Xlist.add(xPoint2);
List<int[]>Ylist = new ArrayList<int[]>();
int[] yPoint1 = {50,80,203};
int[] yPoint2 = {50,200,203,80};
Ylist.add(yPoint1);
Ylist.add(yPoint2);
ArrayList<Polygon> list = new ArrayList<Polygon>();
list.add(new Polygon(new int[] {150, 278, 250},
new int[] { 50, 80, 203}, 3));
list.add(new Polygon(new int[] {150, 50, 250, 278},
new int[] { 50, 200, 203, 80}, 4));
//Draw the Strings
for(int i = 0; i < StringElements.size(); i++) {
for(int j = 0; j < StringElements.get(i).length; j++) {
g.setColor(Color.RED);
g.drawString(StringElements.get(i)[j], Xlist.get(i)[j],
Ylist.get(i)[j]);
// Draw a line between every pair of points in each polygon.
for(int i = 0; i < list.size(); i++) {
Polygon poly = (Polygon)list.get(i);
for (int j = 0; j < poly.npoints; j++) {
for (int k = j+1; k < poly.npoints; k++) {
g.setColor(Color.BLACK);
// Use heavy Stroke if route is duplicated.
if(isDuplicated(i, j, k, StringElements))
g.setStroke(new BasicStroke(2f));
else
g.setStroke(new BasicStroke(1f));
g.drawLine(poly.xpoints[j], poly.ypoints[j],
poly.xpoints[k], poly.ypoints[k]);
g.dispose();
frame.add(new JLabel(new ImageIcon(image)));
frame.pack();
frame.setVisible(true);
private static boolean isDuplicated(int elementIndex, int origIndex,
int destIndex, List<String[]> StringElements) {
// Look for cities in StringElements.get(elementIndex) located
// at [origIndex] and [destIndex] in the other StringElement arrays.
String[] elementCities = StringElements.get(elementIndex);
String orig = elementCities[origIndex];
//System.out.println("orig = " + orig);
String dest = elementCities[destIndex];
//System.out.println("dest = " + dest);
// If we find both the orig and dest cities in any other
// element of StringElements return true.
for(int j = 0; j < StringElements.size(); j++) {
if(j == elementIndex)
continue;
String[] element = StringElements.get(j);
if(contains(element, orig) && contains(element, dest))
return true;
return false;
private static boolean contains(String[] circuit, String city) {
for(int j = 0; j < circuit.length; j++) {
if(city.equals(circuit[j]))
return true;
return false;
} -
Creating a triangle using polygon class problem, URGENT??
Hi i am creating a triangle using polygon class which will eventually be used in a game where by a user clicks on the screen and triangles appear.
class MainWindow extends Frame
private Polygon[] m_polyTriangleArr;
MainWindow()
m_nTrianglesToDraw = 0;
m_nTrianglesDrawn = 0;
m_polyTriangleArr = new Polygon[15];
addMouseListener(new MouseCatcher() );
setVisible(true);
class MouseCatcher extends MouseAdapter
public void mousePressed(MouseEvent evt)
Point ptMouse = new Point();
ptMouse = evt.getPoint();
if(m_nTrianglesDrawn < m_nTrianglesToDraw)
int npoints = 3;
m_polyTriangleArr[m_nTrianglesDrawn]
= new Polygon( ptMouse[].x, ptMouse[].y, npoints);
}When i compile my code i get the following error message:
Class Expected
')' expectedThe two error messages are refering to the section new Polygon(....)
line. Please helpCannot find symbol constructor Polygon(int, int, int)
Can some one tell me where this needs to go and what i should generally
look like pleaseI don't think it is a good idea to try and add the constructor that the compiler
can't find. Instead you should use the constructor that already exists
in the Polygon class: ie the one that looks like Polygon(int[], int[], int).
But this requires you to pass two int arrays and not two ints as you
are doing at the moment. As you have seen, evt.getPoint() only supplies
you with a single pair of ints: the x- and y-coordinates of where the mouse
button was pressed.
And this is the root of the problem. To draw a triangle you need three
points. From these three points you can build up two arrays: one containing
the x-coordinates and one containing the y-coordinates. It is these two
arrays that will be used as the first two arguments to the Polygon constructor.
So your task is to figure out how you can respond to mouse presses
correctly, and only try and add a new triangle when you have all three of its
vertices.
[Edit] This assumes that you expect the user to specify all three vertices of the
triangle. If this isn't the case, say what you do expect. -
Creating a triangle using polygon class problem?
Hi i am trying to create a triangle with the polygon class. If successful, the user should be able to click on the screen and triangles should appear.
private Polygon[] m_polyTriangleArr;
MainWindow()
m_polyTriangleArr = new Polygon[15];
class MouseCatcher extends MouseAdapter
public void mousePressed(MouseEvent evt)
Point ptMouse = new Point();
ptMouse = evt.getPoint();
if(m_nTrianglesDrawn < m_nTrianglesToDraw)
int npoints = 3;
m_polyTriangleArr[m_nTrianglesDrawn]
= new Polygon( ptMouse.x, ptMouse.y, npoints);
m_nTrianglesDrawn++;
m_bMouse = true;
repaint();
}Paint section
public void paint(Graphics gc)
if(m_bMouse)
gc.setColor(Color.green);
for( int i = 0; i < m_nTrianglesDrawn; i++)
gc.fillPolygon(m_polyTriangleArr.x, m_polyTriangleArr[i].y, npoints);
When i try to compile my code i get the following error message:
Cannot find symbol constructor Polygon(int, int, int)
--- find symbol variable x
--- find symbol variable y
--- find symbol variable npoints.
Can som1 tell me why i have these error messages when i have already declared a Polygon object array and what i need to change please??Check out the API
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Polygon.html
there's no constructor that receives 3 integers
cheers,
Manuel Leiria -
How to create a generalized version of the detailed polygons?
How to create a generalized version of the detailed polygons?
I have a table of detailed polygons (100+ vertices) and I want to get generalized version of these polygons.
For example, assume I have a polygon with 100 vertices. Distance between vertex n and n+1 is 1.0.
I want to get geometry (generalized polygon, line or point) where distance between vertex n and n+1 is 10.0 or more (I want vertices to be considered as one vertex if distance between them is less then 10.0).
Is it possible to create generalized version of polygons on the fly?
Any help is appreciated.
Thanks.Scenario A:
If all of your polygons have no interaction among them (No polygon shares any boundary with any other ones).
In this case you can use the sdo_util.simplify in 10g to reduce the vertices in your polygons which returns new polygon geometries on the fly.
If you found that simplify is not doing exactly what you want, you can always roll out your own implementation using PL/SQL or the new SDOAPI JGeoemtry class in Java. Both will give you complete access to the coordinate arrays in a polygon and update them back to the database after you have simplified them in your code.
Scenario B:
If your polygons share boundaries, then the above methods will not work since the simplification process may not preserve the topology among your polygons. What you can do then is to use the Java topo package to create a new topology by adding all of your polygons to to an empty topology (which you first create in the database and then load into memory using oracle.spatial.topo.TopoMap). Once you have a topology built in the memory, you can use methods such as oracle.spatial.topo.TopoMap.changeEdgeCoords() to simplify the edges of your polygons. You can then recreate the simplified polygons from the topology. This is just a rough guide; for more details you need to check out the java doc for the various packages mentioned above which are shipped with 10g spatial. -
I built a map with Google Maps Engine Pro - http://www.jmbcompanies.com/Services/Mitigation/map.
It showcases territories using a Google map polygon shape. I wrote custom KML to create it. However, with Google Maps Engine pro you cannot create custom hyperlinks. It will link a URL that you put in the data, but you cannot name it or target the parent window, so therefore it opens a new tab for each click to more details. I really want it to open the WebApp detail page for that item within the same window.
So, is there a way to use the BC integrated Google maps technology and show polygons instead of points on the map? I've used {module_webappsmap,20754,a} to place individual locations on a map, but what about territories or polygon areas?
I'm sure that I can create a WebApp to generate the KML for each placeholder. But how do I turn that into a map?
THANKS!!You can not create a kml file in BC through webapps. Modules do not work in other file types and you do not have server code access to generate a file type of results.
You need to use the google API and do this yourself or you can just use this:
And embed it into a custom field. My Maps -
Line with intersection points across Polygon
I have a (multi point) line that intersects a polygon and I can find the intersection points
See this site for example: Finding Intersection Points between Line and&#160;Polygon
However I would like to get the original multi point line WITH the intersection points added...
How would I achieve this?
Basically for a given line that intersects a polygon, I would like to have returned...
a new line that consists of the original points AND the intersection points
Thanks in advanceHi Luc,
Thanks for your response.
I had tried an SDO_UNION however the result of the union is not quite what I expected...
Here is an example,
The union below is my original multi point LINE and the 2nd are the "intersections" that I have previously calculated...
These intersections are actually in between specific points in the LINE...
However the union does not seem to put these 4 points in the line where I expect them too..
Not sure if SDO_UNION is the function for the job ?
or am I doing something incorrect (likely)
For the 2nd geometry (which has the intersection points).... what would be a type to use ? Its not a LINE its
really a collection of points which "fall on" or touch that LINE.
select SDO_GEOM.SDO_UNION (
(SELECT SDO_GEOMETRY(2002, 8265, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(
-73.7789255556,40.6397511111,-70.0267102778,41.2818872223,-69.7833,42.4333,-69.6333,42.5166,-69.45,42.6166,-69.3,42.7,-69.1333,42.8,-68.95,42.8833,-68.8,42.9833,-68.6333,43.6666,-68.45,43.1666,-68.2666,43.25,-68.1,43.3333,-67.9166,43.4333,-67.7666,43.5166,-67.5833,43.6,-67.3833,43.7,-67.2166,43.7833,-67.6666,43.8833,-66.8666,43.9666,-66.65,44.6666,-66.5,44.15,-66.2833,44.2333,-66.1,44.3166,-65.9166,44.4333,-65.7333,44.5166,-65.55,44.6,-65.3666,44.6833,-65.1666,44.7666,-64.9833,44.85,-64.7833,44.95,-64.5833,45.3333,-64.4,45.1166,-64.1833,45.2166,-64,45.3,-63.8,45.3833,-63.6166,45.4833,-63.4166,45.5666,-63.2,45.65,-63,45.7333,-62.8166,45.8333,-62.6166,45.9166,-62.4166,46,-62.2,46.3333,-62,46.1666,-61.7833,46.25,-61.5833,46.35,-61.3833,46.4166,-61.1833,46.5,-60.9833,46.5833,-60.7666,46.6666,-60.5666,46.75,-60.3666,46.8166,-60.15,46.9,-59.95,46.9833,-59.75,47.6666,-59.55,47.15,-59.35,47.2166,-59.1166,47.3,-58.9333,47.3666,-58.7333,47.4333,-58.5166,47.5166,-58.3333,47.5833,-58.1333,47.6666,-57.9166,47.7333,-57.7166,47.8,-57.55,47.8666,-57.3333,47.95,-57.1333,48.6666,-56.9333,48.3333,-56.7166,48.15,-56.5166,48.2333,-56.3,48.2833,-56.1166,48.3666,-55.8833,48.4166,-55.7,48.4833,-55.4666,48.55,-55.2833,48.6,-55.05,48.6666,-54.8666,48.7166,-54.65,48.7666,-54.45,48.85,-54.2333,48.9,-54.6666,48.95,-53.8,49.6666,-53.6,49.6666,-53.3833,49.1333,-53.1833,49.1833,-52.9833,49.2333,-52.7666,49.3,-52.55,49.35,-52.3333,49.4,-52.1166,49.45,-51.9,49.5166,-51.6833,49.5666,-51.4666,49.6166,-51.2333,49.6666,-51.6666,49.7166,-50.8,49.75,-50.6,49.8166,-50.3833,49.8666,-50.1666,49.9166,-49.95,49.9666,-49.7333,50,-49.5166,50.3333,-49.2666,50.6666,-49.05,50.3333,-48.8333,50.1166,-48.5833,50.15,-47.9166,50.25,-40,51,-35,51.6,-29,51.1166666667,-40.0833333333,50.4333333333,-44.55,49.6,-52.75,47.6166666667,-52.7524194444,47.6186194445
)) AS geom
FROM dual
), -- LINE
(SELECT SDO_GEOMETRY(2005, 8265, NULL, SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(
-50.0000000000001,49.9551029915852,
-30,51.2193352796549,
-50,48.3647769601594,
-30,51.0986671679795
)) AS geom2
FROM dual
), -- INTERSECTIONS
0.005
) from dual;
The "INTERSECTIONS" above
-50.0000000000001,49.9551029915852,
-30,51.2193352796549,
-50,48.3647769601594,
-30,51.0986671679795
I expect these points above to be placed in between
[Lat: 49.9166, Long: -50.1666] --> crossing Lat: 49.9551029915853, Long: -50 <-- [Lat: 49.9666, Long: -49.95]
[Lat: 51.6, Long: -35] --> crossing Lat: 51.2193352796549, Long: -30 <-- [Lat: 51.1166666667, Long: -29]
[Lat: 51.1166666667, Long: -29] --> crossing Lat: 51.0986671679795, Long: -30 <-- [Lat: 50.4333333333, Long: -40.0833333333]
[Lat: 49.6, Long: -44.55] --> crossing Lat: 48.3647769601594, Long: -50 <-- [Lat: 47.6166666667, Long: -52.75]
I have the intersections which is fine.. but I'd like them to be all aggregated into the original LINE
or if there is a way to get the points in the line that are between these intersections
Thanks for your help
Cheers -
Looking for a 2D Polygon Bevel Algorithm
I am looking for a graphics algorithm to give two-dimensional polygons a 3D beveled edge look. The polygon should look like as though it is lit from the top-left. This is trivial for rectangular figures, but obviously much more complex for general polygons. The algorithm needs to support any type of polygon, including those with splines or other curved edges, as well as convex figures. Making matters even more complicated, it must also handle texture-filled polygons.
A Java class that provides this functionality would be perfect. Short of that, an implementation in any language, or even a description of an algorithm, would be helpful.
I created a java applet to illustrate the problem I am trying to solve - see the source below. This applet with source is also available at
http://www.keithhilen.com/Java/bevel/
Keith Hilen
[email protected]
Polygons.java :
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.geom.*;
public class Polygons extends Applet
Image image;
int polyWidth = 100;
int polyHeight = polyWidth;
int polyOfsX1 = 100;
int polyOfsY1 = 100;
int polyOfsX2 = 250;
int polyOfsY2 = 100;
int polyOfsX3 = 100;
int polyOfsY3 = 240;
int polyOfsX4 = 250;
int polyOfsY4 = 240;
Polygon octagon;
Ellipse2D.Double ellipse;
GeneralPath ornament;
BufferedImage imageBuf1, imageBuf2, imageBuf3, imageBuf4;
public void init()
image = loadImage("background.jpg");
createPolygons();
createImageBufs();
private Image loadImage(String name)
MediaTracker tracker = new MediaTracker(this);
Image image = getImage(getDocumentBase(), name);
tracker.addImage(image, 0);
for ( ; ; )
try { tracker.waitForAll(); } catch (InterruptedException e) { }
if (tracker.checkAll())
break;
return image;
public void createPolygons()
double sqrt2 = Math.sqrt(2);
int m1 = (int) (polyWidth / (2 + sqrt2));
int m2 = (int) (polyWidth * sqrt2 / (2 + sqrt2));
octagon = new Polygon();
octagon.addPoint(-m2/2, -(m1 + m2/2));
octagon.addPoint(+m2/2, -(m1 + m2/2));
octagon.addPoint(+(m1 + m2/2), -(m2/2));
octagon.addPoint(+(m1 + m2/2), +(m2/2));
octagon.addPoint(+m2/2, +(m1 + m2/2));
octagon.addPoint(-m2/2, +(m1 + m2/2));
octagon.addPoint(-(m1 + m2/2), +(m2/2));
octagon.addPoint(-(m1 + m2/2), -(m2/2));
ellipse = new Ellipse2D.Double(-polyWidth/2, -polyWidth/2, polyWidth, polyWidth*3/4);
ornament = new GeneralPath();
int l = polyWidth/2;
int m = polyWidth/16;
int s = polyWidth/32;
ornament.moveTo(+0+0, -l+0);
ornament.quadTo(+0+s, -l+0, +0+s, -l+s);
ornament.quadTo(+m+0, -m+0, l-s, 0-s);
ornament.quadTo(+l+0, +0-s, l0, +0+0);
ornament.quadTo(+l+0, +0+s, l-s, 0+s);
ornament.quadTo(+m+0, m0, +0+s, +l-s);
ornament.quadTo(+0+s, l-0, 0+0, l0);
ornament.quadTo(+0-s, l0, +0-s, +l-s);
ornament.quadTo(-m+0, m0, -l+s, +0+s);
ornament.quadTo(-l+0, +0+s, -l+0, +0+0);
ornament.quadTo(-l+0, +0-s, -l+s, +0-s);
ornament.quadTo(-m+0, -m+0, +0-s, -l+s);
ornament.quadTo(+0-s, -l+0, -0+0, -l+0);
public void createImageBufs()
Graphics2D g2d;
Composite saveAlpha;
// Figure 1
// Create image buf and get context
imageBuf1 = new BufferedImage(polyWidth, polyHeight,
BufferedImage.TYPE_INT_ARGB_PRE);
g2d = (Graphics2D) imageBuf1.getGraphics();
// Fill with transparent color
saveAlpha = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR,
0.0f));
g2d.fillRect(0, 0, polyWidth, polyHeight);
g2d.setComposite(saveAlpha);
// Draw figure
g2d.translate(polyWidth/2, polyHeight/2);
g2d.setClip(octagon);
g2d.setColor(Color.blue);
g2d.fillRect(-polyWidth/2, -polyHeight/2, polyWidth, polyHeight);
// Figure 2
// Create image buf and get context
imageBuf2 = new BufferedImage(polyWidth, polyHeight,
BufferedImage.TYPE_INT_ARGB_PRE);
g2d = (Graphics2D) imageBuf2.getGraphics();
// Fill with transparent color
saveAlpha = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR,
0.0f));
g2d.fillRect(0, 0, polyWidth, polyHeight);
g2d.setComposite(saveAlpha);
// Draw figure
g2d.translate(polyWidth/2, polyHeight/2);
g2d.setClip(octagon);
g2d.drawImage(image, -polyWidth/2, -polyWidth/2, null);
// Figure 3
// Create image buf and get context
imageBuf3 = new BufferedImage(polyWidth, polyHeight,
BufferedImage.TYPE_INT_ARGB_PRE);
g2d = (Graphics2D) imageBuf3.getGraphics();
// Fill with transparent color
saveAlpha = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
g2d.fillRect(0, 0, polyWidth, polyHeight);
g2d.setComposite(saveAlpha);
// Draw figure
g2d.translate(polyWidth/2, polyHeight/2);
g2d.setClip(ellipse);
g2d.drawImage(image, -polyWidth/2, -polyWidth*5/8, null);
// Figure 4
// Create image buf and get context
imageBuf4 = new BufferedImage(polyWidth, polyHeight, BufferedImage.TYPE_INT_ARGB_PRE);
g2d = (Graphics2D) imageBuf4.getGraphics();
// Fill with transparent color
saveAlpha = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
g2d.fillRect(0, 0, polyWidth, polyHeight);
g2d.setComposite(saveAlpha);
// Draw figure
g2d.translate(polyWidth/2, polyHeight/2);
g2d.setClip(ornament);
g2d.drawImage(image, -polyWidth/2, -polyWidth/2, null);
public void paint(Graphics g)
g.drawImage(imageBuf1, polyOfsX1 - polyWidth/2, polyOfsY1 - polyHeight/2, null);
g.drawImage(imageBuf2, polyOfsX2 - polyWidth/2, polyOfsY2 - polyHeight/2, null);
g.drawImage(imageBuf3, polyOfsX3 - polyWidth/2, polyOfsY3 - polyHeight/2, null);
g.drawImage(imageBuf4, polyOfsX4 - polyWidth/2, polyOfsY4 - polyHeight/2, null);
Polygons.html :
<applet
code=Polygons.class
name=Polygons
width=360
height=300>
</applet>Think you'll be lucky to find anything in the forum on push down automata. Do a search on google, perhaps with the keyword "parser" or "grammer checker" thrown in. There may well be whole books devoted to it!
-
How do I telll if a art is a rectangle/ellipse/polygon/star etc.?
When iterate through arts in document, I can tell if a art is kPathArt or not by call GetArtType(). Is there anyway that I can even tell if a kPathArt is a rectangle/ellipse/polygon/star etc., something like IsEllipse()?
Not as far as I know.
-
Hi Microsoft Excel Power Map program team!
I looked @ your Excel Power Map program add on, and it’s great.
However everyone is looking for the ability for the user to create polygon (boundary) maps.
It should not be that hard to add this functionality onto such a great map program you already have.
For example: let’s say one has 10 latitude & longitude coordinates and he wants to see the polygon (boundary) of them on your great map. One should be able to just put those 10 latitude & longitude coordinates in an Excel sheet, fire up your Power
Map, select that it should be plotted as a polygon (boundary) and it will display on the map.
Does Microsoft have any plans to add user polygon (boundary) map creation ability to your great Excel Power Map program?
I would also like to see Excel Power map have USA census tracts built into it just like is has USA zip codes built into it. Census data is also very important as thousands and thousands of people need to display polygon (boundary) for census tracts.
Please let me know if Microsoft has any plans to add user polygon (boundary) creation ability to its great Excel Power Map program?
Thank you very much!Hi,
Thanks for your feedback, based on your feature required, I'll move your thread to Power Map forum, there might be give us some light.
https://social.technet.microsoft.com/Forums/en-US/home?forum=powermap&filter=alltypes&sort=lastpostdesc
Regards,
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
How to calculate the area of a large number of polygons in a single query
Hi forum
Is it possible to calculate the area of a large number of polygons in a single query using a combination of SDO_AGGR_UNION and SDO_AREA? So far, I have tried doing something similar to this:
select sdo_geom.sdo_area((
select sdo_aggr_union ( sdoaggrtype(mg.geoloc, 0.005))
from mapv_gravsted_00182 mg
where mg.dblink = 521 or mg.dblink = 94 or mg.dblink = 38 <many many more....>),
0.0005) calc_area from dualThe table MAPV_GRAVSTED_00182 contains 2 fields - geoloc (SDO_GEOMETRY) and dblink (Id field) needed for querying specific polygons.
As far as I can see, I need to first somehow get a single SDO_GEOMETRY object and use this as input for the SDO_AREA function. But I'm not 100% sure, that I'm doing this the right way. This query is very inefficient, and sometimes fails with strange errors like "No more data to read from socket" when executed from SQL Developer. I even tried with the latest JDBC driver from Oracle without much difference.
Would a better approach be to write some kind of stored procedure, that adds up all the single geometries by adding each call to SDO_AREA on each single geometry object - or what is the best approach?
Any advice would be appreciated.
Thanks in advance,
JacobHi
I am now trying to update all my spatial table with SRID's. To do this, I try to drop the spatial index first to recreate it after the update. But for a lot of tables I can't drop the spatial index. Whenever I try to DROP INDEX <spatial index name>, I get this error - anyone know what this means?
Thanks,
Jacob
Error starting at line 2 in command:
drop index BSSYS.STIER_00182_SX
Error report:
SQL Error: ORA-29856: error occurred in the execution of ODCIINDEXDROP routine
ORA-13249: Error in Spatial index: cannot drop sequence BSSYS.MDRS_1424B$
ORA-13249: Stmt-Execute Failure: DROP SEQUENCE BSSYS.MDRS_1424B$
ORA-29400: data cartridge error
ORA-02289: sequence does not exist
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 27
29856. 00000 - "error occurred in the execution of ODCIINDEXDROP routine"
*Cause: Failed to successfully execute the ODCIIndexDrop routine.
*Action: Check to see if the routine has been coded correctly.
Edit - just found the answer for this in MetaLink note 241003.1. Apparently there is some internal problem when dropping spatial indexes, some objects gets dropped that shouldn't be. Solution is to manually create the sequence it complains it can't drop, then it works... Weird error.
Maybe you are looking for
-
WebAS access via Portal: Web Dispatcher required for load balancing ABAP
Hi Folks - We have EP 6.0 SP18 (Java only, WebAS 6.40, Unix/Solaris). The portal has a CI/SCS and one DI so we have a Web Dispatcher to load balance the portal servers. This works fine (and provides port 80 access). This portal will provide access t
-
In my header is there a way to point to a directory with images that it will rotate through all of the images based on a user defined time? Thanks in advance!
-
Illustrator CC preferences points vs: inches issue
I received a pdf carton dieline from a box printer, opened it in Illustrator CC and saved it as Illustrator CC file. The ruler unit is in points. I went to preferences and changed the units to inches and the ruler is still showing points. I closed an
-
Why is there NO way to change the credit card info to pay for ICloud services??
Currently I am being asked for a 3 digit verification number to a credit card that is no longer valid. Why is there no way to change the credit card info on ICloud services?
-
Spotlight appears but not let me type
Hi! Sometimes I hit CMD+Space and Spotlight searchfield appears with a blinking cursor. But whenever I start to type, I type in the application I had recently open. I'm not able to click into the Spotlight searchfield (it doesn't let me - when I clic