-
Notifications
You must be signed in to change notification settings - Fork 10
/
OSMParser.h
73 lines (63 loc) · 2.26 KB
/
OSMParser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// OSMParser.h
// OSMImporter
//
// Created by y0n3l on 1/14/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Node.h"
#import "Way.h"
#import "Relation.h"
#import "AQXMLParser.h"
/**
Any delegate object should implement selectors from this protocol to be aware of parsing
events.
*/
@protocol OSMParserDelegate
/* Invoked when the parsing of the OSM file has started. */
-(void) parsingStart;
/* Invoked when the parsing of the OSM file has ended. */
-(void) parsingEnd;
@optional
/* Invoked when the parsing of the nodes part of the OSM file has started. */
-(void) didStartParsingNodes;
/* Invoked when a node definition has been parsed in the OSM file. */
-(void) onNodeFound:(Node*)node;
/* Invoked when the parsing of the ways part of the OSM file has started. This usually happens once
all the nodes part parsing has been finished. */
-(void) didStartParsingWays;
/* Invoked when a way definition has been parsed in the OSM file. */
-(void) onWayFound:(Way*)way;
@optional
/* Invoked when the parsing of the relations part of the OSM file has started. This usually happens once
the ways parsing has been done. */
-(void) didStartParsingRelations;
/* Invoked when a relation has been parsed in the OSM file. */
-(void) onRelationFound:(Relation*)relation;
@end
/**
The OSMParser class defines parsers that parse .osm files (XML) that describe street networks defined
in OpenStreetMaps.
OSMParser instances encapsulates a SAX parser that reads the .osm file and generates events when finding
OSM tags such as node, way, relation.
The embedded SAX parser is an instance of a AQXMLParser, that is able to read and parse a stream without
loading the whole file in memory (required when you want to parse .osm files larger XXX megabytes !)
*/
@interface OSMParser : NSObject <AQXMLParserDelegate> {
AQXMLParser* parser;
id <OSMParserDelegate> delegate;
Node* currentNode;
Way* currentWay;
Relation* currentRelation;
NSMutableDictionary* tags;
BOOL isFirstNode;
BOOL isFirstWay;
BOOL isFirstRelation;
}
@property (readwrite, retain) id <OSMParserDelegate> delegate;
- (id)initWithOSMFile:(NSString*)osmFilePath;
- (id)initWithOSMStream:(NSInputStream*)osmStream;
/** Starts the parsing. */
-(void) parse;
@end