Toggle navigation
Toggle navigation
This project
Loading...
Sign in
尹诚
/
Mapbox-iOS-SDK
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Thomas Rasch
13 years ago
Commit
c422d1581dc98d8b1026b87988476d575140e125
1 parent
691f03c3
o Some tile sources cleanup and reorganization
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
101 additions
and
95 deletions
MapView/Map/RMMBTilesTileSource.h
MapView/Map/RMMBTilesTileSource.m
MapView/Map/RMMapQuestOSMSource.h
MapView/Map/RMMapQuestOSMSource.m
MapView/Map/RMOpenCycleMapSource.h
MapView/Map/RMOpenCycleMapSource.m
MapView/Map/RMOpenSeaMapSource.h
MapView/Map/RMOpenSeaMapSource.m
MapView/Map/RMOpenStreetMapSource.h
MapView/Map/RMOpenStreetMapSource.m
MapView/Map/RMTileStreamSource.h
MapView/Map/RMTileStreamSource.m
MapView/MapView.xcodeproj/project.pbxproj
MapView/Map/RMMBTilesTileSource.h
View file @
c422d15
...
...
@@ -33,7 +33,7 @@
//
// http://mbtiles.org
//
//
Example usage at https://github.com/mapbox/mbtiles-ios-exampl
e
//
See samples/MBTilesDemo for example usag
e
//
#import <Foundation/Foundation.h>
...
...
MapView/Map/RMMBTilesTileSource.m
View file @
c422d15
...
...
@@ -46,19 +46,19 @@
{
if
(
!
[
super
init
])
return
nil
;
tileProjection
=
[[
RMFractalTileProjection
alloc
]
initFromProjection
:[
self
projection
]
tileSideLength
:
kMBTilesDefaultTileSize
maxZoom
:
kMBTilesDefaultMaxTileZoom
minZoom
:
kMBTilesDefaultMinTileZoom
];
queue
=
[[
FMDatabaseQueue
databaseQueueWithPath
:[
tileSetURL
relativePath
]]
retain
];
if
(
!
queue
)
return
nil
;
[[
queue
database
]
setShouldCacheStatements
:
YES
];
return
self
;
}
...
...
@@ -93,9 +93,9 @@
NSInteger
zoom
=
tile
.
zoom
;
NSInteger
x
=
tile
.
x
;
NSInteger
y
=
pow
(
2
,
zoom
)
-
tile
.
y
-
1
;
__block
UIImage
*
image
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select tile_data from tiles where zoom_level = ? and tile_column = ? and tile_row = ?"
,
...
...
@@ -105,17 +105,16 @@
if
([
db
hadError
])
image
=
[
RMTileImage
errorTile
]
;
[
results
next
]
;
NSData
*
data
=
[
results
dataForColumn
:
@"tile_data"
]
;
if
(
!
data
)
image
=
[
RMTileImage
errorTile
]
;
else
image
=
[
UIImage
imageWithData
:
data
]
;
[
results
close
]
;
}];
...
...
@@ -150,42 +149,42 @@
-
(
float
)
minZoom
{
__block
double
minZoom
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select min(zoom_level) from tiles"
]
;
if
([
db
hadError
])
minZoom
=
kMBTilesDefaultMinTileZoom
;
[
results
next
]
;
minZoom
=
[
results
doubleForColumnIndex
:
0
]
;
[
results
close
]
;
}];
return
minZoom
;
}
-
(
float
)
maxZoom
{
__block
double
maxZoom
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select max(zoom_level) from tiles"
]
;
if
([
db
hadError
])
maxZoom
=
kMBTilesDefaultMaxTileZoom
;
[
results
next
]
;
maxZoom
=
[
results
doubleForColumnIndex
:
0
]
;
[
results
close
]
;
}];
return
maxZoom
;
}
...
...
@@ -202,21 +201,21 @@
-
(
RMSphericalTrapezium
)
latitudeLongitudeBoundingBox
{
__block
RMSphericalTrapezium
bounds
=
kMBTilesDefaultLatLonBoundingBox
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select value from metadata where name = 'bounds'"
]
;
[
results
next
]
;
NSString
*
boundsString
=
[
results
stringForColumnIndex
:
0
]
;
[
results
close
]
;
if
(
boundsString
)
{
NSArray
*
parts
=
[
boundsString
componentsSeparatedByString
:
@","
]
;
if
([
parts
count
]
==
4
)
{
bounds
.
southWest
.
longitude
=
[[
parts
objectAtIndex
:
0
]
doubleValue
]
;
...
...
@@ -225,9 +224,8 @@
bounds
.
northEast
.
latitude
=
[[
parts
objectAtIndex
:
3
]
doubleValue
]
;
}
}
}];
return
bounds
;
}
...
...
@@ -235,18 +233,18 @@
{
RMSphericalTrapezium
ownBounds
=
[
self
latitudeLongitudeBoundingBox
];
RMSphericalTrapezium
defaultBounds
=
kMBTilesDefaultLatLonBoundingBox
;
if
(
ownBounds
.
southWest
.
longitude
<=
defaultBounds
.
southWest
.
longitude
+
10
&&
ownBounds
.
northEast
.
longitude
>=
defaultBounds
.
northEast
.
longitude
-
10
)
return
YES
;
return
NO
;
}
-
(
NSString
*
)
legend
{
__block
NSString
*
legend
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select value from metadata where name = 'legend'"
]
;
...
...
@@ -260,7 +258,7 @@
[
results
close
]
;
}];
return
legend
;
}
...
...
@@ -277,49 +275,49 @@
-
(
NSString
*
)
shortName
{
__block
NSString
*
shortName
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select value from metadata where name = 'name'"
]
;
if
([
db
hadError
])
shortName
=
nil
;
[
results
next
]
;
shortName
=
[
results
stringForColumnIndex
:
0
]
;
[
results
close
]
;
}];
return
shortName
;
}
-
(
NSString
*
)
longDescription
{
__block
NSString
*
description
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select value from metadata where name = 'description'"
]
;
if
([
db
hadError
])
description
=
nil
;
[
results
next
]
;
description
=
[
results
stringForColumnIndex
:
0
]
;
[
results
close
]
;
}];
return
[
NSString
stringWithFormat
:
@"%@ - %@"
,
[
self
shortName
],
description
];
}
-
(
NSString
*
)
shortAttribution
{
__block
NSString
*
attribution
;
[
queue
inDatabase
:
^
(
FMDatabase
*
db
)
{
FMResultSet
*
results
=
[
db
executeQuery
:
@"select value from metadata where name = 'attribution'"
]
;
...
...
@@ -333,7 +331,7 @@
[
results
close
]
;
}];
return
attribution
;
}
...
...
MapView/Map/RMMapQuestOSMSource.h
View file @
c422d15
//
// RMMapQuestOSMSource.h
//
// Copyright (c) 2008-201
1
, Route-Me Contributors
// Copyright (c) 2008-201
2
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -29,4 +29,4 @@
@interface
RMMapQuestOSMSource
:
RMAbstractWebMapSource
@end
\ No newline at end of file
@end
...
...
MapView/Map/RMMapQuestOSMSource.m
View file @
c422d15
//
// RMMapQuestOSMSource.m
//
// Copyright (c) 2008-201
1
, Route-Me Contributors
// Copyright (c) 2008-201
2
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -29,13 +29,14 @@
@implementation
RMMapQuestOSMSource
-
(
id
)
init
-
(
id
)
init
{
if
(
self
=
[
super
init
])
{
[
self
setMaxZoom
:
18
];
[
self
setMinZoom
:
1
];
}
if
(
!
(
self
=
[
super
init
]))
return
nil
;
[
self
setMaxZoom
:
18
];
[
self
setMinZoom
:
1
];
return
self
;
}
...
...
@@ -44,27 +45,31 @@
NSAssert4
(((
tile
.
zoom
>=
self
.
minZoom
)
&&
(
tile
.
zoom
<=
self
.
maxZoom
)),
@"%@ tried to retrieve tile with zoomLevel %d, outside source's defined range %f to %f"
,
self
,
tile
.
zoom
,
self
.
minZoom
,
self
.
maxZoom
);
return
[
NSURL
URLWithString
:[
NSString
stringWithFormat
:
@"http://otile1.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png"
,
tile
.
zoom
,
tile
.
x
,
tile
.
y
]];
}
-
(
NSString
*
)
uniqueTilecacheKey
-
(
NSString
*
)
uniqueTilecacheKey
{
return
@"MapQuestOSM"
;
}
-
(
NSString
*
)
shortName
-
(
NSString
*
)
shortName
{
return
@"MapQuest"
;
}
-
(
NSString
*
)
longDescription
-
(
NSString
*
)
longDescription
{
return
@"Map tiles courtesy of MapQuest."
;
}
-
(
NSString
*
)
shortAttribution
-
(
NSString
*
)
shortAttribution
{
return
@"Tiles courtesy of MapQuest."
;
}
-
(
NSString
*
)
longAttribution
-
(
NSString
*
)
longAttribution
{
return
@"Tiles courtesy of MapQuest and OpenStreetMap contributors."
;
}
...
...
MapView/Map/RMOpenCycleMapSource.h
View file @
c422d15
//
// OpenCycleMapSource.h
//
// Copyright (c) 2008, Route-Me Contributors
// Copyright (c) 2008
-2012
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -32,6 +32,7 @@
Provides key-based access to tiles from the Open Cycle Map project.
*/
@interface
RMOpenCycleMapSource
:
RMAbstractWebMapSource
@end
\ No newline at end of file
@end
...
...
MapView/Map/RMOpenCycleMapSource.m
View file @
c422d15
//
// OpenCycleMapSource.m
//
// Copyright (c) 2008-20
09
, Route-Me Contributors
// Copyright (c) 2008-20
12
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -70,7 +70,7 @@
return
@"© OpenCycleMap CC-BY-SA"
;
}
-
(
NSString
*
)
longAttribution
-
(
NSString
*
)
longAttribution
{
return
@"Map data © OpenCycleMap, licensed under Creative Commons Share Alike By Attribution."
;
}
...
...
MapView/Map/RMOpenSeaMapSource.h
View file @
c422d15
//
// RMOpenSeaMapSource.h
//
// Copyright (c) 2008-20
09
, Route-Me Contributors
// Copyright (c) 2008-20
12
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
MapView/Map/RMOpenSeaMapSource.m
View file @
c422d15
//
// RMOpenSeaMapSource.m
//
// Copyright (c) 2008-20
09
, Route-Me Contributors
// Copyright (c) 2008-20
12
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -73,7 +73,7 @@
return
@"© OpenStreetMap CC-BY-SA"
;
}
-
(
NSString
*
)
longAttribution
-
(
NSString
*
)
longAttribution
{
return
@"Map data © OpenStreetMap, licensed under Creative Commons Share Alike By Attribution."
;
}
...
...
MapView/Map/RMOpenStreetMapSource.h
View file @
c422d15
//
// OpenStreetMapsSource.h
//
// Copyright (c) 2008-20
09
, Route-Me Contributors
// Copyright (c) 2008-20
12
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -32,6 +32,7 @@
Provides key-based access to tiles from the Open Street Map project.
*/
@interface
RMOpenStreetMapSource
:
RMAbstractWebMapSource
@end
...
...
MapView/Map/RMOpenStreetMapSource.m
View file @
c422d15
//
// OpenStreetMapsSource.m
//
// Copyright (c) 2008-20
09
, Route-Me Contributors
// Copyright (c) 2008-20
12
, Route-Me Contributors
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
...
...
@@ -70,7 +70,7 @@
return
@"© OpenStreetMap CC-BY-SA"
;
}
-
(
NSString
*
)
longAttribution
-
(
NSString
*
)
longAttribution
{
return
@"Map data © OpenStreetMap, licensed under Creative Commons Share Alike By Attribution."
;
}
...
...
MapView/Map/RMTileStreamSource.h
View file @
c422d15
...
...
@@ -32,7 +32,7 @@
//
// http://mapbox.com/hosting/api/
//
//
Example usage at https://github.com/mapbox/tilestream-ios-exampl
e
//
See samples/MBTilesDemo for example usag
e
//
// This class supports both the paid, hosted version of TileStream, as well as the
// open source, self-hosted version.
...
...
MapView/Map/RMTileStreamSource.m
View file @
c422d15
...
...
@@ -47,9 +47,11 @@
-
(
id
)
initWithInfo
:(
NSDictionary
*
)
info
{
if
(
self
=
[
super
init
])
infoDictionary
=
[[
NSDictionary
dictionaryWithDictionary
:
info
]
retain
];
if
(
!
(
self
=
[
super
init
]))
return
nil
;
infoDictionary
=
[[
NSDictionary
dictionaryWithDictionary
:
info
]
retain
];
return
self
;
}
...
...
@@ -61,7 +63,6 @@
-
(
void
)
dealloc
{
[
infoDictionary
release
];
[
super
dealloc
];
}
...
...
@@ -74,13 +75,13 @@
NSInteger
zoom
=
tile
.
zoom
;
NSInteger
x
=
tile
.
x
;
NSInteger
y
=
pow
(
2
,
zoom
)
-
tile
.
y
-
1
;
NSString
*
tileURLString
=
[
self
.
infoDictionary
objectForKey
:
@"tileURL"
];
tileURLString
=
[
tileURLString
stringByReplacingOccurrencesOfString
:
@"{z}"
withString
:[[
NSNumber
numberWithInteger
:
zoom
]
stringValue
]];
tileURLString
=
[
tileURLString
stringByReplacingOccurrencesOfString
:
@"{x}"
withString
:[[
NSNumber
numberWithInteger
:
x
]
stringValue
]];
tileURLString
=
[
tileURLString
stringByReplacingOccurrencesOfString
:
@"{y}"
withString
:[[
NSNumber
numberWithInteger
:
y
]
stringValue
]];
return
[
NSURL
URLWithString
:
tileURLString
];
}
...
...
@@ -97,7 +98,7 @@
-
(
RMSphericalTrapezium
)
latitudeLongitudeBoundingBox
{
NSArray
*
parts
=
[[
self
.
infoDictionary
objectForKey
:
@"bounds"
]
componentsSeparatedByString
:
@","
];
if
([
parts
count
]
==
4
)
{
RMSphericalTrapezium
bounds
=
{
...
...
@@ -110,10 +111,10 @@
.
latitude
=
[[
parts
objectAtIndex
:
3
]
doubleValue
],
},
};
return
bounds
;
}
return
kTileStreamDefaultLatLonBoundingBox
;
}
...
...
@@ -121,11 +122,11 @@
{
RMSphericalTrapezium
ownBounds
=
[
self
latitudeLongitudeBoundingBox
];
RMSphericalTrapezium
defaultBounds
=
kTileStreamDefaultLatLonBoundingBox
;
if
(
ownBounds
.
southWest
.
longitude
<=
defaultBounds
.
southWest
.
longitude
+
10
&&
ownBounds
.
northEast
.
longitude
>=
defaultBounds
.
northEast
.
longitude
-
10
)
return
YES
;
return
NO
;
}
...
...
MapView/MapView.xcodeproj/project.pbxproj
View file @
c422d15
...
...
@@ -344,14 +344,18 @@
children = (
D1437B33122869E400888DAE /* RMDBMapSource.h */,
D1437B32122869E400888DAE /* RMDBMapSource.m */,
DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */,
DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */,
DD2B375314CF8197008DE8CB /* RMMBTilesTileSource.h */,
DD2B375414CF8197008DE8CB /* RMMBTilesTileSource.m */,
1606C9FC13D86BA300547581 /* RMOpenCycleMapSource.h */,
1606C9FD13D86BA300547581 /* RMOpenCycleMapSource.m */,
B83E64ED0E80E73F001663B6 /* RMOpenStreetMapSource.h */,
B83E64EE0E80E73F001663B6 /* RMOpenStreetMapSource.m */,
16128CF3148D295300C23C0E /* RMOpenSeaMapSource.h */,
16128CF4148D295300C23C0E /* RMOpenSeaMapSource.m */,
DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */,
DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */,
B83E64ED0E80E73F001663B6 /* RMOpenStreetMapSource.h */,
B83E64EE0E80E73F001663B6 /* RMOpenStreetMapSource.m */,
DD98B6F814D76B930092882F /* RMTileStreamSource.h */,
DD98B6F914D76B930092882F /* RMTileStreamSource.m */,
);
name = "Map sources";
sourceTree = "<group>";
...
...
@@ -507,10 +511,6 @@
16EC85CD133CA6C300219947 /* RMAbstractMercatorTileSource.m */,
16EC85CE133CA6C300219947 /* RMAbstractWebMapSource.h */,
16EC85CF133CA6C300219947 /* RMAbstractWebMapSource.m */,
DD2B375314CF8197008DE8CB /* RMMBTilesTileSource.h */,
DD2B375414CF8197008DE8CB /* RMMBTilesTileSource.m */,
DD98B6F814D76B930092882F /* RMTileStreamSource.h */,
DD98B6F914D76B930092882F /* RMTileStreamSource.m */,
);
name = "Tile Source";
sourceTree = "<group>";
...
...
Please
register
or
login
to post a comment