Show:

Places_Polyline Class

Static methods for the Polyline models.

Item Index

Methods

Methods

addArea

(
  • $location
  • $title
  • [$floor]
  • [$column]
  • [$options=array()]
)
Array static

Adds a stream to represent an area within a location. Also may add streams to represent the floor and column.

Parameters:

  • $location Streams_Stream

    The location stream

  • $title String

    The title of the area

  • [$floor] String optional

    The number of the floor on which the area is located

  • [$column] String optional

    The name of the column on which the area is located

  • [$options=array()] Array optional

    Any options to pass to Streams::create. Also can include:

    • [asUserId=null] Array optional

      Override the first parameter to Streams::create

Returns:

Array:

An array of ($area, $floor, $column)

byTime

(
  • $publisherId
  • $relationType
  • $fromTime
  • $toTime
  • [$streamName="Streams/experience/main"]
  • [$options]
  • [$meters=null]
)
Array static

Get streams related to Places/nearby streams, which are found from the following parameters. Note that some of these streams may be slightly out of range and you may want to perform additional filtering using Places::distance(). The "latitude", "longitude" and "meters" options can be used to override those found in Places_Nearby::defaults(). If after this, any one of "latitude", "longitude" or "meters" is still not set, then the "Streams/experience/$experienceId" stream is used instead of Places_Nearby streams.

Parameters:

  • $publisherId String

    The publisher of the category streams

  • $relationType String

    The type of the relation

  • $fromTime Integer

    A unix timestamp, in either seconds or milliseconds

  • $toTime Integer

    A unix timestamp, in either seconds or milliseconds

  • [$streamName="Streams/experience/main"] String optional

    The stream name of a community experience

  • [$options] Array optional

    Options to pass to Places_Nearby::related(). Also can contain:

    • [latitude] Double optional

      The latitude of the point to search around

    • [longitude] Double optional

      The longitude of the point to search around

    • [meters] Double optional

      The radius to search within

  • [$meters=null] Double optional

    One of the values in Places/nearby/meters config array, used to find the right Places/nearby stream.

Returns:

Array:

Returns an array of Streams_RelatedTo objects

byTime

(
  • $publisherId
  • $relationType
  • $titles
  • $fromTime
  • $toTime
  • [$experienceId="main"]
  • [$options]
)
Array static

Get streams related to Places/interest streams, which are found from the following parameters. Note that some of these streams may be slightly out of range and you may want to perform additional filtering using Places::distance(). The "latitude", "longitude" and "meters" options can be used to override those found in Places_Nearby::defaults(). If after this, any one of "latitude", "longitude" or "meters" is still not set, then the "Streams/experience/$experienceId" stream is used instead of Places_Nearby streams.

Parameters:

  • $publisherId String

    The publisher of the category streams

  • $relationType String

    The type of the relation

  • $titles String | Array | Db_Range

    The titles of the interests, which will be normalized

  • $fromTime Integer

    A unix timestamp, in either seconds or milliseconds

  • $toTime Integer

    A unix timestamp, in either seconds or milliseconds

  • [$experienceId="main"] String optional

    The id of a community experience, the last part of its stream name

  • [$options] Array optional
    • [latitude] Double optional

      The latitude of the point to search around

    • [longitude] Double optional

      The longitude of the point to search around

    • [meters=null] Double optional

      One of the values in Places/nearby/meters config array, used to find the right Places/nearby stream.

    • [asUserId] String optional

      Override the default user id to fetch streams as. Not used for now, since this function always fetches the relations only.

Returns:

Array:

Returns an array of Streams_RelatedTo objects

defaults

(
  • $meters
)
Array

Get the default latitude, longitude and meters to search around

Parameters:

  • $meters Double

    Can override it to be one of the values in Places/nearby/meters config array

Returns:

Array:

An array containing $latitude, $longitude, $meters

forPublishers

(
  • $latitude
  • $longitude
  • [$metersArray=null]
  • [$experienceId='main']
)
Array static

Call this function to find the "nearby points" to publish to on a grid of quantized (latitude, longitude) pairs which are spaced at most $meters apart.

