Exemple #1
0
 def makeHeaderBlock(self, osmVersion, phyghtmapVersion):
     headerBlock = []
     # bbox, id=1
     bbox = self.makeHeaderBBox()
     headerBlock.append(self.makeVar("S", 1, bbox))
     # required_features, id=4
     requiredFeatures = [
         writableString("OsmSchema-V{0:.1f}".format(osmVersion)),
         writableString("DenseNodes"),
     ]
     for requiredFeature in requiredFeatures:
         headerBlock.append(self.makeVar("S", 4, requiredFeature))
     # writingprogram, id=16
     writingprogram = writableString(
         "phyghtmap {0:s} (http://wiki.openstreetmap.org/wiki/phyghtmap)".
         format(phyghtmapVersion))
     headerBlock.append(self.makeVar("S", 16, writingprogram))
     return join(headerBlock)
Exemple #2
0
    def makeStringPair(self, a, b=None):
        """format a string pair according to the o5m specification.

		<a> and <b> are two strings; <b> can be None.
		"""
        string = chr(0) + a + chr(0)
        if b != None:
            string += b + chr(0)
        return writableString(string)
Exemple #3
0
 def writeWaysChunk(self, ways, startWayId):
     blobHeader = []
     # type, id=1
     blobHeader.append(
         self.makeVar(vType="S", vId=1, content=writableString("OSMData")))
     # datasize, id=3
     blobHeader.append(self.makeVarIdent(vType="V", vId=3))
     blob = self.makeWayBlob(startWayId, ways)
     blobHeader.append(int2str(len(blob)))
     blobHeader = join(blobHeader)
     self.outf.write(pack('!L', len(blobHeader)))
     self.outf.write(blobHeader)
     self.outf.write(blob)
Exemple #4
0
 def makeHeader(self, osmVersion, phyghtmapVersion):
     blobHeader = []
     # type, id=1
     blobHeader.append(self.makeVarIdent(vType="S", vId=1))
     # len("OSMHeader") == 9
     blobHeader.append(int2str(9))
     blobHeader.append(writableString("OSMHeader"))
     # datasize, id=3
     blobHeader.append(self.makeVarIdent(vType="V", vId=3))
     blob = self.makeHeaderBlob(osmVersion, phyghtmapVersion)
     blobHeader.append(int2str(len(blob)))
     blobHeader = join(blobHeader)
     self.outf.write(pack('!L', len(blobHeader)))
     self.outf.write(blobHeader)
     self.outf.write(blob)
Exemple #5
0
 def __init__(self,
              filename,
              osmVersion,
              phyghtmapVersion,
              bbox=[],
              elevClassifier=None):
     self.outf = open(filename, "wb")
     self.bbox = bbox
     self.granularity = 100
     self.date_granularity = 1000
     self.elevClassifier = elevClassifier
     self.maxNodesPerNodeBlock = 8000
     self.maxNodesPerWayBlock = 32000
     self.timestamp = int(time.mktime(time.localtime()))
     self.timestampString = writableString(
         "")  # dummy attribute, needed by main.py
     self.makeHeader(osmVersion, phyghtmapVersion)
Exemple #6
0
 def writeHeader(self, osmVersion, phyghtmapVersion):
     # write reset
     self.writeReset()
     header = []
     #file format dataset (0xe0), length (0x04), format (o5m2)
     header.extend(
         [writableInt(0xe0),
          writableInt(0x04),
          writableString("o5m2")])
     # timestamp dataset
     timestampDataset = self.makeTimestampDataset()
     header.append(timestampDataset)
     # bounding box dataset
     bboxDataset = self.makeBBoxDataset()
     header.append(bboxDataset)
     #write the header
     self.outf.write(join(header))
Exemple #7
0
    def makeStringTable(self, stringList):
        """takes a list of str objects and returns a stringtable variable.
		"""
        # s, id=1
        return join(
            [self.makeVar("S", 1, writableString(s)) for s in stringList])
Exemple #8
0
 def write(self, output):
     self.outF.write(writableString(output))