input
stringlengths
10
828
output
stringlengths
5
107
public void set max coordinates per line int num if num 1 throw new index out of bounds exception invalid coordinate count per line must be 0 max coordinates per line num
sets the number of coordinates printed per line
public geometry read string gml geometry factory geometry factory throws saxexception ioexception parser configuration exception return read new string reader gml geometry factory
reads a gml2 geometry from a tt string tt into a single
public geometry read reader reader geometry factory geometry factory throws saxexception ioexception parser configuration exception saxparser factory fact saxparser factory new instance fact set namespace aware false fact set validating false saxparser parser fact new saxparser if geometry factory null geometry factory new geometry factory gmlhandler gh new gmlhandler geometry factory null parser parse new input source reader default handler gh return gh get geometry
reads a gml2 geometry from a
public void set bytes final byte buffer this buffer buffer this position 0
sets this stream to read from the given buffer
public void read final byte buf int size buf length don t try and copy past the end of the input if position size buffer length size buffer length position system arraycopy buffer position buf 0 size position size
reads up to tt buf
public void set distance tolerance double distance tolerance if distance tolerance 0 0 throw new illegal argument exception tolerance must be non negative this distance tolerance distance tolerance
sets the distance tolerance for the simplification
private geometry collection read geometry collection text throws ioexception parse exception string next token get next empty or opener if next token equals empty return geometry factory create geometry collection new geometry array list geometries new array list geometry geometry read geometry tagged text geometries add geometry next token get next closer or comma while next token equals comma geometry read geometry tagged text geometries add geometry next token get next closer or comma geometry array new geometry geometries size return geometry factory create geometry collection geometry geometries to array array
creates a code geometry collection code using the next token in the
public void set distance tolerance double distance tolerance this distance tolerance distance tolerance
sets the distance tolerance for the simplification
public void simplify collection tagged lines for iterator i tagged lines iterator i has next input index add tagged line string i next for iterator i tagged lines iterator i has next tagged line string simplifier tlss new tagged line string simplifier input index output index tlss set distance tolerance distance tolerance tlss simplify tagged line string i next
simplify a collection of
protected geometry transform polygon polygon geom geometry parent geometry raw geom super transform polygon geom parent don t try and correct if the parent is going to do this if parent instanceof multi polygon return raw geom return create valid area raw geom
simplifies a polygon fixing it if required
public void set distance tolerance double distance tolerance if distance tolerance 0 0 throw new illegal argument exception tolerance must be non negative line simplifier set distance tolerance distance tolerance
sets the distance tolerance for the simplification
protected geometry transform multi polygon multi polygon geom geometry parent geometry raw geom super transform multi polygon geom parent return create valid area raw geom
simplifies a multi polygon fixing it if required
public void add polygon geometry geometry line string bisector horizontal bisector geometry geometry intersections bisector intersection geometry geometry widest intersection widest geometry intersections double width widest intersection get envelope internal get width if interior point null width max width interior point centre widest intersection get envelope internal max width width
finds a reasonable point at which to label a geometry
public coordinate centre envelope envelope return new coordinate avg envelope get min x envelope get max x avg envelope get min y envelope get max y
returns the centre point of the envelope
private double r parameter coordinate p1 coordinate p2 coordinate p double r compute maximum delta for numerical stability also handle case of p1 p2 being vertical or horizontal double dx math abs p2 x p1 x double dy math abs p2 y p1 y if dx dy r p x p1 x p2 x p1 x else r p y p1 y p2 y p1 y return r
rparameter computes the parameter for the point p
public boolean has intersection return result no intersection
tests whether the input geometries intersect
public boolean is intersection coordinate pt for int i 0 i result i if int pt i equals2 d pt return true return false
test whether a point is a intersection point of two line segments
public void insert double x1 double x2 object item super insert new interval math min x1 x2 math max x1 x2 item
inserts an item having the given bounds into the tree
public list query double x return query x x
returns items whose bounds intersect the given value
public list query double x1 double x2 return super query new interval math min x1 x2 math max x1 x2
returns items whose bounds intersect the given bounds
public void build assert is true built root item boundables is empty create node 0 create higher levels item boundables 1 built true
creates parent nodes grandparent nodes and so forth up to the root
protected list create parent boundables list child boundables int new level assert is true child boundables is empty int min leaf count int math ceil child boundables size double get node capacity array list sorted child boundables new array list child boundables collections sort sorted child boundables x comparator list vertical slices vertical slices sorted child boundables int math ceil math sqrt min leaf count return create parent boundables from vertical slices vertical slices new level
creates the parent level for the given child level
protected list create parent boundables list child boundables int new level assert is true child boundables is empty array list parent boundables new array list parent boundables add create node new level array list sorted child boundables new array list child boundables collections sort sorted child boundables get comparator for iterator i sorted child boundables iterator i has next boundable child boundable boundable i next if last node parent boundables get child boundables size get node capacity parent boundables add create node new level last node parent boundables add child boundable child boundable return parent boundables
sorts the child boundables then divides them into groups of size m where
public boolean is proper return has intersection is proper
tests whether an intersection is proper
public coordinate get intersection along segment int segment index int int index lazily compute int line array compute int line index return int pt int line index segment index int index
computes the int indexth intersection point in the direction of
private abstract node create higher levels list boundables of alevel int level assert is true boundables of alevel is empty list parent boundables create parent boundables boundables of alevel level 1 if parent boundables size 1 return abstract node parent boundables get 0 return create higher levels parent boundables level 1
creates the levels higher than the given level
public list get child boundables return child boundables
returns either child
public void insert envelope item env object item if item env is null return super insert item env item
inserts an item having the given bounds into the tree
public int get index along segment int segment index int int index compute int line index return int line index segment index int index
computes the index of the int indexth intersection point in the direction of
public list query envelope search env yes this method does something it specifies that the bounds is an envelope super query takes an object not an envelope jon aquino 10 24 2003 return super query search env
returns items whose bounds intersect the given envelope
public void query envelope search env item visitor visitor yes this method does something it specifies that the bounds is an envelope super query takes an object not an envelope jon aquino 10 24 2003 super query search env visitor
returns items whose bounds intersect the given envelope
public boolean remove envelope item env object item return super remove item env item
removes a single item from the tree
protected list query object search bounds if built build array list matches new array list if item boundables is empty assert is true root get bounds null return matches if get intersects op intersects root get bounds search bounds query search bounds root matches return matches
also builds the tree if necessary
protected void query object search bounds item visitor visitor if built build if item boundables is empty assert is true root get bounds null if get intersects op intersects root get bounds search bounds query search bounds root visitor
also builds the tree if necessary
protected boolean remove object search bounds object item if built build if item boundables is empty assert is true root get bounds null if get intersects op intersects root get bounds search bounds return remove search bounds root item return false
removes an item from the tree
public double get x return p x
returns the x coordinate of the node
public double get y return p y
returns the y coordinate of the node
public coordinate get coordinate return p
returns the location of this node
public kd node insert coordinate p return insert p null
inserts a new point in the kd tree with no data
public kd node get left return left
returns the left node of the tree
public kd node get right return right
returns the right node of the tree
public list query envelope query env list result new array list query node root last query env true result return result
performs a range search of the points in the index
public void query envelope query env list result query node root last query env true result
performs a range search of the points in the index
public coordinate get coordinate int i return coordinates i
get the coordinate with index i
public coordinate get coordinate copy int i return new coordinate coordinates i
get a copy of the coordinate with index i
public void set type int type if type double type float throw new illegal argument exception unknown type type this type type
sets the type of packed coordinate sequences this factory builds
public object clone coordinate clone coordinates new coordinate size for int i 0 i coordinates length i clone coordinates i coordinate coordinates i clone return new coordinate array sequence clone coordinates
creates a deep copy of the object
public int size return coordinates length
returns the size of the coordinate sequence
public void set x int index double value coord ref null set ordinate index 0 value
sets the first ordinate of a coordinate in this sequence
public object clone coordinate list clone coordinate list super clone for int i 0 i this size i clone add i coordinate this get i clone return clone
returns a deep copy of this tt coordinate list tt instance
public void set y int index double value coord ref null set ordinate index 1 value
sets the second ordinate of a coordinate in this sequence
public string to string if coordinates length 0 string buffer str buf new string buffer 17 coordinates length str buf append str buf append coordinates 0 for int i 1 i coordinates length i str buf append str buf append coordinates i str buf append return str buf to string else return
returns the string representation of the coordinate array
public precision model get precision model return precision model
returns the precision model that geometries created by this factory
public point create point coordinate coordinate return create point coordinate null get coordinate sequence factory create new coordinate coordinate null
creates a point using the given coordinate a null coordinate will create
public point create point coordinate sequence coordinates return new point coordinates this
creates a point using the given coordinate sequence a null or empty
public geometry get boundary if is empty return get factory create multi line string null array list all rings new array list for int i 0 i geometries length i polygon polygon polygon geometries i geometry rings polygon get boundary for int j 0 j rings get num geometries j all rings add rings get geometry n j line string all rings array new line string all rings size return get factory create multi line string line string all rings to array all rings array
computes the boundary of this geometry
public geometry collection create geometry collection geometry geometries return new geometry collection geometries this
creates a geometry collection using the given geometries a null or empty
public multi polygon create multi polygon polygon polygons return new multi polygon polygons this
creates a multi polygon using the given polygons a null or empty array
public object clone coordinate clone coordinates new coordinate size for int i 0 i coordinates length i clone coordinates i coordinate coordinates i clone return new default coordinate sequence clone coordinates
creates a deep copy of the object
public multi point create multi point point point return new multi point point this
creates a multi point using the given points
public multi point create multi point coordinate sequence coordinates if coordinates null return create multi point new point 0 point points new point coordinates size for int i 0 i coordinates size i points i create point coordinates get coordinate i return create multi point points
creates a multi point using the given coordinate sequence
public polygon create polygon linear ring shell linear ring holes return new polygon shell holes this
constructs a code polygon code with the given exterior boundary and
public boolean equals2 d coordinate other if x other x return false if y other y return false return true
returns whether the planar projections of the two code coordinate code s
public boolean equals object other if other instanceof coordinate return false return equals2 d coordinate other
returns code true code if code other code has the same values for
public geometry factory get factory return factory
gets the factory which contains the context in which this geometry was created
public double distance coordinate p double dx x p x double dy y p y return math sqrt dx dx dy dy
computes the 2 dimensional euclidean distance to another location
public int hash code algorithm from effective java by joshua bloch jon aquino int result 17 result 37 result hash code x result 37 result hash code y return result
gets a hashcode for this coordinate
public int get boundary dimension return dimension false
returns code dimension
public object clone geometry collection gc geometry collection super clone gc geometries new geometry geometries length for int i 0 i geometries length i gc geometries i geometry geometries i clone return gc return the clone
creates and returns a full copy of this
public int get num geometries return 1
returns the number of
public coordinate sequence create coordinate coordinates return new default coordinate sequence coordinates
returns a default coordinate sequence based on the given array the array is
public geometry get geometry n int n return this
returns an element
public int get maximum significant digits int max sig digits 16 if model type floating max sig digits 16 else if model type floating single max sig digits 6 else if model type fixed max sig digits 1 int math ceil math log get scale math log 10 return max sig digits
returns the maximum number of significant digits provided by this
public double get offset x we actually don t use offset x and offset y anymore jon aquino return 0
returns the x offset used to obtain a precise coordinate
public geometry get boundary if is empty return get factory create multi line string null linear ring rings new linear ring holes length 1 rings 0 shell for int i 0 i holes length i rings i 1 holes i create line string or multi line string as appropriate if rings length 1 return get factory create linear ring rings 0 get coordinate sequence return get factory create multi line string rings
computes the boundary of this geometry
public double get offset y return 0
returns the y offset used to obtain a precise coordinate
public void to internal coordinate external coordinate internal if is floating internal x external x internal y external y else internal x make precise external x internal y make precise external y internal z external z
sets code internal code to the precise representation of code external code
public precision model get precision model return factory get precision model
returns the code precision model code used by the code geometry code
public coordinate to internal coordinate external coordinate internal new coordinate external make precise internal return internal
returns the precise representation of code external code
public coordinate to external coordinate internal coordinate external new coordinate internal return external
returns the external representation of code internal code
public void to external coordinate internal coordinate external external x internal x external y internal y
sets code external code to the external representation of code internal code
public object clone polygon poly polygon super clone poly shell linear ring shell clone poly holes new linear ring holes length for int i 0 i holes length i poly holes i linear ring holes i clone return poly return the clone
creates and returns a full copy of this
public boolean is valid if is valid op is valid get coordinate return false return true
a point is valid iff
public geometry get boundary return get factory create geometry collection null
gets the boundary of this geometry
public object clone point p point super clone p coordinates coordinate sequence coordinates clone return p return the clone
creates and returns a full copy of this
public boolean equals object o if o instanceof line segment return false line segment other line segment o return p0 equals other p0 p1 equals other p1
returns code true code if code other code has the same values for
public int hash code long bits0 java lang double double to long bits p0 x bits0 java lang double double to long bits p0 y 31 int hash0 int bits0 int bits0 32 long bits1 java lang double double to long bits p1 x bits1 java lang double double to long bits p1 y 31 int hash1 int bits1 int bits1 32 xor is supposed to be a good way to combine hashcodes return hash0 hash1
gets a hashcode for this object
protected geometry transform linear ring linear ring geom geometry parent coordinate sequence seq transform coordinates geom get coordinate sequence geom int seq size seq size ensure a valid linear ring if seq size 0 seq size 4 preserve type return factory create line string seq return factory create linear ring seq
transforms a linear ring
public int compare to object o line segment other line segment o int comp0 p0 compare to other p0 if comp0 0 return comp0 return p1 compare to other p1
compares this object with the specified object for order
public geometry get boundary return new boundary op this get boundary
gets the boundary of this geometry
public object clone line string ls line string super clone ls points coordinate sequence points clone return ls
creates and returns a full copy of this
public void set int row int column int dimension value matrix row column dimension value
changes the value of one of this code intersection matrix code s
public void set to null min x double na n
sets the value of this object to the null value
public geometry get envelope return get factory to geometry get envelope internal
returns this code geometry code s bounding box
public void set string dimension symbols for int i 0 i dimension symbols length i int row i 3 int col i 3 matrix row col dimension to dimension value dimension symbols char at i
changes the elements of this code intersection matrix code to the
public void set at least int row int column int minimum dimension value if matrix row column minimum dimension value matrix row column minimum dimension value
changes the specified element to code minimum dimension value code if the
public void set at least string minimum dimension symbols for int i 0 i minimum dimension symbols length i int row i 3 int col i 3 set at least row col dimension to dimension value minimum dimension symbols char at i
for each element in this code intersection matrix code changes the
public int get int row int column return matrix row column
returns the value of one of this matrix
public void geometry changed apply geometry changed filter
notifies this geometry that its coordinates have been changed by an external
public boolean is disjoint return matrix location interior location interior dimension false matrix location interior location boundary dimension false matrix location boundary location interior dimension false matrix location boundary location boundary dimension false
returns code true code if this code intersection matrix code is