Parameters:

  • $latitude Double

    The latitude of the coordinates to search around

  • $longitude Double

    The longitude of the coordinates to search around

  • [$metersArray=null] Array optional

    To override the default in "Places"/"nearby"/"meters" config. Useful for only notifying people within a certain radius.

  • [$experienceId='main'] String optional

    The id of the experience stream, the part that comes after "Streams/experience/"

Returns:

Array:

Returns an array of several ($streamName => $info) pairs where the $streamName is the name of the stream corresponding to the "nearby point" and $info includes the keys "latitude", "longitude", and "meters".

related.

(
  • $publisherId
  • $relationType
  • $latitude
  • $longitude
  • $meters
  • $options
)
Array static

Get all the relations to various Places/nearby (or similar type category) streams, sorted by ascending weight. Note that some of these streams may be slightly out of range and you may want to perform additional filtering using Places::distance().

Parameters:

  • $publisherId String

    The publisher of the category streams

  • $relationType String

    The type of the relation to the category streams

  • $latitude Double

    The latitude of the point to search around

  • $longitude Double

    The longitude of the point to search around

  • $meters Double

    The radius to search within

  • $options Array

    The options to pass to the Streams_RelatedTo::fetchAll function. Also can contain the following options:

    • [categories="array_keys"] Callable optional

      Can be used to override the function which takes the output of Places_Nearby::forSubscribers, and this $options array, and returns the array of ($originalStreamName => $criteria) pairs. The $criteria can be a string or array or Db_Range or Db_Expression.

Returns:

Array:

An array of Streams_RelatedTo objects, sorted by ascending weight.

stream

(
  • $asUserId
  • $publisherId
  • $placeId
  • $throwIfBadValue
)
Streams_Stream | Null static

Get a Places/location stream published by a publisher for a given placeId. This is used to cache information from the Google Places API.

Parameters:

  • $asUserId String

    The user to fetch as

  • $publisherId String

    The user publishing the stream

  • $placeId String

    The id of the place in Google Places

  • $throwIfBadValue Boolean

    Whether to throw Q_Exception if the result contains a bad value

Returns:

Streams_Stream | Null:

stream

(
  • $publisherId
  • $latitude
  • $longitude
  • $meters
  • $streamName
  • [$experienceId='main']
  • [$options=array()]
)
Streams_Stream static

Fetch (and create, if necessary) stream on which messages are posted relating to things happening a given number of $meters around the given location.

Parameters:

  • $publisherId String

    The id of the publisher to publish this stream

  • $latitude Double

    The latitude of the coordinates to search around

  • $longitude Double

    The longitude of the coordinates to search around

  • $meters Double

    The radius, in meters, around this location. Should be one of the array values in the Places/nearby/meters config.

  • $streamName String

    The name of the stream to create. Defaults to Places_Nearby::streamName($latitude, $longitude, $meters, $experienceId).

  • [$experienceId='main'] String optional

    The id of the experience stream, the part that comes after "Streams/experience/"

  • [$options=array()] Array optional

    Options for Q_Text::get()

Returns:

Streams_Stream:

Returns the stream object that was created or fetched.

streamName

(
  • $latitude
  • $longitude
  • $meters
  • [$experienceId='main']
)
String static

Obtain the name of a "Places/nearby" stream corresponding to the given parameters

Parameters:

  • $latitude Double

    The latitude of the coordinates near which to relate

  • $longitude Double

    The longitude of the coordinates near which to relate

  • $meters Double

    The radius, in meters

  • [$experienceId='main'] String optional

    Override the id of the experience, the part of the stream name that's after "Streams/experience/"

Returns:

String:

streams

(
  • $publisherId
  • $latitude
  • $longitude
  • $options
  • [$streamNames=null]
)
Array static

Fetch (and create, if necessary) "Places/nearby" streams corresponding ot the given parameters.

