Convert from latitude, longitude to x, y

No exact solution exists There is no isometric map from the sphere to the plane. When you convert lat/lon coordinates from the sphere to x/y coordinates in the plane, you cannot hope that all lengths will be preserved by this operation. You have to accept some kind of deformation. Many different map projections do exist, … Read more

nHibernate mapping to custom types

You need to implement your own IUserType. See this blog post for details. I’ll also paste the relevant section below in case the blog disappears. In NHibernate, a custom mapping type is a class that derives from either the IUserType or ICompositeUserType interfaces. These interfaces contain several methods that must be implemented, but for our … Read more

What is the best way to map windows drives using Python?

Building off of @Anon’s suggestion: # Drive letter: M # Shared drive path: \\shared\folder # Username: user123 # Password: password import subprocess # Disconnect anything on M subprocess.call(r’net use m: /del’, shell=True) # Connect to shared drive, use drive letter M subprocess.call(r’net use m: \\shared\folder /user:user123 password’, shell=True) I prefer this simple approach, especially if … Read more

How to introduce multi-column constraint with JPA annotations?

You can declare unique constraints using the @Table(uniqueConstraints = …) annotation in your entity class, i.e. @Entity @Table(uniqueConstraints={ @UniqueConstraint(columnNames = {“productId”, “serial”}) }) public class InventoryItem { … } Note that this does not magically create the unique constraint in the database, you still need a DDL for it to be created. But seems like … Read more

Using AutoMapper to unflatten a DTO

This also seems to work for me: Mapper.CreateMap<PersonDto, Address>(); Mapper.CreateMap<PersonDto, Person>() .ForMember(dest => dest.Address, opt => opt.MapFrom( src => src ))); Basically, create a mapping from the dto to both objects, and then use it as the source for the child object.