question: public final void insert ( LineString geom , final int item ) { Coordinate [ ] coord = geom . getCoordinates ( ) ; final TLongSet keys = new TLongHashSet ( coord . length * 8 ) ; for ( int i = 0 ; i < coord . length - 1 ; i ++ ) { double dX = coord [ i ] . x - coord [ i + 1 ] . x ; double dY = coord [ i ] . y - coord [ i + 1 ] . y ; int segments = ( int ) Math . max ( Math . abs ( dX ) / xBinSize , Math . abs ( dY ) / yBinSize ) ; if ( segments > 1000 || segments < 0 ) LOG . warn ( "Huge number of segments ({}) for edge, or possible int overflow)" , segments ) ; segments = Math . max ( segments , 1 ) ; double segFrac = 1D / segments ; for ( int s = 0 ; s < segments ; s ++ ) { Coordinate c0 = new Coordinate ( VertexStore . floatingDegreesToFixed ( coord [ i ] . x + dX * segFrac * s ) , VertexStore . floatingDegreesToFixed ( coord [ i ] . y + dY * segFrac * s ) ) ; Coordinate c1 = new Coordinate ( VertexStore . floatingDegreesToFixed ( coord [ i ] . x + dX * segFrac * ( s + 1 ) ) , VertexStore . floatingDegreesToFixed ( coord [ i ] . y + dY * segFrac * ( s + 1 ) ) ) ; Envelope env = new Envelope ( c0 , c1 ) ; visit ( env , true , null ) ; } } keys . forEach ( null ) ; nObjects ++ ; }
target:  Insert a linestring into the index. NB: the line string uses real-world float coordinates, not fixed coordinates. This function keeps long and angular line strings from winding up in many unnecessary cells by inserting each segment individually and splitting long segments into pieces. We could use a rasterization algorithm, but just splitting the line segments up into manageable pieces works as well and is easier to follow, at the expense of slower insert performance (which so far doesn't seem to be a problem).