Parameters:

  • $publisherId String

    The publisherId of the category streams

  • $latitude Double

    The latitude of the coordinates near which to relate

  • $longitude Double

    The longitude of the coordinates near which to relate

  • $options Array

    The options to pass to the Streams::relate and Streams::create functions. Also can contain the following options:

    • [forSubscribers] Boolean optional

      Set to true to return the streams that are relevant to subscribers instead of publishers, i.e. users who want to know when something relevant happens, rather than users who want to relate the streams they publish to categories.

    • [experienceId='main'] String optional

      Override the id of the experience, the part of the stream name that's after "Streams/experience/"

    • [meters] Array | Double optional

      Override the default array of distances found in the config under Places/nearby/meters. If options.forSubscribers is true, however, this should be one of the entries from the array in Places/nearby/meters config.

    • [create] Callable optional

      If set, this callback will be used to create streams when they don't already exist. It receives the $options array and should return a Streams_Stream object. If this option is set to null, new streams won't be created.

    • [transform="array_keys"] Callable optional

      Can be used to override the function which takes the output of Places_Nearby::forPublishers, and this $options array, and returns the array of ($originalStreamName => $newStreamName) pairs.

  • [$streamNames=null] Array optional

    Optional reference to fill with the stream names

Returns:

Array:

Returns the array of category streams

streams

(
  • $publisherId
  • $latitude
  • $longitude
  • $title
  • $options
  • [$experienceId="main"]
  • [$streamNames=null]
)
Array static

Fetch (and create, if necessary) category streams for things happening around the given location, during a particular hour.

Parameters:

  • $publisherId String

    The publisherId of the category streams

  • $latitude Double

    The latitude of the coordinates near which to relate

  • $longitude Double

    The longitude of the coordinates near which to relate

  • $title String

    The title of the interest, which will be normalized

  • $options Array

    The options to pass to the Streams::relate and Streams::create functions. Also can contain the following options:

    • [meters] Array optional

      Override the default set of distances found in the config under Places/nearby/meters

    • [create] Callable optional

      If set, this callback will be used to create streams when they don't already exist. It receives the $options array and should return a Streams_Stream object. If this option is set to null, new streams won't be created.

    • [transform="array_keys"] Callable optional

      Can be used to override the function which takes the output of Places_Nearby::forPublishers, and this $options array, and returns the array of ($originalStreamName => $newStreamName) pairs.

  • [$experienceId="main"] String optional

    The id of a community experience, the last part of its stream name

  • [$streamNames=null] Array optional

    Optional reference to fill with the stream names

Returns:

Array:

Returns the array of category streams

subscribe

(
  • $publisherId
  • $latitude
  • $longitude
  • $meters
  • [$options=array()]
)
Array static

Call this function to subscribe to streams on which messages are posted related to things happening the given number of $meters around the given location.

Parameters:

  • $publisherId String

    The id of the publisher publishing these streams.

  • $latitude Double

    The latitude of the coordinates to subscribe around

  • $longitude Double

    The longitude of the coordinates to subscribe around

  • $meters Double

    The radius, in meters, around this location. Should be one of the array values in the Places/nearby/meters config.

  • [$options=array()] Array optional

    The options to pass to the streams() and subscribe() functions

Returns:

Array:

Returns an array of up to four arrays of ($publisherId, $streamName) of streams that were subscribed to.

unsubscribe

(
  • $publisherId
  • $latitude
  • $longitude
  • $meters
  • [$options=array()]
)
Array static

Call this function to unsubscribe from streams you previously subscribed to using Places_Nearby::subscribe.

Parameters:

  • $publisherId String

    The id of the publisher publishing these streams.

  • $latitude Double

    The latitude of the coordinates to subscribe around

  • $longitude Double

    The longitude of the coordinates to subscribe around

  • $meters Double

    The radius, in meters, around this location. Should be one of the array values in the Places/nearby/meters config.

  • [$options=array()] Array optional

    The options to pass to the streams() and unsubscribe() function

Returns:

Array:

Returns an array of up to four arrays of ($publisherId, $streamName) of streams that were subscribed to.

userStream

(
  • [$throwIfNotLoggedIn=false]
)
Streams_Stream | Null

Get the logged-in user's location stream

Parameters:

  • [$throwIfNotLoggedIn=false] Boolean optional

    Whether to throw a Users_Exception_NotLoggedIn if no user is logged in.

Returns:

Streams_Stream | Null: