dotConnect for MySQL Documentation
In This Topic
    Distance Units
    In This Topic

    Some MySQL functions accept an additional argument "unit", that allows setting measurement unit for function result. Particularly this applies to the functions, returning the length of an object and distances between objects.

    DbGeometry/DbGeography classes have their own methods to get these values (Length and Distance), however they cannot use this MySQL-specific feature of selecting measurement units directly.

    User can specify the necessary measurement units with GeometryDistanceUnit / GeographyDistanceUnit settings. The default value of these settings is DistanceMeasurementUnit.Default.

    var config = MySqlEntityProviderConfig.Instance;
    config.SpatialOptions.GeometryDistanceUnit = DistanceMeasurementUnit.Meter;
    config.SpatialOptions.GeographyDistanceUnit = DistanceMeasurementUnit.Mile;
    
    
    Dim config = MySqlEntityProviderConfig.Instance
    config.SpatialOptions.GeometryDistanceUnit = DistanceMeasurementUnit.Meter
    config.SpatialOptions.GeographyDistanceUnit = DistanceMeasurementUnit.Mile
    
    

    Alternatively, you may specify measurement units in the project config file. For this, you need to update or add the configSections element like it is described in the Entity Framework Provider Configuration section and then add the following Devart.Data.MySql.Entity tag to the configuration tag:

     <Devart.Data.MySql.Entity xmlns="http://devart.com/schemas/Devart.Data.MySql.Entity/1.0">
      <SpatialOptions
        GeometryDistanceUnit="Meter" 
        GeographyDistanceUnit="Mile" />
     </Devart.Data.MySql.Entity>
    

    Note: If you need to set multiple Entity Framework provider options for dotConnect for MySQL, don't add multiple Devart.Data.MySql.Entity tags. Specify all settings in one Devart.Data.MySql.Entity tag.

    The following measurement units are available:

    DistanceMeasurementUnit:

    See Also

    Choosing Spatial Service  | Default SRID