最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。
We have used MongoDB’s object Id (ObjectId) in the previous chapters.
In this chapter, we will learn about the structure of ObjectId.
ObjectId is a 12-byte BSON type data in the following format:
The first four bytes represent a timestamp
The next three bytes are machine identification codes.
The next two bytes are made up of process id (PID)
The last three bytes are random numbers.
Documents stored in MongoDB must have a “_ id” key. The value of this key can be of any type, and the default is an ObjectId object.
在一个集合里面,每个文档都有唯一的”_id”值,来确保集合里面每个文档都能被唯一标识。
MongoDB uses ObjectId rather than the main reason for other more conventional practices, such as auto-incrementing primary keys, because it is laborious and time-consuming to increase primary key values synchronously on multiple servers. Generate a new ObjectId using the following code: The above statement returns the following unique generated id: You can also use the generated id instead of the ObjectId automatically generated by MongoDB: Because the 4-byte timestamp is stored in ObjectId, you don’t need to save the timestamp field for your document, you can use the getTimestamp function to get the creation time of the document: The above code returns the creation time of the document in ISO format: In some cases, you may need to convert ObjectId to string format. You can use the following code: The above code returns a string in Guid format: 3.38.1. Create a new ObjectId ¶
>newObjectId = ObjectId()
ObjectId("5349b4ddd2781d08c09890f3")
>myObjectId = ObjectId("5349b4ddd2781d08c09890f4")
3.38.2. Timestamp when the document was created ¶
>ObjectId("5349b4ddd2781d08c09890f4").getTimestamp()
ISODate("2014-04-12T21:49:17Z")
3.38.3. Convert ObjectId to string ¶
>new ObjectId().str
5349b4ddd2781d08c09890f3