-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Google Earth Demo: Add support for retrieving credits (#337)
* fix metadata * Add support for containing metadata in tile cache * fix memory leak * Add support for credits
- Loading branch information
Showing
4 changed files
with
115 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
export class MapsTilesCredits { | ||
|
||
constructor() { | ||
|
||
this.creditsCount = {}; | ||
|
||
} | ||
|
||
_adjustCredits( line, add ) { | ||
|
||
const creditsCount = this.creditsCount; | ||
const tokens = line.split( /;/g ); | ||
for ( let i = 0, l = tokens.length; i < l; i ++ ) { | ||
|
||
const t = tokens[ i ]; | ||
if ( ! ( t in creditsCount ) ) { | ||
|
||
creditsCount[ t ] = 0; | ||
|
||
} | ||
|
||
creditsCount[ t ] += add ? 1 : - 1; | ||
|
||
if ( creditsCount[ t ] <= 0 ) { | ||
|
||
delete creditsCount[ t ]; | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
addCredits( line ) { | ||
|
||
this._adjustCredits( line, true ); | ||
|
||
} | ||
|
||
removeCredits( line ) { | ||
|
||
this._adjustCredits( line, false ); | ||
|
||
} | ||
|
||
getCredits() { | ||
|
||
const tokens = Object.keys( this.creditsCount ).sort(); | ||
return tokens.join( ', ' ); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters