# Path: paegan/cdm/dsg/member.py
# class Member(dict):
#     def __init__(self, *args, **kwargs):
#         super(Member, self).__init__(*args, **kwargs)
# 
# Path: paegan/cdm/dsg/features/base/profile.py
# class Profile(PointCollection):
#     """
#         A collection of points along a vertical (z) access
#         ie. A single profile from an ADCP or CTD
# 
#         A profile has a nominal lat/lon and time.
#         Actual time may be constant, or vary with z.
#         The z coordinates are monotonic, and may be increasing or decreasing.
#     """
#     def __init__(self, **kwargs):
#         super(Profile,self).__init__(**kwargs)
#         self._type = "Profile"
# 
#     def get_location(self):
#         return self._location
#     def set_location(self, location):
#         self._location = location
#     location = property(get_location, set_location)
# 
#     def get_time(self):
#         """
#             Nominal time of the profile.  This is usually the first time a reading was taken,
#             since a profile's time can be constant or vary with z.
#         """
#         return self._time
#     def set_time(self, time):
#         self._time = time
#     time = property(get_time, set_time)
# 
# Path: paegan/cdm/dsg/features/base/section.py
# class Section(ProfileCollection):
#     """
#         A collection of profiles along a trajectory
#     """
# 
#     def __init__(self, **kwargs):
#         super(Section,self).__init__(**kwargs)
#         self._type = "Section"
# 
#     def get_path(self):
#         """
#             Returns the nominal times of the profiles and the Points
#             the profile was taken at.
#         """
#         return map(lambda x: [x.location, x.time], self._elements)
# 
# Path: paegan/cdm/dsg/collections/base/section_collection.py
# class SectionCollection(NestedPointCollection):
#     """
#         A collection of Sections
#     """
# 
#     def __init__(self, **kwargs):
#         super(SectionCollection,self).__init__(**kwargs)


import random
import unittest
from datetime import datetime, timedelta
from shapely.geometry import Point as sPoint
from paegan.cdm.dsg.member import Member
from paegan.cdm.dsg.features.base.point import Point
from paegan.cdm.dsg.features.base.profile import Profile
from paegan.cdm.dsg.features.base.section import Section
from paegan.cdm.dsg.collections.base.section_collection import SectionCollection
    def test_section_collection(self):

        s_collection = SectionCollection()

        # 20 sections
        for x in xrange(0,20):

            day = 1
            hour = 0
            sc = Section()
            dt = None

            # 10 profiles per section
            for x in xrange(0,10):
                lat = random.randint(40,44)
                lon = random.randint(-74,-70)
                loc = sPoint(lon,lat,0)
                minute = 0
                dt = datetime(2012, 4, day, hour, minute)
                hour += 1

                prof = Profile()
                prof.location = loc
                prof.time = dt

                # Each with 20 depths
                for y in xrange(0,20):
                    p = Point()
                    p.time = dt
                    p.location = sPoint(loc.x, loc.y, y)

# Path: paegan/cdm/dsg/member.py
# class Member(dict):
#     def __init__(self, *args, **kwargs):
#         super(Member, self).__init__(*args, **kwargs)
# 
# Path: paegan/cdm/dsg/features/base/profile.py
# class Profile(PointCollection):
#     """
#         A collection of points along a vertical (z) access
#         ie. A single profile from an ADCP or CTD
# 
#         A profile has a nominal lat/lon and time.
#         Actual time may be constant, or vary with z.
#         The z coordinates are monotonic, and may be increasing or decreasing.
#     """
#     def __init__(self, **kwargs):
#         super(Profile,self).__init__(**kwargs)
#         self._type = "Profile"
# 
#     def get_location(self):
#         return self._location
#     def set_location(self, location):
#         self._location = location
#     location = property(get_location, set_location)
# 
#     def get_time(self):
#         """
#             Nominal time of the profile.  This is usually the first time a reading was taken,
#             since a profile's time can be constant or vary with z.
#         """
#         return self._time
#     def set_time(self, time):
#         self._time = time
#     time = property(get_time, set_time)
# 
# Path: paegan/cdm/dsg/features/base/section.py
# class Section(ProfileCollection):
#     """
#         A collection of profiles along a trajectory
#     """
# 
#     def __init__(self, **kwargs):
#         super(Section,self).__init__(**kwargs)
#         self._type = "Section"
# 
#     def get_path(self):
#         """
#             Returns the nominal times of the profiles and the Points
#             the profile was taken at.
#         """
#         return map(lambda x: [x.location, x.time], self._elements)
# 
# Path: paegan/cdm/dsg/collections/base/section_collection.py
# class SectionCollection(NestedPointCollection):
#     """
#         A collection of Sections
#     """
# 
#     def __init__(self, **kwargs):
#         super(SectionCollection,self).__init__(**kwargs)


# Path: tests/cdm/dsg/collections/base/test_section_collection.py
import random
import unittest
from datetime import datetime, timedelta
from shapely.geometry import Point as sPoint
from paegan.cdm.dsg.member import Member
from paegan.cdm.dsg.features.base.point import Point
from paegan.cdm.dsg.features.base.profile import Profile
from paegan.cdm.dsg.features.base.section import Section
from paegan.cdm.dsg.collections.base.section_collection import SectionCollection

    def test_section_collection(self):

        s_collection = SectionCollection()

        # 20 sections
        for x in xrange(0,20):

            day = 1
            hour = 0
            sc = Section()
            dt = None

            # 10 profiles per section
            for x in xrange(0,10):
                lat = random.randint(40,44)
                lon = random.randint(-74,-70)
                loc = sPoint(lon,lat,0)
                minute = 0
                dt = datetime(2012, 4, day, hour, minute)
                hour += 1

                prof = Profile()
                prof.location = loc
                prof.time = dt

                # Each with 20 depths
                for y in xrange(0,20):
                    p = Point()
                    p.time = dt
                    p.location = sPoint(loc.x, loc.y, y)

                    m1 = Member(value=random.uniform(30,40), unit='°C', name='Water Temperatire', description='water temperature', standard='sea_water_temperature')