idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
8,900 | protected void generateNewBasename ( ) { Properties localProps = new Properties ( ) ; localProps . setProperty ( "prefix" , settings . getPrefix ( ) ) ; synchronized ( this . getClass ( ) ) { String paddedSerialNumber = WriterPoolMember . serialNoFormatter . format ( serialNo . getAndIncrement ( ) ) ; String timestamp17 = ArchiveUtils . getUnique17DigitDate ( ) ; String timestamp14 = ArchiveUtils . getUnique14DigitDate ( ) ; currentTimestamp = timestamp17 ; localProps . setProperty ( "serialno" , paddedSerialNumber ) ; localProps . setProperty ( "timestamp17" , timestamp17 ) ; localProps . setProperty ( "timestamp14" , timestamp14 ) ; } currentBasename = PropertyUtils . interpolateWithProperties ( settings . getTemplate ( ) , localProps , System . getProperties ( ) ) ; } | Generate a new basename by interpolating values in the configured template . Values come from local state other configured values and global system properties . The recommended default template will generate a unique basename under reasonable assumptions . |
8,901 | protected String getBaseFilename ( ) { String name = this . f . getName ( ) ; if ( settings . getCompress ( ) && name . endsWith ( DOT_COMPRESSED_FILE_EXTENSION ) ) { return name . substring ( 0 , name . length ( ) - 3 ) ; } else if ( settings . getCompress ( ) && name . endsWith ( DOT_COMPRESSED_FILE_EXTENSION + OCCUPIED_SUFFIX ) ) { return name . substring ( 0 , name . length ( ) - ( 3 + OCCUPIED_SUFFIX . length ( ) ) ) ; } else { return name ; } } | Get the file name |
8,902 | protected void preWriteRecordTasks ( ) throws IOException { if ( this . out == null ) { createFile ( ) ; } if ( settings . getCompress ( ) ) { this . out = new CompressedStream ( this . out ) ; } } | Post write tasks . |
8,903 | protected void postWriteRecordTasks ( ) throws IOException { if ( settings . getCompress ( ) ) { CompressedStream o = ( CompressedStream ) this . out ; o . finish ( ) ; o . flush ( ) ; o . end ( ) ; this . out = o . getWrappedStream ( ) ; } } | Post file write tasks . If compressed finishes up compression and flushes stream so any subsequent checks get good reading . |
8,904 | public long computeTotalLines ( ) { long numLines = 0 ; try { numLines = this . getNumLines ( summary . getRange ( "" , "" ) ) ; } catch ( IOException e ) { LOGGER . warning ( e . toString ( ) ) ; return 0 ; } long adjustment = getTotalAdjustment ( ) ; numLines -= ( getNumBlocks ( ) - 1 ) ; numLines *= this . getCdxLinesPerBlock ( ) ; numLines += adjustment ; return numLines ; } | Adjust from shorter blocks if loaded |
8,905 | protected String getCharsetFromMeta ( byte buffer [ ] , int len ) throws IOException { String charsetName = null ; String sample = new String ( buffer , 0 , len , DEFAULT_CHARSET ) ; String metaContentType = findMetaContentType ( sample ) ; if ( metaContentType != null ) { charsetName = contentTypeToCharset ( metaContentType ) ; } return charsetName ; } | Attempt to find a META tag in the HTML that hints at the character set used to write the document . |
8,906 | protected String getCharsetFromBytes ( byte buffer [ ] , int len ) throws IOException { String charsetName = null ; UniversalDetector detector = new UniversalDetector ( null ) ; detector . handleData ( buffer , 0 , len ) ; detector . dataEnd ( ) ; charsetName = detector . getDetectedCharset ( ) ; detector . reset ( ) ; if ( isCharsetSupported ( charsetName ) ) { return mapCharset ( charsetName ) ; } return null ; } | Attempts to figure out the character set of the document using the excellent juniversalchardet library . |
8,907 | public void readContentTo ( OutputStream os , long maxSize ) throws IOException { setToResponseBodyStart ( ) ; byte [ ] buf = new byte [ 4096 ] ; int c = read ( buf ) ; long tot = 0 ; while ( c != - 1 && tot < maxSize ) { os . write ( buf , 0 , c ) ; c = read ( buf ) ; tot += c ; } } | Convenience method to copy content out to target stream . |
8,908 | public void position ( long p ) throws IOException { if ( p < 0 ) { throw new IOException ( "Negative seek offset." ) ; } if ( p > size ) { throw new IOException ( "Desired position exceeds size." ) ; } if ( p < buffer . length ) { if ( position > buffer . length ) { diskStream . position ( 0 ) ; } } else { diskStream . position ( p - buffer . length ) ; } this . position = p ; } | Reposition the stream . |
8,909 | public void close ( ) throws IOException { if ( this . in != null ) { skip ( ) ; this . in = null ; if ( this . digest != null ) { this . digestStr = Base32 . encode ( this . digest . digest ( ) ) ; } } } | Calling close on a record skips us past this record to the next record in the stream . |
8,910 | public int available ( ) { long amount = getHeader ( ) . getLength ( ) - getPosition ( ) ; return ( amount > Integer . MAX_VALUE ? Integer . MAX_VALUE : ( int ) amount ) ; } | This available is not the stream s available . Its an available based on what the stated Archive record length is minus what we ve read to date . |
8,911 | protected void skip ( ) throws IOException { if ( this . eor ) { return ; } int r = available ( ) ; while ( r > 0 && ! this . eor ) { skip ( r ) ; r = available ( ) ; } } | Skip over this records content . |
8,912 | public GenerationFileHandler rotate ( String storeSuffix , String activeSuffix ) throws IOException { return rotate ( storeSuffix , activeSuffix , false ) ; } | Move the current file to a new filename with the storeSuffix in place of the activeSuffix ; continuing logging to a new file under the original filename . |
8,913 | public static GenerationFileHandler makeNew ( String filename , boolean append , boolean shouldManifest ) throws SecurityException , IOException { FileUtils . moveAsideIfExists ( new File ( filename ) ) ; return new GenerationFileHandler ( filename , append , shouldManifest ) ; } | Constructor - helper that rather than clobbering any existing file moves it aside with a timestamp suffix . |
8,914 | public T next ( ) { if ( ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } T returnObj = this . next ; this . next = null ; return returnObj ; } | Return the next item . |
8,915 | public static byte [ ] readToNull ( InputStream is , int maxSize ) throws IOException { byte [ ] bytes = new byte [ maxSize ] ; int i = 0 ; while ( i < maxSize ) { int b = is . read ( ) ; if ( b == - 1 ) { throw new EOFException ( "NO NULL" ) ; } bytes [ i ] = ( byte ) ( b & 0xff ) ; i ++ ; if ( b == 0 ) { return copy ( bytes , 0 , i ) ; } } throw new IOException ( "Buffer too small" ) ; } | Read buffer and return bytes from is until a null byte is encountered |
8,916 | static public void main ( String [ ] args ) { if ( args . length == 0 ) { System . out . println ( "Supply a Base32-encoded argument." ) ; return ; } System . out . println ( " Original: " + args [ 0 ] ) ; byte [ ] decoded = Base32 . decode ( args [ 0 ] ) ; System . out . print ( " Hex: " ) ; for ( int i = 0 ; i < decoded . length ; i ++ ) { int b = decoded [ i ] ; if ( b < 0 ) { b += 256 ; } System . out . print ( ( Integer . toHexString ( b + 256 ) ) . substring ( 1 ) ) ; } System . out . println ( ) ; System . out . println ( "Reencoded: " + Base32 . encode ( decoded ) ) ; } | For testing take a command - line argument in Base32 decode print in hex encode print |
8,917 | public void readHeader ( InputStream in ) throws IOException { CRC32 crc = new CRC32 ( ) ; crc . reset ( ) ; if ( ! testGzipMagic ( in , crc ) ) { throw new NoGzipMagicException ( ) ; } this . length += 2 ; if ( readByte ( in , crc ) != Deflater . DEFLATED ) { throw new IOException ( "Unknown compression" ) ; } this . length ++ ; this . flg = readByte ( in , crc ) ; this . length ++ ; this . mtime = readInt ( in , crc ) ; this . length += 4 ; this . xfl = readByte ( in , crc ) ; this . length ++ ; this . os = readByte ( in , crc ) ; this . length ++ ; final int FLG_FEXTRA = 4 ; if ( ( this . flg & FLG_FEXTRA ) == FLG_FEXTRA ) { int count = readShort ( in , crc ) ; this . length += 2 ; this . fextra = new byte [ count ] ; readByte ( in , crc , this . fextra , 0 , count ) ; this . length += count ; } final int FLG_FNAME = 8 ; if ( ( this . flg & FLG_FNAME ) == FLG_FNAME ) { while ( readByte ( in , crc ) != 0 ) { this . length ++ ; } } final int FLG_FCOMMENT = 16 ; if ( ( this . flg & FLG_FCOMMENT ) == FLG_FCOMMENT ) { while ( readByte ( in , crc ) != 0 ) { this . length ++ ; } } final int FLG_FHCRC = 2 ; if ( ( this . flg & FLG_FHCRC ) == FLG_FHCRC ) { int calcCrc = ( int ) ( crc . getValue ( ) & 0xffff ) ; if ( readShort ( in , crc ) != calcCrc ) { throw new IOException ( "Bad header CRC" ) ; } this . length += 2 ; } } | Read in gzip header . |
8,918 | private int readInt ( InputStream in , CRC32 crc ) throws IOException { int s = readShort ( in , crc ) ; return ( ( readShort ( in , crc ) << 16 ) & 0xffff0000 ) | s ; } | Read an int . |
8,919 | public String getHostBasename ( ) throws URIException { return ( this . getReferencedHost ( ) == null ) ? null : TextUtils . replaceFirst ( MASSAGEHOST_PATTERN , this . getReferencedHost ( ) , UsableURIFactory . EMPTY_STRING ) ; } | Strips www variants from the host . |
8,920 | protected void coalesceUriStrings ( ) { if ( this . cachedString != null && this . cachedEscapedURI != null && this . cachedString . length ( ) == this . cachedEscapedURI . length ( ) ) { this . cachedString = this . cachedEscapedURI ; } } | The two String fields cachedString and cachedEscapedURI are usually identical ; if so coalesce into a single instance . |
8,921 | protected void coalesceHostAuthorityStrings ( ) { if ( this . cachedAuthorityMinusUserinfo != null && this . cachedHost != null && this . cachedHost . length ( ) == this . cachedAuthorityMinusUserinfo . length ( ) ) { this . cachedAuthorityMinusUserinfo = this . cachedHost ; } } | The two String fields cachedHost and cachedAuthorityMinusUserInfo are usually identical ; if so coalesce into a single instance . |
8,922 | public String getReferencedHost ( ) throws URIException { String referencedHost = this . getHost ( ) ; if ( referencedHost == null && this . getScheme ( ) . equals ( "dns" ) ) { String possibleHost = this . getCurrentHierPath ( ) ; if ( possibleHost != null && possibleHost . matches ( "[-_\\w\\.:]+" ) ) { referencedHost = possibleHost ; } } return referencedHost ; } | Return the referenced host in the UURI if any also extracting the host of a DNS - lookup URI where necessary . |
8,923 | public static boolean hasScheme ( String possibleUrl ) { boolean result = false ; for ( int i = 0 ; i < possibleUrl . length ( ) ; i ++ ) { char c = possibleUrl . charAt ( i ) ; if ( c == ':' ) { if ( i != 0 ) { result = true ; } break ; } if ( ! scheme . get ( c ) ) { break ; } } return result ; } | Test if passed String has likely URI scheme prefix . |
8,924 | public void write ( OutputStream out ) throws IOException { for ( HttpHeader header : this ) { header . write ( out ) ; } out . write ( CR ) ; out . write ( LF ) ; } | Write all Headers and a trailing CRLF CRLF |
8,925 | private static boolean finishLastResponse ( final HttpConnection conn ) { InputStream lastResponse = conn . getLastResponseInputStream ( ) ; if ( lastResponse != null ) { conn . setLastResponseInputStream ( null ) ; try { lastResponse . close ( ) ; return true ; } catch ( IOException ioe ) { return false ; } } else { return false ; } } | Since the same connection is about to be reused make sure the previous request was completely processed and if not consume it now . |
8,926 | private byte [ ] generateARCFileMetaData ( String date ) throws IOException { if ( date != null && date . length ( ) > 14 ) { date = date . substring ( 0 , 14 ) ; } int metadataBodyLength = getMetadataLength ( ) ; String metadataHeaderLinesTwoAndThree = getMetadataHeaderLinesTwoAndThree ( "1 " + ( ( metadataBodyLength > 0 ) ? "1" : "0" ) ) ; int recordLength = metadataBodyLength + metadataHeaderLinesTwoAndThree . getBytes ( DEFAULT_ENCODING ) . length ; String metadataHeaderStr = ARC_MAGIC_NUMBER + getBaseFilename ( ) + " 0.0.0.0 " + date + " text/plain " + recordLength + metadataHeaderLinesTwoAndThree ; ByteArrayOutputStream metabaos = new ByteArrayOutputStream ( recordLength ) ; metabaos . write ( metadataHeaderStr . getBytes ( DEFAULT_ENCODING ) ) ; if ( metadataBodyLength > 0 ) { writeMetaData ( metabaos ) ; } metabaos . write ( LINE_SEPARATOR ) ; byte [ ] bytes = metabaos . toByteArray ( ) ; if ( isCompressed ( ) ) { byte [ ] gzippedMetaData = ArchiveUtils . gzip ( bytes ) ; if ( gzippedMetaData [ 3 ] != 0 ) { throw new IOException ( "The GZIP FLG header is unexpectedly " + " non-zero. Need to add smarter code that can deal " + " when already extant extra GZIP header fields." ) ; } gzippedMetaData [ 3 ] = 4 ; gzippedMetaData [ 9 ] = 3 ; byte [ ] assemblyBuffer = new byte [ gzippedMetaData . length + ARC_GZIP_EXTRA_FIELD . length ] ; System . arraycopy ( gzippedMetaData , 0 , assemblyBuffer , 0 , 10 ) ; System . arraycopy ( ARC_GZIP_EXTRA_FIELD , 0 , assemblyBuffer , 10 , ARC_GZIP_EXTRA_FIELD . length ) ; System . arraycopy ( gzippedMetaData , 10 , assemblyBuffer , 10 + ARC_GZIP_EXTRA_FIELD . length , gzippedMetaData . length - 10 ) ; bytes = assemblyBuffer ; } return bytes ; } | Write out the ARCMetaData . |
8,927 | protected String validateMetaLine ( String metaLineStr ) throws IOException { if ( metaLineStr . length ( ) > MAX_METADATA_LINE_LENGTH ) { throw new IOException ( "Metadata line too long (" + metaLineStr . length ( ) + ">" + MAX_METADATA_LINE_LENGTH + "): " + metaLineStr ) ; } Matcher m = METADATA_LINE_PATTERN . matcher ( metaLineStr ) ; if ( ! m . matches ( ) ) { throw new IOException ( "Metadata line doesn't match expected" + " pattern: " + metaLineStr ) ; } return metaLineStr ; } | Test that the metadata line is valid before writing . |
8,928 | private void writeRecord ( OutputStream out , HttpHeaders headers , byte [ ] contents ) throws IOException { if ( contents == null ) { headers . add ( CONTENT_LENGTH , "0" ) ; } else { headers . add ( CONTENT_LENGTH , String . valueOf ( contents . length ) ) ; } out . write ( WARC_ID . getBytes ( DEFAULT_ENCODING ) ) ; out . write ( CR ) ; out . write ( LF ) ; headers . write ( out ) ; if ( contents != null ) { out . write ( contents ) ; } out . write ( CR ) ; out . write ( LF ) ; out . write ( CR ) ; out . write ( LF ) ; } | Write the headers and contents as a WARC record to the given output stream . |
8,929 | public static ArchiveReader get ( final String arcFileOrUrl ) throws MalformedURLException , IOException { return ArchiveReaderFactory . factory . getArchiveReader ( arcFileOrUrl ) ; } | Get an Archive file Reader on passed path or url . Does primitive heuristic figuring if path or URL . |
8,930 | public int getIntegerValue ( ) throws IOException , SaneException { Preconditions . checkState ( getValueType ( ) == OptionValueType . INT , "option is not an integer" ) ; Preconditions . checkState ( getValueCount ( ) == 1 , "option is an integer array, not integer" ) ; ControlOptionResult result = readOption ( ) ; Preconditions . checkState ( result . getType ( ) == OptionValueType . INT ) ; Preconditions . checkState ( result . getValueSize ( ) == SaneWord . SIZE_IN_BYTES , "unexpected value size " + result . getValueSize ( ) + ", expecting " + SaneWord . SIZE_IN_BYTES ) ; return SaneWord . fromBytes ( result . getValue ( ) ) . integerValue ( ) ; } | Reads the current Integer value option . We do not cache value from previous get or set operations so each get involves a round trip to the server . |
8,931 | public boolean setBooleanValue ( boolean value ) throws IOException , SaneException { ControlOptionResult result = writeOption ( SaneWord . forInt ( value ? 1 : 0 ) ) ; Preconditions . checkState ( result . getType ( ) == OptionValueType . BOOLEAN ) ; return SaneWord . fromBytes ( result . getValue ( ) ) . integerValue ( ) != 0 ; } | Sets the value of the current option to the supplied boolean value . Option value must be of boolean type . SANE may ignore your preference so if you need to ensure the value has been set correctly you should examine the return value of this method . |
8,932 | public double setFixedValue ( double value ) throws IOException , SaneException { Preconditions . checkArgument ( value >= - 32768 && value <= 32767.9999 , "value " + value + " is out of range" ) ; SaneWord wordValue = SaneWord . forFixedPrecision ( value ) ; ControlOptionResult result = writeOption ( wordValue ) ; Preconditions . checkState ( result . getType ( ) == OptionValueType . FIXED , "setFixedValue is not appropriate for option of type " + result . getType ( ) ) ; return SaneWord . fromBytes ( result . getValue ( ) ) . fixedPrecisionValue ( ) ; } | Sets the value of the current option to the supplied fixed - precision value . Option value must be of fixed - precision type . |
8,933 | public int setIntegerValue ( int newValue ) throws IOException , SaneException { Preconditions . checkState ( getValueCount ( ) == 1 , "option is an array" ) ; Preconditions . checkState ( isWriteable ( ) ) ; ControlOptionResult result = writeOption ( ImmutableList . of ( newValue ) ) ; Preconditions . checkState ( result . getType ( ) == OptionValueType . INT ) ; Preconditions . checkState ( result . getValueSize ( ) == SaneWord . SIZE_IN_BYTES ) ; return SaneWord . fromBytes ( result . getValue ( ) ) . integerValue ( ) ; } | Set the value of the current option to the supplied value . Option value must be of integer type |
8,934 | public void close ( ) throws IOException { if ( ! isOpen ( ) ) { throw new IOException ( "device is already closed" ) ; } session . closeDevice ( handle ) ; handle = null ; } | Closes the device . |
8,935 | public List < SaneOption > listOptions ( ) throws IOException { if ( optionTitleMap == null ) { groups . clear ( ) ; optionTitleMap = Maps . uniqueIndex ( SaneOption . optionsFor ( this ) , new Function < SaneOption , String > ( ) { public String apply ( SaneOption input ) { return input . getName ( ) ; } } ) ; } return ImmutableList . copyOf ( optionTitleMap . values ( ) ) ; } | Returns the list of options applicable to this device . |
8,936 | void addOption ( SaneOption option ) { Preconditions . checkState ( option . getGroup ( ) == this ) ; options . add ( option ) ; } | Adds an option to the group . |
8,937 | public static SaneSession withRemoteSane ( InetAddress saneAddress , int port ) throws IOException { return withRemoteSane ( saneAddress , port , 0 , TimeUnit . MILLISECONDS , 0 , TimeUnit . MILLISECONDS ) ; } | Establishes a connection to the SANE daemon running on the given host on the given port with no connection timeout . |
8,938 | public List < SaneDevice > listDevices ( ) throws IOException , SaneException { outputStream . write ( SaneRpcCode . SANE_NET_GET_DEVICES ) ; outputStream . flush ( ) ; return inputStream . readDeviceList ( ) ; } | Lists the devices known to the SANE daemon . |
8,939 | public void close ( ) throws IOException { try { outputStream . write ( SaneRpcCode . SANE_NET_EXIT ) ; outputStream . close ( ) ; } finally { socket . close ( ) ; } } | Closes the connection to the SANE server . This is done immediately by closing the socket . |
8,940 | boolean authorize ( String resource ) throws IOException { if ( passwordProvider == null ) { throw new IOException ( "Authorization failed - no password provider present " + "(you must call setPasswordProvider)" ) ; } if ( passwordProvider . canAuthenticate ( resource ) ) { outputStream . write ( SaneRpcCode . SANE_NET_AUTHORIZE ) ; outputStream . write ( resource ) ; outputStream . write ( passwordProvider . getUsername ( resource ) ) ; writePassword ( resource , passwordProvider . getPassword ( resource ) ) ; outputStream . flush ( ) ; inputStream . readWord ( ) ; return true ; } return false ; } | Authorize the resource for access . |
8,941 | private void writePassword ( String resource , String password ) throws IOException { String [ ] resourceParts = resource . split ( "\\$MD5\\$" ) ; if ( resourceParts . length == 1 ) { outputStream . write ( password ) ; } else { outputStream . write ( "$MD5$" + SanePasswordEncoder . derivePassword ( resourceParts [ 1 ] , password ) ) ; } } | Write password to outputstream depending on resource provided by saned . |
8,942 | public void ignoreTileDao ( TileDao tileDao ) { GeoPackageOverlay tileOverlay = new GeoPackageOverlay ( tileDao ) ; linkedOverlays . add ( tileOverlay ) ; } | Ignore drawing tiles if they exist in the tile table represented by the tile dao |
8,943 | private List < Point > simplifyPoints ( List < Point > points ) { List < Point > simplifiedPoints = null ; if ( simplifyTolerance != null ) { if ( projection != null && ! projection . isUnit ( Units . METRES ) ) { points = toWebMercator . transform ( points ) ; } simplifiedPoints = GeometryUtils . simplifyPoints ( points , simplifyTolerance ) ; if ( projection != null && ! projection . isUnit ( Units . METRES ) ) { simplifiedPoints = fromWebMercator . transform ( simplifiedPoints ) ; } } else { simplifiedPoints = points ; } return simplifiedPoints ; } | When the simplify tolerance is set simplify the points to a similar curve with fewer points . |
8,944 | public PolygonOrientation getOrientation ( List < LatLng > points ) { return SphericalUtil . computeSignedArea ( points ) >= 0 ? PolygonOrientation . COUNTERCLOCKWISE : PolygonOrientation . CLOCKWISE ; } | Determine the closed points orientation |
8,945 | public static GoogleMapShape addShapeToMap ( GoogleMap map , GoogleMapShape shape ) { GoogleMapShape addedShape = null ; switch ( shape . getShapeType ( ) ) { case LAT_LNG : addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . MARKER , addLatLngToMap ( map , ( LatLng ) shape . getShape ( ) ) ) ; break ; case MARKER_OPTIONS : addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . MARKER , addMarkerOptionsToMap ( map , ( MarkerOptions ) shape . getShape ( ) ) ) ; break ; case POLYLINE_OPTIONS : addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . POLYLINE , addPolylineToMap ( map , ( PolylineOptions ) shape . getShape ( ) ) ) ; break ; case POLYGON_OPTIONS : addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . POLYGON , addPolygonToMap ( map , ( PolygonOptions ) shape . getShape ( ) ) ) ; break ; case MULTI_LAT_LNG : addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . MULTI_MARKER , addLatLngsToMap ( map , ( MultiLatLng ) shape . getShape ( ) ) ) ; break ; case MULTI_POLYLINE_OPTIONS : addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . MULTI_POLYLINE , addPolylinesToMap ( map , ( MultiPolylineOptions ) shape . getShape ( ) ) ) ; break ; case MULTI_POLYGON_OPTIONS : addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . MULTI_POLYGON , addPolygonsToMap ( map , ( MultiPolygonOptions ) shape . getShape ( ) ) ) ; break ; case COLLECTION : List < GoogleMapShape > addedShapeList = new ArrayList < GoogleMapShape > ( ) ; @ SuppressWarnings ( "unchecked" ) List < GoogleMapShape > shapeList = ( List < GoogleMapShape > ) shape . getShape ( ) ; for ( GoogleMapShape shapeListItem : shapeList ) { addedShapeList . add ( addShapeToMap ( map , shapeListItem ) ) ; } addedShape = new GoogleMapShape ( shape . getGeometryType ( ) , GoogleMapShapeType . COLLECTION , addedShapeList ) ; break ; default : throw new GeoPackageException ( "Unsupported Shape Type: " + shape . getShapeType ( ) ) ; } return addedShape ; } | Add a shape to the map |
8,946 | public static mil . nga . geopackage . map . geom . MultiPolygon addPolygonsToMap ( GoogleMap map , MultiPolygonOptions polygons ) { mil . nga . geopackage . map . geom . MultiPolygon multiPolygon = new mil . nga . geopackage . map . geom . MultiPolygon ( ) ; for ( PolygonOptions polygonOption : polygons . getPolygonOptions ( ) ) { if ( polygons . getOptions ( ) != null ) { polygonOption . fillColor ( polygons . getOptions ( ) . getFillColor ( ) ) ; polygonOption . strokeColor ( polygons . getOptions ( ) . getStrokeColor ( ) ) ; polygonOption . geodesic ( polygons . getOptions ( ) . isGeodesic ( ) ) ; polygonOption . visible ( polygons . getOptions ( ) . isVisible ( ) ) ; polygonOption . zIndex ( polygons . getOptions ( ) . getZIndex ( ) ) ; polygonOption . strokeWidth ( polygons . getOptions ( ) . getStrokeWidth ( ) ) ; } com . google . android . gms . maps . model . Polygon polygon = addPolygonToMap ( map , polygonOption ) ; multiPolygon . add ( polygon ) ; } return multiPolygon ; } | Add a list of Polygons to the map |
8,947 | public List < Marker > addPointsToMapAsMarkers ( GoogleMap map , List < LatLng > points , MarkerOptions customMarkerOptions , boolean ignoreIdenticalEnds ) { List < Marker > markers = new ArrayList < Marker > ( ) ; for ( int i = 0 ; i < points . size ( ) ; i ++ ) { LatLng latLng = points . get ( i ) ; if ( points . size ( ) > 1 && i + 1 == points . size ( ) && ignoreIdenticalEnds ) { LatLng firstLatLng = points . get ( 0 ) ; if ( latLng . latitude == firstLatLng . latitude && latLng . longitude == firstLatLng . longitude ) { break ; } } MarkerOptions markerOptions = new MarkerOptions ( ) ; if ( customMarkerOptions != null ) { markerOptions . icon ( customMarkerOptions . getIcon ( ) ) ; markerOptions . anchor ( customMarkerOptions . getAnchorU ( ) , customMarkerOptions . getAnchorV ( ) ) ; markerOptions . draggable ( customMarkerOptions . isDraggable ( ) ) ; markerOptions . visible ( customMarkerOptions . isVisible ( ) ) ; markerOptions . zIndex ( customMarkerOptions . getZIndex ( ) ) ; } Marker marker = addLatLngToMap ( map , latLng , markerOptions ) ; markers . add ( marker ) ; } return markers ; } | Add the list of points as markers |
8,948 | public PolylineMarkers addPolylineToMapAsMarkers ( GoogleMap map , PolylineOptions polylineOptions , MarkerOptions polylineMarkerOptions , PolylineOptions globalPolylineOptions ) { PolylineMarkers polylineMarkers = new PolylineMarkers ( this ) ; if ( globalPolylineOptions != null ) { polylineOptions . color ( globalPolylineOptions . getColor ( ) ) ; polylineOptions . geodesic ( globalPolylineOptions . isGeodesic ( ) ) ; polylineOptions . visible ( globalPolylineOptions . isVisible ( ) ) ; polylineOptions . zIndex ( globalPolylineOptions . getZIndex ( ) ) ; polylineOptions . width ( globalPolylineOptions . getWidth ( ) ) ; } Polyline polyline = addPolylineToMap ( map , polylineOptions ) ; polylineMarkers . setPolyline ( polyline ) ; List < Marker > markers = addPointsToMapAsMarkers ( map , polylineOptions . getPoints ( ) , polylineMarkerOptions , false ) ; polylineMarkers . setMarkers ( markers ) ; return polylineMarkers ; } | Add a Polyline to the map as markers |
8,949 | public PolygonMarkers addPolygonToMapAsMarkers ( GoogleMapShapeMarkers shapeMarkers , GoogleMap map , PolygonOptions polygonOptions , MarkerOptions polygonMarkerOptions , MarkerOptions polygonMarkerHoleOptions , PolygonOptions globalPolygonOptions ) { PolygonMarkers polygonMarkers = new PolygonMarkers ( this ) ; if ( globalPolygonOptions != null ) { polygonOptions . fillColor ( globalPolygonOptions . getFillColor ( ) ) ; polygonOptions . strokeColor ( globalPolygonOptions . getStrokeColor ( ) ) ; polygonOptions . geodesic ( globalPolygonOptions . isGeodesic ( ) ) ; polygonOptions . visible ( globalPolygonOptions . isVisible ( ) ) ; polygonOptions . zIndex ( globalPolygonOptions . getZIndex ( ) ) ; polygonOptions . strokeWidth ( globalPolygonOptions . getStrokeWidth ( ) ) ; } com . google . android . gms . maps . model . Polygon polygon = addPolygonToMap ( map , polygonOptions ) ; polygonMarkers . setPolygon ( polygon ) ; List < Marker > markers = addPointsToMapAsMarkers ( map , polygon . getPoints ( ) , polygonMarkerOptions , true ) ; polygonMarkers . setMarkers ( markers ) ; for ( List < LatLng > holes : polygon . getHoles ( ) ) { List < Marker > holeMarkers = addPointsToMapAsMarkers ( map , holes , polygonMarkerHoleOptions , true ) ; PolygonHoleMarkers polygonHoleMarkers = new PolygonHoleMarkers ( polygonMarkers ) ; polygonHoleMarkers . setMarkers ( holeMarkers ) ; shapeMarkers . add ( polygonHoleMarkers ) ; polygonMarkers . addHole ( polygonHoleMarkers ) ; } return polygonMarkers ; } | Add a Polygon to the map as markers |
8,950 | public MultiPolylineMarkers addMultiPolylineToMapAsMarkers ( GoogleMapShapeMarkers shapeMarkers , GoogleMap map , MultiPolylineOptions multiPolyline , MarkerOptions polylineMarkerOptions , PolylineOptions globalPolylineOptions ) { MultiPolylineMarkers polylines = new MultiPolylineMarkers ( ) ; for ( PolylineOptions polylineOptions : multiPolyline . getPolylineOptions ( ) ) { PolylineMarkers polylineMarker = addPolylineToMapAsMarkers ( map , polylineOptions , polylineMarkerOptions , globalPolylineOptions ) ; shapeMarkers . add ( polylineMarker ) ; polylines . add ( polylineMarker ) ; } return polylines ; } | Add a MultiPolylineOptions to the map as markers |
8,951 | public MultiPolygonMarkers addMultiPolygonToMapAsMarkers ( GoogleMapShapeMarkers shapeMarkers , GoogleMap map , MultiPolygonOptions multiPolygon , MarkerOptions polygonMarkerOptions , MarkerOptions polygonMarkerHoleOptions , PolygonOptions globalPolygonOptions ) { MultiPolygonMarkers multiPolygonMarkers = new MultiPolygonMarkers ( ) ; for ( PolygonOptions polygon : multiPolygon . getPolygonOptions ( ) ) { PolygonMarkers polygonMarker = addPolygonToMapAsMarkers ( shapeMarkers , map , polygon , polygonMarkerOptions , polygonMarkerHoleOptions , globalPolygonOptions ) ; shapeMarkers . add ( polygonMarker ) ; multiPolygonMarkers . add ( polygonMarker ) ; } return multiPolygonMarkers ; } | Add a MultiPolygonOptions to the map as markers |
8,952 | public List < LatLng > getPointsFromMarkers ( List < Marker > markers ) { List < LatLng > points = new ArrayList < LatLng > ( ) ; for ( Marker marker : markers ) { points . add ( marker . getPosition ( ) ) ; } return points ; } | Get a list of points as LatLng from a list of Markers |
8,953 | public BoundingBox boundingBoxToWebMercator ( BoundingBox boundingBox ) { if ( projection == null ) { throw new GeoPackageException ( "Shape Converter projection is null" ) ; } return boundingBox . transform ( toWebMercator ) ; } | Transform the bounding box in the feature projection to web mercator |
8,954 | public BoundingBox boundingBoxToWgs84 ( BoundingBox boundingBox ) { if ( projection == null ) { throw new GeoPackageException ( "Shape Converter projection is null" ) ; } return boundingBox . transform ( toWgs84 ) ; } | Transform the bounding box in the feature projection to WGS84 |
8,955 | public BoundingBox boundingBoxFromWebMercator ( BoundingBox boundingBox ) { if ( projection == null ) { throw new GeoPackageException ( "Shape Converter projection is null" ) ; } return boundingBox . transform ( fromWebMercator ) ; } | Transform the bounding box in web mercator to the feature projection |
8,956 | public BoundingBox boundingBoxFromWgs84 ( BoundingBox boundingBox ) { if ( projection == null ) { throw new GeoPackageException ( "Shape Converter projection is null" ) ; } return boundingBox . transform ( fromWgs84 ) ; } | Transform the bounding box in WGS84 to the feature projection |
8,957 | public void setDateFormat ( java . text . DateFormat dateFormat , java . text . DateFormat numbersDateFormat ) { this . customDateFormat = dateFormat ; this . secondaryDateFormat = numbersDateFormat ; if ( showMonthItem ) { int monthPosition = getAdapterItemPosition ( 4 ) ; boolean reselectMonthItem = getSelectedItemPosition ( ) == monthPosition ; setShowMonthItem ( false ) ; setShowMonthItem ( true ) ; if ( reselectMonthItem ) setSelection ( monthPosition ) ; } if ( getSelectedItemPosition ( ) == getAdapter ( ) . getCount ( ) ) setSelectedDate ( getSelectedDate ( ) ) ; } | Sets the custom date format to use for formatting Calendar objects to displayable strings . |
8,958 | public void setShowPastItems ( boolean enable ) { if ( enable && ! showPastItems ) { if ( getMinDate ( ) != null && compareCalendarDates ( getMinDate ( ) , Calendar . getInstance ( ) ) == 0 ) setMinDate ( null ) ; final Resources res = getResources ( ) ; final Calendar date = Calendar . getInstance ( ) ; date . add ( Calendar . DAY_OF_YEAR , - 1 ) ; insertAdapterItem ( new DateItem ( res . getString ( R . string . date_yesterday ) , date , R . id . date_yesterday ) , 0 ) ; date . add ( Calendar . DAY_OF_YEAR , - 6 ) ; int weekday = date . get ( Calendar . DAY_OF_WEEK ) ; insertAdapterItem ( new DateItem ( getWeekDay ( weekday , R . string . date_last_weekday ) , date , R . id . date_last_week ) , 0 ) ; } else if ( ! enable && showPastItems ) { removeAdapterItemById ( R . id . date_last_week ) ; removeAdapterItemById ( R . id . date_yesterday ) ; setMinDate ( Calendar . getInstance ( ) ) ; } showPastItems = enable ; } | Toggles showing the past items . Past mode shows the yesterday and last weekday item . |
8,959 | public void setShowMonthItem ( boolean enable ) { if ( enable && ! showMonthItem ) { final Calendar date = Calendar . getInstance ( ) ; date . add ( Calendar . MONTH , 1 ) ; addAdapterItem ( new DateItem ( formatDate ( date ) , date , R . id . date_month ) ) ; } else if ( ! enable && showMonthItem ) { removeAdapterItemById ( R . id . date_month ) ; } showMonthItem = enable ; } | Toggles showing the month item . Month mode an item in exactly one month from now . |
8,960 | public void setFlags ( int modeOrFlags ) { setShowPastItems ( ( modeOrFlags & ReminderDatePicker . FLAG_PAST ) != 0 ) ; setShowMonthItem ( ( modeOrFlags & ReminderDatePicker . FLAG_MONTH ) != 0 ) ; setShowWeekdayNames ( ( modeOrFlags & ReminderDatePicker . FLAG_WEEKDAY_NAMES ) != 0 ) ; setShowNumbersInView ( ( modeOrFlags & ReminderDatePicker . FLAG_NUMBERS ) != 0 ) ; } | Set the flags to use for this date spinner . |
8,961 | private float brightness ( int color ) { int r = ( color >> 16 ) & 0xFF ; int g = ( color >> 8 ) & 0xFF ; int b = color & 0xFF ; int V = Math . max ( b , Math . max ( r , g ) ) ; return ( V / 255.f ) ; } | Returns the brightness component of a color int . Taken from android . graphics . Color . |
8,962 | private Calendar getNextItemDate ( Calendar searchDate ) { final int last = dateSpinner . getLastItemPosition ( ) ; for ( int i = 0 ; i <= last ; i ++ ) { final Calendar date = ( ( DateItem ) dateSpinner . getItemAtPosition ( i ) ) . getDate ( ) ; if ( DateSpinner . compareCalendarDates ( date , searchDate ) >= 0 ) return date ; } return null ; } | Gets the next date item s date equal to or later than the given date in the DateSpinner . Requires that the items are in ascending order . |
8,963 | public void setSelectedDate ( Calendar date ) { if ( date != null ) { dateSpinner . setSelectedDate ( date ) ; timeSpinner . setSelectedTime ( date . get ( Calendar . HOUR_OF_DAY ) , date . get ( Calendar . MINUTE ) ) ; shouldSelectDefault = false ; } } | Sets the Spinners selection as date considering both time and day . |
8,964 | public void setSelectedDate ( int year , int month , int day ) { dateSpinner . setSelectedDate ( new GregorianCalendar ( year , month , day ) ) ; shouldSelectDefault = false ; } | Sets the Spinners date selection as integers considering only day . |
8,965 | public void setHideTime ( boolean enable , final boolean useDarkTheme ) { if ( enable && ! shouldHideTime ) { timeSpinner . setVisibility ( GONE ) ; ImageButton timeButton = ( ImageButton ) LayoutInflater . from ( getContext ( ) ) . inflate ( R . layout . time_button , null ) ; timeButton . setImageResource ( useDarkTheme ? R . drawable . ic_action_time_dark : R . drawable . ic_action_time_light ) ; timeButton . setOnClickListener ( new OnClickListener ( ) { public void onClick ( View v ) { setHideTime ( false , useDarkTheme ) ; } } ) ; this . addView ( timeButton ) ; } else if ( ! enable && shouldHideTime ) { timeSpinner . setVisibility ( VISIBLE ) ; this . removeViewAt ( 2 ) ; } shouldHideTime = enable ; } | Toggles hiding the Time Spinner and replaces it with a Button . |
8,966 | public void setFlags ( int modeOrFlags ) { setHideTime ( ( modeOrFlags & FLAG_HIDE_TIME ) != 0 , isActivityUsingDarkTheme ( ) ) ; dateSpinner . setFlags ( modeOrFlags ) ; timeSpinner . setFlags ( modeOrFlags ) ; } | Set the flags to use for the picker . |
8,967 | public void setTimeFormat ( java . text . DateFormat timeFormat ) { this . timeFormat = timeFormat ; initTimePickerDialog ( getContext ( ) ) ; final PickerSpinnerAdapter adapter = ( ( PickerSpinnerAdapter ) getAdapter ( ) ) ; final boolean moreTimeItems = isShowingMoreTimeItems ( ) ; final boolean numbersInView = adapter . isShowingSecondaryTextInView ( ) ; final Calendar selection = getSelectedTime ( ) ; final boolean temporarySelected = getSelectedItemPosition ( ) == adapter . getCount ( ) ; initAdapter ( getContext ( ) ) ; setShowNumbersInView ( numbersInView ) ; this . showMoreTimeItems = false ; if ( temporarySelected ) { setSelectedTime ( selection . get ( Calendar . HOUR_OF_DAY ) , selection . get ( Calendar . MINUTE ) ) ; setShowMoreTimeItems ( moreTimeItems ) ; } else { setShowMoreTimeItems ( moreTimeItems ) ; setSelectedTime ( selection . get ( Calendar . HOUR_OF_DAY ) , selection . get ( Calendar . MINUTE ) ) ; } } | Sets the time format to use for formatting Calendar objects to displayable strings . |
8,968 | public void setShowMoreTimeItems ( boolean enable ) { if ( enable && ! showMoreTimeItems ) { final Resources res = getResources ( ) ; insertAdapterItem ( new TimeItem ( res . getString ( R . string . time_afternoon_2 ) , formatTime ( 14 , 0 ) , 14 , 0 , R . id . time_afternoon_2 ) , 2 ) ; removeAdapterItemById ( R . id . time_afternoon ) ; insertAdapterItem ( new TimeItem ( res . getString ( R . string . time_noon ) , formatTime ( 12 , 0 ) , 12 , 0 , R . id . time_noon ) , 1 ) ; addAdapterItem ( new TimeItem ( res . getString ( R . string . time_late_night ) , formatTime ( 23 , 0 ) , 23 , 0 , R . id . time_late_night ) ) ; } else if ( ! enable && showMoreTimeItems ) { insertAdapterItem ( new TimeItem ( getResources ( ) . getString ( R . string . time_afternoon ) , formatTime ( 13 , 0 ) , 13 , 0 , R . id . time_afternoon ) , 3 ) ; removeAdapterItemById ( R . id . time_afternoon_2 ) ; removeAdapterItemById ( R . id . time_noon ) ; removeAdapterItemById ( R . id . time_late_night ) ; } showMoreTimeItems = enable ; } | Toggles showing more time items . If enabled a noon and a late night time item are shown . |
8,969 | public void setFlags ( int modeOrFlags ) { setShowMoreTimeItems ( ( modeOrFlags & ReminderDatePicker . FLAG_MORE_TIME ) != 0 ) ; setShowNumbersInView ( ( modeOrFlags & ReminderDatePicker . FLAG_NUMBERS ) != 0 ) ; } | Set the flags to use for this time spinner . |
8,970 | public Map < String , Map < Long , FeatureShape > > getTables ( String database ) { Map < String , Map < Long , FeatureShape > > tables = databases . get ( database ) ; if ( tables == null ) { tables = new HashMap < > ( ) ; databases . put ( database , tables ) ; } return tables ; } | Get the mapping between tables and feature ids for the database |
8,971 | public Map < Long , FeatureShape > getFeatureIds ( String database , String table ) { Map < String , Map < Long , FeatureShape > > tables = getTables ( database ) ; Map < Long , FeatureShape > featureIds = getFeatureIds ( tables , table ) ; return featureIds ; } | Get the mapping between feature ids and map shapes for the database and table |
8,972 | private Map < Long , FeatureShape > getFeatureIds ( Map < String , Map < Long , FeatureShape > > tables , String table ) { Map < Long , FeatureShape > featureIds = tables . get ( table ) ; if ( featureIds == null ) { featureIds = new HashMap < > ( ) ; tables . put ( table , featureIds ) ; } return featureIds ; } | Get the feature ids and map shapes for the tables and table |
8,973 | public FeatureShape getFeatureShape ( String database , String table , long featureId ) { Map < Long , FeatureShape > featureIds = getFeatureIds ( database , table ) ; FeatureShape featureShape = getFeatureShape ( featureIds , featureId ) ; return featureShape ; } | Get the feature shape for the database table and feature id |
8,974 | public int getFeatureShapeCount ( String database , String table , long featureId ) { return getFeatureShape ( database , table , featureId ) . count ( ) ; } | Get the feature shape count for the database table and feature id |
8,975 | private FeatureShape getFeatureShape ( Map < Long , FeatureShape > featureIds , long featureId ) { FeatureShape featureShape = featureIds . get ( featureId ) ; if ( featureShape == null ) { featureShape = new FeatureShape ( featureId ) ; featureIds . put ( featureId , featureShape ) ; } return featureShape ; } | Get the map shapes for the feature ids and feature id |
8,976 | public void addMapShape ( GoogleMapShape mapShape , long featureId , String database , String table ) { FeatureShape featureShape = getFeatureShape ( database , table , featureId ) ; featureShape . addShape ( mapShape ) ; } | Add a map shape with the feature id database and table |
8,977 | public void addMapMetadataShape ( GoogleMapShape mapShape , long featureId , String database , String table ) { FeatureShape featureShape = getFeatureShape ( database , table , featureId ) ; featureShape . addMetadataShape ( mapShape ) ; } | Add a map metadata shape with the feature id database and table |
8,978 | public boolean exists ( long featureId , String database , String table ) { boolean exists = false ; Map < String , Map < Long , FeatureShape > > tables = databases . get ( database ) ; if ( tables != null ) { Map < Long , FeatureShape > featureIds = tables . get ( table ) ; if ( featureIds != null ) { FeatureShape shapes = featureIds . get ( featureId ) ; exists = shapes != null && shapes . hasShapes ( ) ; } } return exists ; } | Check if map shapes exist for the feature id database and table |
8,979 | public int removeShapesWithExclusions ( String database , Set < GoogleMapShapeType > excludedTypes ) { int count = 0 ; Map < String , Map < Long , FeatureShape > > tables = getTables ( database ) ; if ( tables != null ) { Iterator < String > iterator = tables . keySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { String table = iterator . next ( ) ; count += removeShapesWithExclusions ( database , table , excludedTypes ) ; if ( getFeatureIdsCount ( database , table ) <= 0 ) { iterator . remove ( ) ; } } } return count ; } | Remove all map shapes in the database from the map excluding shapes with the excluded types |
8,980 | public int removeShapesWithExclusion ( String database , String table , GoogleMapShapeType excludedType ) { Set < GoogleMapShapeType > excludedTypes = new HashSet < > ( ) ; excludedTypes . add ( excludedType ) ; return removeShapesWithExclusions ( database , table , excludedTypes ) ; } | Remove all map shapes in the database and table from the map excluding shapes with the excluded type |
8,981 | public int removeShapesWithExclusions ( String database , String table , Set < GoogleMapShapeType > excludedTypes ) { int count = 0 ; Map < Long , FeatureShape > featureIds = getFeatureIds ( database , table ) ; if ( featureIds != null ) { Iterator < Long > iterator = featureIds . keySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { long featureId = iterator . next ( ) ; FeatureShape featureShape = getFeatureShape ( featureIds , featureId ) ; if ( featureShape != null ) { Iterator < GoogleMapShape > shapeIterator = featureShape . getShapes ( ) . iterator ( ) ; while ( shapeIterator . hasNext ( ) ) { GoogleMapShape mapShape = shapeIterator . next ( ) ; if ( excludedTypes == null || ! excludedTypes . contains ( mapShape . getShapeType ( ) ) ) { mapShape . remove ( ) ; shapeIterator . remove ( ) ; } } } if ( featureShape == null || ! featureShape . hasShapes ( ) ) { if ( featureShape != null ) { featureShape . removeMetadataShapes ( ) ; } iterator . remove ( ) ; count ++ ; } } } return count ; } | Remove all map shapes in the database and table from the map excluding shapes with the excluded types |
8,982 | public int removeShapesNotWithinMap ( GoogleMap map ) { int count = 0 ; BoundingBox boundingBox = MapUtils . getBoundingBox ( map ) ; for ( String database : databases . keySet ( ) ) { count += removeShapesNotWithinMap ( boundingBox , database ) ; } return count ; } | Remove all map shapes that are not visible in the map |
8,983 | public int removeShapesNotWithinMap ( BoundingBox boundingBox , String database ) { int count = 0 ; Map < String , Map < Long , FeatureShape > > tables = getTables ( database ) ; if ( tables != null ) { for ( String table : tables . keySet ( ) ) { count += removeShapesNotWithinMap ( boundingBox , database , table ) ; } } return count ; } | Remove all map shapes in the database that are not visible in the bounding box |
8,984 | public int removeShapesNotWithinMap ( BoundingBox boundingBox , String database , String table ) { int count = 0 ; Map < Long , FeatureShape > featureIds = getFeatureIds ( database , table ) ; if ( featureIds != null ) { List < Long > deleteFeatureIds = new ArrayList < > ( ) ; for ( long featureId : featureIds . keySet ( ) ) { FeatureShape featureShape = getFeatureShape ( featureIds , featureId ) ; if ( featureShape != null ) { boolean delete = true ; for ( GoogleMapShape mapShape : featureShape . getShapes ( ) ) { BoundingBox mapShapeBoundingBox = mapShape . boundingBox ( ) ; boolean allowEmpty = mapShape . getGeometryType ( ) == GeometryType . POINT ; if ( TileBoundingBoxUtils . overlap ( mapShapeBoundingBox , boundingBox , ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH , allowEmpty ) != null ) { delete = false ; break ; } } if ( delete ) { deleteFeatureIds . add ( featureId ) ; } } } for ( long deleteFeatureId : deleteFeatureIds ) { FeatureShape featureShape = getFeatureShape ( featureIds , deleteFeatureId ) ; if ( featureShape != null ) { featureShape . remove ( ) ; featureIds . remove ( deleteFeatureId ) ; } count ++ ; } } return count ; } | Remove all map shapes in the database and table that are not visible in the bounding box |
8,985 | public boolean removeFeatureShape ( String database , String table , long featureId ) { boolean removed = false ; Map < Long , FeatureShape > featureIds = getFeatureIds ( database , table ) ; if ( featureIds != null ) { FeatureShape featureShape = featureIds . remove ( featureId ) ; if ( featureShape != null ) { featureShape . remove ( ) ; removed = true ; } } return removed ; } | Remove the feature shape from the database and table |
8,986 | public void remove ( ) { switch ( shapeType ) { case MARKER : ( ( Marker ) shape ) . remove ( ) ; break ; case POLYGON : ( ( Polygon ) shape ) . remove ( ) ; break ; case POLYLINE : ( ( Polyline ) shape ) . remove ( ) ; break ; case MULTI_MARKER : ( ( MultiMarker ) shape ) . remove ( ) ; break ; case MULTI_POLYLINE : ( ( MultiPolyline ) shape ) . remove ( ) ; break ; case MULTI_POLYGON : ( ( MultiPolygon ) shape ) . remove ( ) ; break ; case POLYLINE_MARKERS : ( ( PolylineMarkers ) shape ) . remove ( ) ; break ; case POLYGON_MARKERS : ( ( PolygonMarkers ) shape ) . remove ( ) ; break ; case MULTI_POLYLINE_MARKERS : ( ( MultiPolylineMarkers ) shape ) . remove ( ) ; break ; case MULTI_POLYGON_MARKERS : ( ( MultiPolygonMarkers ) shape ) . remove ( ) ; break ; case COLLECTION : @ SuppressWarnings ( "unchecked" ) List < GoogleMapShape > shapeList = ( List < GoogleMapShape > ) shape ; for ( GoogleMapShape shapeListItem : shapeList ) { shapeListItem . remove ( ) ; } break ; default : } } | Removes all objects added to the map |
8,987 | public void setVisible ( boolean visible ) { switch ( shapeType ) { case MARKER_OPTIONS : ( ( MarkerOptions ) shape ) . visible ( visible ) ; break ; case POLYLINE_OPTIONS : ( ( PolylineOptions ) shape ) . visible ( visible ) ; break ; case POLYGON_OPTIONS : ( ( PolygonOptions ) shape ) . visible ( visible ) ; break ; case MULTI_POLYLINE_OPTIONS : ( ( MultiPolylineOptions ) shape ) . visible ( visible ) ; break ; case MULTI_POLYGON_OPTIONS : ( ( MultiPolygonOptions ) shape ) . visible ( visible ) ; break ; case MARKER : ( ( Marker ) shape ) . setVisible ( visible ) ; break ; case POLYGON : ( ( Polygon ) shape ) . setVisible ( visible ) ; break ; case POLYLINE : ( ( Polyline ) shape ) . setVisible ( visible ) ; break ; case MULTI_MARKER : ( ( MultiMarker ) shape ) . setVisible ( visible ) ; break ; case MULTI_POLYLINE : ( ( MultiPolyline ) shape ) . setVisible ( visible ) ; break ; case MULTI_POLYGON : ( ( MultiPolygon ) shape ) . setVisible ( visible ) ; break ; case POLYLINE_MARKERS : ( ( PolylineMarkers ) shape ) . setVisible ( visible ) ; break ; case POLYGON_MARKERS : ( ( PolygonMarkers ) shape ) . setVisible ( visible ) ; break ; case MULTI_POLYLINE_MARKERS : ( ( MultiPolylineMarkers ) shape ) . setVisible ( visible ) ; break ; case MULTI_POLYGON_MARKERS : ( ( MultiPolygonMarkers ) shape ) . setVisible ( visible ) ; break ; case COLLECTION : @ SuppressWarnings ( "unchecked" ) List < GoogleMapShape > shapeList = ( List < GoogleMapShape > ) shape ; for ( GoogleMapShape shapeListItem : shapeList ) { shapeListItem . setVisible ( visible ) ; } break ; default : } } | Updates visibility of all objects |
8,988 | public void update ( ) { switch ( shapeType ) { case POLYLINE_MARKERS : ( ( PolylineMarkers ) shape ) . update ( ) ; break ; case POLYGON_MARKERS : ( ( PolygonMarkers ) shape ) . update ( ) ; break ; case MULTI_POLYLINE_MARKERS : ( ( MultiPolylineMarkers ) shape ) . update ( ) ; break ; case MULTI_POLYGON_MARKERS : ( ( MultiPolygonMarkers ) shape ) . update ( ) ; break ; case COLLECTION : @ SuppressWarnings ( "unchecked" ) List < GoogleMapShape > shapeList = ( List < GoogleMapShape > ) shape ; for ( GoogleMapShape shapeListItem : shapeList ) { shapeListItem . update ( ) ; } break ; default : } } | Updates all objects that could have changed from moved markers |
8,989 | public boolean isValid ( ) { boolean valid = true ; switch ( shapeType ) { case POLYLINE_MARKERS : valid = ( ( PolylineMarkers ) shape ) . isValid ( ) ; break ; case POLYGON_MARKERS : valid = ( ( PolygonMarkers ) shape ) . isValid ( ) ; break ; case MULTI_POLYLINE_MARKERS : valid = ( ( MultiPolylineMarkers ) shape ) . isValid ( ) ; break ; case MULTI_POLYGON_MARKERS : valid = ( ( MultiPolygonMarkers ) shape ) . isValid ( ) ; break ; case COLLECTION : @ SuppressWarnings ( "unchecked" ) List < GoogleMapShape > shapeList = ( List < GoogleMapShape > ) shape ; for ( GoogleMapShape shapeListItem : shapeList ) { valid = shapeListItem . isValid ( ) ; if ( ! valid ) { break ; } } break ; default : } return valid ; } | Determines if the shape is in a valid state |
8,990 | public BoundingBox boundingBox ( ) { BoundingBox boundingBox = new BoundingBox ( Double . MAX_VALUE , Double . MAX_VALUE , - Double . MAX_VALUE , - Double . MAX_VALUE ) ; expandBoundingBox ( boundingBox ) ; return boundingBox ; } | Get a bounding box that includes the shape |
8,991 | public void expandBoundingBox ( BoundingBox boundingBox ) { switch ( shapeType ) { case LAT_LNG : expandBoundingBox ( boundingBox , ( LatLng ) shape ) ; break ; case MARKER_OPTIONS : expandBoundingBox ( boundingBox , ( ( MarkerOptions ) shape ) . getPosition ( ) ) ; break ; case POLYLINE_OPTIONS : expandBoundingBox ( boundingBox , ( ( PolylineOptions ) shape ) . getPoints ( ) ) ; break ; case POLYGON_OPTIONS : expandBoundingBox ( boundingBox , ( ( PolygonOptions ) shape ) . getPoints ( ) ) ; break ; case MULTI_LAT_LNG : expandBoundingBox ( boundingBox , ( ( MultiLatLng ) shape ) . getLatLngs ( ) ) ; break ; case MULTI_POLYLINE_OPTIONS : MultiPolylineOptions multiPolylineOptions = ( MultiPolylineOptions ) shape ; for ( PolylineOptions polylineOptions : multiPolylineOptions . getPolylineOptions ( ) ) { expandBoundingBox ( boundingBox , polylineOptions . getPoints ( ) ) ; } break ; case MULTI_POLYGON_OPTIONS : MultiPolygonOptions multiPolygonOptions = ( MultiPolygonOptions ) shape ; for ( PolygonOptions polygonOptions : multiPolygonOptions . getPolygonOptions ( ) ) { expandBoundingBox ( boundingBox , polygonOptions . getPoints ( ) ) ; } break ; case MARKER : expandBoundingBox ( boundingBox , ( ( Marker ) shape ) . getPosition ( ) ) ; break ; case POLYLINE : expandBoundingBox ( boundingBox , ( ( Polyline ) shape ) . getPoints ( ) ) ; break ; case POLYGON : expandBoundingBox ( boundingBox , ( ( Polygon ) shape ) . getPoints ( ) ) ; break ; case MULTI_MARKER : expandBoundingBoxMarkers ( boundingBox , ( ( MultiMarker ) shape ) . getMarkers ( ) ) ; break ; case MULTI_POLYLINE : MultiPolyline multiPolyline = ( MultiPolyline ) shape ; for ( Polyline polyline : multiPolyline . getPolylines ( ) ) { expandBoundingBox ( boundingBox , polyline . getPoints ( ) ) ; } break ; case MULTI_POLYGON : MultiPolygon multiPolygon = ( MultiPolygon ) shape ; for ( Polygon polygon : multiPolygon . getPolygons ( ) ) { expandBoundingBox ( boundingBox , polygon . getPoints ( ) ) ; } break ; case POLYLINE_MARKERS : expandBoundingBoxMarkers ( boundingBox , ( ( PolylineMarkers ) shape ) . getMarkers ( ) ) ; break ; case POLYGON_MARKERS : expandBoundingBoxMarkers ( boundingBox , ( ( PolygonMarkers ) shape ) . getMarkers ( ) ) ; break ; case MULTI_POLYLINE_MARKERS : MultiPolylineMarkers multiPolylineMarkers = ( MultiPolylineMarkers ) shape ; for ( PolylineMarkers polylineMarkers : multiPolylineMarkers . getPolylineMarkers ( ) ) { expandBoundingBoxMarkers ( boundingBox , polylineMarkers . getMarkers ( ) ) ; } break ; case MULTI_POLYGON_MARKERS : MultiPolygonMarkers multiPolygonMarkers = ( MultiPolygonMarkers ) shape ; for ( PolygonMarkers polygonMarkers : multiPolygonMarkers . getPolygonMarkers ( ) ) { expandBoundingBoxMarkers ( boundingBox , polygonMarkers . getMarkers ( ) ) ; } break ; case COLLECTION : @ SuppressWarnings ( "unchecked" ) List < GoogleMapShape > shapeList = ( List < GoogleMapShape > ) shape ; for ( GoogleMapShape shapeListItem : shapeList ) { shapeListItem . expandBoundingBox ( boundingBox ) ; } break ; } } | Expand the bounding box to include the shape |
8,992 | private void expandBoundingBox ( BoundingBox boundingBox , LatLng latLng ) { double latitude = latLng . latitude ; double longitude = latLng . longitude ; if ( boundingBox . getMinLongitude ( ) <= 3 * ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH && boundingBox . getMaxLongitude ( ) >= 3 * - ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH ) { if ( longitude < boundingBox . getMinLongitude ( ) ) { if ( boundingBox . getMinLongitude ( ) - longitude > ( longitude + ( 2 * ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH ) ) - boundingBox . getMaxLongitude ( ) ) { longitude += ( 2 * ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH ) ; } } else if ( longitude > boundingBox . getMaxLongitude ( ) ) { if ( longitude - boundingBox . getMaxLongitude ( ) > boundingBox . getMinLongitude ( ) - ( longitude - ( 2 * ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH ) ) ) { longitude -= ( 2 * ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH ) ; } } } if ( latitude < boundingBox . getMinLatitude ( ) ) { boundingBox . setMinLatitude ( latitude ) ; } if ( latitude > boundingBox . getMaxLatitude ( ) ) { boundingBox . setMaxLatitude ( latitude ) ; } if ( longitude < boundingBox . getMinLongitude ( ) ) { boundingBox . setMinLongitude ( longitude ) ; } if ( longitude > boundingBox . getMaxLongitude ( ) ) { boundingBox . setMaxLongitude ( longitude ) ; } } | Expand the bounding box by the LatLng |
8,993 | private void expandBoundingBox ( BoundingBox boundingBox , List < LatLng > latLngs ) { for ( LatLng latLng : latLngs ) { expandBoundingBox ( boundingBox , latLng ) ; } } | Expand the bounding box by the LatLngs |
8,994 | private void expandBoundingBoxMarkers ( BoundingBox boundingBox , List < Marker > markers ) { for ( Marker marker : markers ) { expandBoundingBox ( boundingBox , marker . getPosition ( ) ) ; } } | Expand the bounding box by the markers |
8,995 | public void setBoundingBox ( BoundingBox boundingBox , Projection projection ) { ProjectionTransform projectionToWebMercator = projection . getTransformation ( ProjectionConstants . EPSG_WEB_MERCATOR ) ; webMercatorBoundingBox = boundingBox . transform ( projectionToWebMercator ) ; } | Set the bounding box provided as the indicated projection |
8,996 | public BoundingBox getBoundingBox ( Projection projection ) { ProjectionTransform webMercatorToProjection = ProjectionFactory . getProjection ( ProjectionConstants . EPSG_WEB_MERCATOR ) . getTransformation ( projection ) ; return webMercatorBoundingBox . transform ( webMercatorToProjection ) ; } | Get the bounding box as the provided projection |
8,997 | public boolean hasTile ( int x , int y , int zoom ) { boolean hasTile = isWithinBounds ( x , y , zoom ) ; if ( hasTile ) { hasTile = hasTileToRetrieve ( x , y , zoom ) ; } return hasTile ; } | Determine if there is a tile for the x y and zoom |
8,998 | public boolean isWithinBounds ( int x , int y , int zoom ) { return isWithinZoom ( zoom ) && isWithinBoundingBox ( x , y , zoom ) ; } | Is the tile within the zoom and bounding box bounds |
8,999 | public boolean isWithinZoom ( float zoom ) { return ( minZoom == null || zoom >= minZoom ) && ( maxZoom == null || zoom <= maxZoom ) ; } | Check if the zoom is within the overlay zoom range |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.