# Path: ncdjango/interfaces/arcgis/form_fields.py
# class SrField(forms.Field):
#     """Spatial reference field"""
# 
#     def to_python(self, value):
#         if not value or isinstance(value, Proj):
#             return value
# 
#         try:
#             obj = json.loads(value)
# 
#             if isinstance(obj, int):
#                 wkid = obj
#             elif isinstance(obj, dict) and obj.get('wkid'):
#                 wkid = obj['wkid']
#             else:
#                 raise ValidationError('SR must have a wkid parameter.')
# 
#             # Well-known ids below 32767 have a corresponding EPSG
#             if wkid < 32767:
#                 return Proj('+init=epsg:{}'.format(wkid))
#             elif wkid in wkid_to_proj:
#                 return Proj(str(wkid_to_proj[wkid]))
#             else:
#                 raise RuntimeError
#         except ValueError:
#             raise ValidationError('Invalid SR')
#         except RuntimeError:
#             raise ValidationError('Projection not supported')
# 
#     def prepare_value(self, value):
#         if not value or not isinstance(value, Proj):
#             return value
# 
#         epsg = proj4_to_epsg(value)
#         if epsg:
#             return str(epsg)
#         else:
#             raise ValidationError('Could not convert projection to EPSG/WKID')


from django import forms
from ncdjango.interfaces.arcgis.form_fields import SrField


class PointForm(forms.Form):
    x = forms.FloatField()
    y = forms.FloatField()

# Path: ncdjango/interfaces/arcgis/form_fields.py
# class SrField(forms.Field):
#     """Spatial reference field"""
# 
#     def to_python(self, value):
#         if not value or isinstance(value, Proj):
#             return value
# 
#         try:
#             obj = json.loads(value)
# 
#             if isinstance(obj, int):
#                 wkid = obj
#             elif isinstance(obj, dict) and obj.get('wkid'):
#                 wkid = obj['wkid']
#             else:
#                 raise ValidationError('SR must have a wkid parameter.')
# 
#             # Well-known ids below 32767 have a corresponding EPSG
#             if wkid < 32767:
#                 return Proj('+init=epsg:{}'.format(wkid))
#             elif wkid in wkid_to_proj:
#                 return Proj(str(wkid_to_proj[wkid]))
#             else:
#                 raise RuntimeError
#         except ValueError:
#             raise ValidationError('Invalid SR')
#         except RuntimeError:
#             raise ValidationError('Projection not supported')
# 
#     def prepare_value(self, value):
#         if not value or not isinstance(value, Proj):
#             return value
# 
#         epsg = proj4_to_epsg(value)
#         if epsg:
#             return str(epsg)
#         else:
#             raise ValidationError('Could not convert projection to EPSG/WKID')


# Path: ncdjango/interfaces/data/forms.py
from django import forms
from ncdjango.interfaces.arcgis.form_fields import SrField



class PointForm(forms.Form):
    x = forms.FloatField()
    y = forms.FloatField()

    projection = SrField()