Skip to content

Commit

Permalink
Merge pull request #1550 from Framstag/vyskocil-fix-and-modernize-app…
Browse files Browse the repository at this point in the history
…le-sample

Fix and modernize Apple sample code
  • Loading branch information
Framstag authored Dec 31, 2023
2 parents a352d6d + d731bbe commit bfc6e05
Show file tree
Hide file tree
Showing 152 changed files with 205 additions and 12,319 deletions.
100 changes: 44 additions & 56 deletions Apple/OSMScoutOSX/OSMScoutOSX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
15 changes: 0 additions & 15 deletions Apple/OSMScoutOSX/OSMScoutOSX/AppDelegate.h

This file was deleted.

16 changes: 0 additions & 16 deletions Apple/OSMScoutOSX/OSMScoutOSX/AppDelegate.m

This file was deleted.

15 changes: 15 additions & 0 deletions Apple/OSMScoutOSX/OSMScoutOSX/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// AppDelegate.swift
// OSMScoutOSX
//
// Created by Vladimir Vyskocil on 30/12/2023.
// Copyright © 2023 libosmscout. All rights reserved.
//

import AppKit

@main
class AppDelegate: NSResponder, NSApplicationDelegate {
var window : NSWindow? = nil

}
19 changes: 11 additions & 8 deletions Apple/OSMScoutOSX/OSMScoutOSX/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -11,7 +12,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<menu title="AMainMenu" systemMenu="main" id="29">
<items>
<menuItem title="OSMScoutOSX" id="56">
Expand Down Expand Up @@ -646,16 +647,18 @@
</menu>
</menuItem>
</items>
<point key="canvasLocation" x="27" y="-92"/>
</menu>
<window title="OSMScoutOSX" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
<view key="contentView" id="372" customClass="OSMScoutView">
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
<view key="contentView" id="372" customClass="OSMScoutView" customModule="OSMScoutOSX" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<point key="canvasLocation" x="26" y="-369"/>
</window>
<customObject id="494" customClass="AppDelegate">
<connections>
Expand All @@ -664,4 +667,4 @@
</customObject>
<customObject id="420" customClass="NSFontManager"/>
</objects>
</document>
</document>
3 changes: 2 additions & 1 deletion Apple/OSMScoutOSX/OSMScoutOSX/OSMScout.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <osmscoutmap/StyleConfig.h>
#include <osmscoutmap/MapService.h>
#include <osmscout/location/LocationService.h>
#include <osmscout/projection/TileProjection.h>

namespace osmscout {
class MyBreaker : public Breaker {
Expand Down Expand Up @@ -46,7 +47,7 @@ namespace osmscout {
bool isDatabaseOpened;
StyleConfigRef styleConfig;
MapPainterIOS *mapPainter;
TileProjection projection;
TileProjection projection;
MapParameter drawParameter;
std::shared_ptr<MyBreaker> drawBreaker;
double loadedLatMin;
Expand Down
2 changes: 1 addition & 1 deletion Apple/OSMScoutOSX/OSMScoutOSX/OSMScout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
Magnification mag(zoom);
projection.Set(OSMTileId((uint32_t)x,(uint32_t)y), mag, dpi, (width+1), (height+1));
GeoBox boundingBox;
projection.GetDimensions(boundingBox);
boundingBox = projection.GetDimensions();

std::list<osmscout::TileRef> tiles;
mapService->LookupTiles(projection,tiles);
Expand Down
14 changes: 14 additions & 0 deletions Apple/OSMScoutOSX/OSMScoutOSX/OSMScoutOSX-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// OSMScoutOSX-Bridging-Header.h
// OSMScoutOSX
//
// Created by Vladimir Vyskocil on 30/12/2023.
// Copyright © 2023 libosmscout. All rights reserved.
//

#ifndef OSMScoutOSX_Bridging_Header_h
#define OSMScoutOSX_Bridging_Header_h

#import "OSMScoutMKTileOverlay.h"

#endif /* OSMScoutOSX_Bridging_Header_h */
18 changes: 0 additions & 18 deletions Apple/OSMScoutOSX/OSMScoutOSX/OSMScoutView.h

This file was deleted.

59 changes: 0 additions & 59 deletions Apple/OSMScoutOSX/OSMScoutOSX/OSMScoutView.m

This file was deleted.

13 changes: 0 additions & 13 deletions Apple/OSMScoutOSX/OSMScoutOSX/OSMScoutViewController.h

This file was deleted.

26 changes: 0 additions & 26 deletions Apple/OSMScoutOSX/OSMScoutOSX/OSMScoutViewController.m

This file was deleted.

14 changes: 0 additions & 14 deletions Apple/OSMScoutOSX/OSMScoutOSX/main.m

This file was deleted.

68 changes: 68 additions & 0 deletions Apple/OSMScoutOSX/OSMScoutView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// OSMScoutView.swift
// OSMScoutOSX
//
// Created by Vladimir Vyskocil on 31/12/2023.
// Copyright © 2023 libosmscout. All rights reserved.
//

import MapKit
import CoreLocation

// The OpenStreetMap compiled data with the Import tools should be put in map.osmscout
// folder in the Resources of the project, a example of OSM source data is
// the Greater London from GeoFabrik
// (https://download.geofabrik.de/europe/great-britain/england/greater-london.html)

class OSMScoutView: MKMapView, MKMapViewDelegate {
// The center of the displayed map
let LATITUDE = 51.5102
let LONGITUDE = -0.1024
// The zoom level
let ZOOM = 16.0

var tileOverlay : MKTileOverlay! = nil

func defaults() {
showsTraffic = false
showsBuildings = false
pointOfInterestFilter = .excludingAll

let centerCoordinate = CLLocationCoordinate2D(latitude:LATITUDE, longitude:LONGITUDE)
let longitudeDelta = 360.0 / pow(2, ZOOM) * Double(frame.size.width/256)
let span = MKCoordinateSpan(latitudeDelta: 0, longitudeDelta: longitudeDelta)

setRegion(MKCoordinateRegion(center: centerCoordinate, span: span), animated:false)
delegate = self
let overlay = OSMScoutMKTileOverlay(urlTemplate: nil)
let path = (Bundle.main.resourcePath ?? "") + "/map.osmscout"
OSMScoutMKTileOverlay.path = path
tileOverlay = overlay;
insertOverlay(tileOverlay, at:0, level:.aboveLabels)
}

override func awakeFromNib() {
super.awakeFromNib()
defaults()
}

override init(frame: CGRect) {
super.init(frame: frame)
defaults()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
defaults()
}

// MARK: - MKMapViewDelegate

func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
if let overlay = overlay as? MKTileOverlay {
return MKTileOverlayRenderer(tileOverlay: overlay)
} else {
return MKOverlayRenderer()
}
}
}
19 changes: 0 additions & 19 deletions Apple/OSMScoutOSX/OSMScoutiOS/AppDelegate.h

This file was deleted.

29 changes: 0 additions & 29 deletions Apple/OSMScoutOSX/OSMScoutiOS/AppDelegate.m

This file was deleted.

Loading

0 comments on commit bfc6e05

Please sign in to comment.